Merge pull request #1 from BrandyBuizel/master

switch build works
This commit is contained in:
Cameron Taylor 2020-11-02 15:38:08 -08:00 committed by GitHub
commit 4594a7aa6c
7 changed files with 185 additions and 11 deletions

View file

@ -2,7 +2,7 @@
<project>
<!-- _________________________ Application Settings _________________________ -->
<app title="Friday Night Funkin" file="Funkin" main="Main" version="0.0.1" company="HaxeFlixel" />
<app title="Friday Night Funkin" file="Funkin" packageName="com.ninjamuffin99.fridaynightfunkin" main="Main" version="0.0.1" company="ninjamuffin99" />
<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
@ -25,6 +25,9 @@
<!--Mobile-specific-->
<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />
<!--Switch-specific-->
<window if="switch" orientation="landscape" fullscreen="true" width="0" height="0" resizable="true" />
<!-- _____________________________ Path Settings ____________________________ -->
<set name="BUILD_DIR" value="export/debug" if="debug" />
@ -93,7 +96,10 @@
<!-- _________________________________ Custom _______________________________ -->
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
<icon path="art/icon.png"/>
<haxedef name="SKIP_TO_PLAYSTATE" if="debug" />
<!-- <haxedef name="NG_LOGIN" /> -->
<icon path="art/icon.png" />
<!-- <haxedef name="SKIP_TO_PLAYSTATE" if="debug" /> -->
<haxedef name="NG_LOGIN" />
</project>

View file

