From e15815afa8ea8ad60855fd5d153604b1ee70ffc0 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 8 Sep 2022 04:03:50 -0400 Subject: [PATCH] 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; }