From 1301cf3ab6234055e9587c4faf287b3a80ad0025 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 4 Jun 2021 12:53:53 -0400 Subject: [PATCH] WASD controls for animation --- source/TitleState.hx | 2 +- .../animDebugShit}/DebugBoundingState.hx | 69 ++++++++++++++----- 2 files changed, 53 insertions(+), 18 deletions(-) rename source/{ => ui/animDebugShit}/DebugBoundingState.hx (88%) diff --git a/source/TitleState.hx b/source/TitleState.hx index 4e4760c15..4c793684a 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -160,7 +160,7 @@ class TitleState extends MusicBeatState #elseif STAGEBUILD FlxG.switchState(new StageBuilderState()); #elseif ANIMDEBUG - FlxG.switchState(new DebugBoundingState()); + FlxG.switchState(new ui.animDebugShit.DebugBoundingState()); #else new FlxTimer().start(1, function(tmr:FlxTimer) { diff --git a/source/DebugBoundingState.hx b/source/ui/animDebugShit/DebugBoundingState.hx similarity index 88% rename from source/DebugBoundingState.hx rename to source/ui/animDebugShit/DebugBoundingState.hx index 3deedc3c3..32c96af13 100644 --- a/source/DebugBoundingState.hx +++ b/source/ui/animDebugShit/DebugBoundingState.hx @@ -1,4 +1,4 @@ -package; +package ui.animDebugShit; import flixel.FlxCamera; import flixel.FlxG; @@ -47,6 +47,7 @@ class DebugBoundingState extends FlxState var curView:ANIMDEBUGVIEW = SPRITESHEET; var spriteSheetView:FlxGroup; + var offsetView:FlxGroup; var animDropDownMenu:FlxUIDropDownMenu; var dropDownSetup:Bool = false; @@ -65,27 +66,13 @@ class DebugBoundingState extends FlxState add(bg); initSpritesheetView(); + initOffsetView(); // charInput = new FlxInputText(300, 10, 150, "bf", 16); // charInput.focusCam = hudCam; // charInput.cameras = [hudCam]; // charInput.scrollFactor.set(); - animDropDownMenu = new FlxUIDropDownMenu(370, 20, FlxUIDropDownMenu.makeStrIdLabelArray(['weed'], true)); - animDropDownMenu.cameras = [hudCam]; - add(animDropDownMenu); - - var characters:Array = CoolUtil.coolTextFile(Paths.txt('characterList')); - - charInput = new FlxUIDropDownMenu(200, 20, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(str:String) - { - loadAnimShit(characters[Std.parseInt(str)]); - // trace(); - }); - // charInput. - charInput.cameras = [hudCam]; - add(charInput); - super.create(); } @@ -145,6 +132,27 @@ class DebugBoundingState extends FlxState }); } + function initOffsetView():Void + { + offsetView = new FlxGroup(); + add(offsetView); + + animDropDownMenu = new FlxUIDropDownMenu(370, 20, FlxUIDropDownMenu.makeStrIdLabelArray(['weed'], true)); + animDropDownMenu.cameras = [hudCam]; + offsetView.add(animDropDownMenu); + + var characters:Array = CoolUtil.coolTextFile(Paths.txt('characterList')); + + charInput = new FlxUIDropDownMenu(200, 20, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(str:String) + { + loadAnimShit(characters[Std.parseInt(str)]); + // trace(); + }); + // charInput. + charInput.cameras = [hudCam]; + offsetView.add(charInput); + } + function addInfo(str:String, value:Dynamic) { var swagText:FlxText = new FlxText(10, 10 + (28 * txtGrp.length)); @@ -184,8 +192,12 @@ class DebugBoundingState extends FlxState { case SPRITESHEET: spriteSheetView.visible = true; + offsetView.visible = false; + offsetView.active = false; case OFFSETSHIT: spriteSheetView.visible = false; + offsetView.visible = true; + offsetView.active = true; offsetControls(); } @@ -209,14 +221,37 @@ class DebugBoundingState extends FlxState { if (FlxG.keys.justPressed.RBRACKET) { - if (Std.parseInt(animDropDownMenu.selectedId) + 1 < animDropDownMenu.length) + if (Std.parseInt(animDropDownMenu.selectedId) + 1 <= animDropDownMenu.length) animDropDownMenu.selectedId = Std.string(Std.parseInt(animDropDownMenu.selectedId) + 1); + else + animDropDownMenu.selectedId = Std.string(0); animDropDownMenu.callback(animDropDownMenu.selectedId); } if (FlxG.keys.justPressed.LBRACKET) { if (Std.parseInt(animDropDownMenu.selectedId) - 1 >= 0) animDropDownMenu.selectedId = Std.string(Std.parseInt(animDropDownMenu.selectedId) - 1); + else + animDropDownMenu.selectedId = Std.string(animDropDownMenu.length - 1); + animDropDownMenu.callback(animDropDownMenu.selectedId); + } + + if (FlxG.keys.justPressed.W || FlxG.keys.justPressed.S || FlxG.keys.justPressed.D || FlxG.keys.justPressed.A) + { + var missShit:String = ''; + + if (FlxG.keys.pressed.SHIFT) + missShit = 'miss'; + + if (FlxG.keys.justPressed.W) + animDropDownMenu.selectedLabel = 'singUP' + missShit; + if (FlxG.keys.justPressed.S) + animDropDownMenu.selectedLabel = 'singDOWN' + missShit; + if (FlxG.keys.justPressed.A) + animDropDownMenu.selectedLabel = 'singLEFT' + missShit; + if (FlxG.keys.justPressed.D) + animDropDownMenu.selectedLabel = 'singRIGHT' + missShit; + animDropDownMenu.callback(animDropDownMenu.selectedId); }