@ -48,6 +48,7 @@ class Alphabet extends FlxSpriteGroup
this.text = text;
isBold = bold;
if (text != "")
{
if (typed)
@ -77,7 +78,8 @@ class Alphabet extends FlxSpriteGroup
lastWasSpace = true;
}
if (AlphaCharacter.alphabet.contains(character.toLowerCase()))
if (AlphaCharacter.alphabet.indexOf(character.toLowerCase()) != -1)
//if (AlphaCharacter.alphabet.contains(character.toLowerCase()))
{
if (lastSprite != null)
{
@ -121,6 +123,7 @@ class Alphabet extends FlxSpriteGroup
_finalText = text;
doSplitWords();
// trace(arrayShit);
var loopNum:Int = 0;
@ -137,6 +140,7 @@ class Alphabet extends FlxSpriteGroup
xPosResetted = true;
xPos = 0;
curRow += 1;
}
if (splitWords[loopNum] == " ")
@ -144,9 +148,17 @@ class Alphabet extends FlxSpriteGroup
lastWasSpace = true;
}
#if (haxe >= "4.0.0")
var isNumber:Bool = AlphaCharacter.numbers.contains(splitWords[loopNum]);
var isSymbol:Bool = AlphaCharacter.symbols.contains(splitWords[loopNum]);
if (AlphaCharacter.alphabet.contains(splitWords[loopNum].toLowerCase()) || isNumber || isSymbol)
#else
var isNumber:Bool = AlphaCharacter.numbers.indexOf(splitWords[loopNum]) != -1;
var isSymbol:Bool = AlphaCharacter.symbols.indexOf(splitWords[loopNum]) != -1;
#end
if (AlphaCharacter.alphabet.indexOf(splitWords[loopNum].toLowerCase()) != -1 || isNumber || isSymbol)
//if (AlphaCharacter.alphabet.contains(splitWords[loopNum].toLowerCase()) || isNumber || isSymbol)
{
if (lastSprite != null && !xPosResetted)
{

View file

@ -108,7 +108,11 @@ class Controls extends FlxActionSet
var _pause = new FlxActionDigital(Action.PAUSE);
var _reset = new FlxActionDigital(Action.RESET);
#if (haxe >= "4.0.0")
var byName:Map<String, FlxActionDigital> = [];
#else
var byName:Map<String, FlxActionDigital> = new Map<String, FlxActionDigital>();
#end
public var gamepadsAdded:Array<Int> = [];
public var keyboardScheme = KeyboardScheme.None;
@ -193,6 +197,7 @@ class Controls extends FlxActionSet
inline function get_RESET()
return _reset.check();
#if (haxe >= "4.0.0")
public function new(name, scheme = None)
{
super(name);
@ -219,6 +224,36 @@ class Controls extends FlxActionSet
setKeyboardScheme(scheme, false);
}
#else
public function new(name, scheme:KeyboardScheme = null)
{
super(name);
add(_up);
add(_left);
add(_right);
add(_down);
add(_upP);
add(_leftP);
add(_rightP);
add(_downP);
add(_upR);
add(_leftR);
add(_rightR);
add(_downR);
add(_accept);
add(_back);
add(_pause);
add(_reset);
for (action in digitalActions)
byName[action.name] = action;
if (scheme == null)
scheme = None;
setKeyboardScheme(scheme, false);
}
#end
override function update()
{
@ -278,7 +313,7 @@ class Controls extends FlxActionSet
* @param func
* @return ->Void)
*/
function forEachBound(control:Control, func:(FlxActionDigital, FlxInputState) -> Void)
function forEachBound(control:Control, func:FlxActionDigital->FlxInputState->Void)
{
switch (control)
{
@ -332,6 +367,7 @@ class Controls extends FlxActionSet
public function copyFrom(controls:Controls, ?device:Device)
{
#if (haxe >= "4.0.0")
for (name => action in controls.byName)
{
for (input in action.inputs)
@ -340,14 +376,31 @@ class Controls extends FlxActionSet
byName[name].add(cast input);
}
}
#else
for (name in controls.byName.keys())
{
var action = controls.byName[name];
for (input in action.inputs)
{
if (device == null || isDevice(input, device))
byName[name].add(cast input);
}
}
#end
switch (device)
{
case null:
// add all
#if (haxe >= "4.0.0")
for (gamepad in controls.gamepadsAdded)
if (!gamepadsAdded.contains(gamepad))
gamepadsAdded.push(gamepad);
#else
for (gamepad in controls.gamepadsAdded)
if (gamepadsAdded.indexOf(gamepad) == -1)
gamepadsAdded.push(gamepad);
#end
mergeKeyboardScheme(controls.keyboardScheme);
@ -383,7 +436,11 @@ class Controls extends FlxActionSet
*/
public function bindKeys(control:Control, keys:Array<FlxKey>)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, state) -> addKeys(action, keys, state));
#else
forEachBound(control, function(action, state) addKeys(action, keys, state));
#end
}
/**
@ -392,7 +449,11 @@ class Controls extends FlxActionSet
*/
public function unbindKeys(control:Control, keys:Array<FlxKey>)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, _) -> removeKeys(action, keys));
#else
forEachBound(control, function(action, _) removeKeys(action, keys));
#end
}
inline static function addKeys(action:FlxActionDigital, keys:Array<FlxKey>, state:FlxInputState)
@ -418,6 +479,8 @@ class Controls extends FlxActionSet
removeKeyboard();
keyboardScheme = scheme;
#if (haxe >= "4.0.0")
switch (scheme)
{
case Solo:
@ -450,6 +513,40 @@ class Controls extends FlxActionSet
case None: // nothing
case Custom: // nothing
}
#else
switch (scheme)
{
case Solo:
bindKeys(Control.UP, [W, FlxKey.UP]);
bindKeys(Control.DOWN, [S, FlxKey.DOWN]);
bindKeys(Control.LEFT, [A, FlxKey.LEFT]);
bindKeys(Control.RIGHT, [D, FlxKey.RIGHT]);
bindKeys(Control.ACCEPT, [Z, SPACE, ENTER]);
bindKeys(Control.BACK, [BACKSPACE, ESCAPE]);
bindKeys(Control.PAUSE, [P, ENTER, ESCAPE]);
bindKeys(Control.RESET, [R]);
case Duo(true):
bindKeys(Control.UP, [W]);
bindKeys(Control.DOWN, [S]);
bindKeys(Control.LEFT, [A]);
bindKeys(Control.RIGHT, [D]);
bindKeys(Control.ACCEPT, [G, Z]);
bindKeys(Control.BACK, [H, X]);
bindKeys(Control.PAUSE, [ONE]);
bindKeys(Control.RESET, [R]);
case Duo(false):
bindKeys(Control.UP, [FlxKey.UP]);
bindKeys(Control.DOWN, [FlxKey.DOWN]);
bindKeys(Control.LEFT, [FlxKey.LEFT]);
bindKeys(Control.RIGHT, [FlxKey.RIGHT]);
bindKeys(Control.ACCEPT, [O]);
bindKeys(Control.BACK, [P]);
bindKeys(Control.PAUSE, [ENTER]);
bindKeys(Control.RESET, [BACKSPACE]);
case None: // nothing
case Custom: // nothing
}
#end
}
function removeKeyboard()
@ -469,15 +566,27 @@ class Controls extends FlxActionSet
public function addGamepad(id:Int, ?buttonMap:Map<Control, Array<FlxGamepadInputID>>):Void
{
gamepadsAdded.push(id);
#if (haxe >= "4.0.0")
for (control => buttons in buttonMap)
bindButtons(control, id, buttons);
inline bindButtons(control, id, buttons);
#else
for (control in buttonMap.keys())
bindButtons(control, id, buttonMap[control]);
#end
}
inline function addGamepadLiteral(id:Int, ?buttonMap:Map<Control, Array<FlxGamepadInputID>>):Void
{
gamepadsAdded.push(id);
#if (haxe >= "4.0.0")
for (control => buttons in buttonMap)
inline bindButtons(control, id, buttons);
#else
for (control in buttonMap.keys())
bindButtons(control, id, buttonMap[control]);
#end
}
public function removeGamepad(deviceID:Int = FlxInputDeviceID.ALL):Void
@ -498,6 +607,7 @@ class Controls extends FlxActionSet
public function addDefaultGamepad(id):Void
{
#if !switch
addGamepadLiteral(id, [
Control.ACCEPT => [A],
Control.BACK => [B],
@ -508,6 +618,19 @@ class Controls extends FlxActionSet
Control.PAUSE => [START],
Control.RESET => [Y]
]);
#else
addGamepadLiteral(id, [
//Swap A and B for switch
Control.ACCEPT => [B],
Control.BACK => [A],
Control.UP => [DPAD_UP, LEFT_STICK_DIGITAL_UP],
Control.DOWN => [DPAD_DOWN, LEFT_STICK_DIGITAL_DOWN],
Control.LEFT => [DPAD_LEFT, LEFT_STICK_DIGITAL_LEFT],
Control.RIGHT => [DPAD_RIGHT, LEFT_STICK_DIGITAL_RIGHT],
Control.PAUSE => [START],
Control.RESET => [Y]
]);
#end
}
/**
@ -516,7 +639,11 @@ class Controls extends FlxActionSet
*/
public function bindButtons(control:Control, id, buttons)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, state) -> addButtons(action, buttons, state, id));
#else
forEachBound(control, function(action, state) addButtons(action, buttons, state, id));
#end
}
/**
@ -525,7 +652,11 @@ class Controls extends FlxActionSet
*/
public function unbindButtons(control:Control, gamepadID:Int, buttons)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, _) -> removeButtons(action, gamepadID, buttons));
#else
forEachBound(control, function(action, _) removeButtons(action, gamepadID, buttons));
#end
}
inline static function addButtons(action:FlxActionDigital, buttons:Array<FlxGamepadInputID>, state, id)

