applying formats and parameters
also due to a merge conflict apparently the deathCounter++ was never merged from my original old pr😭
This commit is contained in:
@@ -4,8 +4,8 @@ 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) {
|
||||
super(X, Y, FieldWidth, TranslationsUtil.checkTransl(Text, TranslationID), Size);
|
||||
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, TranslationsUtil.getTransl(Text, TranslationID, TranslParameters), Size);
|
||||
setFormat(Paths.font("vcr.ttf"), Size, FlxColor.WHITE);
|
||||
if (Border) {
|
||||
borderStyle = OUTLINE;
|
||||
|
||||
@@ -17,7 +17,7 @@ class TranslationsUtil
|
||||
*
|
||||
* Using this class function it'll never be `null`.
|
||||
*/
|
||||
public static var transMap(default, null):Map<String, String> = [];
|
||||
public static var transMap(default, null):Map<String, FormatInfo> = [];
|
||||
|
||||
/**
|
||||
* The default language used inside of the source code.
|
||||
@@ -56,17 +56,18 @@ class TranslationsUtil
|
||||
transMap = loadLanguage(name == null ? curLanguage : name);
|
||||
|
||||
/**
|
||||
* This is for checking a translation, `defString` it's just the string that gets returned just in case it won't find the translation OR the current language selected is ``DEFAULT_LANGUAGE``.
|
||||
* This is for checking and getting a translation, `defString` it's just the string that gets returned just in case it won't find the translation OR the current language selected is ``DEFAULT_LANGUAGE``.
|
||||
*
|
||||
* If `id` is `null` then it's gonna search using `defString`.
|
||||
*/
|
||||
public static function checkTransl(defString:String, ?id:String):String
|
||||
public static function getTransl(defString:String, ?id:String, ?parms:Array<Dynamic>):String
|
||||
{
|
||||
if(parms == null) parms = [];
|
||||
#if TRANSLATIONS_SUPPORT
|
||||
if(id == null) id = defString;
|
||||
if(transMap.exists(id)) return transMap.get(id);
|
||||
if(transMap.exists(id)) return transMap.get(id).format(parms);
|
||||
#end
|
||||
return defString;
|
||||
return new FormatInfo(defString).format(parms);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +87,7 @@ class TranslationsUtil
|
||||
/**
|
||||
* Returns a map of translations based on its XML.
|
||||
*/
|
||||
public static function loadLanguage(name:String):Map<String, String>
|
||||
public static function loadLanguage(name:String):Map<String, FormatInfo>
|
||||
{
|
||||
#if TRANSLATIONS_SUPPORT
|
||||
var path:String = Paths.translationsMain(name);
|
||||
@@ -106,7 +107,7 @@ class TranslationsUtil
|
||||
return [];
|
||||
}
|
||||
|
||||
var leMap:Map<String, String> = [];
|
||||
var leMap:Map<String, FormatInfo> = [];
|
||||
for(node in xml.node.translations.elements) {
|
||||
switch(node.name) {
|
||||
case "trans":
|
||||
@@ -118,7 +119,7 @@ class TranslationsUtil
|
||||
FlxG.log.warn("A translation node requires a string attribute.");
|
||||
continue;
|
||||
}
|
||||
leMap.set(node.att.id, node.att.string);
|
||||
leMap.set(node.att.id, new FormatInfo(node.att.string));
|
||||
}
|
||||
}
|
||||
return leMap;
|
||||
@@ -164,7 +165,7 @@ class FormatInfo {
|
||||
var str:String = "";
|
||||
for(i=>s in strings) {
|
||||
str += s;
|
||||
if(i < strings.length-1)
|
||||
if(i < indexes.length)
|
||||
str += values[indexes[i]];
|
||||
}
|
||||
|
||||
|
||||
@@ -1409,6 +1409,7 @@ class PlayState extends MusicBeatState
|
||||
FlxG.sound.music.stop();
|
||||
for (strumLine in strumLines.members) strumLine.vocals.stop();
|
||||
|
||||
deathCounter++;
|
||||
openSubState(new GameOverSubstate(event.x, event.y, event.deathCharID, event.isPlayer, event.gameOverSong, event.lossSFX, event.retrySFX));
|
||||
|
||||
scripts.event("onPostGameOver", event);
|
||||
|
||||
@@ -347,10 +347,10 @@ class FreeplayState extends MusicBeatState
|
||||
* Array containing all labels for Co-Op / Opponent modes.
|
||||
*/
|
||||
public var coopLabels:Array<String> = [
|
||||
TranslationsUtil.checkTransl("[TAB] Solo"),
|
||||
TranslationsUtil.checkTransl("[TAB] Opponent Mode"),
|
||||
TranslationsUtil.checkTransl("[TAB] Co-Op Mode"),
|
||||
TranslationsUtil.checkTransl("[TAB] Co-Op Mode (Switched)")
|
||||
TranslationsUtil.getTransl("[TAB] Solo"),
|
||||
TranslationsUtil.getTransl("[TAB] Opponent Mode"),
|
||||
TranslationsUtil.getTransl("[TAB] Co-Op Mode"),
|
||||
TranslationsUtil.getTransl("[TAB] Co-Op Mode (Switched)")
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,8 +72,7 @@ class PauseSubState extends MusicBeatSubstate
|
||||
var levelInfo:FunkinText = new FunkinText(20, 15, 0, PlayState.SONG.meta.displayName, 32, false);
|
||||
var levelDifficulty:FunkinText = new FunkinText(20, 15, 0, PlayState.difficulty.toUpperCase(), 32, false);
|
||||
var multiplayerText:FunkinText = new FunkinText(20, 15, 0, PlayState.opponentMode ? 'OPPONENT MODE' : (PlayState.coopMode ? 'CO-OP MODE' : ''), 32, false);
|
||||
var deathCounter:FunkinText = new FunkinText(20, 15, 0, "Blue balled", 32, false);
|
||||
deathCounter.text += ": " + PlayState.deathCounter; // Adding it later for the translation - Nex
|
||||
var deathCounter:FunkinText = new FunkinText(20, 15, 0, "Blue balled: {0}", 32, false, "blue_balled", [PlayState.deathCounter]);
|
||||
|
||||
for(k=>label in [levelInfo, levelDifficulty, deathCounter, multiplayerText]) {
|
||||
label.scrollFactor.set();
|
||||
|
||||
@@ -77,11 +77,11 @@ class Alphabet extends FlxSpriteGroup
|
||||
trace(e.details());
|
||||
}
|
||||
}
|
||||
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false, typed:Bool = false, ?transID:String)
|
||||
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false, typed:Bool = false, ?transID:String, ?transParams:Array<Dynamic>)
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
_finalText = this.text = TranslationsUtil.checkTransl(text, transID);
|
||||
_finalText = this.text = TranslationsUtil.getTransl(text, transID, transParams);
|
||||
isBold = bold;
|
||||
|
||||
var alphabetPath = Paths.xml("alphabet");
|
||||
|
||||
Reference in New Issue
Block a user