Character Editor Translatable

This commit is contained in:
Furo
2025-07-22 22:59:56 +02:00
parent d39691a96e
commit 8565bf280a
10 changed files with 155 additions and 133 deletions
@@ -48,6 +48,9 @@ class CharacterAnimButton extends UIButton {
public var foldableButtons:Array<FlxSprite> = [];
public var closed:Bool = true;
inline function translate(id:String, ?args:Array<Dynamic>)
return TU.translate("characterEditor.characterAnim." + id, args);
public function new(x:Float, y:Float, animData:AnimData, parent:CharacterAnimsWindow) {
this.anim = animData.name;
this.data = animData;
@@ -76,13 +79,13 @@ class CharacterAnimButton extends UIButton {
nameTextBox.onChange = (newName:String) -> {this.changeName(newName);};
members.push(nameTextBox);
foldableButtons.push(nameTextBox);
addLabelOn(nameTextBox, "Name", 12);
addLabelOn(nameTextBox, translate("name"), 12);
animTextBox = new UIAutoCompleteTextBox(nameTextBox.x + 100, nameTextBox.y, animData.anim, 156, 22, false, true);
animTextBox.onChange = (newAnim:String) -> {this.changeAnim(newAnim);};
members.push(animTextBox);
foldableButtons.push(animTextBox);
addLabelOn(animTextBox, "Animation", 12);
addLabelOn(animTextBox, translate("anim"), 12);
positionXStepper = new UINumericStepper(animTextBox.x, animTextBox.y+32+18, animData.x, 0.001, 2, null, null, 64, 22, true);
positionXStepper.onChange = (text:String) -> {
@@ -91,7 +94,7 @@ class CharacterAnimButton extends UIButton {
};
members.push(positionXStepper);
foldableButtons.push(positionXStepper);
addLabelOn(positionXStepper, "Position (X,Y)", 12);
addLabelOn(positionXStepper, translate("position"), 12);
members.push(XYComma = new UIText(positionXStepper.x+104-32+0, positionXStepper.y + 9, 0, ",", 18));
foldableButtons.push(XYComma);
@@ -111,7 +114,7 @@ class CharacterAnimButton extends UIButton {
};
members.push(fpsStepper);
foldableButtons.push(fpsStepper);
addLabelOn(fpsStepper, "FPS", 12);
addLabelOn(fpsStepper, translate("fps"), 12);
loopedCheckbox = new UICheckbox(fpsStepper.x + 82 - 32 + 26, fpsStepper.y, "Looping?", animData.loop, 0, true);
loopedCheckbox.onChecked = (newLooping:Bool) -> {this.changeLooping(newLooping);};
@@ -126,7 +129,7 @@ class CharacterAnimButton extends UIButton {
}
members.push(indicesTextBox);
foldableButtons.push(indicesTextBox);
addLabelOn(indicesTextBox, "Indices (frames)", 12);
addLabelOn(indicesTextBox, translate("indices"), 12);
animIcon = new FlxSprite(x-(10+16), y+8).loadGraphic(Paths.image("editors/character/anim-icons"), true, 16, 12);
animIcon.animation.add("play", [0]);
@@ -112,13 +112,14 @@ class CharacterAnimsWindow extends UIButtonList<CharacterAnimButton> {
}
public function generateAnimation() {
var animName:String = "New Anim";
var newAnim = TU.translate("characterEditor.characterAnim.defaultAnimName");
var animName:String = newAnim;
var animNames:Array<String> = character.getNameList();
var newAnimCount:Int = 0;
while (animNames.indexOf(animName) != -1) {
newAnimCount++;
animName = 'New Anim - $newAnimCount';
animName = '$newAnim - $newAnimCount';
}
if (__autoCompleteAnims.length <= 0)
@@ -15,13 +15,16 @@ class CharacterCreationScreen extends UISubstateWindow {
public var saveButton:UIButton;
public var closeButton:UIButton;
inline function translate(id:String, ?args:Array<Dynamic>)
return TU.translate("characterCreationScreen." + id, args);
public function new(?onSave:(String, ImageSaveData, Xml)->Void) {
super();
if (onSave != null) this.onSave = onSave;
}
public override function create() {
winTitle = "Creating New Character";
winTitle = translate("win-title");
winWidth = 360;
winHeight = 520;
@@ -37,14 +40,14 @@ class CharacterCreationScreen extends UISubstateWindow {
characterNameTextBox = new UITextBox(windowSpr.x + 20, windowSpr.y + 30 + 16 + 20, "character", 320);
characterNameTextBox.onChange = (_) -> {checkRequired();};
add(characterNameTextBox);
addLabelOn(characterNameTextBox, "Character File Name").applyMarkup(
"Character File Name $* Required$",
addLabelOn(characterNameTextBox, "").applyMarkup(
translate("charName"),
[new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFAD1212), "$")]);
imageExplorer = new UIImageExplorer(characterNameTextBox.x, characterNameTextBox.y + 30 + 16 + 20, null, 320, 58, (_, _) -> {onLoadImage();}, "images/characters");
add(imageExplorer);
addLabelOn(imageExplorer, "Character Image File").applyMarkup(
"Character Image File $* Required$",
addLabelOn(imageExplorer, "").applyMarkup(
translate("charImgName"),
[new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFAD1212), "$")]);
imageExplorer.maxSize.y -= 100;
@@ -54,7 +57,7 @@ class CharacterCreationScreen extends UISubstateWindow {
}, 125);
add(saveButton);
closeButton = new UIButton(saveButton.x - 20 - saveButton.bWidth, saveButton.y, "Cancel", function() {
closeButton = new UIButton(saveButton.x - 20 - saveButton.bWidth, saveButton.y, TU.translate("editor.cancel"), function() {
close();
}, 125);
add(closeButton);
@@ -107,12 +107,12 @@ class CharacterEditor extends UIState {
label: translate("topBar.edit"),
childs: [
{
label: "Copy Offset",
label: translate("edit.copyOffset"),
keybind: [CONTROL, C],
onSelect: _edit_copy_offset
},
{
label: "Paste Offset",
label: translate("edit.pasteOffset"),
keybind: [CONTROL, V],
onSelect: _edit_paste_offset
},
@@ -129,13 +129,13 @@ class CharacterEditor extends UIState {
},
null,
{
label: "Edit information",
label: translate("edit.editInfo"),
color: 0xFF959829, icon: 4,
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;},
onSelect: _edit_info
},
{
label: "Edit sprite",
label: translate("edit.editSprite"),
color: 0xFF959829, icon: 4,
onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;},
onSelect: _edit_sprite
@@ -188,7 +188,7 @@ class CharacterEditor extends UIState {
},
null,
{
label: "Drag Offsets With Mouse?",
label: translate("offset.dragOffsetsMouse"),
onSelect: _offsets_drag_offsets_mouse,
icon: Options.characterDragging ? 1 : 0
},
@@ -200,7 +200,7 @@ class CharacterEditor extends UIState {
]
},
{
label: "Stage",
label: translate("topBar.stage"),
childs: buildStagesUI()
},
{
@@ -223,48 +223,48 @@ class CharacterEditor extends UIState {
},
null,
{
label: "Character Hitbox?",
label: translate("view.charHitbox"),
onSelect: _view_character_show_hitbox,
icon: Options.characterHitbox ? 1 : 0
},
{
label: "Character Camera?",
label: translate("view.charCam"),
onSelect: _view_character_show_camera,
icon: Options.characterCamera ? 1 : 0
},
{
label: "XY Axis?",
label: translate("view.axis"),
onSelect: _view_character_show_axis,
icon: Options.characterAxis ? 1 : 0
}
]
},
{
label: "Animation >",
label: translate("topBar.animation") + " >",
childs: [
{
label: "Play Animation",
label: translate("animation.playAnim"),
keybind: [SPACE],
onSelect: _animation_play,
},
{
label: "Stop Animation",
label: translate("animation.stopAnim"),
onSelect: _animation_stop
},
null,
{
label: "Change Animation ↑",
label: translate("animation.changeAnimUp"),
keybind: [W],
onSelect: _animation_up
},
{
label: "Change Animation ↓",
label: translate("animation.changeAnimDown"),
keybind: [S],
onSelect: _animation_down
},
null,
{
label: "Play Animation On Offset?",
label: translate("animation.playAnimOnOffset"),
onSelect: _animation_toggle_anim_playing_offsets,
icon: Options.playAnimOnOffset ? 1 : 0
},
@@ -685,16 +685,17 @@ class CharacterEditor extends UIState {
var stageFileList = Stage.getList(true);
if (stageFileList.length == 0) stageFileList = Stage.getList(false);
var stageText = TU.getRaw("characterEditor.stage.useStage");
for (stage in stageFileList)
newChilds.push({
label: 'Use "$stage"?',
label: stageText.format([stage]),
icon: currentStage == stage ? 1 : 0,
onSelect: (_) -> {changeStage(stage);}
});
newChilds.push(null);
newChilds.push({
label: "Use No Stage?",
label: translate("stage.useNone"),
icon: currentStage == null ? 1 : 0,
onSelect: (_) -> {changeStage(null);}
});
@@ -53,11 +53,11 @@ class CharacterInfoScreen extends UISubstateWindow {
add(new UIText(ui.x, ui.y - 24, 0, text));
var title:UIText;
add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, "Edit Character Info", 28));
add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, translate("title"), 28));
iconColorPicker = new UIIconColorPicker(title.x, title.y + title.height + 38, character.getIcon(), character.antialiasing, null);
add(iconColorPicker);
addLabelOn(iconColorPicker, "Icon");
addLabelOn(iconColorPicker, translate("icon"));
iconColorWheel = new UIColorwheel(iconColorPicker.x+12+125+12+22, iconColorPicker.y, character.iconColor);
add(iconColorWheel);
@@ -69,9 +69,9 @@ class CharacterInfoScreen extends UISubstateWindow {
durationStepper = new UINumericStepper(iconColorWheel.x, iconColorWheel.y + 125 + 36, character.holdTime == -1 ? 4 : character.holdTime, 0.001, 2, 0, 9999999, 74);
add(durationStepper);
addLabelOn(durationStepper, "Sing Duration");
addLabelOn(durationStepper, translate("singDuration"));
useDurationCheckbox = new UICheckbox(durationStepper.x + durationStepper.bWidth + 20, durationStepper.y+6, "Use Sing Duration?", character.holdTime != -1);
useDurationCheckbox = new UICheckbox(durationStepper.x + durationStepper.bWidth + 20, durationStepper.y+6, translate("useSingDuration"), character.holdTime != -1);
useDurationCheckbox.onChecked = (checked:Bool) -> {durationStepper.selectable = checked;};
add(useDurationCheckbox);
@@ -28,7 +28,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
public var labels:Map<UISprite, UIText> = [];
inline function translate(id:String, ?args:Array<Dynamic>)
return TU.translate("characterEditor.characterPropertiesWindow." + id, args);
return TU.translate("characterEditor.characterProperties." + id, args);
public function new(x:Float, y:Float, character:Character) @:privateAccess {
super(x, y, 424+16, 204+20, "editors/ui/inputbox");
@@ -44,7 +44,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
this.changePosition(positionXStepper.value, null);
};
members.push(positionXStepper);
addLabelOn(positionXStepper, "Position (X,Y)");
addLabelOn(positionXStepper, translate("position"));
members.push(positionXYComma = new UIText(positionXStepper.x+104-32+0, positionXStepper.y + 9, 0, ",", 22));
@@ -61,17 +61,17 @@ class CharacterPropertiesWindow extends UISliceSprite {
this.changeScale(scaleStepper.value);
};
members.push(scaleStepper);
addLabelOn(scaleStepper, "Scale");
addLabelOn(scaleStepper, translate("scale"));
editCharacterButton = new UIButton(scaleStepper.x + 90 -32 + 26, scaleStepper.y-20, "Edit Info", editCharacterInfoUI, 120, 24);
editCharacterButton = new UIButton(scaleStepper.x + 90 -32 + 26, scaleStepper.y-20, translate("editInfo"), editCharacterInfoUI, 120, 24);
editCharacterButton.field.size -= 2;
members.push(editCharacterButton);
editSpriteButton = new UIButton(editCharacterButton.x, editCharacterButton.y+24+6, "Edit Sprite", editCharacterSpriteUI, 120, 24);
editSpriteButton = new UIButton(editCharacterButton.x, editCharacterButton.y+24+6, translate("editSprite"), editCharacterSpriteUI, 120, 24);
editSpriteButton.field.size -= 2;
members.push(editSpriteButton);
flipXCheckbox = new UICheckbox(scaleStepper.x+22, scaleStepper.y+32+14, "Flipped?", character.isPlayer ? !character.__baseFlipped : character.__baseFlipped);
flipXCheckbox = new UICheckbox(scaleStepper.x+22, scaleStepper.y+32+14, translate("charFlipped"), character.isPlayer ? !character.__baseFlipped : character.__baseFlipped);
flipXCheckbox.onChecked = (checked:Bool) -> {this.changeFlipX(checked);};
members.push(flipXCheckbox);
@@ -81,7 +81,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
this.changeCamPosition(cameraXStepper.value, null);
};
members.push(cameraXStepper);
addLabelOn(cameraXStepper, "Camera Position (X,Y)");
addLabelOn(cameraXStepper, translate("camPosition"));
members.push(cameraXYComma = new UIText(cameraXStepper.x + 104-32+0, cameraXStepper.y+9, 0, ",", 22));
@@ -92,7 +92,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
};
members.push(cameraYStepper);
antialiasingCheckbox = new UICheckbox(scaleStepper.x+22, flipXCheckbox.y+32, "Antialiased?", character.antialiasing);
antialiasingCheckbox = new UICheckbox(scaleStepper.x+22, flipXCheckbox.y+32, translate("antialiased"), character.antialiasing);
antialiasingCheckbox.onChecked = (checked:Bool) -> {this.changeAntialiasing(checked);};
members.push(antialiasingCheckbox);
@@ -101,7 +101,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
CharacterEditor.instance.changeStagePosition(testAsDropDown.options[index]);
};
members.push(testAsDropDown);
addLabelOn(testAsDropDown, "Test Character As...");
addLabelOn(testAsDropDown, translate("testCharAs"));
testAsDropDown.bWidth = 193; //REFUSES TO FUCKING SET TO 170 PIECE OF SHIT!!
designedAsDropDown = new UIDropDown(testAsDropDown.x+193+22, testAsDropDown.y, 193, 32, ["BOYFRIEND", "DAD"], character.playerOffsets ? 0 : 1);
@@ -109,7 +109,7 @@ class CharacterPropertiesWindow extends UISliceSprite {
CharacterEditor.instance.changeCharacterDesginedAs(designedAsDropDown.options[index] == "BOYFRIEND");
};
members.push(designedAsDropDown);
addLabelOn(designedAsDropDown, "Char Desgined As...");
addLabelOn(designedAsDropDown, translate("charDesign"));
designedAsDropDown.bWidth = 193;
alpha = 0.7;
@@ -16,6 +16,9 @@ class CharacterSpriteScreen extends UISubstateWindow {
public var saveButton:UIButton;
public var closeButton:UIButton;
inline function translate(id:String, ?args:Array<Dynamic>)
return TU.translate("characterEditor.characterSpriteScreen." + id, args);
public function new(imagePath:String, ?onSave:(String, Bool)->Void) {
super();
this.imagePath = imagePath;
@@ -23,7 +26,7 @@ class CharacterSpriteScreen extends UISubstateWindow {
}
public override function create() {
winTitle = 'Edit character sprite';
winTitle = translate("win-title");
winWidth = 360; winHeight = 183;
function addLabelOn(ui:UISprite, text:String):UIText {
@@ -36,8 +39,8 @@ class CharacterSpriteScreen extends UISubstateWindow {
imageExplorer = new UIImageExplorer(20, windowSpr.y + 30 + 16 + 20, imagePath, 320, 58, (_, _) -> {onLoadImage();}, "images/characters");
add(imageExplorer);
addLabelOn(imageExplorer, "Character Image File").applyMarkup(
"Character Image File $* Required$",
addLabelOn(imageExplorer, "").applyMarkup(
translate('charImageFile'),
[new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFAD1212), "$")]);
ogImageSaveData = imageExplorer.getSaveData();
@@ -53,7 +56,7 @@ class CharacterSpriteScreen extends UISubstateWindow {
saveButton.y -= saveButton.bHeight;
saveButton.selectable = false;
closeButton = new UIButton(saveButton.x - 20, saveButton.y, "Cancel", function() {
closeButton = new UIButton(saveButton.x - 20, saveButton.y, TU.translate("editor.cancel"), function() {
close();
}, 125);
closeButton.color = 0xFFFF0000;
@@ -48,7 +48,7 @@ class StageCreationScreen extends UISubstateWindow {
close();
}, 125));
add(closeButton = new UIButton(saveButton.x - 20 - saveButton.bWidth, saveButton.y, "Cancel", close, 125));
add(closeButton = new UIButton(saveButton.x - 20 - saveButton.bWidth, saveButton.y, TU.translate("editor.cancel"), close, 125));
closeButton.color = 0xFFFF0000;
}
+18 -13
View File
@@ -35,6 +35,9 @@ class UIImageExplorer extends UIFileExplorer {
public var directoryTextBoxLabel:UIText;
public var directoryTextBox:UITextBox;
inline function translate(id:String, ?args:Array<Dynamic>)
return TU.translate("uiImageExplorer." + id, args);
public function new(x:Float, y:Float, image:String, ?w:Int, ?h:Int, ?onFile:(String, Bytes)->Void, ?directory:String = "images") {
super(x, y, w, h, "png, jpg", function (filePath, file) {
if (filePath != null && file != null) uploadImage(filePath, file);
@@ -51,7 +54,7 @@ class UIImageExplorer extends UIFileExplorer {
members.push(directoryIcon);
directoryBG = new UISliceSprite(0, 0, 210+16, 8+12+4+22+8, 'editors/ui/inputbox');
directoryBG.alpha = 0.9; directoryBG.members.push(directoryTextBoxLabel = new UIText(8, 6, 0, 'Directory ($directory/)', 12));
directoryBG.alpha = 0.9; directoryBG.members.push(directoryTextBoxLabel = new UIText(8, 6, 0, TU.getRaw('uiImageExplorer.directory').format([directory]), 12));
directoryTextBox = new UITextBox(8, 8+12+4, "", 210, 22, false, true);
directoryBG.members.push(directoryTextBox);
@@ -245,17 +248,18 @@ class UIImageExplorer extends UIFileExplorer {
message.add('${imagePath.file}.${imagePath.ext}');
message.add(' (${CoolUtil.getSizeString(size)}');
var typeOfFrame = isAtlas ? translate("symbol") : translate("animation");
var shouldUsePlural = animationList.length != 1;
if (animationList.length > 0) {
if(animationList.length == 1) message.add(', ${animationList.length} ${isAtlas ? "Symbol" : "Animation"} Found');
else message.add(', ${animationList.length} ${isAtlas ? "Symbol" : "Animation"}s Found');
} else message.add(', #NO ${isAtlas ? "Symbol" : "Animation"}s Found#');
message.add(', ${TU.getRaw("uiImageExplorer." + (shouldUsePlural ? "foundplural" : "found")).format([animationList.length, typeOfFrame])}');
} else message.add(', ${TU.getRaw("uiImageExplorer.notFound").format([typeOfFrame])}');
if (isAtlas) {
if(spritemaps.length == 1) message.add(', ${spritemaps.length} Spritemap Found');
else message.add(', ${spritemaps.length} Spritemaps Found');
shouldUsePlural = spritemaps.length != 1;
message.add(', ${TU.getRaw("uiImageExplorer.foundAtlas" + (shouldUsePlural ? "plural" : "")).format([spritemaps.length])}');
}
message.add(')');
message.add(isAtlas ? " - Atlas" : " - Spritemap");
message.add(isAtlas ? ' - ${translate("atlas")}' : ' - ${translate("spritemap")}');
fileText = new UIText(x+20, y+16, bWidth-20-deleteButton.bWidth-16, "");
fileText.applyMarkup(message.toString(), [new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFAD1212), "#")]);
@@ -337,10 +341,9 @@ class UIImageExplorer extends UIFileExplorer {
}
if (alreadlyExistingFiles.length > 0 && checkExisting) @:privateAccess {
(FlxG.state.subState != null && !FlxG.state._requestSubStateReset ? FlxG.state.subState : FlxG.state).openSubState(new UIWarningSubstate("Alreadly Existing Files!!!",
"The following files alreadly exist: \n\n" + alreadlyExistingFiles.join('\n') + "\n\nIMPORTANT: OVERRIDING CAN NOT BE UNDONE!!!!!!!!",
[ {
label: "Override Files",
var buttons = [
{
label: TU.translate("uiImageExplorer.override"),
color: 0xFFFF0000,
onClick: (_) -> {
deleteExistingFiles();
@@ -348,10 +351,12 @@ class UIImageExplorer extends UIFileExplorer {
}
},
{
label: "Use Existing",
label: TU.translate("uiImageExplorer.useExisting"),
onClick: (_) -> {if (onFinishSaving != null) onFinishSaving();}
}
], false));
];
(FlxG.state.subState != null && !FlxG.state._requestSubStateReset ? FlxG.state.subState : FlxG.state).openSubState(new UIWarningSubstate("Alreadly Existing Files!!!",
TU.getRaw("uiImageExplorer.fileAlreadyExists").format([alreadlyExistingFiles.join('\n')]), buttons, false));
} else acuttalySaveFiles();
}