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
@@ -41,7 +41,9 @@ class UpdateAvailableScreen extends MusicBeatState {
bg.screenCenter();
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.scrollFactor.set();
@@ -61,8 +63,8 @@ class UpdateAvailableScreen extends MusicBeatState {
changeLogText.borderColor = 0xFF000000;
MarkdownUtil.applyMarkdownText(changeLogText, check.updates.last().body);
installButton = new FunkinText(0, FlxG.height - 25, Std.int(FlxG.width / 2), "> INSTALL <", 32);
skipButton = new FunkinText(Std.int(FlxG.width / 2), FlxG.height - 25, Std.int(FlxG.width / 2), "SKIP", 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), "PLACEHOLDER", 32);
skipButton.y -= skipButton.height;
installButton.y -= installButton.height;
@@ -91,6 +93,8 @@ class UpdateAvailableScreen extends MusicBeatState {
oldPos = FlxG.mouse.getScreenPosition();
changeSelection(false);
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);
if (installSelected) {
installButton.text = "> INSTALL <";
skipButton.text = "SKIP";
} else {
installButton.text = "INSTALL";
skipButton.text = "> SKIP <";
}
// keeping this local just incase we wanna change this later
inline function wrap(str:String, shouldWrap:Bool)
return shouldWrap ? "> " + str + " <" : str;
installButton.text = wrap(installText, installSelected);
skipButton.text = wrap(skipText, !installSelected);
}
public override function destroy() {
+4 -4
View File
@@ -21,15 +21,15 @@ class SaveWarning {
if (warningFunc != null) warningFunc(closingWindow);
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,
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,
onClick: function(_) {
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,
onClick: function(_) {
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 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) {
super();
if (song != null) {
@@ -1220,13 +1226,15 @@ class Charter extends UIState {
for (strumLine in strumLines.members) strumLine.vocals.pause();
}
// TODO: make this translatable?
songPosInfo.text = '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}'
+ '\nStep: ${curStep}'
+ '\nBeat: ${curBeat}'
+ '\nMeasure: ${curMeasure}'
+ '\nBPM: ${Conductor.bpm}'
+ '\nTime Signature: ${Conductor.beatsPerMeasure}/${Conductor.stepsPerBeat}';
songPosInfo.text = [
// no need to translate the time text since it has no text only numbers
'${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}',
SONGPOSINFO_STEP.format([curStep]),
SONGPOSINFO_BEAT.format([curBeat]),
SONGPOSINFO_MEASURE.format([curMeasure]),
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)))
updateDisplaySprites();
+12 -6
View File
@@ -741,9 +741,9 @@ class PlayState extends MusicBeatState
add(icon);
}
scoreTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TU.translate("game.score", [songScore]), 16);
missesTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TU.translate("game.misses", [misses]), 16);
accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), TU.translate("game.accuracy", ["-%", "(N/A)"]), 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), TEXT_GAME_MISSES.format([misses]), 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);
for(text in [scoreTxt, missesTxt, accuracyTxt]) {
@@ -1211,16 +1211,22 @@ class PlayState extends MusicBeatState
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() {
scoreTxt.text = TU.translate("game.score", [songScore]);
missesTxt.text = TU.translate(comboBreaks ? "game.comboBreaks" : "game.misses", [misses]);
scoreTxt.text = TEXT_GAME_SCORE.format([songScore]);
missesTxt.text = (comboBreaks ? TEXT_GAME_COMBOBREAKS : TEXT_GAME_MISSES).format([misses]);
if (curRating == null)
curRating = new ComboRating(0, "[N/A]", 0xFF888888);
@:privateAccess {
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.end = accuracyTxt.text.length;
+11 -6
View File
@@ -202,6 +202,8 @@ class FreeplayState extends MusicBeatState
public var autoplayShouldPlay:Bool = true;
#end
private var TEXT_FREEPLAY_SCORE = TU.getRaw("freeplay.score");
override function update(elapsed:Float)
{
super.update(elapsed);
@@ -224,7 +226,7 @@ class FreeplayState extends MusicBeatState
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.updateHitbox();
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));
if (event.cancelled) return;
for (i in 0...iconArray.length)
iconArray[i].alpha = lerp(iconArray[i].alpha, #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha, event.lerp);
final idleAlpha = #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha;
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)
{
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)
item.alpha = #if PRELOAD_ALL songInstPlaying ? event.selectedPlayingAlpha : #end event.selectedAlpha;
item.alpha = selectedAlpha;
}
}
}