Character Info UI

This commit is contained in:
lunarcleint
2023-07-13 18:51:09 -07:00
parent 16479c98e0
commit d5a2de296b
3 changed files with 32 additions and 13 deletions
@@ -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);
@@ -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();
@@ -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:");