This commit is contained in:
Cameron Taylor 2022-09-20 15:53:57 -04:00
commit 3d8d5ebdec

View file

@ -1,13 +1,11 @@
package funkin.ui.animDebugShit; 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.FlxCamera;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.FlxState; 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.FlxAtlasFrames;
import flixel.graphics.frames.FlxFrame; import flixel.graphics.frames.FlxFrame;
import flixel.group.FlxGroup; import flixel.group.FlxGroup;
@ -18,6 +16,13 @@ import flixel.util.FlxColor;
import flixel.util.FlxSpriteUtil; import flixel.util.FlxSpriteUtil;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
import funkin.play.character.BaseCharacter; 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 lime.utils.Assets as LimeAssets;
import openfl.Assets; import openfl.Assets;
import openfl.events.Event; import openfl.events.Event;
@ -51,8 +56,6 @@ class DebugBoundingState extends FlxState
var hudCam:FlxCamera; var hudCam:FlxCamera;
var charInput:FlxUIDropDownMenu;
var curView:ANIMDEBUGVIEW = SPRITESHEET; var curView:ANIMDEBUGVIEW = SPRITESHEET;
var spriteSheetView:FlxGroup; var spriteSheetView:FlxGroup;
@ -63,10 +66,37 @@ class DebugBoundingState extends FlxState
var onionSkinChar:FlxSprite; var onionSkinChar:FlxSprite;
var txtOffsetShit:FlxText; var txtOffsetShit:FlxText;
var uiStuff:Component;
override function create() override function create()
{ {
Paths.setCurrentLevel('week1'); 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 = new FlxCamera();
hudCam.bgColor.alpha = 0; hudCam.bgColor.alpha = 0;
@ -81,10 +111,9 @@ class DebugBoundingState extends FlxState
initSpritesheetView(); initSpritesheetView();
initOffsetView(); initOffsetView();
// charInput = new FlxInputText(300, 10, 150, "bf", 16); uiStuff.cameras = [hudCam];
// charInput.focusCam = hudCam;
// charInput.cameras = [hudCam]; add(uiStuff);
// charInput.scrollFactor.set();
super.create(); super.create();
} }
@ -222,15 +251,16 @@ class DebugBoundingState extends FlxState
var characters:Array<String> = CoolUtil.coolTextFile(Paths.txt('characterList')); var characters:Array<String> = CoolUtil.coolTextFile(Paths.txt('characterList'));
// charInput isnt only exclusive to offsetView shit now var charDropdown:DropDown = cast uiStuff.findComponent('characterDropdown');
charInput = new FlxUIDropDownMenu(500, 20, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(str:String) for (char in characters)
{ {
loadAnimShit(characters[Std.parseInt(str)]); charDropdown.dataSource.add({text: char});
// trace(); }
});
// charInput. charDropdown.onChange = function(e:UIEvent)
charInput.cameras = [hudCam]; {
add(charInput); loadAnimShit(e.data.text);
};
} }
public var mouseOffset:FlxPoint = FlxPoint.get(0, 0); public var mouseOffset:FlxPoint = FlxPoint.get(0, 0);
@ -290,9 +320,16 @@ class DebugBoundingState extends FlxState
override function update(elapsed:Float) override function update(elapsed:Float)
{ {
if (FlxG.keys.justPressed.ONE) if (FlxG.keys.justPressed.ONE)
{
var lv:DropDown = cast uiStuff.findComponent("swapper");
lv.selectedIndex = 0;
curView = SPRITESHEET; curView = SPRITESHEET;
}
if (FlxG.keys.justReleased.TWO) if (FlxG.keys.justReleased.TWO)
{ {
var lv:DropDown = cast uiStuff.findComponent("swapper");
lv.selectedIndex = 1;
curView = OFFSETSHIT; curView = OFFSETSHIT;
if (swagChar != null) if (swagChar != null)
{ {
@ -318,11 +355,6 @@ class DebugBoundingState extends FlxState
if (FlxG.keys.justPressed.H) if (FlxG.keys.justPressed.H)
hudCam.visible = !hudCam.visible; hudCam.visible = !hudCam.visible;
/* if (charInput.hasFocus && FlxG.keys.justPressed.ENTER)
{
loadAnimShit();
}*/
CoolUtil.mouseCamDrag(); CoolUtil.mouseCamDrag();
CoolUtil.mouseWheelZoom(); CoolUtil.mouseWheelZoom();
@ -437,6 +469,9 @@ class DebugBoundingState extends FlxState
var swagChar:BaseCharacter; var swagChar:BaseCharacter;
/*
Called when animation dropdown is changed!
*/
function loadAnimShit(char:String) function loadAnimShit(char:String)
{ {
if (swagChar != null) if (swagChar != null)
@ -528,8 +563,8 @@ class DebugBoundingState extends FlxState
} }
} }
enum ANIMDEBUGVIEW enum abstract ANIMDEBUGVIEW(String)
{ {
SPRITESHEET; var SPRITESHEET;
OFFSETSHIT; var OFFSETSHIT;
} }