View file

@ -820,7 +820,11 @@ class PlayState extends MusicBeatState
{
trace('SONG DONE' + isStoryMode);
#if !switch
NGio.postScore(songScore, SONG.song);
#end
if (isStoryMode)
{
@ -834,7 +838,10 @@ class PlayState extends MusicBeatState
StoryMenuState.weekUnlocked[1] = true;
#if !switch
NGio.unlockMedal(60961);
#end
FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked;
FlxG.save.flush();

View file

@ -14,12 +14,21 @@ class PlayerSettings
static public var player1(default, null):PlayerSettings;
static public var player2(default, null):PlayerSettings;
#if (haxe >= "4.0.0")
static public final onAvatarAdd = new FlxTypedSignal<PlayerSettings->Void>();
static public final onAvatarRemove = new FlxTypedSignal<PlayerSettings->Void>();
#else
static public var onAvatarAdd = new FlxTypedSignal<PlayerSettings->Void>();
static public var onAvatarRemove = new FlxTypedSignal<PlayerSettings->Void>();
#end
public var id(default, null):Int;
#if (haxe >= "4.0.0")
public final controls:Controls;
#else
public var controls:Controls;
#end
// public var avatar:Player;
// public var camera(get, never):PlayCamera;

View file

@ -49,7 +49,7 @@ class Song
public static function loadFromJson(jsonInput:String, ?folder:String):SwagSong
{
// var rawJson = Assets.getText('assets/data/ridge/ridge.json').trim();
var rawJson = Assets.getText('assets/data/' + folder.toLowerCase() + '/' + jsonInput.toLowerCase() + '.json').trim();
while (!rawJson.endsWith("}"))

View file

@ -42,6 +42,7 @@ class TitleState extends MusicBeatState
var wackyImage:FlxSprite;
override public function create():Void
{
#if (!web)
@ -56,12 +57,16 @@ class TitleState extends MusicBeatState
super.create();
#if (!debug && NG_LOGIN)
#if (!switch && !debug && NG_LOGIN)
var ng:NGio = new NGio(APIStuff.API, APIStuff.EncKey);
#end
#if SKIP_TO_PLAYSTATE
FlxG.switchState(new ChartingState());
FlxG.switchState(new StoryMenuState());
#else
startIntro();
#end
@ -199,7 +204,11 @@ class TitleState extends MusicBeatState
if (pressedEnter && !transitioning && skippedIntro)
{
#if !switch
NGio.unlockMedal(60960);
#end
titleText.animation.play('press');
FlxG.camera.flash(FlxColor.WHITE, 1);