From d5a2de296b2e33152d2161d8b0e1ea0bd5267c68 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Thu, 13 Jul 2023 18:51:09 -0700 Subject: [PATCH] Character Info UI --- .../editors/character/CharacterEditor.hx | 11 +++++-- .../editors/character/CharacterInfoScreen.hx | 30 +++++++++++++------ .../character/CharacterPropertiesWindow.hx | 4 ++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 8be4f5c4..83e5c03e 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -253,13 +253,12 @@ class CharacterEditor extends UIState { if (FlxG.mouse.justPressedMiddle) { FlxG.mouse.getScreenPosition(charCamera, camDrag); - camDrag *= 1.2; camDrag += charCamera.scroll; } if (FlxG.mouse.pressedMiddle) { var pos = FlxG.mouse.getScreenPosition(charCamera); - nextScroll.set((camDrag.x - (pos.x*1.2)), (camDrag.y - (pos.y*1.2))); + nextScroll.set((camDrag.x - pos.x), (camDrag.y - pos.y)); } charCamera.scroll.set( @@ -385,7 +384,9 @@ class CharacterEditor extends UIState { XMLUtil.addAnimToSprite(character, animData); button.updateInfo(animData.name, character.getAnimOffset(animData.name), false); - playAnimation(animData.name); + + if (character.animation.name == animData.name) // update anim ifs its currently selected + playAnimation(animData.name); if (addtoUndo) addToUndo(CEditAnim(animData.name, oldAnimData, animData)); @@ -410,6 +411,10 @@ class CharacterEditor extends UIState { addToUndo(CDeleteAnim(oldID, oldAnimData)); } + public function editInfoWithUI(addtoUndo:Bool = true) { + FlxG.state.openSubState(new CharacterInfoScreen(character)); + } + function _playback_play_anim(_) { if (character.animation.getNameList().length != 0) playAnimation(character.animation.name); diff --git a/source/funkin/editors/character/CharacterInfoScreen.hx b/source/funkin/editors/character/CharacterInfoScreen.hx index 5d5dddc4..25e5c636 100644 --- a/source/funkin/editors/character/CharacterInfoScreen.hx +++ b/source/funkin/editors/character/CharacterInfoScreen.hx @@ -9,6 +9,8 @@ class CharacterInfoScreen extends UISubstateWindow { public var iconTextBox:UITextBox; public var iconSprite:FlxSprite; public var gameOverCharTextBox:UITextBox; + public var antialiasingCheckbox:UICheckbox; + public var flipXCheckbox:UICheckbox; public var positionXStepper:UINumericStepper; public var positionYStepper:UINumericStepper; public var cameraXStepper:UINumericStepper; @@ -16,10 +18,7 @@ class CharacterInfoScreen extends UISubstateWindow { public var scaleStepper:UINumericStepper; public var singTimeStepper:UINumericStepper; public var isPlayerCheckbox:UICheckbox; - // TODO: ADD THESE OPTIONS AND A HEALTH BAR COLOR OPTION public var isGFCheckbox:UICheckbox; - public var flipXCheckbox:UICheckbox; - public var antialiasingCheckbox:UICheckbox; public var saveButton:UIButton; public var closeButton:UIButton; @@ -31,7 +30,8 @@ class CharacterInfoScreen extends UISubstateWindow { public override function create() { winTitle = "Editing Character"; - winWidth = 960; + winWidth = 714; + winHeight = 500; super.create(); @@ -52,11 +52,19 @@ class CharacterInfoScreen extends UISubstateWindow { updateIcon(character.getIcon()); - gameOverCharTextBox = new UITextBox(iconTextBox.x + 150 + (75 + 16), iconTextBox.y, character.gameOverCharacter, 200); + gameOverCharTextBox = new UITextBox(iconTextBox.x + 150 + (75 + 12), iconTextBox.y, character.gameOverCharacter, 200); add(gameOverCharTextBox); addLabelOn(gameOverCharTextBox, "Game Over Character"); - add(title = new UIText(spriteTextBox.x, spriteTextBox.y + 10 + 46, 0, "Character Data", 28)); + antialiasingCheckbox = new UICheckbox(spriteTextBox.x, spriteTextBox.y + 10 + 32 + 28, "Antialiasing", character.antialiasing); + add(antialiasingCheckbox); + addLabelOn(antialiasingCheckbox, "Antialiased"); + + flipXCheckbox = new UICheckbox(antialiasingCheckbox.x + 172, spriteTextBox.y + 10 + 32 + 28, "FlipX", character.flipX); + add(flipXCheckbox); + addLabelOn(flipXCheckbox, "Flipped"); + + add(title = new UIText(spriteTextBox.x, spriteTextBox.y + 10 + 46 + 64, 0, "Character Data", 28)); positionXStepper = new UINumericStepper(title.x, title.y + title.height + 36, character.globalOffset.x, 0.001, 2, null, null, 84); add(positionXStepper); @@ -84,12 +92,16 @@ class CharacterInfoScreen extends UISubstateWindow { add(singTimeStepper); addLabelOn(singTimeStepper, "Sing Duration (Steps)"); - isPlayerCheckbox = new UICheckbox(positionXStepper.x, positionXStepper.y + 10 + 32 + 26, "isPlayer", character.playerOffsets); + isPlayerCheckbox = new UICheckbox(positionXStepper.x, positionXStepper.y + 10 + 32 + 28, "isPlayer", character.playerOffsets); add(isPlayerCheckbox); addLabelOn(isPlayerCheckbox, "Is Player"); - for (checkbox in [isPlayerCheckbox]) - {checkbox.y += 6; checkbox.x += 4;} + isGFCheckbox = new UICheckbox(isPlayerCheckbox.x + 128, positionXStepper.y + 10 + 32 + 28, "isGF", character.isGF); + add(isGFCheckbox); + addLabelOn(isGFCheckbox, "Is GF"); + + for (checkbox in [isPlayerCheckbox, isGFCheckbox, antialiasingCheckbox, flipXCheckbox]) + {checkbox.y += 4; checkbox.x += 6;} saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20, windowSpr.y + windowSpr.bHeight- 20, "Save & Close", function() { close(); diff --git a/source/funkin/editors/character/CharacterPropertiesWindow.hx b/source/funkin/editors/character/CharacterPropertiesWindow.hx index 51c5a1cf..3822fbe2 100644 --- a/source/funkin/editors/character/CharacterPropertiesWindow.hx +++ b/source/funkin/editors/character/CharacterPropertiesWindow.hx @@ -15,7 +15,9 @@ class CharacterPropertiesWindow extends UIWindow { members.push(newButton); newButton.color = FlxColor.GREEN; - editButton = new UIButton(newButton.x, newButton.y + 12 + 30 + 4, "Edit Character Info", null, 200); + editButton = new UIButton(newButton.x, newButton.y + 12 + 30 + 4, "Edit Character Info", function () { + CharacterEditor.instance.editInfoWithUI(); + }, 200); members.push(editButton); characterInfo = new UIText(x + 450 + 20 - 42 - 400, y + 36 + 16, 400, "(Num) Animations:\nFlipped:\nSprite:\nCurrent Anim:");