From e15815afa8ea8ad60855fd5d153604b1ee70ffc0 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 8 Sep 2022 04:03:50 -0400 Subject: [PATCH 1/2] initial haxeui for character offset editor --- .../ui/animDebugShit/DebugBoundingState.hx | 59 ++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/source/funkin/ui/animDebugShit/DebugBoundingState.hx b/source/funkin/ui/animDebugShit/DebugBoundingState.hx index 19012a500..f92e38d67 100644 --- a/source/funkin/ui/animDebugShit/DebugBoundingState.hx +++ b/source/funkin/ui/animDebugShit/DebugBoundingState.hx @@ -1,13 +1,11 @@ package funkin.ui.animDebugShit; -import funkin.play.character.CharacterData.CharacterDataParser; -import funkin.play.character.SparrowCharacter; -import flixel.addons.display.FlxGridOverlay; -import flixel.addons.ui.FlxInputText; -import flixel.addons.ui.FlxUIDropDownMenu; import flixel.FlxCamera; import flixel.FlxSprite; import flixel.FlxState; +import flixel.addons.display.FlxGridOverlay; +import flixel.addons.ui.FlxInputText; +import flixel.addons.ui.FlxUIDropDownMenu; import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxFrame; import flixel.group.FlxGroup; @@ -18,6 +16,13 @@ import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import flixel.util.FlxTimer; import funkin.play.character.BaseCharacter; +import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.play.character.SparrowCharacter; +import haxe.ui.RuntimeComponentBuilder; +import haxe.ui.components.DropDown; +import haxe.ui.core.Component; +import haxe.ui.events.ItemEvent; +import haxe.ui.events.UIEvent; import lime.utils.Assets as LimeAssets; import openfl.Assets; import openfl.events.Event; @@ -63,10 +68,37 @@ class DebugBoundingState extends FlxState var onionSkinChar:FlxSprite; var txtOffsetShit:FlxText; + var uiStuff:Component; + override function create() { Paths.setCurrentLevel('week1'); + var str = Paths.xml('ui/offset-editor-view'); + uiStuff = RuntimeComponentBuilder.fromAsset(str); + + // uiStuff.findComponent("btnViewSpriteSheet").onClick = _ -> curView = SPRITESHEET; + var dropdown:DropDown = cast uiStuff.findComponent("swapper"); + dropdown.onChange = function(e:UIEvent) + { + trace(e.type); + curView = cast e.data.curView; + trace(e.data); + // trace(e.data); + }; + // lv. + // lv.onChange = function(e:UIEvent) + // { + // trace(e.type); + // // trace(e.data.curView); + // // var item:haxe.ui.core.ItemRenderer = cast e.target; + // trace(e.target); + // // if (e.type == "change") + // // { + // // curView = cast e.data; + // // } + // }; + hudCam = new FlxCamera(); hudCam.bgColor.alpha = 0; @@ -86,6 +118,10 @@ class DebugBoundingState extends FlxState // charInput.cameras = [hudCam]; // charInput.scrollFactor.set(); + uiStuff.cameras = [hudCam]; + + add(uiStuff); + super.create(); } @@ -290,9 +326,16 @@ class DebugBoundingState extends FlxState override function update(elapsed:Float) { if (FlxG.keys.justPressed.ONE) + { + var lv:DropDown = cast uiStuff.findComponent("swapper"); + lv.selectedIndex = 0; curView = SPRITESHEET; + } + if (FlxG.keys.justReleased.TWO) { + var lv:DropDown = cast uiStuff.findComponent("swapper"); + lv.selectedIndex = 1; curView = OFFSETSHIT; if (swagChar != null) { @@ -528,8 +571,8 @@ class DebugBoundingState extends FlxState } } -enum ANIMDEBUGVIEW +enum abstract ANIMDEBUGVIEW(String) { - SPRITESHEET; - OFFSETSHIT; + var SPRITESHEET; + var OFFSETSHIT; } From 43b952b321b0a47b98ea1e00d92aa3ac2e5b9b0a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 8 Sep 2022 16:39:31 -0400 Subject: [PATCH 2/2] char input haxeUI stuff --- .../ui/animDebugShit/DebugBoundingState.hx | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/source/funkin/ui/animDebugShit/DebugBoundingState.hx b/source/funkin/ui/animDebugShit/DebugBoundingState.hx index f92e38d67..cf28d23da 100644 --- a/source/funkin/ui/animDebugShit/DebugBoundingState.hx +++ b/source/funkin/ui/animDebugShit/DebugBoundingState.hx @@ -56,8 +56,6 @@ class DebugBoundingState extends FlxState var hudCam:FlxCamera; - var charInput:FlxUIDropDownMenu; - var curView:ANIMDEBUGVIEW = SPRITESHEET; var spriteSheetView:FlxGroup; @@ -113,11 +111,6 @@ class DebugBoundingState extends FlxState initSpritesheetView(); initOffsetView(); - // charInput = new FlxInputText(300, 10, 150, "bf", 16); - // charInput.focusCam = hudCam; - // charInput.cameras = [hudCam]; - // charInput.scrollFactor.set(); - uiStuff.cameras = [hudCam]; add(uiStuff); @@ -258,15 +251,16 @@ class DebugBoundingState extends FlxState var characters:Array = CoolUtil.coolTextFile(Paths.txt('characterList')); - // charInput isnt only exclusive to offsetView shit now - charInput = new FlxUIDropDownMenu(500, 20, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(str:String) + var charDropdown:DropDown = cast uiStuff.findComponent('characterDropdown'); + for (char in characters) { - loadAnimShit(characters[Std.parseInt(str)]); - // trace(); - }); - // charInput. - charInput.cameras = [hudCam]; - add(charInput); + charDropdown.dataSource.add({text: char}); + } + + charDropdown.onChange = function(e:UIEvent) + { + loadAnimShit(e.data.text); + }; } public var mouseOffset:FlxPoint = FlxPoint.get(0, 0); @@ -361,11 +355,6 @@ class DebugBoundingState extends FlxState if (FlxG.keys.justPressed.H) hudCam.visible = !hudCam.visible; - /* if (charInput.hasFocus && FlxG.keys.justPressed.ENTER) - { - loadAnimShit(); - }*/ - CoolUtil.mouseCamDrag(); CoolUtil.mouseWheelZoom(); @@ -480,6 +469,9 @@ class DebugBoundingState extends FlxState var swagChar:BaseCharacter; + /* + Called when animation dropdown is changed! + */ function loadAnimShit(char:String) { if (swagChar != null)