[Adventure] Support for localization

-refactor some codes for localization
This commit is contained in:
Anthony Calosa
2022-03-06 12:23:33 +08:00
parent 0933034f98
commit d4be53c72f
113 changed files with 11780 additions and 1977 deletions

View File

@@ -16,6 +16,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import forge.Forge;
import java.util.function.Function;
@@ -24,6 +25,7 @@ import java.util.function.Function;
*/
public class Controls {
private static Skin SelectedSkin = null;
private static BitmapFont defaultfont, bigfont, miKrollFantasy;
static public TextButton newTextButton(String text) {
@@ -98,13 +100,17 @@ public class Controls {
CheckBox ret = new CheckBox(text, GetSkin());
return ret;
}
static public BitmapFont bigFont()
{
return SelectedSkin.getFont("big");
}
static public BitmapFont font()
{
return SelectedSkin.getFont("default");
static public BitmapFont getBitmapFont(String fontName) {
switch (fontName) {
case "MiKrollFantasyBig":
return miKrollFantasy;
case "blackbig":
case "big":
return bigfont;
default:
return defaultfont;
}
}
@@ -113,26 +119,34 @@ public class Controls {
if (SelectedSkin == null) {
SelectedSkin = new Skin();
FileHandle skinFile = Config.instance().getFile(Paths.SKIN);
FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas");
TextureAtlas atlas = new TextureAtlas(atlasFile);
SelectedSkin.addRegions(atlas);
SelectedSkin.load(skinFile);
//font
defaultfont = new BitmapFont(Config.instance().getFile(Paths.SKIN).sibling("LanaPixelCJK.fnt"));
miKrollFantasy = new BitmapFont(Config.instance().getFile(Paths.SKIN).sibling("MiKrollFantasyBig.fnt"));
bigfont = new BitmapFont(Config.instance().getFile(Paths.SKIN).sibling("LanaPixelCJK.fnt"));
bigfont.getData().setScale(2, 2);
}
return SelectedSkin;
}
public static Label newLabel(String name) {
Label ret = new Label(name, GetSkin());
if (!Forge.isLandscapeMode()) {
ret.setFontScaleX(2);
}
return ret;
}
public static Dialog newDialog(String title) {
Dialog ret = new Dialog(title, GetSkin());
if (!Forge.isLandscapeMode()) {
ret.getTitleLabel().setFontScaleX(2);
}
return ret;
}