From 6b537da762085e87d6842d2e66b4bc8f35851a57 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:33:52 -0700 Subject: [PATCH] stage beta in char editor (needa add isPlayer) --- .../editors/character/CharacterEditor.hx | 80 +++++++++++++++++-- .../character/CharacterPropertiesWindow.hx | 3 + source/funkin/game/Stage.hx | 2 - 3 files changed, 77 insertions(+), 8 deletions(-) diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 1dc58365..06bcf671 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -42,6 +42,9 @@ class CharacterEditor extends UIState { public var currentStage:String = null; public var stage:Stage = null; + public var stageSprites:Array = []; + public var stagePosition:String = null; + public function new(character:String) { super(); if (character != null) __character = character; @@ -228,17 +231,15 @@ class CharacterEditor extends UIState { uiGroup.add(characterPropertiesWindow); topMenuSpr = new UITopMenu(topMenu); - topMenuSpr.cameras = [uiCamera]; + uiGroup.add(topMenuSpr); animationText = new UIText(0, 0, 0, ""); - animationText.cameras = [uiCamera]; + uiGroup.add(animationText); characterAnimsWindow = new CharacterAnimsWindow(characterPropertiesWindow.x, characterPropertiesWindow.y+224+16, character); uiGroup.add(characterAnimsWindow); add(uiGroup); - add(topMenuSpr); - add(animationText); playAnimation(character.getAnimOrder()[0]); _view_focus_character(null); @@ -341,19 +342,86 @@ class CharacterEditor extends UIState { for (stage in stageFileList) newChilds.push({ label: 'Use "$stage"?', - icon: currentStage == stage ? 1 : 0 + icon: currentStage == stage ? 1 : 0, + onSelect: (_) -> {changeStage(stage);} }); newChilds.push(null); newChilds.push({ label: "Use No Stage?", - icon: currentStage == null ? 1 : 0 + icon: currentStage == null ? 1 : 0, + onSelect: (_) -> {changeStage(null);} }); if (stageTopButton != null) stageTopButton.contextMenu = newChilds; return newChilds; } + function changeStage(__stage:String) { + if (stage != null) { + if (stage.characterPoses.exists(stagePosition)) + stage.characterPoses[stagePosition].revertCharacter(character); + + for (sprite in stageSprites) { + remove(sprite); + sprite.destroy(); + } + stageSprites.clear(); + + stage.destroy(); + stage = null; + } + remove(character); + + if (__stage == null) { + updateStagePositions(["NONE"]); + add(character); + } else { + stage = new Stage(__stage, this, false); + stage.onAddSprite = (sprite:FlxBasic) -> { + sprite.cameras = [charCamera]; + stageSprites.push(sprite); + }; + + stage.loadXml(stage.stageXML, true); + add(stage); + + updateStagePositions([ + for (pose in stage.characterPoses.keys()) + pose.toUpperCase() + ]); + } + + currentStage = __stage; + buildStagesUI(); + } + + function updateStagePositions(stagePositions:Array) @:privateAccess { + if (stage != null && stagePositions.length > 0) { + stagePosition = stagePositions[0]; + stage.applyCharStuff(character, stagePosition, 0); + + characterPropertiesWindow.testAsDropDown.items = + UIDropDown.getItems(characterPropertiesWindow.testAsDropDown.options = stagePositions); + } else + characterPropertiesWindow.testAsDropDown.items = + UIDropDown.getItems(characterPropertiesWindow.testAsDropDown.options = ["NONE"]); + + characterPropertiesWindow.testAsDropDown.index = 0; + characterPropertiesWindow.testAsDropDown.label.text = stagePositions[0]; + } + + public function changeStagePosition(position:String) { + if (stage.characterPoses.exists(stagePosition)) + stage.characterPoses[stagePosition].revertCharacter(character); + + stagePosition = position.toLowerCase(); + remove(character); + + if (stage.characterPoses.exists(stagePosition)) + stage.applyCharStuff(character, stagePosition, 0); + } + function buildCharacter():String { var charXML:Xml = character.buildXML([ for (button in characterAnimsWindow.buttons.members) diff --git a/source/funkin/editors/character/CharacterPropertiesWindow.hx b/source/funkin/editors/character/CharacterPropertiesWindow.hx index b3d0785f..439b8c7c 100644 --- a/source/funkin/editors/character/CharacterPropertiesWindow.hx +++ b/source/funkin/editors/character/CharacterPropertiesWindow.hx @@ -75,6 +75,9 @@ class CharacterPropertiesWindow extends UISliceSprite { addLabelOn(antialiasingCheckbox, "Antialiasing"); testAsDropDown = new UIDropDown(cameraXStepper.x, cameraXStepper.y+32+32+4, 238, 32, ["PLAYER", "OPPONENT"], 0); + testAsDropDown.onChange = (index:Int) -> { + CharacterEditor.instance.changeStagePosition(testAsDropDown.options[index]); + }; members.push(testAsDropDown); addLabelOn(testAsDropDown, "Test Character As..."); diff --git a/source/funkin/game/Stage.hx b/source/funkin/game/Stage.hx index f4f13d70..eb64c169 100644 --- a/source/funkin/game/Stage.hx +++ b/source/funkin/game/Stage.hx @@ -312,8 +312,6 @@ class Stage extends FlxBasic implements IBeatReceiver { } } - trace(list); - return list; } }