some more translations
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
package funkin.backend;
|
||||
|
||||
import funkin.backend.utils.TranslationUtil.IFormatInfo;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.text.FlxText;
|
||||
|
||||
class FunkinText extends FlxText {
|
||||
public function new(X:Float = 0, Y:Float = 0, FieldWidth:Float = 0, ?Text:String, Size:Int = 16, Border:Bool = true, ?TranslationID:String, ?TranslParameters:Array<Dynamic>) {
|
||||
super(X, Y, FieldWidth, TranslationUtil.get(Text, TranslationID, TranslParameters), Size);
|
||||
public var langStrID:String = null;
|
||||
private var langFormat:IFormatInfo;
|
||||
|
||||
public function new(X:Float = 0, Y:Float = 0, FieldWidth:Float = 0, ?Text:String, Size:Int = 16, Border:Bool = true, ?LangStrID:String, ?Parameters:Array<Dynamic>) {
|
||||
langStrID = LangStrID;
|
||||
langFormat = TranslationUtil.getUnformatted(Text, LangStrID);
|
||||
|
||||
// Should still default to the normal string if the translation is not found
|
||||
super(X, Y, FieldWidth, getFormattedText(Parameters), Size);
|
||||
setFormat(Paths.font("vcr.ttf"), Size, FlxColor.WHITE);
|
||||
if (Border) {
|
||||
borderStyle = OUTLINE;
|
||||
@@ -13,4 +21,10 @@ class FunkinText extends FlxText {
|
||||
borderColor = 0xFF000000;
|
||||
}
|
||||
}
|
||||
|
||||
public inline function resetLang(Parameters:Array<Dynamic>)
|
||||
return this.text = getFormattedText(Parameters);
|
||||
|
||||
private inline function getFormattedText(Parameters:Array<Dynamic>)
|
||||
return langFormat.format(Parameters);
|
||||
}
|
||||
@@ -98,13 +98,16 @@ class TranslationUtil
|
||||
*
|
||||
* If `id` is `null` then it's gonna search using `defString`.
|
||||
*/
|
||||
public static function get(defString:String, ?id:String, ?params:Array<Dynamic>):String
|
||||
public static inline function get(defString:String, ?id:String, ?params:Array<Dynamic>):String
|
||||
return getUnformatted(defString, id).format(params);
|
||||
|
||||
public static function getUnformatted(defString:String, ?id:String):IFormatInfo
|
||||
{
|
||||
#if TRANSLATIONS_SUPPORT
|
||||
if (id == null) id = defString;
|
||||
if (stringMap.exists(id)) return stringMap.get(id).format(params);
|
||||
if (stringMap.exists(id)) return stringMap.get(id);
|
||||
#end
|
||||
return FormatUtil.get(defString).format(params);
|
||||
return FormatUtil.get(defString);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -720,9 +720,9 @@ class PlayState extends MusicBeatState
|
||||
add(icon);
|
||||
}
|
||||
|
||||
scoreTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Score:0", 16);
|
||||
scoreTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Score:{0}", 16, "score", [songScore]);
|
||||
missesTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Misses:0", 16);
|
||||
accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Accuracy:-% (N/A)", 16);
|
||||
accuracyTxt = new FunkinText(healthBarBG.x + 50, healthBarBG.y + 30, Std.int(healthBarBG.width - 100), "Accuracy:{0} - {1}", 16, "accuracy", ["-%", "(N/A)"]);
|
||||
accuracyTxt.addFormat(accFormat, 0, 1);
|
||||
|
||||
for(text in [scoreTxt, missesTxt, accuracyTxt]) {
|
||||
@@ -1189,7 +1189,7 @@ class PlayState extends MusicBeatState
|
||||
}
|
||||
|
||||
function updateRatingStuff() {
|
||||
scoreTxt.text = 'Score:$songScore';
|
||||
scoreTxt.resetLang([songScore]);
|
||||
missesTxt.text = '${comboBreaks ? "Combo Breaks" : "Misses"}:$misses';
|
||||
|
||||
if (curRating == null)
|
||||
@@ -1197,7 +1197,7 @@ class PlayState extends MusicBeatState
|
||||
|
||||
@:privateAccess {
|
||||
accFormat.format.color = curRating.color;
|
||||
accuracyTxt.text = 'Accuracy:${accuracy < 0 ? "-%" : '${CoolUtil.quantize(accuracy * 100, 100)}%'} - ${curRating.rating}';
|
||||
accuracyTxt.resetLang([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;
|
||||
@@ -1913,7 +1913,7 @@ class ComboRating {
|
||||
|
||||
public function new(percent:Float, rating:String, color:FlxColor) {
|
||||
this.percent = percent;
|
||||
this.rating = rating;
|
||||
this.rating = TranslationUtil.get(rating, 'rating_$rating');
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user