this should be better (still a wip)
i'll brb later to continue
This commit is contained in:
@@ -5,7 +5,7 @@ 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, TranslationsUtil.get(Text, TranslationID, TranslParameters), Size);
|
||||
super(X, Y, FieldWidth, TranslationUtil.get(Text, TranslationID, TranslParameters), Size);
|
||||
setFormat(Paths.font("vcr.ttf"), Size, FlxColor.WHITE);
|
||||
if (Border) {
|
||||
borderStyle = OUTLINE;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package funkin.backend.assets;
|
||||
|
||||
import openfl.utils.AssetLibrary;
|
||||
//import lime.utils.Assets as LimeAssets;
|
||||
|
||||
import lime.media.AudioBuffer;
|
||||
import lime.graphics.Image;
|
||||
import lime.text.Font;
|
||||
@@ -26,10 +24,7 @@ class ModsFolderLibrary extends AssetLibrary implements IModsAssetLibrary {
|
||||
this.basePath = basePath;
|
||||
this.libName = libName;
|
||||
this.prefix = 'assets/$libName/';
|
||||
if(modName == null)
|
||||
this.modName = libName;
|
||||
else
|
||||
this.modName = modName;
|
||||
this.modName = modName == null ? libName : modName;
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class Paths
|
||||
return getPath('$translFolderName/$key');
|
||||
|
||||
public static inline function translations(key:String)
|
||||
return translationsMain('${TranslationsUtil.curLanguage}/$key');
|
||||
return translationsMain('${TranslationUtil.curLanguage}/$key');
|
||||
|
||||
public static inline function video(key:String, ?ext:String = "mp4")
|
||||
return getPath('videos/$key.$ext');
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package funkin.backend.assets;
|
||||
|
||||
import openfl.utils.AssetLibrary;
|
||||
import lime.utils.Bytes;
|
||||
|
||||
class TranslatedAssetLibrary extends AssetLibrary {
|
||||
public var langFolder:String;
|
||||
public var langPath:String;
|
||||
|
||||
public function new(langFolder:String) {
|
||||
this.langFolder = langFolder;
|
||||
this.langPath = '${Paths.translFolderName}/$langFolder';
|
||||
super();
|
||||
}
|
||||
|
||||
function toString():String
|
||||
return '(TranslatedAssetLibrary: The labguage folder is $langFolder)';
|
||||
|
||||
public override function getBytes(id:String):Bytes {
|
||||
for(lib in ModsFolder.getLoadedModsLibs()) {
|
||||
if(!(lib is AssetLibrary)) continue;
|
||||
|
||||
var mainPath = lib.prefix;
|
||||
if(!mainPath.endsWith('/')) mainPath += '/';
|
||||
var val = cast(lib, AssetLibrary).getBytes('$mainPath$langPath/$id');
|
||||
if(val != null) return val;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// I'll brb later and continue - Nex
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class MainState extends FlxState {
|
||||
|
||||
Main.refreshAssets();
|
||||
ModsFolder.onModSwitch.dispatch(ModsFolder.currentModFolder);
|
||||
TranslationsUtil.setLanguage();
|
||||
TranslationUtil.setLanguage();
|
||||
DiscordUtil.init();
|
||||
EventsData.reloadEvents();
|
||||
TitleState.initialized = false;
|
||||
|
||||
+2
-12
@@ -14,7 +14,7 @@ import haxe.Exception;
|
||||
*
|
||||
* Made by @NexIsDumb originally for the Poldhub mod.
|
||||
*/
|
||||
class TranslationsUtil
|
||||
class TranslationUtil
|
||||
{
|
||||
/**
|
||||
* The current language selected translation map; If the current language it's english, this map will be empty.
|
||||
@@ -68,17 +68,7 @@ class TranslationsUtil
|
||||
public static function setLanguage(?name:String) {
|
||||
if(name == null) name = curLanguage;
|
||||
transMap = loadLanguage(name);
|
||||
|
||||
for(mod in ModsFolder.getLoadedModsLibs()) {
|
||||
if(!(mod is IModsAssetLibrary) || mod is ZipFolderLibrary) continue; // TODO: add support for zipped mods
|
||||
// TODO: clean this code
|
||||
var _mod = cast(mod, openfl.utils.AssetLibrary);
|
||||
var mod = cast(mod, IModsAssetLibrary);
|
||||
var mainPath = mod.basePath;
|
||||
if(!mainPath.endsWith('/')) mainPath += '/';
|
||||
trace("Set sub library to " + mainPath + Paths.translFolderName + "/" + name + "/assets/");
|
||||
_mod.subLibraries = [ModsFolder.loadLibraryFromFolder(name, '$mainPath${Paths.translFolderName}/$name/assets/', true)];
|
||||
}
|
||||
// To add the switch for the language in TranslatedAssetLibrary here! - Nex
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,10 +347,10 @@ class FreeplayState extends MusicBeatState
|
||||
* Array containing all labels for Co-Op / Opponent modes.
|
||||
*/
|
||||
public var coopLabels:Array<String> = [
|
||||
TranslationsUtil.get("[TAB] Solo"),
|
||||
TranslationsUtil.get("[TAB] Opponent Mode"),
|
||||
TranslationsUtil.get("[TAB] Co-Op Mode"),
|
||||
TranslationsUtil.get("[TAB] Co-Op Mode (Switched)")
|
||||
TranslationUtil.get("[TAB] Solo"),
|
||||
TranslationUtil.get("[TAB] Opponent Mode"),
|
||||
TranslationUtil.get("[TAB] Co-Op Mode"),
|
||||
TranslationUtil.get("[TAB] Co-Op Mode (Switched)")
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,7 +81,7 @@ class Alphabet extends FlxSpriteGroup
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
_finalText = this.text = TranslationsUtil.get(text, transID, transParams);
|
||||
_finalText = this.text = TranslationUtil.get(text, transID, transParams);
|
||||
isBold = bold;
|
||||
|
||||
var alphabetPath = Paths.xml("alphabet");
|
||||
|
||||
@@ -35,7 +35,7 @@ class Options
|
||||
public static var songOffset:Float = 0;
|
||||
public static var framerate:Int = 120;
|
||||
public static var gpuOnlyBitmaps:Bool = #if (mac || web) false #else true #end; // causes issues on mac and web
|
||||
public static var language = funkin.backend.utils.TranslationsUtil.DEFAULT_LANGUAGE;
|
||||
public static var language = funkin.backend.utils.TranslationUtil.DEFAULT_LANGUAGE;
|
||||
|
||||
public static var lastLoadedMod:String = null;
|
||||
|
||||
|
||||
@@ -6,17 +6,17 @@ class MiscOptions extends OptionsScreen {
|
||||
super("Miscellaneous", "Use this menu to reset save data or engine settings.");
|
||||
|
||||
{ // Language Option
|
||||
var lanArray:Array<String> = TranslationsUtil.getLanguages();
|
||||
if (lanArray.contains(TranslationsUtil.DEFAULT_LANGUAGE))
|
||||
lanArray.remove(TranslationsUtil.DEFAULT_LANGUAGE);
|
||||
lanArray.insert(0, TranslationsUtil.DEFAULT_LANGUAGE);
|
||||
var lanArray:Array<String> = TranslationUtil.getLanguages();
|
||||
if (lanArray.contains(TranslationUtil.DEFAULT_LANGUAGE))
|
||||
lanArray.remove(TranslationUtil.DEFAULT_LANGUAGE);
|
||||
lanArray.insert(0, TranslationUtil.DEFAULT_LANGUAGE);
|
||||
|
||||
add(new ArrayOption(
|
||||
"Language",
|
||||
'The language that the engine currently uses (the default one is ${TranslationsUtil.DEFAULT_LANGUAGE}).',
|
||||
'The language that the engine currently uses (the default one is ${TranslationUtil.DEFAULT_LANGUAGE}).',
|
||||
lanArray, [for(lan in lanArray) lan.split("/").last()], "language",
|
||||
function(path:String) {
|
||||
TranslationsUtil.setLanguage(path);
|
||||
TranslationUtil.setLanguage(path);
|
||||
parent.remove(this);
|
||||
// Reload the current screen
|
||||
// todo add parent.reload();
|
||||
|
||||
Reference in New Issue
Block a user