本文整理汇总了Java中com.badlogic.gdx.utils.I18NBundle.createBundle方法的典型用法代码示例。如果您正苦于以下问题:Java I18NBundle.createBundle方法的具体用法?Java I18NBundle.createBundle怎么用?Java I18NBundle.createBundle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.I18NBundle
的用法示例。
在下文中一共展示了I18NBundle.createBundle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
/**
* Initialisierung.
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
*/
@Override
public void create(SchoolGame game) {
Gdx.app.getApplicationLogger().log("INFO", "Menu init...");
this.game = game;
entries = new ArrayList<MenuEntry>();
this.setupMenu();
batch = new SpriteBatch();
font = game.getDefaultFont();
fontLayout = new GlyphLayout();
selectSound = game.getAudioManager().createSound("menu", "select.wav", true);
changeSound = game.getAudioManager().createSound("menu", "change.wav", true);
game.getAudioManager().selectMusic(MUSIC_NAME, 0f);
FileHandle baseFileHandle = Gdx.files.internal("data/I18n/" + getI18nName());
localeBundle = I18NBundle.createBundle(baseFileHandle);
Gdx.app.getApplicationLogger().log("INFO", "Menu finished...");
}
示例2: create
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
/**
* Initialisierung
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
*/
@Override
public void create(SchoolGame game) {
this.game = game;
saveData = new SaveData(this.game, this.slot);
batch = new SpriteBatch();
font = game.getDefaultFont();
smallFont = game.getLongTextFont();
fontLayout = new GlyphLayout();
FileHandle baseFileHandle = Gdx.files.internal("data/I18n/GameMenu");
localeBundle = I18NBundle.createBundle(baseFileHandle);
}
示例3: preLoad
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
public void preLoad()
{
input = new InputManager(se);
Controllers.addListener(input);
atlas = new TextureAtlas("main.atlas");
titleScreenAtlas = new TextureAtlas("titlescreen.atlas");
menuControlsAtlas = new TextureAtlas("menu.atlas");
menuFont = new BitmapFont(Gdx.files.internal("data/cgcfont.fnt"), atlas.findRegion("cgcfont"), false);
titleFont = new BitmapFont(Gdx.files.internal("data/cgctitlefont.fnt"), atlas.findRegion("cgctitlefont"), false);
sBatch = new SpriteBatch(1625);
shapes = new ShapeRenderer();
tManager = new TweenManager();
FileHandle baseFileHandle = Gdx.files.internal("i18n/CGCLang");
I18NBundle myBundle = I18NBundle.createBundle(baseFileHandle, locale);
lang = myBundle;
ChaseApp.alert("lang loaded");
}
示例4: getLocalizedLabel
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
/**
* returns localized label {@code labelKey} out of the label bundle file.
*
* The label bundle file path is specified within the GameConstants class (check LABE_BUNDLE_PATH)
*
* @param labelKey key to be searched within the label bundle
*
* @return localized label of key {@code labelKey}
*/
public static String getLocalizedLabel(String labelKey) {
if (labelBundle == null) {
String cfgFileValue = getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_LANGUAGE);
Locale locale = null;
if (cfgFileValue != null) {
locale = new Locale(cfgFileValue);
} else {
// get default locale
locale = Locale.getDefault();
}
labelBundle = I18NBundle.createBundle(Gdx.files.internal(GameConstants.LABEL_BUNDLE_PATH), locale);
}
String result = "";
try {
result = labelBundle.get(labelKey);
} catch (MissingResourceException e) {
Gdx.app.error(GameConstants.LOG_TAG_ERROR, "Could not find label for key: " + labelKey, e);
}
return result;
}
示例5: reloadBundles
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
/** @param locale will be used to reload all managed {@link I18NBundle} instances. */
public void reloadBundles(final Locale locale) {
final AssetManager assetManager = getAssetManager();
for (final String id : bundles.keys()) {
final String path = determinePath(id);
try {
assetManager.unload(path);
} catch (final Exception exception) {
Exceptions.ignore(exception); // Asset not loaded. Somewhat expected.
}
final I18NBundle bundle = I18NBundle.createBundle(Gdx.files.internal(path), locale, encoding);
bundles.put(id, bundle);
final EagerI18NBundleParameter parameters = new EagerI18NBundleParameter(bundle);
assetManager.load(path, I18NBundle.class, parameters);
assetManager.finishLoadingAsset(path);
for (final BundleInjection injection : bundlesData.get(id)) {
injection.inject(bundle);
}
parser.getData().addI18nBundle(id, bundle);
if (defaultBundle.equals(id)) {
parser.getData().setDefaultI18nBundle(bundle);
}
}
}
示例6: loadAsync
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
@Override
public void loadAsync (AssetManager manager, String fileName, FileHandle file, I18NBundleParameter parameter) {
this.bundle = null;
Locale locale;
String encoding;
if (parameter == null) {
locale = Locale.getDefault();
encoding = null;
} else {
locale = parameter.locale == null ? Locale.getDefault() : parameter.locale;
encoding = parameter.encoding;
}
if (encoding == null) {
this.bundle = I18NBundle.createBundle(file, locale);
} else {
this.bundle = I18NBundle.createBundle(file, locale, encoding);
}
}
示例7: forceinit
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
public static boolean forceinit(FileHandle baseFileHandle) {
if (GlobalConf.program == null || GlobalConf.program.LOCALE.isEmpty()) {
// Use system default
locale = Locale.getDefault();
} else {
locale = forLanguageTag(GlobalConf.program.LOCALE);
}
try {
bundle = I18NBundle.createBundle(baseFileHandle, locale);
return true;
} catch (MissingResourceException e) {
Logger.info(I18n.class.getSimpleName(), e.getLocalizedMessage());
// Use default locale - en_GB
locale = new Locale("en", "GB");
try {
bundle = I18NBundle.createBundle(baseFileHandle, locale);
} catch (Exception e2) {
Logger.error(e, I18n.class.getSimpleName());
}
return false;
}
}
示例8: SplashScreen
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
public SplashScreen(AssetManager manager) {
super("MainMenu", manager);
// Splash
camera = new OrthographicCamera(GlobalVars.width, GlobalVars.height);
camera.position.set(GlobalVars.width / 2, GlobalVars.height / 2, 0f);
camera.update();
batch = new SpriteBatch();
splash = manager.get("gfx/deathsbreedgames/logo.png", Texture.class);
splashWidth = (float)GlobalVars.width;
splashHeight = splashWidth * 2f / 9.5f;
// Alpha
a = 0f;
timer = 0f;
// Set the preferences
Preferences prefs = Gdx.app.getPreferences("SpaceRun");
GlobalVars.gameBundle = I18NBundle.createBundle(Gdx.files.internal("i18n/GameBundle"), Locale.getDefault());
GlobalVars.highScore = prefs.getInteger("HighScore");
GlobalVars.killCount = prefs.getInteger("KillCount");
GlobalVars.soundOn = !prefs.getBoolean("SoundOff");
GlobalVars.musicOn = !prefs.getBoolean("MusicOff");
}
示例9: StatusScreen
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
public StatusScreen(CaramelosGame game, boolean victory,int level)
{
this.game = game;
this.victory = victory;
this.level = level;
Preferences prefs = Gdx.app.getPreferences("My Preferences");
flagSound = prefs.getBoolean("sound");
if(victory)
mp3Music = Gdx.audio.newMusic(Gdx.files.internal("Music/Victory.mp3"));
else{
mp3Music = Gdx.audio.newMusic(Gdx.files.internal("Music/GameOver.mp3"));
}
mp3Music.setLooping(true);
if(flagSound){
mp3Music.play();
}
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Vollkorn/Vollkorn-Regular.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 24;
font12 = generator.generateFont(parameter); // font size 12 pixels
generator.dispose(); // don't forget to dispose to avoid memory leaks!
FileHandle baseFileHandle = Gdx.files.internal("Messages/menus");
String localeLanguage =java.util.Locale.getDefault().toString();
Locale locale = new Locale(localeLanguage);
I18NBundle myBundle = I18NBundle.createBundle(baseFileHandle, locale,"UTF-8");
menulevel = myBundle.get("menulevel");
menuvictory = myBundle.get("menuvictory");
menuchampion = myBundle.get("menuchampion");
menucontinue = myBundle.get("menucontinue");
menugameover = myBundle.get("menugameover");
}
示例10: create
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
/**
* Initialisierung
*
* Wird automatisch aufgerufen.
* Erfasst auch gleich die Liste aller Level.
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet.
*/
@Override
public void create(SchoolGame game) {
this.game = game;
if (lastSlot == null)
{
game.setGameState(new MainMenu());
return;
}
saveData = new SaveData(game, lastSlot);
batch = new SpriteBatch();
font = game.getDefaultFont();
smallFont = game.getLongTextFont();
fontLayout = new GlyphLayout();
FileHandle baseFileHandle = Gdx.files.internal("data/I18n/Cheats");
localeBundle = I18NBundle.createBundle(baseFileHandle);
Set<String> levelIdSet = levelMap.keySet();
levelIds = levelIdSet.toArray(new String[levelIdSet.size()]);
Arrays.sort(levelIds);
cols = (levelIds.length - (levelIds.length % MAX_ROWS)) / MAX_ROWS;
if (levelIds.length % MAX_ROWS > 0)
cols++;
}
示例11: getOrLoad
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
@Override
public I18NBundle getOrLoad(final String id) {
if (bundles.containsKey(id)) {
return bundles.get(id);
}
final String path = determinePath(id);
final I18NBundle bundle = I18NBundle.createBundle(Gdx.files.internal(path), localePreference.getLocale(),
encoding);
bundles.put(id, bundle);
final EagerI18NBundleParameter parameters = new EagerI18NBundleParameter(bundle);
getAssetManager().load(path, I18NBundle.class, parameters);
return bundle;
}
示例12: loadAsync
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
@Override
public void loadAsync(final AssetManager manager, final String fileName, final FileHandle file,
final I18NBundleLoader.I18NBundleParameter parameter) {
I18NBundle bundle;
if (parameter instanceof EagerI18NBundleParameter && ((EagerI18NBundleParameter) parameter).bundle != null) {
return;
} else if (parameter.encoding == null) {
bundle = I18NBundle.createBundle(file, parameter.locale);
} else {
bundle = I18NBundle.createBundle(file, parameter.locale, parameter.encoding);
}
synchronized (bundles) {
bundles.put(fileName, bundle);
}
}
示例13: create
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
public void create () {
WIDTH = Gdx.graphics.getWidth();
HEIGHT = Gdx.graphics.getHeight();
scaleWidth = (float) WIDTH / SCALE;
PIXELS_TO_METERS = 100f * scaleWidth;
generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/editundo.ttf"));
parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = WIDTH / 18;
text = generator.generateFont(parameter);
parameter.size = WIDTH / 6;
title = generator.generateFont(parameter);
generator.dispose();
FileHandle fileHandle = Gdx.files.internal("translations/TranslationBundle");
bundle = I18NBundle.createBundle(fileHandle, Locale.getDefault());
start = new StartScreen(this);
game = new GameScreen(this);
end = new EndScreen(this);
SCORE = 0;
MAXSCORE = 0;
pathScore = "Meteoric/score.txt";
FileHandle file = Gdx.files.local(pathScore);
if (!file.exists()){
file = Gdx.files.local(pathScore);
file.writeString("0", false);
}else{
try{
MAXSCORE = Integer.valueOf(file.readString());
}catch (Exception e){
MAXSCORE = 0;
}
}
startScreen();
}
示例14: testLoadI18N
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
public static void testLoadI18N () {
switch (Locale.getDefault().toString()) {
case "es":
mainBundle = I18NBundle.createBundle(Gdx.files.internal("i18n/MainBundle_es"), new Locale("es"));
break;
default:
mainBundle = I18NBundle.createBundle(Gdx.files.internal("i18n/MainBundle"), new Locale("en"));
break;
}
}
示例15: create
import com.badlogic.gdx.utils.I18NBundle; //导入方法依赖的package包/类
@Override
public void create () {
font = new BitmapFont();
batch = new SpriteBatch();
try {
FileHandle bfh = Gdx.files.internal("data/i18n/message1");
rb_root = I18NBundle.createBundle(bfh, Locale.ROOT);
rb_default = I18NBundle.createBundle(bfh);
rb_en = I18NBundle.createBundle(bfh, new Locale("en", "US"));
rb_it = I18NBundle.createBundle(bfh, new Locale("it", "IT"));
rb_unsupported = I18NBundle.createBundle(bfh, new Locale("unsupported"));
println("Default locale: " + Locale.getDefault());
println("\n\n---- Parent chain test ----");
println(getMessage("root", rb_root));
println(getMessage("default", rb_default));
println(getMessage("en", rb_en));
println(getMessage("it", rb_it));
println(getMessage("unsupported", rb_unsupported));
println("\n\n---- Parametric message test ----");
println(getParametricMessage("root", rb_root));
println(getParametricMessage("default", rb_default));
println(getParametricMessage("en", rb_en));
println(getParametricMessage("it", rb_it));
println(getParametricMessage("unsupported", rb_unsupported));
Gdx.app.log("", message);
} catch (Throwable t) {
message = "FAILED: " + t.getMessage() + "\n";
message += t.getClass();
Gdx.app.error(I18NMessageTest.class.getSimpleName(), "Error", t);
}
}