some custom values

This commit is contained in:
Frakist
2024-01-28 21:11:13 +02:00
parent a87f2dbac7
commit d914db50fd
4 changed files with 49 additions and 22 deletions
@@ -3,6 +3,7 @@ package funkin.editors.character;
import flixel.math.FlxPoint;
import haxe.xml.Access;
import funkin.game.Character;
import funkin.editors.extra.PropertyButton;
class CharacterInfoScreen extends UISubstateWindow {
public var character:Character;
@@ -20,6 +21,7 @@ class CharacterInfoScreen extends UISubstateWindow {
public var cameraYStepper:UINumericStepper;
public var scaleStepper:UINumericStepper;
public var singTimeStepper:UINumericStepper;
public var customPropertiesButtonList:UIButtonList<PropertyButton>;
public var isPlayerCheckbox:UICheckbox;
public var isGFCheckbox:UICheckbox;
@@ -36,7 +38,7 @@ class CharacterInfoScreen extends UISubstateWindow {
public override function create() {
winTitle = "Editing Character";
winWidth = 714;
winWidth = 1014;
winHeight = 600;
super.create();
@@ -70,11 +72,11 @@ class CharacterInfoScreen extends UISubstateWindow {
add(flipXCheckbox);
addLabelOn(flipXCheckbox, "Flipped");
iconColorWheel = new UIColorwheel(flipXCheckbox.x + 100, flipXCheckbox.y, character.iconColor);
iconColorWheel = new UIColorwheel(gameOverCharTextBox.x + 200 + 20, gameOverCharTextBox.y, character.iconColor);
add(iconColorWheel);
addLabelOn(iconColorWheel, "Icon Color");
add(title = new UIText(spriteTextBox.x, spriteTextBox.y + 10 + 46 + 64 + 100, 0, "Character Data", 28));
add(title = new UIText(spriteTextBox.x, spriteTextBox.y + 10 + 46 + 84, 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);
@@ -102,6 +104,17 @@ class CharacterInfoScreen extends UISubstateWindow {
add(singTimeStepper);
addLabelOn(singTimeStepper, "Sing Duration (Steps)");
customPropertiesButtonList = new UIButtonList<PropertyButton>(singTimeStepper.x + singTimeStepper.width + 200, singTimeStepper.y, 290, 200, '', FlxPoint.get(280, 35), null, 5);
customPropertiesButtonList.frames = Paths.getFrames('editors/ui/inputbox');
customPropertiesButtonList.cameraSpacing = 0;
customPropertiesButtonList.addButton.callback = function() {
customPropertiesButtonList.add(new PropertyButton("New Property", "Value Here"));
}
for (prop=>val in character.extra)
customPropertiesButtonList.add(new PropertyButton(prop, val));
add(customPropertiesButtonList);
addLabelOn(customPropertiesButtonList, "Custom Values (Advanced)");
isPlayerCheckbox = new UICheckbox(positionXStepper.x, positionXStepper.y + 10 + 32 + 28, "isPlayer", character.playerOffsets);
add(isPlayerCheckbox);
addLabelOn(isPlayerCheckbox, "Is Player");
@@ -169,6 +182,8 @@ class CharacterInfoScreen extends UISubstateWindow {
xml.set("sprite", spriteTextBox.label.text);
if (iconColorWheel.colorChanged)
xml.set("color", iconColorWheel.curColor.toHexString(false).replace("0x", "#"));
for (val in customPropertiesButtonList.buttons.members)
xml.set(val.propertyText.label.text, val.valueText.label.text);
for (anim in character.animDatas)
{
@@ -2,6 +2,7 @@ package funkin.editors.charter;
import flixel.math.FlxPoint;
import funkin.backend.chart.ChartData.ChartMetaData;
import funkin.editors.extra.PropertyButton;
using StringTools;
@@ -104,7 +105,6 @@ class MetaDataScreen extends UISubstateWindow {
}
for (val in Reflect.fields(metadata.customValues))
customPropertiesButtonList.add(new PropertyButton(val, Reflect.field(metadata.customValues, val)));
add(customPropertiesButtonList);
addLabelOn(customPropertiesButtonList, "Custom Values (Advanced)");
@@ -174,21 +174,4 @@ class MetaDataScreen extends UISubstateWindow {
Charter.instance.updateBPMEvents();
}
}
class PropertyButton extends UIButton {
public var propertyText:UITextBox;
public var valueText:UITextBox;
public function new(property, value) {
super(0, 0, '', function () {}, 280, 35);
propertyText = new UITextBox(5, 5, property, 125, 25);
valueText = new UITextBox(135, 5, value, 125, 25);
members.push(propertyText);
members.push(valueText);
}
public override function update(elapsed) {
super.update(elapsed);
propertyText.follow(this, 5, 5);
valueText.follow(this, 135, 5);
}
}
@@ -0,0 +1,18 @@
package funkin.editors.extra;
class PropertyButton extends UIButton {
public var propertyText:UITextBox;
public var valueText:UITextBox;
public function new(property, value) {
super(0, 0, '', function () {}, 280, 35);
propertyText = new UITextBox(5, 5, property, 125, 25);
valueText = new UITextBox(135, 5, value, 125, 25);
members.push(propertyText);
members.push(valueText);
}
public override function update(elapsed) {
super.update(elapsed);
propertyText.follow(this, 5, 5);
valueText.follow(this, 135, 5);
}
}
+12 -1
View File
@@ -28,7 +28,7 @@ using StringTools;
@:allow(funkin.game.PlayState)
class Character extends FunkinSprite implements IBeatReceiver implements IOffsetCompatible
{
public var extra:Map<String, Dynamic> = [];
public var extra:Map<String, String> = [];
private var __stunnedTime:Float = 0;
private var __lockAnimThisFrame:Bool = false;
@@ -414,6 +414,13 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
if (xml.x.exists("antialiasing")) antialiasing = (xml.x.get("antialiasing") == "true");
if (xml.x.exists("sprite")) sprite = xml.x.get("sprite");
var tempList = ["isPlayer", "isGF", "x", "y", "gameOverChar", "camx", "camy", "holdTime", "flipX", "icon", "color", "scale", "antialiasing", "sprite"];
var atts = [for (i in xml.x.attributes()) i];
for (i in atts)
if (!tempList.contains(i)) {
extra[i] = xml.x.get(i);
}
loadSprite(Paths.image('characters/$sprite'));
animation.destroyAnimations();
@@ -445,6 +452,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
xml.set("antialiasing", antialiasing == true ? "true" : "false");
xml.set("sprite", sprite);
for (prop=>val in extra) {
xml.set(prop, Std.string(val));
}
var anims:Array<AnimData> = [];
if (animsOrder != null) {
for (name in animsOrder)