diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 412d9e0b..084efdd4 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -402,10 +402,14 @@ class CharacterEditor extends UIState { stage.loadXml(stage.stageXML, true); add(stage); + stagePosition = character.playerOffsets || character.isPlayer ? "BOYFRIEND" : "DAD"; updateStagePositions([ for (pose in stage.characterPoses.keys()) pose.toUpperCase() ]); + + changeStagePosition(stagePosition); + changeCharacterDesginedAs(stagePosition.toUpperCase() == "BOYFRIEND"); } currentStage = __stage; @@ -414,20 +418,16 @@ class CharacterEditor extends UIState { 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 == null) return; + if (stage.characterPoses.exists(stagePosition)) stage.characterPoses[stagePosition].revertCharacter(character); @@ -436,6 +436,34 @@ class CharacterEditor extends UIState { if (stage.characterPoses.exists(stagePosition)) stage.applyCharStuff(character, stagePosition, 0); + _playback_play_anim(null); + + characterPropertiesWindow.testAsDropDown.index = characterPropertiesWindow.testAsDropDown.options.indexOf(stagePosition.toUpperCase()); + characterPropertiesWindow.testAsDropDown.label.text = stagePosition.toUpperCase(); + } + + public function changeCharacterDesginedAs(player:Bool) @:privateAccess { + trace(player); + if (stage == null) return; + + if (stage.characterPoses.exists(stagePosition)) + stage.characterPoses[stagePosition].revertCharacter(character); + + if (character.__swappedLeftRightAnims) + character.swapLeftRightAnimations(); + if (character.isPlayer) + character.flipX = !character.__baseFlipped; + remove(character); + + character.isPlayer = player; + character.fixChar(false, false); + + if (stage.characterPoses.exists(stagePosition)) + stage.applyCharStuff(character, stagePosition, 0); + _playback_play_anim(null); + + characterPropertiesWindow.designedAsDropDown.index = characterPropertiesWindow.designedAsDropDown.options.indexOf(player ? "BOYFRIEND" : "DAD"); + characterPropertiesWindow.designedAsDropDown.label.text = player ? "BOYFRIEND" : "DAD"; } function buildCharacter():String { diff --git a/source/funkin/editors/character/CharacterPropertiesWindow.hx b/source/funkin/editors/character/CharacterPropertiesWindow.hx index 439b8c7c..54cc5220 100644 --- a/source/funkin/editors/character/CharacterPropertiesWindow.hx +++ b/source/funkin/editors/character/CharacterPropertiesWindow.hx @@ -74,14 +74,17 @@ class CharacterPropertiesWindow extends UISliceSprite { members.push(antialiasingCheckbox); addLabelOn(antialiasingCheckbox, "Antialiasing"); - testAsDropDown = new UIDropDown(cameraXStepper.x, cameraXStepper.y+32+32+4, 238, 32, ["PLAYER", "OPPONENT"], 0); + testAsDropDown = new UIDropDown(cameraXStepper.x, cameraXStepper.y+32+32+4, 238, 32, ["BOYFRIEND", "DAD"], character.playerOffsets ? 0 : 1); testAsDropDown.onChange = (index:Int) -> { CharacterEditor.instance.changeStagePosition(testAsDropDown.options[index]); }; members.push(testAsDropDown); addLabelOn(testAsDropDown, "Test Character As..."); - designedAsDropDown = new UIDropDown(testAsDropDown.x+238, testAsDropDown.y, 238, 32, ["PLAYER", "OPPONENT"], 0); + designedAsDropDown = new UIDropDown(testAsDropDown.x+238, testAsDropDown.y, 238, 32, ["BOYFRIEND", "DAD"], character.playerOffsets ? 0 : 1); + designedAsDropDown.onChange = (index:Int) -> { + CharacterEditor.instance.changeCharacterDesginedAs(designedAsDropDown.options[index] == "BOYFRIEND"); + }; members.push(designedAsDropDown); addLabelOn(designedAsDropDown, "Char Desgined As..."); diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index fe02b745..7d016be4 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -98,9 +98,6 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset if (isPlayer != playerOffsets && switchAnims) swapLeftRightAnimations(); - var o:FlxPoint = getAnimOffset(getAnimName()); - frameOffset.set(o.x, o.y); - o.put(); if (isPlayer) flipX = !flipX; __baseFlipped = flipX; }