Optimize formatutil more
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package funkin.backend.system;
|
||||
|
||||
import funkin.backend.utils.translations.FormatUtil;
|
||||
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.addons.transition.TransitionData;
|
||||
@@ -58,6 +59,12 @@ class Main extends Sprite
|
||||
public static var gameThreads:Array<Thread> = [];
|
||||
#end
|
||||
|
||||
public static function preInit() {
|
||||
funkin.backend.utils.NativeAPI.registerAsDPICompatible();
|
||||
funkin.backend.system.CommandLineHandler.parseCommandLine(Sys.args());
|
||||
funkin.backend.system.Main.fixWorkingDirectory();
|
||||
}
|
||||
|
||||
public function new()
|
||||
{
|
||||
super();
|
||||
|
||||
@@ -5,7 +5,7 @@ package funkin.backend.utils.translations;
|
||||
*
|
||||
* For example if the parameter list is just an `Int` which is `9`, `You have been blue balled {0} times` becomes `You have been blue balled 9 times`.
|
||||
*/
|
||||
class FormatUtil {
|
||||
final class FormatUtil {
|
||||
private static var cache:Map<String, IFormatInfo> = new Map();
|
||||
private static var cacheStr:Map<String, IFormatInfo> = new Map();
|
||||
|
||||
@@ -87,14 +87,17 @@ class ParamFormatInfo implements IFormatInfo {
|
||||
public function format(params:Array<Dynamic>):String {
|
||||
if (params == null) params = [];
|
||||
|
||||
var str:String = "";
|
||||
for (i=>s in strings) {
|
||||
str += s;
|
||||
if (i < indexes.length)
|
||||
str += params[indexes[i]];
|
||||
}
|
||||
var lenStr = strings.length;
|
||||
var lenInd = indexes.length;
|
||||
|
||||
return str;
|
||||
var arr = new haxe.ds.Vector<String>(lenStr + ((lenStr < lenInd) ? lenStr : lenInd));
|
||||
var i = 0;
|
||||
for (idx=>s in strings) {
|
||||
arr[i++] = s;
|
||||
if (idx < lenInd)
|
||||
arr[i++] = Std.string(params[indexes[idx]]);
|
||||
}
|
||||
return arr.join("");
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
|
||||
@@ -602,9 +602,7 @@ class System
|
||||
{
|
||||
// executes first!!
|
||||
#if (sys && !macro)
|
||||
funkin.backend.utils.NativeAPI.registerAsDPICompatible();
|
||||
funkin.backend.system.CommandLineHandler.parseCommandLine(Sys.args());
|
||||
funkin.backend.system.Main.fixWorkingDirectory();
|
||||
funkin.backend.system.Main.preInit();
|
||||
#end
|
||||
|
||||
if (__applicationEntryPoint == null)
|
||||
|
||||
Reference in New Issue
Block a user