mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-04-03 18:59:42 -04:00
flxg import.hx thing lol
This commit is contained in:
parent
39d93616d2
commit
fcc7a91597
48 changed files with 700 additions and 635 deletions
Preloader.hx
source
Alphabet.hxBoyfriend.hxCharacter.hxChartingState.hxControls.hxCoolUtil.hxCutsceneAnimTestState.hxDialogueBox.hxFlxVideo.hxFreeplayState.hxGameOverState.hxGameOverSubstate.hxGitarooPause.hxHighscore.hxInputFormatter.hxLatencyState.hxLoadingState.hxMainMenuState.hxMenuItem.hxMusicBeatState.hxMusicBeatSubstate.hxNGio.hxNote.hxNoteSplash.hxOutdatedSubState.hxPaths.hxPauseSubState.hxPlayState.hxPlayerSettings.hxStoryMenuState.hxSwagCamera.hxTankmenBG.hxTitleState.hxVideoState.hx
animate
import.hxui
103
Preloader.hx
103
Preloader.hx
|
@ -1,57 +1,58 @@
|
|||
package ;
|
||||
|
||||
import flixel.system.FlxBasePreloader;
|
||||
import openfl.display.Sprite;
|
||||
package;
|
||||
|
||||
import flash.Lib;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.BlendMode;
|
||||
import flash.display.Sprite;
|
||||
import flash.Lib;
|
||||
import flixel.FlxG;
|
||||
|
||||
@:bitmap("art/preloaderArt.png") class LogoImage extends BitmapData { }
|
||||
|
||||
import flixel.system.FlxBasePreloader;
|
||||
import openfl.display.Sprite;
|
||||
|
||||
@:bitmap("art/preloaderArt.png") class LogoImage extends BitmapData {}
|
||||
|
||||
class Preloader extends FlxBasePreloader
|
||||
{
|
||||
public function new(MinDisplayTime:Float=3, ?AllowedURLs:Array<String>)
|
||||
{
|
||||
super(MinDisplayTime, AllowedURLs);
|
||||
}
|
||||
|
||||
var logo:Sprite;
|
||||
|
||||
override function create():Void
|
||||
{
|
||||
this._width = Lib.current.stage.stageWidth;
|
||||
this._height = Lib.current.stage.stageHeight;
|
||||
|
||||
var ratio:Float = this._width / 2560; //This allows us to scale assets depending on the size of the screen.
|
||||
|
||||
logo = new Sprite();
|
||||
logo.addChild(new Bitmap(new LogoImage(0,0))); //Sets the graphic of the sprite to a Bitmap object, which uses our embedded BitmapData class.
|
||||
logo.scaleX = logo.scaleY = ratio;
|
||||
logo.x = ((this._width) / 2) - ((logo.width) / 2);
|
||||
logo.y = (this._height / 2) - ((logo.height) / 2);
|
||||
addChild(logo); //Adds the graphic to the NMEPreloader's buffer.
|
||||
|
||||
super.create();
|
||||
}
|
||||
|
||||
override function update(Percent:Float):Void
|
||||
{
|
||||
if(Percent < 69)
|
||||
{
|
||||
logo.scaleX += Percent / 1920;
|
||||
logo.scaleY += Percent / 1920;
|
||||
logo.x -= Percent * 0.6;
|
||||
logo.y -= Percent / 2;
|
||||
}else{
|
||||
logo.scaleX = this._width / 1280;
|
||||
logo.scaleY = this._width / 1280;
|
||||
logo.x = ((this._width) / 2) - ((logo.width) / 2);
|
||||
logo.y = (this._height / 2) - ((logo.height) / 2);
|
||||
}
|
||||
|
||||
super.update(Percent);
|
||||
}
|
||||
}
|
||||
public function new(MinDisplayTime:Float = 3, ?AllowedURLs:Array<String>)
|
||||
{
|
||||
super(MinDisplayTime, AllowedURLs);
|
||||
}
|
||||
|
||||
var logo:Sprite;
|
||||
|
||||
override function create():Void
|
||||
{
|
||||
this._width = Lib.current.stage.stageWidth;
|
||||
this._height = Lib.current.stage.stageHeight;
|
||||
|
||||
var ratio:Float = this._width / 2560; // This allows us to scale assets depending on the size of the screen.
|
||||
|
||||
logo = new Sprite();
|
||||
logo.addChild(new Bitmap(new LogoImage(0, 0))); // Sets the graphic of the sprite to a Bitmap object, which uses our embedded BitmapData class.
|
||||
logo.scaleX = logo.scaleY = ratio;
|
||||
logo.x = ((this._width) / 2) - ((logo.width) / 2);
|
||||
logo.y = (this._height / 2) - ((logo.height) / 2);
|
||||
addChild(logo); // Adds the graphic to the NMEPreloader's buffer.
|
||||
|
||||
super.create();
|
||||
}
|
||||
|
||||
override function update(Percent:Float):Void
|
||||
{
|
||||
if (Percent < 69)
|
||||
{
|
||||
logo.scaleX += Percent / 1920;
|
||||
logo.scaleY += Percent / 1920;
|
||||
logo.x -= Percent * 0.6;
|
||||
logo.y -= Percent / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
logo.scaleX = this._width / 1280;
|
||||
logo.scaleY = this._width / 1280;
|
||||
logo.x = ((this._width) / 2) - ((logo.width) / 2);
|
||||
logo.y = (this._height / 2) - ((logo.height) / 2);
|
||||
}
|
||||
|
||||
super.update(Percent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.util.FlxTimer;
|
||||
|
@ -10,7 +9,6 @@ using StringTools;
|
|||
class Boyfriend extends Character
|
||||
{
|
||||
// public var stunned:Bool = false;
|
||||
|
||||
public function new(x:Float, y:Float, ?char:String = 'bf')
|
||||
{
|
||||
super(x, y, char, true);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import Section.SwagSection;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.animation.FlxBaseAnimation;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
|
|
@ -3,7 +3,6 @@ package;
|
|||
import Conductor.BPMChangeEvent;
|
||||
import Section.SwagSection;
|
||||
import Song.SwagSong;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
import flixel.addons.ui.FlxInputText;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.input.FlxInput;
|
||||
import flixel.input.actions.FlxAction;
|
||||
import flixel.input.actions.FlxActionInput;
|
||||
|
@ -39,30 +38,30 @@ enum Control
|
|||
@:enum
|
||||
abstract Action(String) to String from String
|
||||
{
|
||||
var UI_UP = "ui_up";
|
||||
var UI_LEFT = "ui_left";
|
||||
var UI_RIGHT = "ui_right";
|
||||
var UI_DOWN = "ui_down";
|
||||
var UI_UP_P = "ui_up-press";
|
||||
var UI_LEFT_P = "ui_left-press";
|
||||
var UI_UP = "ui_up";
|
||||
var UI_LEFT = "ui_left";
|
||||
var UI_RIGHT = "ui_right";
|
||||
var UI_DOWN = "ui_down";
|
||||
var UI_UP_P = "ui_up-press";
|
||||
var UI_LEFT_P = "ui_left-press";
|
||||
var UI_RIGHT_P = "ui_right-press";
|
||||
var UI_DOWN_P = "ui_down-press";
|
||||
var UI_UP_R = "ui_up-release";
|
||||
var UI_LEFT_R = "ui_left-release";
|
||||
var UI_DOWN_P = "ui_down-press";
|
||||
var UI_UP_R = "ui_up-release";
|
||||
var UI_LEFT_R = "ui_left-release";
|
||||
var UI_RIGHT_R = "ui_right-release";
|
||||
var UI_DOWN_R = "ui_down-release";
|
||||
var NOTE_UP = "note_up";
|
||||
var NOTE_LEFT = "note_left";
|
||||
var NOTE_RIGHT = "note_right";
|
||||
var NOTE_DOWN = "note_down";
|
||||
var NOTE_UP_P = "note_up-press";
|
||||
var NOTE_LEFT_P = "note_left-press";
|
||||
var UI_DOWN_R = "ui_down-release";
|
||||
var NOTE_UP = "note_up";
|
||||
var NOTE_LEFT = "note_left";
|
||||
var NOTE_RIGHT = "note_right";
|
||||
var NOTE_DOWN = "note_down";
|
||||
var NOTE_UP_P = "note_up-press";
|
||||
var NOTE_LEFT_P = "note_left-press";
|
||||
var NOTE_RIGHT_P = "note_right-press";
|
||||
var NOTE_DOWN_P = "note_down-press";
|
||||
var NOTE_UP_R = "note_up-release";
|
||||
var NOTE_LEFT_R = "note_left-release";
|
||||
var NOTE_DOWN_P = "note_down-press";
|
||||
var NOTE_UP_R = "note_up-release";
|
||||
var NOTE_LEFT_R = "note_left-release";
|
||||
var NOTE_RIGHT_R = "note_right-release";
|
||||
var NOTE_DOWN_R = "note_down-release";
|
||||
var NOTE_DOWN_R = "note_down-release";
|
||||
var ACCEPT = "accept";
|
||||
var BACK = "back";
|
||||
var PAUSE = "pause";
|
||||
|
@ -92,30 +91,30 @@ enum KeyboardScheme
|
|||
*/
|
||||
class Controls extends FlxActionSet
|
||||
{
|
||||
var _ui_up = new FlxActionDigital(Action.UI_UP);
|
||||
var _ui_left = new FlxActionDigital(Action.UI_LEFT);
|
||||
var _ui_right = new FlxActionDigital(Action.UI_RIGHT);
|
||||
var _ui_down = new FlxActionDigital(Action.UI_DOWN);
|
||||
var _ui_upP = new FlxActionDigital(Action.UI_UP_P);
|
||||
var _ui_leftP = new FlxActionDigital(Action.UI_LEFT_P);
|
||||
var _ui_up = new FlxActionDigital(Action.UI_UP);
|
||||
var _ui_left = new FlxActionDigital(Action.UI_LEFT);
|
||||
var _ui_right = new FlxActionDigital(Action.UI_RIGHT);
|
||||
var _ui_down = new FlxActionDigital(Action.UI_DOWN);
|
||||
var _ui_upP = new FlxActionDigital(Action.UI_UP_P);
|
||||
var _ui_leftP = new FlxActionDigital(Action.UI_LEFT_P);
|
||||
var _ui_rightP = new FlxActionDigital(Action.UI_RIGHT_P);
|
||||
var _ui_downP = new FlxActionDigital(Action.UI_DOWN_P);
|
||||
var _ui_upR = new FlxActionDigital(Action.UI_UP_R);
|
||||
var _ui_leftR = new FlxActionDigital(Action.UI_LEFT_R);
|
||||
var _ui_downP = new FlxActionDigital(Action.UI_DOWN_P);
|
||||
var _ui_upR = new FlxActionDigital(Action.UI_UP_R);
|
||||
var _ui_leftR = new FlxActionDigital(Action.UI_LEFT_R);
|
||||
var _ui_rightR = new FlxActionDigital(Action.UI_RIGHT_R);
|
||||
var _ui_downR = new FlxActionDigital(Action.UI_DOWN_R);
|
||||
var _note_up = new FlxActionDigital(Action.NOTE_UP);
|
||||
var _note_left = new FlxActionDigital(Action.NOTE_LEFT);
|
||||
var _note_right = new FlxActionDigital(Action.NOTE_RIGHT);
|
||||
var _note_down = new FlxActionDigital(Action.NOTE_DOWN);
|
||||
var _note_upP = new FlxActionDigital(Action.NOTE_UP_P);
|
||||
var _note_leftP = new FlxActionDigital(Action.NOTE_LEFT_P);
|
||||
var _ui_downR = new FlxActionDigital(Action.UI_DOWN_R);
|
||||
var _note_up = new FlxActionDigital(Action.NOTE_UP);
|
||||
var _note_left = new FlxActionDigital(Action.NOTE_LEFT);
|
||||
var _note_right = new FlxActionDigital(Action.NOTE_RIGHT);
|
||||
var _note_down = new FlxActionDigital(Action.NOTE_DOWN);
|
||||
var _note_upP = new FlxActionDigital(Action.NOTE_UP_P);
|
||||
var _note_leftP = new FlxActionDigital(Action.NOTE_LEFT_P);
|
||||
var _note_rightP = new FlxActionDigital(Action.NOTE_RIGHT_P);
|
||||
var _note_downP = new FlxActionDigital(Action.NOTE_DOWN_P);
|
||||
var _note_upR = new FlxActionDigital(Action.NOTE_UP_R);
|
||||
var _note_leftR = new FlxActionDigital(Action.NOTE_LEFT_R);
|
||||
var _note_downP = new FlxActionDigital(Action.NOTE_DOWN_P);
|
||||
var _note_upR = new FlxActionDigital(Action.NOTE_UP_R);
|
||||
var _note_leftR = new FlxActionDigital(Action.NOTE_LEFT_R);
|
||||
var _note_rightR = new FlxActionDigital(Action.NOTE_RIGHT_R);
|
||||
var _note_downR = new FlxActionDigital(Action.NOTE_DOWN_R);
|
||||
var _note_downR = new FlxActionDigital(Action.NOTE_DOWN_R);
|
||||
var _accept = new FlxActionDigital(Action.ACCEPT);
|
||||
var _back = new FlxActionDigital(Action.BACK);
|
||||
var _pause = new FlxActionDigital(Action.PAUSE);
|
||||
|
@ -123,50 +122,159 @@ class Controls extends FlxActionSet
|
|||
#if CAN_CHEAT
|
||||
var _cheat = new FlxActionDigital(Action.CHEAT);
|
||||
#end
|
||||
|
||||
|
||||
var byName:Map<String, FlxActionDigital> = new Map<String, FlxActionDigital>();
|
||||
|
||||
public var gamepadsAdded:Array<Int> = [];
|
||||
public var keyboardScheme = KeyboardScheme.None;
|
||||
|
||||
public var UI_UP (get, never):Bool; inline function get_UI_UP () return _ui_up .check();
|
||||
public var UI_LEFT (get, never):Bool; inline function get_UI_LEFT () return _ui_left .check();
|
||||
public var UI_RIGHT(get, never):Bool; inline function get_UI_RIGHT() return _ui_right.check();
|
||||
public var UI_DOWN (get, never):Bool; inline function get_UI_DOWN () return _ui_down .check();
|
||||
public var UI_UP(get, never):Bool;
|
||||
|
||||
public var UI_UP_P (get, never):Bool; inline function get_UI_UP_P () return _ui_upP .check();
|
||||
public var UI_LEFT_P (get, never):Bool; inline function get_UI_LEFT_P () return _ui_leftP .check();
|
||||
public var UI_RIGHT_P(get, never):Bool; inline function get_UI_RIGHT_P() return _ui_rightP.check();
|
||||
public var UI_DOWN_P (get, never):Bool; inline function get_UI_DOWN_P () return _ui_downP .check();
|
||||
inline function get_UI_UP()
|
||||
return _ui_up.check();
|
||||
|
||||
public var UI_UP_R (get, never):Bool; inline function get_UI_UP_R () return _ui_upR .check();
|
||||
public var UI_LEFT_R (get, never):Bool; inline function get_UI_LEFT_R () return _ui_leftR .check();
|
||||
public var UI_RIGHT_R(get, never):Bool; inline function get_UI_RIGHT_R() return _ui_rightR.check();
|
||||
public var UI_DOWN_R (get, never):Bool; inline function get_UI_DOWN_R () return _ui_downR .check();
|
||||
|
||||
public var NOTE_UP (get, never):Bool; inline function get_NOTE_UP () return _note_up .check();
|
||||
public var NOTE_LEFT (get, never):Bool; inline function get_NOTE_LEFT () return _note_left .check();
|
||||
public var NOTE_RIGHT(get, never):Bool; inline function get_NOTE_RIGHT() return _note_right.check();
|
||||
public var NOTE_DOWN (get, never):Bool; inline function get_NOTE_DOWN () return _note_down .check();
|
||||
public var UI_LEFT(get, never):Bool;
|
||||
|
||||
public var NOTE_UP_P (get, never):Bool; inline function get_NOTE_UP_P () return _note_upP .check();
|
||||
public var NOTE_LEFT_P (get, never):Bool; inline function get_NOTE_LEFT_P () return _note_leftP .check();
|
||||
public var NOTE_RIGHT_P(get, never):Bool; inline function get_NOTE_RIGHT_P() return _note_rightP.check();
|
||||
public var NOTE_DOWN_P (get, never):Bool; inline function get_NOTE_DOWN_P () return _note_downP .check();
|
||||
inline function get_UI_LEFT()
|
||||
return _ui_left.check();
|
||||
|
||||
public var NOTE_UP_R (get, never):Bool; inline function get_NOTE_UP_R () return _note_upR .check();
|
||||
public var NOTE_LEFT_R (get, never):Bool; inline function get_NOTE_LEFT_R () return _note_leftR .check();
|
||||
public var NOTE_RIGHT_R(get, never):Bool; inline function get_NOTE_RIGHT_R() return _note_rightR.check();
|
||||
public var NOTE_DOWN_R (get, never):Bool; inline function get_NOTE_DOWN_R () return _note_downR .check();
|
||||
public var UI_RIGHT(get, never):Bool;
|
||||
|
||||
inline function get_UI_RIGHT()
|
||||
return _ui_right.check();
|
||||
|
||||
public var UI_DOWN(get, never):Bool;
|
||||
|
||||
inline function get_UI_DOWN()
|
||||
return _ui_down.check();
|
||||
|
||||
public var UI_UP_P(get, never):Bool;
|
||||
|
||||
inline function get_UI_UP_P()
|
||||
return _ui_upP.check();
|
||||
|
||||
public var UI_LEFT_P(get, never):Bool;
|
||||
|
||||
inline function get_UI_LEFT_P()
|
||||
return _ui_leftP.check();
|
||||
|
||||
public var UI_RIGHT_P(get, never):Bool;
|
||||
|
||||
inline function get_UI_RIGHT_P()
|
||||
return _ui_rightP.check();
|
||||
|
||||
public var UI_DOWN_P(get, never):Bool;
|
||||
|
||||
inline function get_UI_DOWN_P()
|
||||
return _ui_downP.check();
|
||||
|
||||
public var UI_UP_R(get, never):Bool;
|
||||
|
||||
inline function get_UI_UP_R()
|
||||
return _ui_upR.check();
|
||||
|
||||
public var UI_LEFT_R(get, never):Bool;
|
||||
|
||||
inline function get_UI_LEFT_R()
|
||||
return _ui_leftR.check();
|
||||
|
||||
public var UI_RIGHT_R(get, never):Bool;
|
||||
|
||||
inline function get_UI_RIGHT_R()
|
||||
return _ui_rightR.check();
|
||||
|
||||
public var UI_DOWN_R(get, never):Bool;
|
||||
|
||||
inline function get_UI_DOWN_R()
|
||||
return _ui_downR.check();
|
||||
|
||||
public var NOTE_UP(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_UP()
|
||||
return _note_up.check();
|
||||
|
||||
public var NOTE_LEFT(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_LEFT()
|
||||
return _note_left.check();
|
||||
|
||||
public var NOTE_RIGHT(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_RIGHT()
|
||||
return _note_right.check();
|
||||
|
||||
public var NOTE_DOWN(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_DOWN()
|
||||
return _note_down.check();
|
||||
|
||||
public var NOTE_UP_P(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_UP_P()
|
||||
return _note_upP.check();
|
||||
|
||||
public var NOTE_LEFT_P(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_LEFT_P()
|
||||
return _note_leftP.check();
|
||||
|
||||
public var NOTE_RIGHT_P(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_RIGHT_P()
|
||||
return _note_rightP.check();
|
||||
|
||||
public var NOTE_DOWN_P(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_DOWN_P()
|
||||
return _note_downP.check();
|
||||
|
||||
public var NOTE_UP_R(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_UP_R()
|
||||
return _note_upR.check();
|
||||
|
||||
public var NOTE_LEFT_R(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_LEFT_R()
|
||||
return _note_leftR.check();
|
||||
|
||||
public var NOTE_RIGHT_R(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_RIGHT_R()
|
||||
return _note_rightR.check();
|
||||
|
||||
public var NOTE_DOWN_R(get, never):Bool;
|
||||
|
||||
inline function get_NOTE_DOWN_R()
|
||||
return _note_downR.check();
|
||||
|
||||
public var ACCEPT(get, never):Bool;
|
||||
|
||||
inline function get_ACCEPT()
|
||||
return _accept.check();
|
||||
|
||||
public var BACK(get, never):Bool;
|
||||
|
||||
inline function get_BACK()
|
||||
return _back.check();
|
||||
|
||||
public var PAUSE(get, never):Bool;
|
||||
|
||||
inline function get_PAUSE()
|
||||
return _pause.check();
|
||||
|
||||
public var RESET(get, never):Bool;
|
||||
|
||||
inline function get_RESET()
|
||||
return _reset.check();
|
||||
|
||||
public var ACCEPT(get, never):Bool; inline function get_ACCEPT() return _accept.check();
|
||||
public var BACK (get, never):Bool; inline function get_BACK () return _back .check();
|
||||
public var PAUSE (get, never):Bool; inline function get_PAUSE () return _pause .check();
|
||||
public var RESET (get, never):Bool; inline function get_RESET () return _reset .check();
|
||||
#if CAN_CHEAT
|
||||
public var CHEAT (get, never):Bool; inline function get_CHEAT () return _cheat.check ();
|
||||
public var CHEAT(get, never):Bool;
|
||||
|
||||
inline function get_CHEAT()
|
||||
return _cheat.check();
|
||||
#end
|
||||
|
||||
|
||||
public function new(name, scheme:KeyboardScheme = null)
|
||||
{
|
||||
super(name);
|
||||
|
@ -208,7 +316,7 @@ class Controls extends FlxActionSet
|
|||
|
||||
if (scheme == null)
|
||||
scheme = None;
|
||||
|
||||
|
||||
setKeyboardScheme(scheme, false);
|
||||
}
|
||||
|
||||
|
@ -342,7 +450,7 @@ class Controls extends FlxActionSet
|
|||
forEachBound(control, function(action, _) replaceButton(action, id, toAdd, toRemove));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function replaceKey(action:FlxActionDigital, toAdd:Int, toRemove:Int)
|
||||
{
|
||||
for (i in 0...action.inputs.length)
|
||||
|
@ -355,7 +463,7 @@ class Controls extends FlxActionSet
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function replaceButton(action:FlxActionDigital, deviceID:Int, toAdd:Int, toRemove:Int)
|
||||
{
|
||||
for (i in 0...action.inputs.length)
|
||||
|
@ -377,7 +485,7 @@ class Controls extends FlxActionSet
|
|||
for (input in action.inputs)
|
||||
{
|
||||
if (device == null || isDevice(input, device))
|
||||
byName[name].add(cast input);
|
||||
byName[name].add(cast input);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +495,7 @@ class Controls extends FlxActionSet
|
|||
// add all
|
||||
for (gamepad in controls.gamepadsAdded)
|
||||
if (gamepadsAdded.indexOf(gamepad) == -1)
|
||||
gamepadsAdded.push(gamepad);
|
||||
gamepadsAdded.push(gamepad);
|
||||
|
||||
mergeKeyboardScheme(controls.keyboardScheme);
|
||||
|
||||
|
@ -458,7 +566,7 @@ class Controls extends FlxActionSet
|
|||
removeKeyboard();
|
||||
|
||||
keyboardScheme = scheme;
|
||||
|
||||
|
||||
switch (scheme)
|
||||
{
|
||||
case Solo:
|
||||
|
@ -522,7 +630,7 @@ class Controls extends FlxActionSet
|
|||
public function addGamepadWithSaveData(id:Int, ?padData:Dynamic):Void
|
||||
{
|
||||
gamepadsAdded.push(id);
|
||||
|
||||
|
||||
fromSaveData(padData, Gamepad(id));
|
||||
}
|
||||
|
||||
|
@ -553,7 +661,7 @@ class Controls extends FlxActionSet
|
|||
public function addDefaultGamepad(id):Void
|
||||
{
|
||||
addGamepadLiteral(id, [
|
||||
|
||||
|
||||
Control.ACCEPT => [#if switch B #else A #end],
|
||||
Control.BACK => [#if switch A #else B #end, FlxGamepadInputID.BACK],
|
||||
Control.UI_UP => [DPAD_UP, LEFT_STICK_DIGITAL_UP],
|
||||
|
@ -567,8 +675,7 @@ class Controls extends FlxActionSet
|
|||
Control.NOTE_RIGHT => [DPAD_RIGHT, B, LEFT_STICK_DIGITAL_RIGHT, RIGHT_STICK_DIGITAL_RIGHT],
|
||||
Control.PAUSE => [START],
|
||||
Control.RESET => [Y]
|
||||
#if CAN_CHEAT
|
||||
,Control.CHEAT => [X]
|
||||
#if CAN_CHEAT, Control.CHEAT => [X]
|
||||
#end
|
||||
]);
|
||||
}
|
||||
|
@ -649,15 +756,17 @@ class Controls extends FlxActionSet
|
|||
var inputs:Array<Int> = Reflect.field(data, control.getName());
|
||||
if (inputs != null)
|
||||
{
|
||||
switch(device)
|
||||
switch (device)
|
||||
{
|
||||
case Keys: bindKeys(control, inputs.copy());
|
||||
case Gamepad(id): bindButtons(control, id, inputs.copy());
|
||||
case Keys:
|
||||
bindKeys(control, inputs.copy());
|
||||
case Gamepad(id):
|
||||
bindButtons(control, id, inputs.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function createSaveData(device:Device):Dynamic
|
||||
{
|
||||
var isEmpty = true;
|
||||
|
@ -666,10 +775,10 @@ class Controls extends FlxActionSet
|
|||
{
|
||||
var inputs = getInputsFor(control, device);
|
||||
isEmpty = isEmpty && inputs.length == 0;
|
||||
|
||||
|
||||
Reflect.setField(data, control.getName(), inputs);
|
||||
}
|
||||
|
||||
|
||||
return isEmpty ? null : data;
|
||||
}
|
||||
|
||||
|
@ -688,5 +797,8 @@ class Controls extends FlxActionSet
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
typedef SaveInputLists = {?keys:Array<Int>, ?pad:Array<Int>};
|
||||
typedef SaveInputLists =
|
||||
{
|
||||
?keys:Array<Int>,
|
||||
?pad:Array<Int>
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.math.FlxMath;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.text.FlxTypeText;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
@ -79,7 +78,7 @@ class DialogueBox extends FlxSpriteGroup
|
|||
portraitRight.visible = false;
|
||||
|
||||
box = new FlxSprite(-20, 45);
|
||||
|
||||
|
||||
var hasDialog = false;
|
||||
switch (PlayState.SONG.song.toLowerCase())
|
||||
{
|
||||
|
@ -108,10 +107,10 @@ class DialogueBox extends FlxSpriteGroup
|
|||
}
|
||||
|
||||
this.dialogueList = dialogueList;
|
||||
|
||||
|
||||
if (!hasDialog)
|
||||
return;
|
||||
|
||||
|
||||
box.animation.play('normalOpen');
|
||||
box.setGraphicSize(Std.int(box.width * PlayState.daPixelZoom * 0.9));
|
||||
box.updateHitbox();
|
||||
|
@ -126,7 +125,6 @@ class DialogueBox extends FlxSpriteGroup
|
|||
handSelect.visible = false;
|
||||
add(handSelect);
|
||||
|
||||
|
||||
if (!talkingRight)
|
||||
{
|
||||
// box.flipX = true;
|
||||
|
@ -184,7 +182,7 @@ class DialogueBox extends FlxSpriteGroup
|
|||
if (FlxG.keys.justPressed.ANY && dialogueEnded)
|
||||
{
|
||||
remove(dialogue);
|
||||
|
||||
|
||||
FlxG.sound.play(Paths.sound('clickText'), 0.8);
|
||||
|
||||
if (dialogueList[1] == null && dialogueList[0] != null)
|
||||
|
@ -222,7 +220,7 @@ class DialogueBox extends FlxSpriteGroup
|
|||
}
|
||||
else if (FlxG.keys.justPressed.ANY && dialogueStarted)
|
||||
swagDialogue.skip();
|
||||
|
||||
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxBasic;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import openfl.events.NetStatusEvent;
|
||||
import openfl.media.Video;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import flash.text.TextField;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSubState;
|
||||
import flixel.math.FlxPoint;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
|
||||
class Highscore
|
||||
{
|
||||
#if (haxe >= "4.0.0")
|
||||
|
@ -10,7 +8,6 @@ class Highscore
|
|||
public static var songScores:Map<String, Int> = new Map<String, Int>();
|
||||
#end
|
||||
|
||||
|
||||
public static function saveScore(song:String, score:Int = 0, ?diff:Int = 0):Void
|
||||
{
|
||||
var formattedSong:String = formatSong(song, diff);
|
||||
|
@ -56,7 +53,6 @@ class Highscore
|
|||
* I moved the compiler flag here, rather than using it everywhere else.
|
||||
*/
|
||||
#if !switch
|
||||
|
||||
// Reminder that I don't need to format this song, it should come formatted!
|
||||
songScores.set(formattedSong, score);
|
||||
FlxG.save.data.songScores = songScores;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package ;
|
||||
package;
|
||||
|
||||
import Controls;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.input.gamepad.FlxGamepad;
|
||||
import flixel.input.gamepad.FlxGamepadInputID;
|
||||
import flixel.input.keyboard.FlxKey;
|
||||
|
@ -11,210 +9,192 @@ using flixel.util.FlxStringUtil;
|
|||
|
||||
class InputFormatter
|
||||
{
|
||||
static public function format(id:Int, device:Device):String
|
||||
{
|
||||
return switch (device)
|
||||
{
|
||||
case Keys: getKeyName(id);
|
||||
case Gamepad(gamepadID): getButtonName(id, FlxG.gamepads.getByID(gamepadID));
|
||||
}
|
||||
}
|
||||
|
||||
static public function getKeyName(id:Int):String
|
||||
{
|
||||
return switch(id)
|
||||
{
|
||||
case ZERO : "0";
|
||||
case ONE : "1";
|
||||
case TWO : "2";
|
||||
case THREE : "3";
|
||||
case FOUR : "4";
|
||||
case FIVE : "5";
|
||||
case SIX : "6";
|
||||
case SEVEN : "7";
|
||||
case EIGHT : "8";
|
||||
case NINE : "9";
|
||||
case PAGEUP : "PgUp";
|
||||
case PAGEDOWN : "PgDown";
|
||||
// case HOME : "Hm";
|
||||
// case END : "End";
|
||||
// case INSERT : "Ins";
|
||||
// case ESCAPE : "Esc";
|
||||
// case MINUS : "-";
|
||||
// case PLUS : "+";
|
||||
// case DELETE : "Del";
|
||||
case BACKSPACE : "BckSpc";
|
||||
case LBRACKET : "[";
|
||||
case RBRACKET : "]";
|
||||
case BACKSLASH : "\\";
|
||||
case CAPSLOCK : "Caps";
|
||||
case SEMICOLON : ";";
|
||||
case QUOTE : "'";
|
||||
// case ENTER : "Ent";
|
||||
// case SHIFT : "Shf";
|
||||
case COMMA : ",";
|
||||
case PERIOD : ".";
|
||||
case SLASH : "/";
|
||||
case GRAVEACCENT : "`";
|
||||
case CONTROL : "Ctrl";
|
||||
case ALT : "Alt";
|
||||
// case SPACE : "Spc";
|
||||
// case UP : "Up";
|
||||
// case DOWN : "Dn";
|
||||
// case LEFT : "Lf";
|
||||
// case RIGHT : "Rt";
|
||||
// case TAB : "Tab";
|
||||
case PRINTSCREEN : "PrtScrn";
|
||||
case NUMPADZERO : "#0";
|
||||
case NUMPADONE : "#1";
|
||||
case NUMPADTWO : "#2";
|
||||
case NUMPADTHREE : "#3";
|
||||
case NUMPADFOUR : "#4";
|
||||
case NUMPADFIVE : "#5";
|
||||
case NUMPADSIX : "#6";
|
||||
case NUMPADSEVEN : "#7";
|
||||
case NUMPADEIGHT : "#8";
|
||||
case NUMPADNINE : "#9";
|
||||
case NUMPADMINUS : "#-";
|
||||
case NUMPADPLUS : "#+";
|
||||
case NUMPADPERIOD : "#.";
|
||||
case NUMPADMULTIPLY: "#*";
|
||||
default: titleCase(FlxKey.toStringMap[id]);
|
||||
}
|
||||
}
|
||||
|
||||
static var dirReg = ~/^(l|r).?-(left|right|down|up)$/;
|
||||
inline static public function getButtonName(id:Int, gamepad:FlxGamepad):String
|
||||
{
|
||||
return switch(gamepad.getInputLabel(id))
|
||||
{
|
||||
// case null | "": shortenButtonName(FlxGamepadInputID.toStringMap[id]);
|
||||
case label: shortenButtonName(label);
|
||||
}
|
||||
}
|
||||
|
||||
static function shortenButtonName(name:String)
|
||||
{
|
||||
return switch (name == null ? "" : name.toLowerCase())
|
||||
{
|
||||
case "": "[?]";
|
||||
// case "square" : "[]";
|
||||
// case "circle" : "()";
|
||||
// case "triangle": "/\\";
|
||||
// case "plus" : "+";
|
||||
// case "minus" : "-";
|
||||
// case "home" : "Hm";
|
||||
// case "guide" : "Gd";
|
||||
// case "back" : "Bk";
|
||||
// case "select" : "Bk";
|
||||
// case "start" : "St";
|
||||
// case "left" : "Lf";
|
||||
// case "right" : "Rt";
|
||||
// case "down" : "Dn";
|
||||
// case "up" : "Up";
|
||||
case dir if (dirReg.match(dir)):
|
||||
dirReg.matched(1).toUpperCase() + " " + titleCase(dirReg.matched(2));
|
||||
case label: titleCase(label);
|
||||
}
|
||||
}
|
||||
|
||||
inline static function titleCaseTrim(str:String, length = 8)
|
||||
{
|
||||
return str.charAt(0).toUpperCase() + str.substr(1, length - 1).toLowerCase();
|
||||
}
|
||||
|
||||
inline static function titleCase(str:String)
|
||||
{
|
||||
return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();
|
||||
}
|
||||
|
||||
inline static public function parsePadName(name:String):ControllerName
|
||||
{
|
||||
return ControllerName.parseName(name);
|
||||
}
|
||||
|
||||
inline static public function getPadName(gamepad:FlxGamepad):ControllerName
|
||||
{
|
||||
return ControllerName.getName(gamepad);
|
||||
}
|
||||
|
||||
inline static public function getPadNameById(id:Int):ControllerName
|
||||
{
|
||||
return ControllerName.getNameById(id);
|
||||
}
|
||||
static public function format(id:Int, device:Device):String
|
||||
{
|
||||
return switch (device)
|
||||
{
|
||||
case Keys: getKeyName(id);
|
||||
case Gamepad(gamepadID): getButtonName(id, FlxG.gamepads.getByID(gamepadID));
|
||||
}
|
||||
}
|
||||
|
||||
static public function getKeyName(id:Int):String
|
||||
{
|
||||
return switch (id)
|
||||
{
|
||||
case ZERO: "0";
|
||||
case ONE: "1";
|
||||
case TWO: "2";
|
||||
case THREE: "3";
|
||||
case FOUR: "4";
|
||||
case FIVE: "5";
|
||||
case SIX: "6";
|
||||
case SEVEN: "7";
|
||||
case EIGHT: "8";
|
||||
case NINE: "9";
|
||||
case PAGEUP: "PgUp";
|
||||
case PAGEDOWN: "PgDown";
|
||||
// case HOME : "Hm";
|
||||
// case END : "End";
|
||||
// case INSERT : "Ins";
|
||||
// case ESCAPE : "Esc";
|
||||
// case MINUS : "-";
|
||||
// case PLUS : "+";
|
||||
// case DELETE : "Del";
|
||||
case BACKSPACE: "BckSpc";
|
||||
case LBRACKET: "[";
|
||||
case RBRACKET: "]";
|
||||
case BACKSLASH: "\\";
|
||||
case CAPSLOCK: "Caps";
|
||||
case SEMICOLON: ";";
|
||||
case QUOTE: "'";
|
||||
// case ENTER : "Ent";
|
||||
// case SHIFT : "Shf";
|
||||
case COMMA: ",";
|
||||
case PERIOD: ".";
|
||||
case SLASH: "/";
|
||||
case GRAVEACCENT: "`";
|
||||
case CONTROL: "Ctrl";
|
||||
case ALT: "Alt";
|
||||
// case SPACE : "Spc";
|
||||
// case UP : "Up";
|
||||
// case DOWN : "Dn";
|
||||
// case LEFT : "Lf";
|
||||
// case RIGHT : "Rt";
|
||||
// case TAB : "Tab";
|
||||
case PRINTSCREEN: "PrtScrn";
|
||||
case NUMPADZERO: "#0";
|
||||
case NUMPADONE: "#1";
|
||||
case NUMPADTWO: "#2";
|
||||
case NUMPADTHREE: "#3";
|
||||
case NUMPADFOUR: "#4";
|
||||
case NUMPADFIVE: "#5";
|
||||
case NUMPADSIX: "#6";
|
||||
case NUMPADSEVEN: "#7";
|
||||
case NUMPADEIGHT: "#8";
|
||||
case NUMPADNINE: "#9";
|
||||
case NUMPADMINUS: "#-";
|
||||
case NUMPADPLUS: "#+";
|
||||
case NUMPADPERIOD: "#.";
|
||||
case NUMPADMULTIPLY: "#*";
|
||||
default: titleCase(FlxKey.toStringMap[id]);
|
||||
}
|
||||
}
|
||||
|
||||
static var dirReg = ~/^(l|r).?-(left|right|down|up)$/;
|
||||
|
||||
inline static public function getButtonName(id:Int, gamepad:FlxGamepad):String
|
||||
{
|
||||
return switch (gamepad.getInputLabel(id))
|
||||
{
|
||||
// case null | "": shortenButtonName(FlxGamepadInputID.toStringMap[id]);
|
||||
case label: shortenButtonName(label);
|
||||
}
|
||||
}
|
||||
|
||||
static function shortenButtonName(name:String)
|
||||
{
|
||||
return switch (name == null ? "" : name.toLowerCase())
|
||||
{
|
||||
case "": "[?]";
|
||||
// case "square" : "[]";
|
||||
// case "circle" : "()";
|
||||
// case "triangle": "/\\";
|
||||
// case "plus" : "+";
|
||||
// case "minus" : "-";
|
||||
// case "home" : "Hm";
|
||||
// case "guide" : "Gd";
|
||||
// case "back" : "Bk";
|
||||
// case "select" : "Bk";
|
||||
// case "start" : "St";
|
||||
// case "left" : "Lf";
|
||||
// case "right" : "Rt";
|
||||
// case "down" : "Dn";
|
||||
// case "up" : "Up";
|
||||
case dir if (dirReg.match(dir)):
|
||||
dirReg.matched(1).toUpperCase() + " " + titleCase(dirReg.matched(2));
|
||||
case label: titleCase(label);
|
||||
}
|
||||
}
|
||||
|
||||
inline static function titleCaseTrim(str:String, length = 8)
|
||||
{
|
||||
return str.charAt(0).toUpperCase() + str.substr(1, length - 1).toLowerCase();
|
||||
}
|
||||
|
||||
inline static function titleCase(str:String)
|
||||
{
|
||||
return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();
|
||||
}
|
||||
|
||||
inline static public function parsePadName(name:String):ControllerName
|
||||
{
|
||||
return ControllerName.parseName(name);
|
||||
}
|
||||
|
||||
inline static public function getPadName(gamepad:FlxGamepad):ControllerName
|
||||
{
|
||||
return ControllerName.getName(gamepad);
|
||||
}
|
||||
|
||||
inline static public function getPadNameById(id:Int):ControllerName
|
||||
{
|
||||
return ControllerName.getNameById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@:forward
|
||||
@:enum abstract ControllerName(String) from String to String
|
||||
{
|
||||
var OUYA = "Ouya" ;
|
||||
var PS4 = "PS4" ;
|
||||
var LOGI = "Logi" ;
|
||||
var XBOX = "XBox" ;
|
||||
var XINPUT = "XInput" ;
|
||||
var WII = "Wii" ;
|
||||
var PRO_CON = "Pro_Con" ;
|
||||
var JOYCONS = "Joycons" ;
|
||||
var JOYCON_L = "Joycon_L";
|
||||
var JOYCON_R = "Joycon_R";
|
||||
var MFI = "MFI" ;
|
||||
var PAD = "Pad" ;
|
||||
|
||||
static public function getAssetByDevice(device:Device):String
|
||||
{
|
||||
return switch (device)
|
||||
{
|
||||
case Keys: getAsset(null);
|
||||
case Gamepad(id): getAsset(FlxG.gamepads.getByID(id));
|
||||
}
|
||||
}
|
||||
|
||||
static public function getAsset(gamepad:FlxGamepad):String
|
||||
{
|
||||
if (gamepad == null)
|
||||
return 'assets/images/ui/devices/Keys.png';
|
||||
|
||||
final name = parseName(gamepad.name);
|
||||
var path = 'assets/images/ui/devices/$name.png';
|
||||
if (openfl.utils.Assets.exists(path))
|
||||
return path;
|
||||
|
||||
return 'assets/images/ui/devices/Pad.png';
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline static public function getNameById(id:Int):ControllerName return getName(FlxG.gamepads.getByID(id));
|
||||
inline static public function getName(gamepad:FlxGamepad):ControllerName return parseName(gamepad.name);
|
||||
static public function parseName(name:String):ControllerName
|
||||
{
|
||||
name = name.toLowerCase().remove("-").remove("_");
|
||||
return
|
||||
if (name.contains("ouya"))
|
||||
OUYA;
|
||||
else if (name.contains("wireless controller") || name.contains("ps4"))
|
||||
PS4;
|
||||
else if (name.contains("logitech"))
|
||||
LOGI;
|
||||
else if (name.contains("xbox"))
|
||||
XBOX
|
||||
else if (name.contains("xinput"))
|
||||
XINPUT;
|
||||
else if (name.contains("nintendo rvlcnt01tr") || name.contains("nintendo rvlcnt01"))
|
||||
WII;
|
||||
else if (name.contains("mayflash wiimote pc adapter"))
|
||||
WII;
|
||||
else if (name.contains("pro controller"))
|
||||
PRO_CON;
|
||||
else if (name.contains("joycon l+r"))
|
||||
JOYCONS;
|
||||
else if (name.contains("joycon (l)"))
|
||||
JOYCON_L;
|
||||
else if (name.contains("joycon (r)"))
|
||||
JOYCON_R;
|
||||
else if (name.contains("mfi"))
|
||||
MFI;
|
||||
else
|
||||
PAD;
|
||||
}
|
||||
}
|
||||
var OUYA = "Ouya";
|
||||
var PS4 = "PS4";
|
||||
var LOGI = "Logi";
|
||||
var XBOX = "XBox";
|
||||
var XINPUT = "XInput";
|
||||
var WII = "Wii";
|
||||
var PRO_CON = "Pro_Con";
|
||||
var JOYCONS = "Joycons";
|
||||
var JOYCON_L = "Joycon_L";
|
||||
var JOYCON_R = "Joycon_R";
|
||||
var MFI = "MFI";
|
||||
var PAD = "Pad";
|
||||
|
||||
static public function getAssetByDevice(device:Device):String
|
||||
{
|
||||
return switch (device)
|
||||
{
|
||||
case Keys: getAsset(null);
|
||||
case Gamepad(id): getAsset(FlxG.gamepads.getByID(id));
|
||||
}
|
||||
}
|
||||
|
||||
static public function getAsset(gamepad:FlxGamepad):String
|
||||
{
|
||||
if (gamepad == null)
|
||||
return 'assets/images/ui/devices/Keys.png';
|
||||
|
||||
final name = parseName(gamepad.name);
|
||||
var path = 'assets/images/ui/devices/$name.png';
|
||||
if (openfl.utils.Assets.exists(path))
|
||||
return path;
|
||||
|
||||
return 'assets/images/ui/devices/Pad.png';
|
||||
}
|
||||
|
||||
inline static public function getNameById(id:Int):ControllerName
|
||||
return getName(FlxG.gamepads.getByID(id));
|
||||
|
||||
inline static public function getName(gamepad:FlxGamepad):ControllerName
|
||||
return parseName(gamepad.name);
|
||||
|
||||
static public function parseName(name:String):ControllerName
|
||||
{
|
||||
name = name.toLowerCase().remove("-").remove("_");
|
||||
return if (name.contains("ouya")) OUYA; else if (name.contains("wireless controller")
|
||||
|| name.contains("ps4")) PS4; else if (name.contains("logitech")) LOGI; else if (name.contains("xbox")) XBOX else if (name.contains("xinput"))
|
||||
XINPUT; else if (name.contains("nintendo rvlcnt01tr")
|
||||
|| name.contains("nintendo rvlcnt01")) WII; else if (name.contains("mayflash wiimote pc adapter")) WII; else if (name.contains("pro controller"))
|
||||
PRO_CON; else if (name.contains("joycon l+r")) JOYCONS; else if (name.contains("joycon (l)")) JOYCON_L; else if (name.contains("joycon (r)"))
|
||||
JOYCON_R; else if (name.contains("mfi")) MFI; else PAD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import NGio;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import Conductor.BPMChangeEvent;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxGame;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.addons.ui.FlxUIState;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import Conductor.BPMChangeEvent;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSubState;
|
||||
|
||||
class MusicBeatSubstate extends FlxSubState
|
||||
|
@ -20,7 +19,7 @@ class MusicBeatSubstate extends FlxSubState
|
|||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
//everyStep();
|
||||
// everyStep();
|
||||
var oldStep:Int = curStep;
|
||||
|
||||
updateCurStep();
|
||||
|
@ -29,7 +28,6 @@ class MusicBeatSubstate extends FlxSubState
|
|||
if (oldStep != curStep && curStep >= 0)
|
||||
stepHit();
|
||||
|
||||
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
|
@ -57,6 +55,6 @@ class MusicBeatSubstate extends FlxSubState
|
|||
|
||||
public function beatHit():Void
|
||||
{
|
||||
//do literally nothing dumbass
|
||||
// do literally nothing dumbass
|
||||
}
|
||||
}
|
||||
|
|
117
source/NGio.hx
117
source/NGio.hx
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
#if newgrounds
|
||||
|
||||
import flixel.FlxG;
|
||||
#if newgrounds
|
||||
import flixel.util.FlxSignal;
|
||||
import flixel.util.FlxTimer;
|
||||
import io.newgrounds.NG;
|
||||
|
@ -19,6 +18,7 @@ import openfl.display.Stage;
|
|||
|
||||
using StringTools;
|
||||
#end
|
||||
|
||||
/**
|
||||
* MADE BY GEOKURELI THE LEGENED GOD HERO MVP
|
||||
*/
|
||||
|
@ -30,8 +30,10 @@ class NGio
|
|||
* Used in MainMenuState to show a popup to establish a new connection
|
||||
*/
|
||||
public static var savedSessionFailed(default, null):Bool = false;
|
||||
|
||||
public static var scoreboardsLoaded:Bool = false;
|
||||
public static var isLoggedIn(get, never):Bool;
|
||||
|
||||
inline static function get_isLoggedIn()
|
||||
{
|
||||
return NG.core != null && NG.core.loggedIn;
|
||||
|
@ -43,20 +45,18 @@ class NGio
|
|||
public static var ngScoresLoaded(default, null):FlxSignal = new FlxSignal();
|
||||
|
||||
public static var GAME_VER:String = "";
|
||||
|
||||
|
||||
static public function checkVersion(callback:String->Void)
|
||||
{
|
||||
trace('checking NG.io version');
|
||||
GAME_VER = "v" + Application.current.meta.get('version');
|
||||
|
||||
NG.core.calls.app.getCurrentVersion(GAME_VER)
|
||||
.addDataHandler(function(response)
|
||||
{
|
||||
GAME_VER = response.result.data.currentVersion;
|
||||
trace('CURRENT NG VERSION: ' + GAME_VER);
|
||||
callback(GAME_VER);
|
||||
})
|
||||
.send();
|
||||
NG.core.calls.app.getCurrentVersion(GAME_VER).addDataHandler(function(response)
|
||||
{
|
||||
GAME_VER = response.result.data.currentVersion;
|
||||
trace('CURRENT NG VERSION: ' + GAME_VER);
|
||||
callback(GAME_VER);
|
||||
}).send();
|
||||
}
|
||||
|
||||
static public function init()
|
||||
|
@ -68,40 +68,41 @@ class NGio
|
|||
return;
|
||||
}
|
||||
trace("connecting to newgrounds");
|
||||
|
||||
|
||||
#if NG_FORCE_EXPIRED_SESSION
|
||||
var sessionId:String = "fake_session_id";
|
||||
function onSessionFail(error:Error)
|
||||
{
|
||||
trace("Forcing an expired saved session. "
|
||||
+ "To disable, comment out NG_FORCE_EXPIRED_SESSION in Project.xml");
|
||||
savedSessionFailed = true;
|
||||
}
|
||||
var sessionId:String = "fake_session_id";
|
||||
function onSessionFail(error:Error)
|
||||
{
|
||||
trace("Forcing an expired saved session. " + "To disable, comment out NG_FORCE_EXPIRED_SESSION in Project.xml");
|
||||
savedSessionFailed = true;
|
||||
}
|
||||
#else
|
||||
var sessionId:String = NGLite.getSessionId();
|
||||
if (sessionId != null)
|
||||
trace("found web session id");
|
||||
|
||||
#if (debug)
|
||||
if (sessionId == null && APIStuff.SESSION != null)
|
||||
{
|
||||
trace("using debug session id");
|
||||
sessionId = APIStuff.SESSION;
|
||||
}
|
||||
#end
|
||||
|
||||
var onSessionFail:Error->Void = null;
|
||||
if (sessionId == null && FlxG.save.data.sessionId != null)
|
||||
{
|
||||
trace("using stored session id");
|
||||
sessionId = FlxG.save.data.sessionId;
|
||||
onSessionFail = function (error) savedSessionFailed = true;
|
||||
}
|
||||
var sessionId:String = NGLite.getSessionId();
|
||||
if (sessionId != null)
|
||||
trace("found web session id");
|
||||
|
||||
#if (debug)
|
||||
if (sessionId == null && APIStuff.SESSION != null)
|
||||
{
|
||||
trace("using debug session id");
|
||||
sessionId = APIStuff.SESSION;
|
||||
}
|
||||
#end
|
||||
|
||||
|
||||
var onSessionFail:Error->Void = null;
|
||||
if (sessionId == null && FlxG.save.data.sessionId != null)
|
||||
{
|
||||
trace("using stored session id");
|
||||
sessionId = FlxG.save.data.sessionId;
|
||||
onSessionFail = function(error) savedSessionFailed = true;
|
||||
}
|
||||
#end
|
||||
|
||||
NG.create(api, sessionId, #if NG_DEBUG true #else false #end, onSessionFail);
|
||||
|
||||
#if NG_VERBOSE NG.core.verbose = true; #end
|
||||
|
||||
#if NG_VERBOSE
|
||||
NG.core.verbose = true;
|
||||
#end
|
||||
// Set the encryption cipher/format to RC4/Base64. AES128 and Hex are not implemented yet
|
||||
NG.core.initEncryption(APIStuff.EncKey); // Found in you NG project view
|
||||
|
||||
|
@ -113,7 +114,7 @@ class NGio
|
|||
trace("attempting login");
|
||||
NG.core.onLogin.add(onNGLogin);
|
||||
}
|
||||
//GK: taking out auto login, adding a login button to the main menu
|
||||
// GK: taking out auto login, adding a login button to the main menu
|
||||
// else
|
||||
// {
|
||||
// /* They are NOT playing on newgrounds.com, no session id was found. We must start one manually, if we want to.
|
||||
|
@ -122,7 +123,7 @@ class NGio
|
|||
// NG.core.requestLogin(onNGLogin);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to log in to newgrounds by requesting a new session ID, only call if no session ID was found automatically
|
||||
* @param popupLauncher The function to call to open the login url, must be inside
|
||||
|
@ -135,26 +136,26 @@ class NGio
|
|||
var onPending:Void->Void = null;
|
||||
if (popupLauncher != null)
|
||||
{
|
||||
onPending = function () popupLauncher(NG.core.openPassportUrl);
|
||||
onPending = function() popupLauncher(NG.core.openPassportUrl);
|
||||
}
|
||||
|
||||
|
||||
var onSuccess:Void->Void = onNGLogin;
|
||||
var onFail:Error->Void = null;
|
||||
var onCancel:Void->Void = null;
|
||||
if (onComplete != null)
|
||||
{
|
||||
onSuccess = function ()
|
||||
onSuccess = function()
|
||||
{
|
||||
onNGLogin();
|
||||
onComplete(Success);
|
||||
}
|
||||
onFail = function (e) onComplete(Fail(e.message));
|
||||
onFail = function(e) onComplete(Fail(e.message));
|
||||
onCancel = function() onComplete(Cancelled);
|
||||
}
|
||||
|
||||
|
||||
NG.core.requestLogin(onSuccess, onPending, onFail, onCancel);
|
||||
}
|
||||
|
||||
|
||||
inline static public function cancelLogin():Void
|
||||
{
|
||||
NG.core.cancelLoginRequest();
|
||||
|
@ -173,11 +174,11 @@ class NGio
|
|||
|
||||
ngDataLoaded.dispatch();
|
||||
}
|
||||
|
||||
|
||||
static public function logout()
|
||||
{
|
||||
NG.core.logOut();
|
||||
|
||||
|
||||
FlxG.save.data.sessionId = null;
|
||||
FlxG.save.flush();
|
||||
}
|
||||
|
@ -251,7 +252,9 @@ class NGio
|
|||
NG.core.calls.event.logEvent(event).send();
|
||||
trace('should have logged: ' + event);
|
||||
#else
|
||||
#if debug trace('event:$event - not logged, missing NG.io lib'); #end
|
||||
#if debug
|
||||
trace('event:$event - not logged, missing NG.io lib');
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
|
@ -265,7 +268,9 @@ class NGio
|
|||
medal.sendUnlock();
|
||||
}
|
||||
#else
|
||||
#if debug trace('medal:$id - not unlocked, missing NG.io lib'); #end
|
||||
#if debug
|
||||
trace('medal:$id - not unlocked, missing NG.io lib');
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
|
@ -287,7 +292,9 @@ class NGio
|
|||
}
|
||||
}
|
||||
#else
|
||||
#if debug trace('Song:$song, Score:$score - not posted, missing NG.io lib'); #end
|
||||
#if debug
|
||||
trace('Song:$song, Score:$score - not posted, missing NG.io lib');
|
||||
#end
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
@ -296,8 +303,10 @@ enum ConnectionResult
|
|||
{
|
||||
/** Log in successful */
|
||||
Success;
|
||||
|
||||
/** Could not login */
|
||||
Fail(msg:String);
|
||||
|
||||
/** User cancelled the login */
|
||||
Cancelled;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.math.FlxMath;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import haxe.io.Path;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxSubState;
|
||||
import flixel.text.FlxText;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import openfl.utils.AssetType;
|
||||
import openfl.utils.Assets as OpenFlAssets;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import Controls.Control;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxSubState;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
|
|
|
@ -5,7 +5,6 @@ import Song.SwagSong;
|
|||
import WiggleEffect.WiggleEffectType;
|
||||
import flixel.FlxBasic;
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxGame;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package;
|
||||
|
||||
import Controls;
|
||||
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.input.actions.FlxActionInput;
|
||||
import flixel.input.gamepad.FlxGamepad;
|
||||
import flixel.util.FlxSignal;
|
||||
|
@ -31,12 +29,12 @@ class PlayerSettings
|
|||
{
|
||||
this.id = id;
|
||||
this.controls = new Controls('player$id', None);
|
||||
|
||||
|
||||
#if CLEAR_INPUT_SAVE
|
||||
FlxG.save.data.controls = null;
|
||||
FlxG.save.flush();
|
||||
#end
|
||||
|
||||
|
||||
var useDefault = true;
|
||||
var controlData = FlxG.save.data.controls;
|
||||
if (controlData != null)
|
||||
|
@ -46,7 +44,7 @@ class PlayerSettings
|
|||
keyData = controlData.p1.keys;
|
||||
else if (id == 1 && controlData.p2 != null && controlData.p2.keys != null)
|
||||
keyData = controlData.p2.keys;
|
||||
|
||||
|
||||
if (keyData != null)
|
||||
{
|
||||
useDefault = false;
|
||||
|
@ -54,11 +52,11 @@ class PlayerSettings
|
|||
controls.fromSaveData(keyData, Keys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (useDefault)
|
||||
controls.setKeyboardScheme(Solo);
|
||||
}
|
||||
|
||||
|
||||
function addGamepad(gamepad:FlxGamepad)
|
||||
{
|
||||
var useDefault = true;
|
||||
|
@ -70,7 +68,7 @@ class PlayerSettings
|
|||
padData = controlData.p1.pad;
|
||||
else if (id == 1 && controlData.p2 != null && controlData.p2.pad != null)
|
||||
padData = controlData.p2.pad;
|
||||
|
||||
|
||||
if (padData != null)
|
||||
{
|
||||
useDefault = false;
|
||||
|
@ -78,17 +76,17 @@ class PlayerSettings
|
|||
controls.addGamepadWithSaveData(gamepad.id, padData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (useDefault)
|
||||
controls.addDefaultGamepad(gamepad.id);
|
||||
}
|
||||
|
||||
|
||||
public function saveControls()
|
||||
{
|
||||
if (FlxG.save.data.controls == null)
|
||||
FlxG.save.data.controls = {};
|
||||
|
||||
var playerData:{ ?keys:Dynamic, ?pad:Dynamic }
|
||||
|
||||
var playerData:{?keys:Dynamic, ?pad:Dynamic}
|
||||
if (id == 0)
|
||||
{
|
||||
if (FlxG.save.data.controls.p1 == null)
|
||||
|
@ -101,14 +99,14 @@ class PlayerSettings
|
|||
FlxG.save.data.controls.p2 = {};
|
||||
playerData = FlxG.save.data.controls.p2;
|
||||
}
|
||||
|
||||
|
||||
var keyData = controls.createSaveData(Keys);
|
||||
if (keyData != null)
|
||||
{
|
||||
playerData.keys = keyData;
|
||||
trace("saving key data: " + haxe.Json.stringify(keyData));
|
||||
}
|
||||
|
||||
|
||||
if (controls.gamepadsAdded.length > 0)
|
||||
{
|
||||
var padData = controls.createSaveData(Gamepad(controls.gamepadsAdded[0]));
|
||||
|
@ -118,10 +116,10 @@ class PlayerSettings
|
|||
playerData.pad = padData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FlxG.save.flush();
|
||||
}
|
||||
|
||||
|
||||
static public function init():Void
|
||||
{
|
||||
if (player1 == null)
|
||||
|
@ -129,7 +127,7 @@ class PlayerSettings
|
|||
player1 = new PlayerSettings(0);
|
||||
++numPlayers;
|
||||
}
|
||||
|
||||
|
||||
FlxG.gamepads.deviceConnected.add(onGamepadAdded);
|
||||
|
||||
var numGamepads = FlxG.gamepads.numActiveGamepads;
|
||||
|
@ -160,90 +158,88 @@ class PlayerSettings
|
|||
|
||||
// DeviceManager.init();
|
||||
}
|
||||
|
||||
|
||||
static function onGamepadAdded(gamepad:FlxGamepad)
|
||||
{
|
||||
player1.addGamepad(gamepad);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public function setKeyboardScheme(scheme)
|
||||
{
|
||||
controls.setKeyboardScheme(scheme);
|
||||
}
|
||||
|
||||
static public function addAvatar(avatar:Player):PlayerSettings
|
||||
{
|
||||
var settings:PlayerSettings;
|
||||
|
||||
if (player1 == null)
|
||||
public function setKeyboardScheme(scheme)
|
||||
{
|
||||
player1 = new PlayerSettings(0, Solo);
|
||||
++numPlayers;
|
||||
controls.setKeyboardScheme(scheme);
|
||||
}
|
||||
|
||||
if (player1.avatar == null)
|
||||
settings = player1;
|
||||
else
|
||||
static public function addAvatar(avatar:Player):PlayerSettings
|
||||
{
|
||||
if (player2 == null)
|
||||
var settings:PlayerSettings;
|
||||
|
||||
if (player1 == null)
|
||||
{
|
||||
if (player1.controls.keyboardScheme.match(Duo(true)))
|
||||
player2 = new PlayerSettings(1, Duo(false));
|
||||
else
|
||||
player2 = new PlayerSettings(1, None);
|
||||
player1 = new PlayerSettings(0, Solo);
|
||||
++numPlayers;
|
||||
}
|
||||
|
||||
if (player2.avatar == null)
|
||||
settings = player2;
|
||||
if (player1.avatar == null)
|
||||
settings = player1;
|
||||
else
|
||||
throw throw 'Invalid number of players: ${numPlayers + 1}';
|
||||
{
|
||||
if (player2 == null)
|
||||
{
|
||||
if (player1.controls.keyboardScheme.match(Duo(true)))
|
||||
player2 = new PlayerSettings(1, Duo(false));
|
||||
else
|
||||
player2 = new PlayerSettings(1, None);
|
||||
++numPlayers;
|
||||
}
|
||||
|
||||
if (player2.avatar == null)
|
||||
settings = player2;
|
||||
else
|
||||
throw throw 'Invalid number of players: ${numPlayers + 1}';
|
||||
}
|
||||
++numAvatars;
|
||||
settings.avatar = avatar;
|
||||
avatar.settings = settings;
|
||||
|
||||
splitCameras();
|
||||
|
||||
onAvatarAdd.dispatch(settings);
|
||||
|
||||
return settings;
|
||||
}
|
||||
++numAvatars;
|
||||
settings.avatar = avatar;
|
||||
avatar.settings = settings;
|
||||
|
||||
splitCameras();
|
||||
|
||||
onAvatarAdd.dispatch(settings);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
static public function removeAvatar(avatar:Player):Void
|
||||
{
|
||||
var settings:PlayerSettings;
|
||||
|
||||
if (player1 != null && player1.avatar == avatar)
|
||||
settings = player1;
|
||||
else if (player2 != null && player2.avatar == avatar)
|
||||
static public function removeAvatar(avatar:Player):Void
|
||||
{
|
||||
settings = player2;
|
||||
if (player1.controls.keyboardScheme.match(Duo(_)))
|
||||
player1.setKeyboardScheme(Solo);
|
||||
var settings:PlayerSettings;
|
||||
|
||||
if (player1 != null && player1.avatar == avatar)
|
||||
settings = player1;
|
||||
else if (player2 != null && player2.avatar == avatar)
|
||||
{
|
||||
settings = player2;
|
||||
if (player1.controls.keyboardScheme.match(Duo(_)))
|
||||
player1.setKeyboardScheme(Solo);
|
||||
}
|
||||
else
|
||||
throw "Cannot remove avatar that is not for a player";
|
||||
|
||||
settings.avatar = null;
|
||||
while (settings.controls.gamepadsAdded.length > 0)
|
||||
{
|
||||
final id = settings.controls.gamepadsAdded.shift();
|
||||
settings.controls.removeGamepad(id);
|
||||
DeviceManager.releaseGamepad(FlxG.gamepads.getByID(id));
|
||||
}
|
||||
|
||||
--numAvatars;
|
||||
|
||||
splitCameras();
|
||||
|
||||
onAvatarRemove.dispatch(avatar.settings);
|
||||
}
|
||||
else
|
||||
throw "Cannot remove avatar that is not for a player";
|
||||
|
||||
settings.avatar = null;
|
||||
while (settings.controls.gamepadsAdded.length > 0)
|
||||
{
|
||||
final id = settings.controls.gamepadsAdded.shift();
|
||||
settings.controls.removeGamepad(id);
|
||||
DeviceManager.releaseGamepad(FlxG.gamepads.getByID(id));
|
||||
}
|
||||
|
||||
--numAvatars;
|
||||
|
||||
splitCameras();
|
||||
|
||||
onAvatarRemove.dispatch(avatar.settings);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static public function reset()
|
||||
{
|
||||
player1 = null;
|
||||
|
|
|
@ -3,7 +3,6 @@ package;
|
|||
#if discord_rpc
|
||||
import Discord.DiscordClient;
|
||||
#end
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.math.FlxPoint;
|
||||
|
||||
|
@ -100,4 +99,4 @@ class SwagCamera extends FlxCamera
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import haxe.display.Display.Package;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxGame;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import openfl.display.Sprite;
|
||||
import openfl.events.AsyncErrorEvent;
|
||||
import openfl.events.MouseEvent;
|
||||
|
|
|
@ -3,7 +3,6 @@ package animate;
|
|||
// import animateAtlasPlayer.assets.AssetManager;
|
||||
// import animateAtlasPlayer.core.Animation;
|
||||
import animate.FlxSymbol.Parsed;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package animate;
|
||||
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
|
||||
import flixel.math.FlxAngle;
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
import Paths;
|
||||
import Paths;
|
||||
import flixel.FlxG;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ui;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.addons.effects.chainable.FlxEffectSprite;
|
||||
import flixel.addons.effects.chainable.FlxOutlineEffect;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
|
|
|
@ -2,7 +2,6 @@ package ui;
|
|||
|
||||
import Controls;
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup;
|
||||
|
|
|
@ -1,36 +1,42 @@
|
|||
package ui;
|
||||
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.effects.FlxFlicker;
|
||||
import flixel.group.FlxGroup;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.util.FlxSignal;
|
||||
|
||||
class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
|
||||
{
|
||||
public var selectedIndex(default, null) = 0;
|
||||
public var selectedItem(get, never):T;
|
||||
|
||||
/** Called when a new item is highlighted */
|
||||
public var onChange(default, null) = new FlxTypedSignal<T->Void>();
|
||||
|
||||
/** Called when an item is accepted */
|
||||
public var onAcceptPress(default, null) = new FlxTypedSignal<T->Void>();
|
||||
|
||||
/** The navigation control scheme to use */
|
||||
public var navControls:NavControls;
|
||||
|
||||
/** Set to false to disable nav control */
|
||||
public var enabled:Bool = true;
|
||||
|
||||
/** */
|
||||
public var wrapMode:WrapMode = Both;
|
||||
|
||||
|
||||
var byName = new Map<String, T>();
|
||||
|
||||
/** Set to true, internally to disable controls, without affecting vars like `enabled` */
|
||||
public var busy(default, null):Bool = false;
|
||||
|
||||
// bit awkward because BACK is also a menu control and this doesn't affect that
|
||||
|
||||
public function new (navControls:NavControls = Vertical, ?wrapMode:WrapMode)
|
||||
|
||||
public function new(navControls:NavControls = Vertical, ?wrapMode:WrapMode)
|
||||
{
|
||||
this.navControls = navControls;
|
||||
|
||||
|
||||
if (wrapMode != null)
|
||||
this.wrapMode = wrapMode;
|
||||
else
|
||||
|
@ -42,69 +48,69 @@ class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
|
|||
}
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public function addItem(name:String, item:T):T
|
||||
{
|
||||
if (length == selectedIndex)
|
||||
item.select();
|
||||
|
||||
|
||||
byName[name] = item;
|
||||
return add(item);
|
||||
}
|
||||
|
||||
|
||||
public function resetItem(oldName:String, newName:String, ?callback:Void->Void):T
|
||||
{
|
||||
if (!byName.exists(oldName))
|
||||
throw "No item named:" + oldName;
|
||||
|
||||
|
||||
var item = byName[oldName];
|
||||
byName.remove(oldName);
|
||||
byName[newName] = item;
|
||||
item.setItem(newName, callback);
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
|
||||
if (enabled && !busy)
|
||||
updateControls();
|
||||
}
|
||||
|
||||
|
||||
inline function updateControls()
|
||||
{
|
||||
var controls = PlayerSettings.player1.controls;
|
||||
|
||||
|
||||
var wrapX = wrapMode.match(Horizontal | Both);
|
||||
var wrapY = wrapMode.match(Vertical | Both);
|
||||
var newIndex = switch(navControls)
|
||||
var newIndex = switch (navControls)
|
||||
{
|
||||
case Vertical : navList(controls.UI_UP_P , controls.UI_DOWN_P, wrapY);
|
||||
case Horizontal : navList(controls.UI_LEFT_P, controls.UI_RIGHT_P, wrapX);
|
||||
case Both : navList(controls.UI_LEFT_P || controls.UI_UP_P, controls.UI_RIGHT_P || controls.UI_DOWN_P, !wrapMode.match(None));
|
||||
|
||||
case Columns(num): navGrid(num, controls.UI_LEFT_P, controls.UI_RIGHT_P, wrapX, controls.UI_UP_P , controls.UI_DOWN_P , wrapY);
|
||||
case Rows (num): navGrid(num, controls.UI_UP_P , controls.UI_DOWN_P , wrapY, controls.UI_LEFT_P, controls.UI_RIGHT_P, wrapX);
|
||||
case Vertical: navList(controls.UI_UP_P, controls.UI_DOWN_P, wrapY);
|
||||
case Horizontal: navList(controls.UI_LEFT_P, controls.UI_RIGHT_P, wrapX);
|
||||
case Both: navList(controls.UI_LEFT_P || controls.UI_UP_P, controls.UI_RIGHT_P || controls.UI_DOWN_P, !wrapMode.match(None));
|
||||
|
||||
case Columns(num): navGrid(num, controls.UI_LEFT_P, controls.UI_RIGHT_P, wrapX, controls.UI_UP_P, controls.UI_DOWN_P, wrapY);
|
||||
case Rows(num): navGrid(num, controls.UI_UP_P, controls.UI_DOWN_P, wrapY, controls.UI_LEFT_P, controls.UI_RIGHT_P, wrapX);
|
||||
}
|
||||
|
||||
|
||||
if (newIndex != selectedIndex)
|
||||
{
|
||||
FlxG.sound.play(Paths.sound('scrollMenu'));
|
||||
selectItem(newIndex);
|
||||
}
|
||||
|
||||
//Todo: bypass popup blocker on firefox
|
||||
|
||||
// Todo: bypass popup blocker on firefox
|
||||
if (controls.ACCEPT)
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
function navAxis(index:Int, size:Int, prev:Bool, next:Bool, allowWrap:Bool):Int
|
||||
{
|
||||
if (prev == next)
|
||||
return index;
|
||||
|
||||
|
||||
if (prev)
|
||||
{
|
||||
if (index > 0)
|
||||
|
@ -119,10 +125,10 @@ class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
|
|||
else if (allowWrap)
|
||||
index = 0;
|
||||
}
|
||||
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Controls navigation on a linear list of items such as Vertical.
|
||||
* @param prev
|
||||
|
@ -133,7 +139,7 @@ class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
|
|||
{
|
||||
return navAxis(selectedIndex, length, prev, next, allowWrap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Controls navigation on a grid
|
||||
* @param latSize The size of the fixed axis of the grid, or the "lateral axis"
|
||||
|
@ -151,18 +157,18 @@ class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
|
|||
var index = Math.floor(selectedIndex / latSize);
|
||||
// The selected position along the fixed axis
|
||||
var latIndex = selectedIndex % latSize;
|
||||
|
||||
|
||||
latIndex = navAxis(latIndex, latSize, latPrev, latNext, latAllowWrap);
|
||||
index = navAxis(index, size, prev, next, allowWrap);
|
||||
|
||||
|
||||
return Std.int(Math.min(length - 1, index * latSize + latIndex));
|
||||
}
|
||||
|
||||
|
||||
public function accept()
|
||||
{
|
||||
var selected = members[selectedIndex];
|
||||
onAcceptPress.dispatch(selected);
|
||||
|
||||
|
||||
if (selected.fireInstantly)
|
||||
selected.callback();
|
||||
else
|
||||
|
@ -176,28 +182,28 @@ class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function selectItem(index:Int)
|
||||
{
|
||||
members[selectedIndex].idle();
|
||||
|
||||
|
||||
selectedIndex = index;
|
||||
|
||||
|
||||
var selected = members[selectedIndex];
|
||||
selected.select();
|
||||
onChange.dispatch(selected);
|
||||
}
|
||||
|
||||
|
||||
public function has(name:String)
|
||||
{
|
||||
return byName.exists(name);
|
||||
}
|
||||
|
||||
|
||||
public function getItem(name:String)
|
||||
{
|
||||
return byName[name];
|
||||
}
|
||||
|
||||
|
||||
override function destroy()
|
||||
{
|
||||
super.destroy();
|
||||
|
@ -205,7 +211,7 @@ class MenuTypedList<T:MenuItem> extends FlxTypedGroup<T>
|
|||
onChange.removeAll();
|
||||
onAcceptPress.removeAll();
|
||||
}
|
||||
|
||||
|
||||
inline function get_selectedItem():T
|
||||
{
|
||||
return members[selectedIndex];
|
||||
|
@ -216,30 +222,34 @@ class MenuItem extends FlxSprite
|
|||
{
|
||||
public var callback:Void->Void;
|
||||
public var name:String;
|
||||
|
||||
/**
|
||||
* Set to true for things like opening URLs otherwise, it may it get blocked.
|
||||
*/
|
||||
public var fireInstantly = false;
|
||||
|
||||
public var selected(get, never):Bool;
|
||||
function get_selected() return alpha == 1.0;
|
||||
|
||||
public function new (x = 0.0, y = 0.0, name:String, callback)
|
||||
|
||||
function get_selected()
|
||||
return alpha == 1.0;
|
||||
|
||||
public function new(x = 0.0, y = 0.0, name:String, callback)
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
|
||||
antialiasing = true;
|
||||
setData(name, callback);
|
||||
idle();
|
||||
}
|
||||
|
||||
|
||||
function setData(name:String, ?callback:Void->Void)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
|
||||
if (callback != null)
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls setData and resets/redraws the state of the item
|
||||
* @param name the label.
|
||||
|
@ -248,18 +258,18 @@ class MenuItem extends FlxSprite
|
|||
public function setItem(name:String, ?callback:Void->Void)
|
||||
{
|
||||
setData(name, callback);
|
||||
|
||||
|
||||
if (selected)
|
||||
select();
|
||||
else
|
||||
idle();
|
||||
}
|
||||
|
||||
|
||||
public function idle()
|
||||
{
|
||||
alpha = 0.6;
|
||||
}
|
||||
|
||||
|
||||
public function select()
|
||||
{
|
||||
alpha = 1.0;
|
||||
|
@ -269,14 +279,14 @@ class MenuItem extends FlxSprite
|
|||
class MenuTypedItem<T:FlxSprite> extends MenuItem
|
||||
{
|
||||
public var label(default, set):T;
|
||||
|
||||
public function new (x = 0.0, y = 0.0, label:T, name:String, callback)
|
||||
|
||||
public function new(x = 0.0, y = 0.0, label:T, name:String, callback)
|
||||
{
|
||||
super(x, y, name, callback);
|
||||
// set label after super otherwise setters fuck up
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use this when you only want to show the label
|
||||
*/
|
||||
|
@ -288,7 +298,7 @@ class MenuTypedItem<T:FlxSprite> extends MenuItem
|
|||
width = oldWidth;
|
||||
height = oldHeight;
|
||||
}
|
||||
|
||||
|
||||
function set_label(value:T)
|
||||
{
|
||||
if (value != null)
|
||||
|
@ -299,14 +309,14 @@ class MenuTypedItem<T:FlxSprite> extends MenuItem
|
|||
}
|
||||
return this.label = value;
|
||||
}
|
||||
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
if (label != null)
|
||||
label.update(elapsed);
|
||||
}
|
||||
|
||||
|
||||
override function draw()
|
||||
{
|
||||
super.draw();
|
||||
|
@ -321,30 +331,30 @@ class MenuTypedItem<T:FlxSprite> extends MenuItem
|
|||
override function set_alpha(value:Float):Float
|
||||
{
|
||||
super.set_alpha(value);
|
||||
|
||||
|
||||
if (label != null)
|
||||
label.alpha = alpha;
|
||||
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
override function set_x(value:Float):Float
|
||||
{
|
||||
super.set_x(value);
|
||||
|
||||
|
||||
if (label != null)
|
||||
label.x = x;
|
||||
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
override function set_y(Value:Float):Float
|
||||
{
|
||||
super.set_y(Value);
|
||||
|
||||
|
||||
if (label != null)
|
||||
label.y = y;
|
||||
|
||||
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
@ -364,4 +374,4 @@ enum WrapMode
|
|||
Vertical;
|
||||
Both;
|
||||
None;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ui;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.util.FlxColor;
|
||||
|
@ -84,6 +83,7 @@ class ModMenu extends ui.OptionsState.Page
|
|||
}
|
||||
|
||||
inline static var MOD_PATH = "./mods";
|
||||
|
||||
private function refreshModList():Void
|
||||
{
|
||||
while (grpMods.members.length > 0)
|
||||
|
@ -94,14 +94,14 @@ class ModMenu extends ui.OptionsState.Page
|
|||
#if desktop
|
||||
var modList = [];
|
||||
modFolders = [];
|
||||
|
||||
|
||||
trace("mods path:" + FileSystem.absolutePath(MOD_PATH));
|
||||
if (!FileSystem.exists(MOD_PATH))
|
||||
{
|
||||
FlxG.log.warn("missing mods folder, expected: " + FileSystem.absolutePath(MOD_PATH));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (file in FileSystem.readDirectory(MOD_PATH))
|
||||
{
|
||||
if (FileSystem.isDirectory(MOD_PATH + file))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ui;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxSubState;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ui;
|
||||
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup;
|
||||
|
|
|
@ -1,64 +1,61 @@
|
|||
package ui;
|
||||
|
||||
import ui.AtlasText;
|
||||
import ui.MenuList;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.util.FlxColor;
|
||||
import ui.AtlasText;
|
||||
import ui.MenuList;
|
||||
|
||||
class Prompt extends flixel.FlxSubState
|
||||
{
|
||||
inline static var MARGIN = 100;
|
||||
|
||||
|
||||
public var onYes:Void->Void;
|
||||
public var onNo:Void->Void;
|
||||
public var buttons:TextMenuList;
|
||||
public var field:AtlasText;
|
||||
public var back:FlxSprite;
|
||||
|
||||
|
||||
var style:ButtonStyle;
|
||||
|
||||
public function new (text:String, style:ButtonStyle = Ok)
|
||||
|
||||
public function new(text:String, style:ButtonStyle = Ok)
|
||||
{
|
||||
this.style = style;
|
||||
super(0x80000000);
|
||||
|
||||
|
||||
buttons = new TextMenuList(Horizontal);
|
||||
|
||||
|
||||
field = new BoldText(text);
|
||||
field.scrollFactor.set(0, 0);
|
||||
}
|
||||
|
||||
|
||||
override function create()
|
||||
{
|
||||
super.create();
|
||||
|
||||
|
||||
field.y = MARGIN;
|
||||
field.screenCenter(X);
|
||||
add(field);
|
||||
|
||||
|
||||
createButtons();
|
||||
add(buttons);
|
||||
}
|
||||
|
||||
|
||||
public function createBg(width:Int, height:Int, color = 0xFF808080)
|
||||
{
|
||||
back = new FlxSprite();
|
||||
back.makeGraphic(width, height, color, false, "prompt-bg");
|
||||
back.screenCenter(XY);
|
||||
add(back);
|
||||
members.unshift(members.pop());// bring to front
|
||||
members.unshift(members.pop()); // bring to front
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function createBgFromMargin(margin = MARGIN, color = 0xFF808080)
|
||||
{
|
||||
createBg(Std.int(FlxG.width - margin * 2), Std.int(FlxG.height - margin * 2), color);
|
||||
}
|
||||
|
||||
|
||||
public function setButtons(style:ButtonStyle)
|
||||
{
|
||||
if (this.style != style)
|
||||
|
@ -67,24 +64,28 @@ class Prompt extends flixel.FlxSubState
|
|||
createButtons();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function createButtons()
|
||||
{
|
||||
// destroy previous buttons
|
||||
while(buttons.members.length > 0)
|
||||
while (buttons.members.length > 0)
|
||||
{
|
||||
buttons.remove(buttons.members[0], true).destroy();
|
||||
}
|
||||
|
||||
switch(style)
|
||||
|
||||
switch (style)
|
||||
{
|
||||
case Yes_No : createButtonsHelper("yes", "no");
|
||||
case Ok : createButtonsHelper("ok");
|
||||
case Custom(yes, no): createButtonsHelper(yes, no);
|
||||
case None : buttons.exists = false;
|
||||
case Yes_No:
|
||||
createButtonsHelper("yes", "no");
|
||||
case Ok:
|
||||
createButtonsHelper("ok");
|
||||
case Custom(yes, no):
|
||||
createButtonsHelper(yes, no);
|
||||
case None:
|
||||
buttons.exists = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function createButtonsHelper(yes:String, ?no:String)
|
||||
{
|
||||
buttons.exists = true;
|
||||
|
@ -97,14 +98,14 @@ class Prompt extends flixel.FlxSubState
|
|||
{
|
||||
// place right
|
||||
yesButton.x = FlxG.width - yesButton.width - MARGIN;
|
||||
|
||||
|
||||
var noButton = buttons.createItem(no, function() onNo());
|
||||
noButton.x = MARGIN;
|
||||
noButton.y = FlxG.height - noButton.height - MARGIN;
|
||||
noButton.scrollFactor.set(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function setText(text:String)
|
||||
{
|
||||
field.text = text;
|
||||
|
@ -114,8 +115,8 @@ class Prompt extends flixel.FlxSubState
|
|||
|
||||
enum ButtonStyle
|
||||
{
|
||||
Ok;
|
||||
Yes_No;
|
||||
Custom(yes:String, no:Null<String>);//Todo: more than 2
|
||||
Ok;
|
||||
Yes_No;
|
||||
Custom(yes:String, no:Null<String>); // Todo: more than 2
|
||||
None;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ui.animDebugShit;
|
||||
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ui.stageBuildShit;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.input.mouse.FlxMouseEventManager;
|
||||
import flixel.math.FlxPoint;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ui.stageBuildShit;
|
||||
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
import flixel.group.FlxGroup;
|
||||
|
|
Loading…
Add table
Reference in a new issue