New Character Editor UI + [New] Button WIP
This commit is contained in:
@@ -38,8 +38,13 @@ class CharacterEditor extends UIState
|
||||
public var curAnim:Int = 0;
|
||||
|
||||
public var playingAnim:UIText;
|
||||
public var currentChar:UIText;
|
||||
public var movingCamText:UIText;
|
||||
|
||||
//Healthbar
|
||||
public var healthBarBG:FlxSprite;
|
||||
public var icon:FlxSprite;
|
||||
|
||||
public var camZoom(default, set):Float = 1;
|
||||
|
||||
public function new(charName:String)
|
||||
@@ -85,16 +90,49 @@ class CharacterEditor extends UIState
|
||||
// UI
|
||||
loadUI();
|
||||
|
||||
playingAnim = new UIText((FlxG.width / 2), 30, -1, 'Animation:\n${char.characterData.animations[curAnim].name}', 24);
|
||||
playingAnim = new UIText(846.62, 64.23, 0, 'Animation: ${char.characterData.animations[curAnim].name}', 24);
|
||||
playingAnim.alignment = LEFT;
|
||||
playingAnim.cameras = [uiCamera];
|
||||
|
||||
currentChar = new UIText(846.62, 30.23, 0, 'Character: ${char.curCharacter}', 24);
|
||||
currentChar.alignment = LEFT;
|
||||
currentChar.cameras = [uiCamera];
|
||||
|
||||
movingCamText = new UIText((FlxG.width / 4) - 310, (FlxG.height / 2), -1,
|
||||
"Press the left mouse button anywhere on this stage to set the character's camera position.", 24);
|
||||
movingCamText.cameras = [uiCamera];
|
||||
movingCamText.visible = false;
|
||||
|
||||
//Health Bar
|
||||
healthBarBG = new FlxSprite(747, 102).loadGraphic(Paths.image('game/healthBar'));
|
||||
healthBarBG.setGraphicSize(399,13);
|
||||
healthBarBG.scrollFactor.set();
|
||||
healthBarBG.cameras = [uiCamera];
|
||||
|
||||
|
||||
var charData:CharacterData;
|
||||
charData = char.characterData;
|
||||
|
||||
var path = Paths.image('icons/${charData.icon}');
|
||||
if (!Assets.exists(path)) path = Paths.image('icons/face');
|
||||
|
||||
//Show both Losing Normal Icons
|
||||
icon = new FlxSprite(754, 86).loadGraphic(path);
|
||||
icon.scale.set(0.5,0.5);
|
||||
icon.scrollFactor.set();
|
||||
icon.cameras = [uiCamera];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
healthBarBG.color = charData.iconColor;
|
||||
|
||||
// Top Menu
|
||||
add(currentChar);
|
||||
add(playingAnim);
|
||||
add(icon);
|
||||
add(healthBarBG);
|
||||
add(movingCamText);
|
||||
add(topMenuSpr);
|
||||
add(uiGroup);
|
||||
@@ -108,11 +146,22 @@ class CharacterEditor extends UIState
|
||||
changeAnim();
|
||||
moveCharPos();
|
||||
detectCamClick();
|
||||
mouseControl();
|
||||
|
||||
ghostChar.setPosition(char.x, char.y);
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
public function reloadIcon()
|
||||
{
|
||||
var charData:CharacterData;
|
||||
charData = char.characterData;
|
||||
|
||||
var path = Paths.image('icons/${charData.icon}');
|
||||
if (!Assets.exists(path)) path = Paths.image('icons/face');
|
||||
icon.loadGraphic(path);
|
||||
}
|
||||
|
||||
public function searchAnim(name:String, ?array:Array<AnimData>):AnimData
|
||||
{
|
||||
if (array == null)
|
||||
@@ -186,6 +235,13 @@ class CharacterEditor extends UIState
|
||||
|
||||
animAtlas = (char.animateAtlas != null ? char.animateAtlas : null);
|
||||
|
||||
currentChar.text = 'Character: ${char.curCharacter}';
|
||||
healthBarBG.color = charData.iconColor;
|
||||
reloadIcon();
|
||||
|
||||
|
||||
trace(charData.iconColor);
|
||||
|
||||
updateCharPos(charData.offsetX, charData.offsetY);
|
||||
updatePointerPos();
|
||||
mixDataToChar(char, charData);
|
||||
@@ -255,7 +311,8 @@ class CharacterEditor extends UIState
|
||||
label: "File",
|
||||
childs: [
|
||||
{
|
||||
label: "New"
|
||||
label: "New",
|
||||
onSelect: new_character
|
||||
},
|
||||
null,
|
||||
{
|
||||
@@ -509,6 +566,18 @@ class CharacterEditor extends UIState
|
||||
ghostChar.playAnim(char.characterData.animations[curAnim].name, true);
|
||||
}
|
||||
|
||||
public function mouseControl()
|
||||
{
|
||||
if (FlxG.mouse.justReleasedRight) {
|
||||
closeCurrentContextMenu();
|
||||
openContextMenu(topMenu[1].childs);
|
||||
}
|
||||
|
||||
if (FlxG.mouse.wheel != 0) {
|
||||
camZoom += (FlxG.mouse.wheel / 10);
|
||||
}
|
||||
}
|
||||
|
||||
function controlCharacter()
|
||||
{
|
||||
var controlArray:Array<Bool> = [
|
||||
@@ -607,6 +676,10 @@ class CharacterEditor extends UIState
|
||||
if (camZoom < 0.1)
|
||||
camZoom = 0.1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function changeAnim()
|
||||
@@ -624,7 +697,7 @@ class CharacterEditor extends UIState
|
||||
trace(char.characterData.animations[curAnim]);
|
||||
|
||||
char.playAnim(char.characterData.animations[curAnim].name, false);
|
||||
playingAnim.text = 'Animation:\n${char.characterData.animations[curAnim].name}';
|
||||
playingAnim.text = 'Animation: ${char.characterData.animations[curAnim].name}';
|
||||
}
|
||||
|
||||
if (space)
|
||||
@@ -659,6 +732,10 @@ class CharacterEditor extends UIState
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
function new_character(_)
|
||||
FlxG.state.openSubState(new NewCharacter(char, ghostChar, this));
|
||||
|
||||
|
||||
function edit_properties_window(_)
|
||||
FlxG.state.openSubState(new CharacterProperties(char, ghostChar, this));
|
||||
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
package funkin.editors.character;
|
||||
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.math.FlxPoint;
|
||||
import funkin.backend.utils.XMLUtil.AnimData;
|
||||
import funkin.game.Character;
|
||||
import funkin.editors.character.DeleteAnimScreen;
|
||||
|
||||
class NewCharacter extends UISubstateWindow
|
||||
{
|
||||
public var char:Character;
|
||||
public var ghostChar:Character;
|
||||
public var charData:CharacterData;
|
||||
|
||||
public var applyButton:UIButton;
|
||||
public var nextButton:UIButton;
|
||||
public var cancelButton:UIButton;
|
||||
public var editor:CharacterEditor;
|
||||
|
||||
public var curAnimData:AnimData;
|
||||
|
||||
public var spriteFile:UITextBox;
|
||||
public var gameOverChar:UITextBox;
|
||||
public var healthIcon:UITextBox;
|
||||
public var iconColor:UITextBox;
|
||||
public var flipX:UICheckbox;
|
||||
public var isPlayer:UICheckbox;
|
||||
public var isGF:UICheckbox;
|
||||
public var antialiasing:UICheckbox;
|
||||
public var scale:UITextBox;
|
||||
public var holdTime:UITextBox;
|
||||
|
||||
public function new(char:Character, ghostChar, editor:CharacterEditor)
|
||||
{
|
||||
super();
|
||||
this.char = char;
|
||||
this.ghostChar = ghostChar;
|
||||
this.charData = char.characterData;
|
||||
this.editor = editor;
|
||||
|
||||
//TO DO: Generate and Save
|
||||
//----
|
||||
|
||||
|
||||
//Delete old Animaitons
|
||||
}
|
||||
|
||||
public override function create()
|
||||
{
|
||||
winTitle = 'Create New Character';
|
||||
winWidth = 960;
|
||||
|
||||
super.create();
|
||||
|
||||
// Offsets
|
||||
var y_ofs = 60;
|
||||
var x_ofs = 60;
|
||||
var y_text_ofs = 20;
|
||||
|
||||
// Character Properties
|
||||
spriteFile = new UITextBox(windowSpr.x + 50, windowSpr.y + 10 + y_ofs, charData.sprite);
|
||||
add(spriteFile);
|
||||
add(new UIText(spriteFile.x, spriteFile.y - y_text_ofs, -1, "Image/Atlas file: "));
|
||||
|
||||
gameOverChar = new UITextBox(spriteFile.x + spriteFile.bWidth + x_ofs, spriteFile.y, charData.gameOverChar);
|
||||
add(gameOverChar);
|
||||
add(new UIText(gameOverChar.x, gameOverChar.y - y_text_ofs, -1, "Game Over character: "));
|
||||
|
||||
healthIcon = new UITextBox(spriteFile.x, spriteFile.y + y_ofs, charData.icon);
|
||||
add(healthIcon);
|
||||
add(new UIText(healthIcon.x, healthIcon.y - y_text_ofs, -1, "Health Icon: "));
|
||||
|
||||
iconColor = new UITextBox(healthIcon.x + healthIcon.bWidth + x_ofs, healthIcon.y, CharacterConfig.rgbToString(charData.iconColor));
|
||||
add(iconColor);
|
||||
add(new UIText(iconColor.x, iconColor.y - y_text_ofs, -1, "Icon color (RGB): "));
|
||||
|
||||
flipX = new UICheckbox(healthIcon.x, healthIcon.y + y_ofs, "Flip X", charData.flipX);
|
||||
add(flipX);
|
||||
|
||||
antialiasing = new UICheckbox(flipX.x + flipX.field.width + x_ofs, flipX.y, "Antialiasing", charData.antialiasing);
|
||||
add(antialiasing);
|
||||
|
||||
isPlayer = new UICheckbox(flipX.x, flipX.y + y_ofs, "Playable Character", charData.isPlayer);
|
||||
add(isPlayer);
|
||||
|
||||
isGF = new UICheckbox(isPlayer.x + isPlayer.field.width + x_ofs, isPlayer.y, "GF Character", charData.isGF);
|
||||
add(isGF);
|
||||
|
||||
scale = new UITextBox(isPlayer.x, isPlayer.y + y_ofs, Std.string(charData.scale));
|
||||
add(scale);
|
||||
add(new UIText(scale.x, scale.y - y_text_ofs, -1, "Scale: "));
|
||||
|
||||
holdTime = new UITextBox(scale.x + scale.bWidth + y_ofs, scale.y, Std.string(charData.holdTime));
|
||||
add(holdTime);
|
||||
add(new UIText(holdTime.x, holdTime.y - y_text_ofs, -1, "Hold time: "));
|
||||
|
||||
// Apply / Cancel buttons
|
||||
|
||||
|
||||
applyButton = new UIButton(windowSpr.x - x_ofs - 70, windowSpr.y, "Apply", function()
|
||||
{
|
||||
|
||||
updateProperties(spriteFile.label.text, healthIcon.label.text, CharacterConfig.stringToRGB(healthIcon.label.text), flipX.checked,
|
||||
antialiasing.checked, isPlayer.checked, isGF.checked, Std.parseFloat(scale.label.text), Std.parseFloat(holdTime.label.text), gameOverChar.label.text);
|
||||
|
||||
//TO DO: Add a Animation
|
||||
});
|
||||
add(applyButton);
|
||||
|
||||
cancelButton = new UIButton(applyButton.x, applyButton.y + y_ofs, "Cancel", function()
|
||||
{
|
||||
close();
|
||||
});
|
||||
add(cancelButton);
|
||||
}
|
||||
|
||||
public function updateProperties(sprite:String, healthIcon:String, iconColor:FlxColor, flipX:Bool, antialiasing:Bool, isPlayer:Bool, isGF:Bool,
|
||||
scale:Float, holdTime:Float, gameOverChar:String)
|
||||
{
|
||||
// Character Data
|
||||
charData.sprite = sprite;
|
||||
charData.icon = healthIcon;
|
||||
charData.iconColor = iconColor;
|
||||
charData.flipX = flipX;
|
||||
charData.antialiasing = antialiasing;
|
||||
charData.isPlayer = isPlayer;
|
||||
charData.isGF = isGF;
|
||||
charData.scale = scale;
|
||||
charData.holdTime = holdTime;
|
||||
charData.gameOverChar = gameOverChar;
|
||||
|
||||
//Bring Player Char to Default Position for User
|
||||
if(isPlayer)
|
||||
{
|
||||
charData.offsetX = 770;
|
||||
charData.offsetY = 410;
|
||||
}
|
||||
else if(isGF)
|
||||
{
|
||||
charData.offsetX = 400;
|
||||
charData.offsetY = 330;
|
||||
}
|
||||
else
|
||||
{
|
||||
charData.offsetX = 100;
|
||||
charData.offsetY = 410;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
editor.reloadChar(!char.isPlayer, charData);
|
||||
editor.reloadStage();
|
||||
editor.loadCross();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function removeAnimation(anim:AnimData)
|
||||
{
|
||||
var refreshAnim:Bool = false;
|
||||
if (char.animation.curAnim != null && anim.name == char.animation.curAnim.name)
|
||||
refreshAnim = true;
|
||||
|
||||
if (char.animation.getByName(anim.name) != null)
|
||||
char.animation.remove(anim.name);
|
||||
if (char.animOffsets.exists(anim.name))
|
||||
char.animOffsets.remove(anim.name);
|
||||
char.characterData.animations.remove(anim);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user