character info editing with broken anims
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package funkin.editors.character;
|
||||
|
||||
import hscript.Printer;
|
||||
import haxe.xml.Access;
|
||||
import funkin.editors.character.CharacterAnimsWindow.CharacterAnimButtons;
|
||||
import funkin.backend.utils.XMLUtil.AnimData;
|
||||
import flixel.math.FlxPoint;
|
||||
@@ -305,6 +307,8 @@ class CharacterEditor extends UIState {
|
||||
switch (v) {
|
||||
case null:
|
||||
// do nothing
|
||||
case CEditInfo(oldInfo, newInfo):
|
||||
editInfo(oldInfo);
|
||||
case CCreateAnim(animID, animData):
|
||||
deleteAnim(animData.name, false);
|
||||
case CEditAnim(name, oldData, animData):
|
||||
@@ -331,6 +335,8 @@ class CharacterEditor extends UIState {
|
||||
switch (v) {
|
||||
case null:
|
||||
// do nothing
|
||||
case CEditInfo(oldInfo, newInfo):
|
||||
editInfo(newInfo);
|
||||
case CCreateAnim(animID, animData):
|
||||
createAnim(animData, animID, false);
|
||||
case CEditAnim(name, oldData, animData):
|
||||
@@ -359,7 +365,7 @@ class CharacterEditor extends UIState {
|
||||
}
|
||||
|
||||
function _char_edit_info(_) {
|
||||
FlxG.state.openSubState(new CharacterInfoScreen(character));
|
||||
editInfoWithUI();
|
||||
}
|
||||
|
||||
public function createAnimWithUI() {
|
||||
@@ -417,9 +423,19 @@ class CharacterEditor extends UIState {
|
||||
addToUndo(CDeleteAnim(oldID, oldAnimData));
|
||||
}
|
||||
|
||||
public function editInfoWithUI(addtoUndo:Bool = true) {
|
||||
FlxG.state.openSubState(new CharacterInfoScreen(character));
|
||||
}
|
||||
public function editInfoWithUI() {
|
||||
FlxG.state.openSubState(new CharacterInfoScreen(character, (_) -> {
|
||||
if (_ != null) editInfo(_);
|
||||
}));
|
||||
}
|
||||
|
||||
public function editInfo(newInfo:Xml, addtoUndo:Bool = true) {
|
||||
var oldInfo = character.buildXML();
|
||||
character.applyXML(new Access(newInfo));
|
||||
|
||||
if (addtoUndo)
|
||||
addToUndo(CEditInfo(oldInfo, newInfo));
|
||||
}
|
||||
|
||||
function _playback_play_anim(_) {
|
||||
if (character.getNameList().length != 0)
|
||||
@@ -525,6 +541,7 @@ class CharacterEditor extends UIState {
|
||||
}
|
||||
|
||||
enum CharacterChange {
|
||||
CEditInfo(oldInfo:Xml, newInfo:Xml);
|
||||
CCreateAnim(animID:Int, animData:AnimData);
|
||||
CEditAnim(name:String, oldData:AnimData, animData:AnimData);
|
||||
CDeleteAnim(animID:Int, animData:AnimData);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.editors.character;
|
||||
|
||||
import haxe.xml.Access;
|
||||
import funkin.game.Character;
|
||||
|
||||
class CharacterInfoScreen extends UISubstateWindow {
|
||||
@@ -23,9 +24,12 @@ class CharacterInfoScreen extends UISubstateWindow {
|
||||
public var saveButton:UIButton;
|
||||
public var closeButton:UIButton;
|
||||
|
||||
public function new(character:Character) {
|
||||
super();
|
||||
public var onSave:(xml:Xml) -> Void = null;
|
||||
|
||||
public function new(character:Character, ?onSave:(xml:Xml) -> Void) {
|
||||
this.character = character;
|
||||
this.onSave = onSave;
|
||||
super();
|
||||
}
|
||||
|
||||
public override function create() {
|
||||
@@ -104,12 +108,14 @@ class CharacterInfoScreen extends UISubstateWindow {
|
||||
{checkbox.y += 4; checkbox.x += 6;}
|
||||
|
||||
saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20, windowSpr.y + windowSpr.bHeight- 20, "Save & Close", function() {
|
||||
saveCharacterInfo();
|
||||
close();
|
||||
}, 125);
|
||||
saveButton.x -= saveButton.bWidth;
|
||||
saveButton.y -= saveButton.bHeight;
|
||||
|
||||
closeButton = new UIButton(saveButton.x - 20, saveButton.y, "Close", function() {
|
||||
if (onSave != null) onSave(null);
|
||||
close();
|
||||
}, 125);
|
||||
closeButton.x -= closeButton.bWidth;
|
||||
@@ -135,4 +141,26 @@ class CharacterInfoScreen extends UISubstateWindow {
|
||||
iconSprite.updateHitbox();
|
||||
iconSprite.setPosition(iconTextBox.x + 150 + 8, (iconTextBox.y + 16) - (iconSprite.height/2));
|
||||
}
|
||||
|
||||
function saveCharacterInfo() {
|
||||
for (stepper in [positionXStepper, positionYStepper, cameraXStepper, cameraYStepper, singTimeStepper, scaleStepper])
|
||||
@:privateAccess stepper.__onChange(stepper.label.text);
|
||||
|
||||
var xml = Xml.createElement("character");
|
||||
xml.set("isPlayer", isPlayerCheckbox.checked ? "true" : "false");
|
||||
xml.set("isGF", isGFCheckbox.checked ? "true" : "false");
|
||||
xml.set("x", Std.string(positionXStepper.value));
|
||||
xml.set("y", Std.string(positionYStepper.value));
|
||||
xml.set("gameOverChar", gameOverCharTextBox.label.text);
|
||||
xml.set("camx", Std.string(cameraXStepper.value));
|
||||
xml.set("camy", Std.string(cameraYStepper.value));
|
||||
xml.set("holdTime", Std.string(singTimeStepper.value));
|
||||
xml.set("flipX", Std.string(flipXCheckbox.checked));
|
||||
xml.set("icon", iconTextBox.label.text);
|
||||
xml.set("scale", Std.string(scaleStepper.value));
|
||||
xml.set("antialiasing", antialiasingCheckbox.checked ? "true" : "false");
|
||||
xml.set("sprite", spriteTextBox.label.text);
|
||||
|
||||
if (onSave != null) onSave(xml);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.game;
|
||||
|
||||
import haxe.xml.Printer;
|
||||
import flixel.util.FlxColor;
|
||||
import funkin.backend.FunkinSprite;
|
||||
import flixel.graphics.frames.FlxFrame;
|
||||
@@ -404,18 +405,18 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
|
||||
xml.set("antialiasing", antialiasing == true ? "true" : "false");
|
||||
xml.set("sprite", sprite);
|
||||
|
||||
for (anim in animation.getAnimationList())
|
||||
for (anim in animDatas)
|
||||
{
|
||||
var animXml:Xml = Xml.createElement('anim');
|
||||
animXml.set("name", anim.name);
|
||||
animXml.set("anim", anim.prefix);
|
||||
animXml.set("loop", Std.string(anim.looped));
|
||||
animXml.set("fps", Std.string(anim.frameRate));
|
||||
animXml.set("anim", anim.anim);
|
||||
animXml.set("loop", Std.string(anim.loop));
|
||||
animXml.set("fps", Std.string(anim.fps));
|
||||
var offset:FlxPoint = getAnimOffset(anim.name);
|
||||
animXml.set("x", Std.string(offset.x));
|
||||
animXml.set("y", Std.string(offset.y));
|
||||
if (anim.usesIndicies)
|
||||
animXml.set("indices", anim.frames.join(","));
|
||||
if (anim.indices.length > 0)
|
||||
animXml.set("indices", anim.indices.join(","));
|
||||
xml.addChild(animXml);
|
||||
}
|
||||
return xml;
|
||||
|
||||
Reference in New Issue
Block a user