Made SaveWarning translatable + more

Optimized Playstate
Made the songPosInfo translatable
Made UpdateAvailableScreen translatable

Co-Authored-By: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com>
This commit is contained in:
Ne_Eo
2024-10-04 21:22:53 +02:00
co-authored by ⍚~Nex
parent 1dc2604749
commit 8e2ffbb920
8 changed files with 95 additions and 47 deletions
+34
View File
@@ -43,6 +43,14 @@
<str id="scrollSpeed">Scroll Speed</str> <str id="scrollSpeed">Scroll Speed</str>
</group> </group>
<group name="SongPosInfo" prefix="songPosInfo.">
<str id="step">Step: {0}</str>
<str id="beat">Beat: {0}</str>
<str id="measure">Measure: {0}</str>
<str id="bpm">BPM: {0}</str>
<str id="timeSignature">Time Signature: {0}/{1}</str>
</group>
<group name="CharterEventScreen" prefix="charterEventScreen."> <group name="CharterEventScreen" prefix="charterEventScreen.">
<str id="title-creating">Create Event Group</str> <str id="title-creating">Create Event Group</str>
<str id="title-editing">Edit Event Group</str> <str id="title-editing">Edit Event Group</str>
@@ -387,4 +395,30 @@
<group name="DebugOptions"> <group name="DebugOptions">
<str id="debugOptions.name">Debug Options</str> <str id="debugOptions.name">Debug Options</str>
</group> </group>
<!-- PlayTesting and SaveWarning are almost the same but with some small differences -->
<!-- PlayTesting allows color in the description by doing *hello* -->
<!-- SaveWarning doesnt allow color in the description -->
<group name="PlayTesting" prefix="playtesting.">
<str id="chartPlaytesting" notrim="true"> (Chart Playtesting)</str>
<str id="exitGame">Exit Game</str>
<str id="exitToMenu">Exit To Menu</str>
<str id="saveAndExitGame">Save &amp; Exit Game</str>
<str id="saveAndExitToMenu">Save &amp; Exit To Menu</str>
<str id="cancel">Cancel</str>
<str id="warningTitle">UNSAVED CHANGES!</str>
<str id="warningDesc">Your changes will be *lost* if you don't save them. (Can't be recovered)\n\n\nWould you like to Cancel?</str>
</group>
<group name="SaveWarning" prefix="saveWarning.">
<str id="warningTitle">Unsaved Changes!</str>
<str id="warningDesc">Your changes will be lost if you don't save them. (Can't be recovered)\n\n\nWould you like to Cancel?</str>
<str id="exitGame">Exit Game</str>
<str id="exitToMenu">Exit To Menu</str>
<str id="saveAndExitGame">Save &amp; Exit Game</str>
<str id="saveAndExitToMenu">Save &amp; Exit To Menu</str>
<str id="cancel">Cancel</str>
</group>
</language> </language>
-12
View File
@@ -18,18 +18,6 @@
<str id="game.rating.S++">S++</str> <str id="game.rating.S++">S++</str>
</group> </group>
<group name="PlayTesting">
<str id="playtesting.chartPlaytesting" notrim="true"> (Chart Playtesting)</str>
<str id="playtesting.exitGame">Exit Game</str>
<str id="playtesting.exitToMenu">Exit To Menu</str>
<str id="playtesting.saveAndExitGame">Save &amp; Exit Game</str>
<str id="playtesting.saveAndExitToMenu">Save &amp; Exit To Menu</str>
<str id="playtesting.cancel">Cancel</str>
<str id="playtesting.warningTitle">UNSAVED CHANGES!</str>
<str id="playtesting.warningDesc">Your changes will be *lost* if you don't save them. (Can't be recovered)\n\n\nWould you like to Cancel?</str>
</group>
<group name="StoryMenu"> <group name="StoryMenu">
<str id="story.score">WEEK SCORE:{0}</str> <str id="story.score">WEEK SCORE:{0}</str>
<str id="story.tracks">TRACKS</str> <str id="story.tracks">TRACKS</str>
+2 -1
View File
@@ -42,7 +42,8 @@
<str id="category.engine">Engine</str> <str id="category.engine">Engine</str>
<group name="engine" prefix="engine."> <group name="engine" prefix="engine.">
<str id="switchMod">Switch Mod</str> <!-- Change this to / when alphabet has it -->
<str id="switchMod">Change Mod or Mode</str>
</group> </group>
</group> </group>
@@ -41,7 +41,9 @@ class UpdateAvailableScreen extends MusicBeatState {
bg.screenCenter(); bg.screenCenter();
add(bg); add(bg);
title = new Alphabet(0, 10, "NEW UPDATE", true); // which file should i put this in?
// Misc.xml?
title = new Alphabet(0, 10, TU.translate("updateAvailable.title"), true);
title.screenCenter(X); title.screenCenter(X);
title.scrollFactor.set(); title.scrollFactor.set();
@@ -61,8 +63,8 @@ class UpdateAvailableScreen extends MusicBeatState {
changeLogText.borderColor = 0xFF000000; changeLogText.borderColor = 0xFF000000;
MarkdownUtil.applyMarkdownText(changeLogText, check.updates.last().body); MarkdownUtil.applyMarkdownText(changeLogText, check.updates.last().body);
installButton = new FunkinText(0, FlxG.height - 25, Std.int(FlxG.width / 2), "> INSTALL <", 32); installButton = new FunkinText(0, FlxG.height - 25, Std.int(FlxG.width / 2), "PLACEHOLDER", 32);
skipButton = new FunkinText(Std.int(FlxG.width / 2), FlxG.height - 25, Std.int(FlxG.width / 2), "SKIP", 32); skipButton = new FunkinText(Std.int(FlxG.width / 2), FlxG.height - 25, Std.int(FlxG.width / 2), "PLACEHOLDER", 32);
skipButton.y -= skipButton.height; skipButton.y -= skipButton.height;
installButton.y -= installButton.height; installButton.y -= installButton.height;
@@ -91,6 +93,8 @@ class UpdateAvailableScreen extends MusicBeatState {
oldPos = FlxG.mouse.getScreenPosition(); oldPos = FlxG.mouse.getScreenPosition();
changeSelection(false);
DiscordUtil.call("onMenuLoaded", ["Update Available Screen"]); DiscordUtil.call("onMenuLoaded", ["Update Available Screen"]);
} }
@@ -132,16 +136,18 @@ class UpdateAvailableScreen extends MusicBeatState {
} }
} }
var installText = TU.translate("updateAvailable.install");
var skipText = TU.translate("updateAvailable.skip");
public function changeSelection() { public function changeSelection(playSFX:Bool = true) {
CoolUtil.playMenuSFX(SCROLL, 0.7); CoolUtil.playMenuSFX(SCROLL, 0.7);
if (installSelected) {
installButton.text = "> INSTALL <"; // keeping this local just incase we wanna change this later
skipButton.text = "SKIP"; inline function wrap(str:String, shouldWrap:Bool)
} else { return shouldWrap ? "> " + str + " <" : str;
installButton.text = "INSTALL";
skipButton.text = "> SKIP <"; installButton.text = wrap(installText, installSelected);
} skipButton.text = wrap(skipText, !installSelected);
} }
public override function destroy() { public override function destroy() {
+4 -4
View File
@@ -21,15 +21,15 @@ class SaveWarning {
if (warningFunc != null) warningFunc(closingWindow); if (warningFunc != null) warningFunc(closingWindow);
if (FlxG.state != null && FlxG.state is UIState) { if (FlxG.state != null && FlxG.state is UIState) {
FlxG.state.openSubState(new UIWarningSubstate("Unsaved Changes!", "Your changes will be lost if you don't save them. (Can't be recovered)\n\n\nWould you like to Cancel?", FlxG.state.openSubState(new UIWarningSubstate(TU.translate("saveWarning.warningTitle"), TU.translate("saveWarning.warningDesc"),
[ [
{ {
label: "Cancel", label: TU.translate("saveWarning.cancel"),
color: 0x969533, color: 0x969533,
onClick: function (_) {if (closingWindow) WindowUtils.resetClosing();} onClick: function (_) {if (closingWindow) WindowUtils.resetClosing();}
}, },
{ {
label: closingWindow ? "Exit Game" : "Exit To Menu", label: closingWindow ? TU.translate("saveWarning.exitGame") : TU.translate("saveWarning.exitToMenu"),
color: 0x969533, color: 0x969533,
onClick: function(_) { onClick: function(_) {
if (!closingWindow) { if (!closingWindow) {
@@ -42,7 +42,7 @@ class SaveWarning {
} }
}, },
{ {
label: closingWindow ? "Save & Exit Game" : "Save & Exit To Menu", label: closingWindow ? TU.translate("saveWarning.saveAndExitGame") : TU.translate("saveWarning.saveAndExitToMenu"),
color: 0x969533, color: 0x969533,
onClick: function(_) { onClick: function(_) {
if (saveFunc != null) saveFunc(); if (saveFunc != null) saveFunc();
+15 -7
View File
@@ -88,6 +88,12 @@ class Charter extends UIState {
public static var clipboard:Array<CharterCopyboardObject> = []; public static var clipboard:Array<CharterCopyboardObject> = [];
public static var waveformHandler:CharterWaveformHandler; public static var waveformHandler:CharterWaveformHandler;
private var SONGPOSINFO_STEP = TU.getRaw("songPosInfo.step");
private var SONGPOSINFO_BEAT = TU.getRaw("songPosInfo.beat");
private var SONGPOSINFO_MEASURE = TU.getRaw("songPosInfo.measure");
private var SONGPOSINFO_BPM = TU.getRaw("songPosInfo.bpm");
private var SONGPOSINFO_TIMESIGNATURE = TU.getRaw("songPosInfo.timeSignature");
public function new(song:String, diff:String, reload:Bool = true) { public function new(song:String, diff:String, reload:Bool = true) {
super(); super();
if (song != null) { if (song != null) {
@@ -1220,13 +1226,15 @@ class Charter extends UIState {
for (strumLine in strumLines.members) strumLine.vocals.pause(); for (strumLine in strumLines.members) strumLine.vocals.pause();
} }
// TODO: make this translatable? songPosInfo.text = [
songPosInfo.text = '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}' // no need to translate the time text since it has no text only numbers
+ '\nStep: ${curStep}' '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}',
+ '\nBeat: ${curBeat}' SONGPOSINFO_STEP.format([curStep]),
+ '\nMeasure: ${curMeasure}' SONGPOSINFO_BEAT.format([curBeat]),
+ '\nBPM: ${Conductor.bpm}' SONGPOSINFO_MEASURE.format([curMeasure]),
+ '\nTime Signature: ${Conductor.beatsPerMeasure}/${Conductor.stepsPerBeat}'; SONGPOSINFO_BPM.format([Conductor.bpm]),
SONGPOSINFO_TIMESIGNATURE.format([Conductor.beatsPerMeasure, Conductor.stepsPerBeat])
].join("\n");
if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, __firstFrame ? 1 : 0.125))) if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, __firstFrame ? 1 : 0.125)))
updateDisplaySprites(); updateDisplaySprites();
+12 -6
View File
@@ -741,9 +741,9 @@ class PlayState extends MusicBeatState
add(icon); add(icon);
} }
scoreTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TU.translate("game.score", [songScore]), 16); scoreTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TEXT_GAME_SCORE.format([songScore]), 16);
missesTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TU.translate("game.misses", [misses]), 16); missesTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TEXT_GAME_MISSES.format([misses]), 16);
accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TU.translate("game.accuracy", ["-%", "(N/A)"]), 16); accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TEXT_GAME_ACCURACY.format(["-%", "(N/A)"]), 16);
accuracyTxt.addFormat(accFormat, 0, 1); accuracyTxt.addFormat(accFormat, 0, 1);
for(text in [scoreTxt, missesTxt, accuracyTxt]) { for(text in [scoreTxt, missesTxt, accuracyTxt]) {
@@ -1211,16 +1211,22 @@ class PlayState extends MusicBeatState
iconP2.health = 1 - (healthBar.percent / 100); iconP2.health = 1 - (healthBar.percent / 100);
} }
// bypass the caching in FormatUtil by doing it manually so its faster
private var TEXT_GAME_SCORE = TU.getRaw("game.score");
private var TEXT_GAME_MISSES = TU.getRaw("game.misses");
private var TEXT_GAME_COMBOBREAKS = TU.getRaw("game.comboBreaks");
private var TEXT_GAME_ACCURACY = TU.getRaw("game.accuracy");
function updateRatingStuff() { function updateRatingStuff() {
scoreTxt.text = TU.translate("game.score", [songScore]); scoreTxt.text = TEXT_GAME_SCORE.format([songScore]);
missesTxt.text = TU.translate(comboBreaks ? "game.comboBreaks" : "game.misses", [misses]); missesTxt.text = (comboBreaks ? TEXT_GAME_COMBOBREAKS : TEXT_GAME_MISSES).format([misses]);
if (curRating == null) if (curRating == null)
curRating = new ComboRating(0, "[N/A]", 0xFF888888); curRating = new ComboRating(0, "[N/A]", 0xFF888888);
@:privateAccess { @:privateAccess {
accFormat.format.color = curRating.color; accFormat.format.color = curRating.color;
accuracyTxt.text = TU.translate("game.accuracy", [accuracy < 0 ? "-%" : '${CoolUtil.quantize(accuracy * 100, 100)}%', curRating.rating]); accuracyTxt.text = TEXT_GAME_ACCURACY.format([accuracy < 0 ? "-%" : '${CoolUtil.quantize(accuracy * 100, 100)}%', curRating.rating]);
accuracyTxt._formatRanges[0].range.start = accuracyTxt.text.length - curRating.rating.length; accuracyTxt._formatRanges[0].range.start = accuracyTxt.text.length - curRating.rating.length;
accuracyTxt._formatRanges[0].range.end = accuracyTxt.text.length; accuracyTxt._formatRanges[0].range.end = accuracyTxt.text.length;
+11 -6
View File
@@ -202,6 +202,8 @@ class FreeplayState extends MusicBeatState
public var autoplayShouldPlay:Bool = true; public var autoplayShouldPlay:Bool = true;
#end #end
private var TEXT_FREEPLAY_SCORE = TU.getRaw("freeplay.score");
override function update(elapsed:Float) override function update(elapsed:Float)
{ {
super.update(elapsed); super.update(elapsed);
@@ -224,7 +226,7 @@ class FreeplayState extends MusicBeatState
updateOptionsAlpha(); updateOptionsAlpha();
} }
scoreText.text = TU.translate("freeplay.score", [Math.round(lerpScore)]); scoreText.text = TEXT_FREEPLAY_SCORE.format([Math.round(lerpScore)]);
scoreBG.scale.set(Math.max(Math.max(diffText.width, scoreText.width), coopText.width) + 8, (coopText.visible ? coopText.y + coopText.height : 66)); scoreBG.scale.set(Math.max(Math.max(diffText.width, scoreText.width), coopText.width) + 8, (coopText.visible ? coopText.y + coopText.height : 66));
scoreBG.updateHitbox(); scoreBG.updateHitbox();
scoreBG.x = FlxG.width - scoreBG.width; scoreBG.x = FlxG.width - scoreBG.width;
@@ -425,19 +427,22 @@ class FreeplayState extends MusicBeatState
var event = event("onUpdateOptionsAlpha", EventManager.get(FreeplayAlphaUpdateEvent).recycle(0.6, 0.45, 1, 1, 0.25)); var event = event("onUpdateOptionsAlpha", EventManager.get(FreeplayAlphaUpdateEvent).recycle(0.6, 0.45, 1, 1, 0.25));
if (event.cancelled) return; if (event.cancelled) return;
for (i in 0...iconArray.length) final idleAlpha = #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha;
iconArray[i].alpha = lerp(iconArray[i].alpha, #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha, event.lerp); final selectedAlpha = #if PRELOAD_ALL songInstPlaying ? event.selectedPlayingAlpha : #end event.selectedAlpha;
iconArray[curSelected].alpha = #if PRELOAD_ALL songInstPlaying ? event.selectedPlayingAlpha : #end event.selectedAlpha; for (i in 0...iconArray.length)
iconArray[i].alpha = lerp(iconArray[i].alpha, idleAlpha, event.lerp);
iconArray[curSelected].alpha = selectedAlpha;
for (i=>item in grpSongs.members) for (i=>item in grpSongs.members)
{ {
item.targetY = i - curSelected; item.targetY = i - curSelected;
item.alpha = lerp(item.alpha, #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha, event.lerp); item.alpha = lerp(item.alpha, idleAlpha, event.lerp);
if (item.targetY == 0) if (item.targetY == 0)
item.alpha = #if PRELOAD_ALL songInstPlaying ? event.selectedPlayingAlpha : #end event.selectedAlpha; item.alpha = selectedAlpha;
} }
} }
} }