Java 类com.badlogic.gdx.utils.I18NBundle 实例源码
项目:school-game
文件:NewGameMenu.java
public void render(OrthographicCamera camera, SpriteBatch batch, int y, MenuEntry activeEntry, SchoolGame game, I18NBundle localeBundle, float deltaTime) {
Color entryColor = getColor();
if (this == activeEntry)
{
entryColor = getActiveColor();
if (used == 1)
{
entryColor = getDisabledColor();
}
}
if (font == null)
font = game.getDefaultFont();
if (fontSmall == null)
fontSmall = game.getLongTextFont();
fontLayout.setText(font, localeBundle.format(getLabel(), id, used, playerName, gender), entryColor, camera.viewportWidth, Align.center, false);
font.draw(batch, fontLayout, -camera.viewportWidth / 2, y);
fontLayout.setText(fontSmall, localeBundle.format(detail, used, levelName, playTime), entryColor, camera.viewportWidth, Align.center, false);
fontSmall.draw(batch, fontLayout, -camera.viewportWidth / 2, y - 50);
}
项目:school-game
文件:MenuState.java
/**
* 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...");
}
项目:school-game
文件:CreateGameSlot.java
/**
* 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);
}
项目:school-game
文件:LoadGameMenu.java
public void render(OrthographicCamera camera, SpriteBatch batch, int y, MenuEntry activeEntry, SchoolGame game, I18NBundle localeBundle, float deltaTime) {
Color entryColor = getColor();
if (this == activeEntry)
{
entryColor = getActiveColor();
}
if (!isEnabled())
{
entryColor = getDisabledColor();
}
if (font == null)
font = game.getDefaultFont();
if (fontSmall == null)
fontSmall = game.getLongTextFont();
fontLayout.setText(font, localeBundle.format(getLabel(), id, used, playerName, gender), entryColor, camera.viewportWidth, Align.center, false);
font.draw(batch, fontLayout, -camera.viewportWidth / 2, y);
fontLayout.setText(fontSmall, localeBundle.format(detail, used, levelName, playTime), entryColor, camera.viewportWidth, Align.center, false);
fontSmall.draw(batch, fontLayout, -camera.viewportWidth / 2, y - 50);
}
项目:Hexpert
文件:Objective.java
public String toString(I18NBundle bundle) {
String s = "";
if(minScore != Integer.MIN_VALUE)
{
s+= bundle.format("objective_score", minScore);
}
for(int i = 0; i < Const.BUILDING_COUNT; i++)
{
if(buildingRequirement[i] > 0)
{
if(!s.equals(""))
s+="\n";
s+= bundle.format("objective_building",
buildingRequirement[i],
bundle.format(BuildingType.values()[i + 1].name().toLowerCase() + "_choice", buildingRequirement[i]));
}
}
return s;
}
项目:Hexpert
文件:ActionDialog.java
public ActionDialog(Label text, Action action, I18NBundle bundle, Skin skin, Hexpert hexpert) {
super(hexpert, skin);
this.action = action;
getBackground().setMinWidth(1000);
getBackground().setMinHeight(400);
text.setWrap(true);
text.setAlignment(Align.center);
getContentTable().add(text).width(getBackground().getMinWidth()).expandX();
getButtonTable().defaults().width(200).height(120).pad(15);
TextButton textButtonYes = new TextButton(bundle.get("yes"), skin);
getButtonTable().add(textButtonYes);
setObject(textButtonYes, 1);
TextButton textButtonNo = new TextButton(bundle.get("no"), skin);
getButtonTable().add(textButtonNo);
setObject(textButtonNo, null);
}
项目:Hexpert
文件:TutorialDialog.java
public TutorialDialog(Hexpert hexpert, Skin skin, boolean useScrollPane) {
super(hexpert, skin);
scrollContent = new Table();
if(useScrollPane) {
scrollPane = new ScrollPane(scrollContent, skin);
getContentTable().add(scrollPane);
}
getButtonTable().defaults().pad(15);
I18NBundle i18N = hexpert.i18NBundle;
TextButton textButtonOk = new TextButton(i18N.get("ok"), skin);
getButtonTable().add(textButtonOk);
setObject(textButtonOk, null);
}
项目:gdxjam-ugg
文件:LoaderUtils.java
public void init() {
/*************** ASSET MANAGER ********************/
assetManager.load("data/gui.json", Skin.class, new SkinLoader.SkinParameter(guiAtlas));
assetManager.load(gameAtlas, TextureAtlas.class);
assetManager.load("data/mental-space", I18NBundle.class, new I18NBundleLoader.I18NBundleParameter(java.util.Locale.getDefault()));
/**************** Load Sounds and music *******************/
SoundManager.getInstance().loadBasicSounds();
MusicManager.getInstance().init(this);
MusicManager.getInstance().loadBasics();
/**************** Finish ******************/
this.finishLoading();
this.loadParticles();
}
项目:cgc-game
文件:ChaseApp.java
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");
}
项目:GDefence
文件:LoadingStage.java
public LoadingStage() {
GDefence.getInstance().assetLoader.load("MainMenuBg.png", Texture.class);//TODO
GDefence.getInstance().assetLoader.load("mobHpBarBg.png", Texture.class);
GDefence.getInstance().assetLoader.load("mobHpBarKnob.png", Texture.class);
// I18NBundleLoader.I18NBundleParameter param = new I18NBundleLoader.I18NBundleParameter(/*new Locale("ru")*/Locale.US, "UTF-8");//TODO move to another place
// GDefence.getInstance().assetLoader.load("Language/text", I18NBundle.class, param);
// GDefence.getInstance().assetLoader.finishLoading();
GDefence.getInstance().assetLoader.initLang("en");
Image bg = new Image(GDefence.getInstance().assetLoader.get("MainMenuBg.png", Texture.class));
addActor(bg);
loadBar = new ProgressBar(0, 100, 1, false, GDefence.getInstance().assetLoader.getMobHpBarStyle());
loadBar.setSize(300, 50);
loadBar.getStyle().background.setMinHeight(loadBar.getHeight());
loadBar.getStyle().knob.setMinHeight(loadBar.getHeight());
loadBar.setPosition(Gdx.graphics.getWidth()/2 - loadBar.getWidth()/2, Gdx.graphics.getHeight()/2 - loadBar.getHeight()/2);
addActor(loadBar);
I18NBundle b = GDefence.getInstance().assetLoader.get("Language/text", I18NBundle.class);
Label loading = new Label(b.get("loading"), FontLoader.generateStyle(34, Color.BLACK));//
loading.setPosition(loadBar.getX() + loadBar.getWidth()/2 - loading.getWidth()/2,
loadBar.getY() - loadBar.getHeight());
addActor(loading);
}
项目:Protoman-vs-Megaman
文件:GameUtils.java
/**
* 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;
}
项目:gdx-lml
文件:I18NBundleProvider.java
@Override
public I18NBundle provide(final Object target, final Member member) {
if (member == null) {
throwUnknownPathException();
}
final String id = member.getName();
if (id.isEmpty()) {
throwUnknownPathException();
}
final I18NBundle asset = getOrLoad(id);
if (member instanceof FieldMember) {
final BundleInjection injection = new BundleInjection(determinePath(id), ((FieldMember) member).getField(),
target);
if (target instanceof Loaded) {
((Loaded) target).onLoad(determinePath(id), I18NBundle.class, asset);
}
bundlesData.get(id).add(injection);
}
return asset;
}
项目:gdx-lml
文件:I18NBundleProvider.java
/** @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);
}
}
}
项目:libgdxcn
文件:I18NBundleLoader.java
@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);
}
}
项目:libgdxcn
文件:AssetManager.java
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
setLoader(Music.class, new MusicLoader(resolver));
setLoader(Pixmap.class, new PixmapLoader(resolver));
setLoader(Sound.class, new SoundLoader(resolver));
setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
setLoader(Texture.class, new TextureLoader(resolver));
setLoader(Skin.class, new SkinLoader(resolver));
setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
setLoader(Model.class, ".obj", new ObjLoader(resolver));
executor = new AsyncExecutor(1);
}
项目:libgdxcn
文件:AssetManagerTest.java
private void load () {
// Gdx.app.setLogLevel(Logger.DEBUG);
start = TimeUtils.nanoTime();
tex1 = new Texture("data/animation.png");
tex2 = new TextureAtlas(Gdx.files.internal("data/pack"));
font2 = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
// tex3 = new Texture("data/test.etc1");
// map = TiledLoader.createMap(Gdx.files.internal("data/tiledmap/tilemap csv.tmx"));
// atlas = new TileAtlas(map, Gdx.files.internal("data/tiledmap/"));
// renderer = new TileMapRenderer(map, atlas, 8, 8);
System.out.println("plain took: " + (TimeUtils.nanoTime() - start) / 1000000000.0f);
start = TimeUtils.nanoTime();
manager.load("data/animation.png", Texture.class);
// manager.load("data/pack1.png", Texture.class);
manager.load("data/pack", TextureAtlas.class);
// manager.load("data/verdana39.png", Texture.class);
manager.load("data/verdana39.fnt", BitmapFont.class);
// manager.load("data/multipagefont.fnt", BitmapFont.class);
// manager.load("data/test.etc1", Texture.class);
// manager.load("data/tiledmap/tilemap csv.tmx", TileMapRenderer.class, new
// TileMapRendererLoader.TileMapParameter("data/tiledmap/", 8, 8));
manager.load("data/i18n/message2", I18NBundle.class, new I18NBundleLoader.I18NBundleParameter(reloads % 2 == 0 ? Locale.ITALIAN : Locale.ENGLISH));
}
项目:gaiasky
文件:I18n.java
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;
}
}
项目:SpaceRun
文件:SplashScreen.java
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");
}
项目:Stray-core
文件:Translator.java
private void loadResources() {
base = Gdx.files.internal("localization/default");
languageList.clear();
languageList.ordered = true;
addBundle(defaultLang, I18NBundle.createBundle(base, new Locale("")));
// addBundle("Česky", I18NBundle.createBundle(base, new Locale("cz")));
Preferences settings = Settings.getPreferences();
for (int i = 0; i < languageList.size; i++) {
String lang = languageList.get(i);
if (lang.equalsIgnoreCase(settings.getString("language", defaultLang))) {
toUse = i;
}
}
}
项目:Caramelos
文件:StatusScreen.java
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");
}
项目:school-game
文件:MenuState.java
public void render(OrthographicCamera camera, SpriteBatch batch, int y, MenuEntry activeEntry, SchoolGame game, I18NBundle localeBundle, float deltaTime) {
if (font == null)
font = game.getDefaultFont();
fontLayout.setText(font, localeBundle.get(getLabel()), getColor(), camera.viewportWidth, Align.center, false);
font.draw(batch, fontLayout, -camera.viewportWidth / 2, y);
}
项目:school-game
文件:MenuState.java
public void render(OrthographicCamera camera, SpriteBatch batch, int y, MenuEntry activeEntry, SchoolGame game, I18NBundle localeBundle, float deltaTime) {
if (font == null)
font = game.getTitleFont();
fontLayout.setText(font, localeBundle.get(getLabel()), getColor(), camera.viewportWidth, Align.center, false);
font.draw(batch, fontLayout, -camera.viewportWidth / 2, y);
}
项目:school-game
文件:CheatLevelSelection.java
/**
* 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++;
}
项目:Hexpert
文件:FreeridingDialog.java
public FreeridingDialog(final Hexpert hexpert, Skin skin)
{
super(hexpert, skin.get("gold", WindowStyle.class));
getBackground().setMinWidth(1400);
I18NBundle i18N = hexpert.i18NBundle;
Label lblRate = new Label(i18N.get("freerider"), skin.get("bigger", Label.LabelStyle.class));
lblRate.setAlignment(Align.center);
lblRate.setWrap(true);
getContentTable().add(lblRate).width(1200);
TextButton.TextButtonStyle goldenStyle = skin.get("gold", TextButton.TextButtonStyle.class);
TextButton textButtonRate = new TextButton(i18N.get("rate"), goldenStyle);
getButtonTable().add(textButtonRate).width(textButtonRate.getLabelCell().getPrefWidth() + 30);
TextButton textButtonNo = new TextButton(i18N.get("no"), goldenStyle);
getButtonTable().add(textButtonNo);
setObject(textButtonNo, null);
textButtonRate.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
hexpert.playServices.rateGame();
hide();
}
});
setObject(textButtonRate, null);
}
项目:Hexpert
文件:LockedTutDialog.java
public LockedTutDialog(Hexpert hexpert, Skin skin) {
super(hexpert, skin, false);
I18NBundle i18n = hexpert.i18NBundle;
Label lblContent = new Label(i18n.get("lck_diag"), skin);
lblContent.setAlignment(Align.center);
lblContent.setWrap(true);
getContentTable().defaults().pad(25);
getContentTable().add(lblContent).width(800);
}
项目:jewelthief
文件:JewelThief.java
private void loadAssets() {
assetManager.load("audio/sounds/mouse_click.ogg", Sound.class);
assetManager.load("audio/sounds/finger_cymbal_hit.ogg", Sound.class);
assetManager.load("i18n/" + preferences.getString("language"), I18NBundle.class);
assetManager.finishLoading();
soundClick = assetManager.get("audio/sounds/mouse_click.ogg");
soundCymbal = assetManager.get("audio/sounds/finger_cymbal_hit.ogg");
bundle = assetManager.get("i18n/" + preferences.getString("language"), I18NBundle.class);
}
项目:jewelthief
文件:JewelThief.java
/**
* Globally sets the locale of the application.
*
* @param localeId The locale id to set (en, de, es, fr, ...)
* @return The bundle associated with the given locale id
*/
public I18NBundle setLocale(String localeId) {
preferences.putString("language", localeId).flush();
if (!assetManager.isLoaded("i18n/" + localeId)) {
assetManager.load("i18n/" + localeId, I18NBundle.class);
assetManager.finishLoading();
}
bundle = assetManager.get("i18n/" + localeId, I18NBundle.class);
return bundle;
}
项目:gdxjam-ugg
文件:LoaderUtils.java
public LoaderUtils() {
resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), resolutions);
assetManager = new AssetManager(resolver);
assetManager.setErrorListener(this);
Texture.setAssetManager(assetManager);
assetManager.setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
GUIConfig.initializeValues(resolutions);
this.atlas = null;
this.regions = new ObjectMap<String, AtlasRegion>();
}
项目:GDefence
文件:AbstractCampainScreen.java
public AbstractCampainScreen(String name) {
super();
setBackground(GDefence.getInstance().assetLoader.get("CampainBg.png", Texture.class));
I18NBundle b = GDefence.getInstance().assetLoader.get("Language/text", I18NBundle.class);
this.name = b.get(name);
batch = new SpriteBatch();
//stage = new Stage();
//shape = new ShapeRenderer();
// Gdx.input.setInputProcessor(stage);
define();
}
项目:GDefence
文件:AssetLoader.java
public void changeLang(String locale){
unload("Language/text");
I18NBundleLoader.I18NBundleParameter param = new I18NBundleLoader.I18NBundleParameter(new Locale(locale), "UTF-8");
load("Language/text", I18NBundle.class, param);
finishLoading();
b = get("Language/text", I18NBundle.class);
GDefence.getInstance().initTips();
GDefence.getInstance().initScreens();
GDefence.getInstance().switchScreen(GDefence.getInstance().getOptionScreen());
}
项目:GDefence
文件:LevelTooltip.java
private void init(){
I18NBundle b = GDefence.getInstance().assetLoader.get("Language/text", I18NBundle.class);
getTitleLabel().setText(b.get("level") + " " + levelButton.getNumber());
getTitleLabel().setAlignment(Align.center);
clear();
MapLoader ml = new MapLoader(levelButton.getNumber());
ml.loadMap();
ml.loadProperties(ml.getSpawnersNumber(), false);
User u = GDefence.getInstance().user;
waves = b.get("waves") + ": " + ml.getNumberWaves();
exp = b.get("exp") + " : ";// + ml.getExpFromLvl();
expValue = u.getLevelCompleted(levelButton.getNumber()) ? ml.getExpFromLvl()/4: ml.getExpFromLvl();
gold = b.get("gold") + ": ";// + ml.getGoldFromLvl();
goldValue = u.getLevelCompleted(levelButton.getNumber()) ? ml.getGoldFromLvl()/4: ml.getGoldFromLvl();
hp = b.get("sHealth") + ": " + (int)(ml.getStartHpPercent() * 100) + "%";
en = b.get("sEnergy") + ": " + (int)(ml.getStartEnergyPercent() * 100) + "%";
// drop1 = "";
// drop2 = "";
drop1 = getDropTooltip(ml.getDropList());
drop2 = getDropTooltip(ml.getPenaltyDropList());
// drop += GDefence.getInstance().user.getLevelCompleted(levelButton.getNumber()) ? getDropTooltip(ml.getPenaltyDropList()) : getDropTooltip(ml.getDropList());
// String drop = GDefence.getInstance().user.getLevelCompleted(levelButton.getNumber()) ? drop2 : drop1;
label = new Label(""/*waves + System.getProperty("line.separator") +
exp + System.getProperty("line.separator") +
gold + System.getProperty("line.separator") +
hp + System.getProperty("line.separator") +
en +
drop*/, skin, "description");
hasChanged();
add(label);
// pack();
}
项目:gdx-texture-packer-gui
文件:ConfigurationController.java
@Initiate(priority = HIGH_PRIORITY)
public void initVisUiI18n(InterfaceService interfaceService, final LocaleService localeService) {
Locales.setLocale(localeService.getCurrentLocale());
interfaceService.setActionOnBundlesReload(new Runnable() {
@Override
public void run() {
Locale locale = localeService.getCurrentLocale();
Locales.setButtonBarBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/buttonbar"), locale));
Locales.setColorPickerBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/colorpicker"), locale));
Locales.setDialogsBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/dialogs"), locale));
Locales.setFileChooserBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/filechooser"), locale));
Locales.setTabbedPaneBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/tabbedpane"), locale));
}
});
}
项目:gdx-autumn-mvc
文件:InterfaceService.java
private void validateLocale() {
final Locale currentLocale = localeService.getCurrentLocale();
if (!currentLocale.equals(lastLocale)) {
saveLastLocale(currentLocale);
for (final Entry<String, FileHandle> bundleData : i18nBundleFiles) {
parser.getData().addI18nBundle(bundleData.key,
I18NBundle.createBundle(bundleData.value, currentLocale));
}
executeActionOnBundlesReload();
}
}
项目:gdx-lml
文件:Core.java
@Override
protected LmlParser createParser() {
return VisLml.parser()
// Registering global actions, available in all views:
.actions("global", new GlobalActions())
// Adding i18n bundle - all LML strings proceeded with @ will be taken from this bundle:
.i18nBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/nls")))
// Creating a new parser instance:
.build();
}
项目:gdx-lml
文件:Core.java
@Override
protected LmlParser createParser() {
return VisLml.parser()
// Registering global action container:
.actions("global", Global.class)
// Adding localization support:
.i18nBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/bundle"))).build();
}
项目:gdx-lml
文件:Global.java
@LmlAction("setLocale")
public void setLocale(final Actor actor) {
final String localeId = LmlUtilities.getActorId(actor);
final I18NBundle currentBundle = core.getParser().getData().getDefaultI18nBundle();
if (currentBundle.getLocale().getLanguage().equalsIgnoreCase(localeId)) {
// Same language.
return;
}
core.getParser().getData()
.setDefaultI18nBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/bundle"), new Locale(localeId)));
core.reloadViews();
}
项目:gdx-lml
文件:AbstractLmlParser.java
/** @param rawLmlData unparsed LML data that might or might not start with bundle line key (which will be stripped).
* @param actor might be required to parse some of the bundle line arguments.
* @return formatted bundle line. */
protected String parseBundleLine(final String rawLmlData, final Object actor) {
String bundleKey = LmlUtilities.stripMarker(rawLmlData, syntax.getBundleLineMarker());
final I18NBundle bundle;
if (Strings.contains(rawLmlData, syntax.getIdSeparatorMarker())) {
// Bundle name is given, as bundle key contains separator. Extracting specific bundle.
final int separatorIndex = bundleKey.indexOf(syntax.getIdSeparatorMarker());
final String bundleName = bundleKey.substring(0, separatorIndex);
bundle = data.getI18nBundle(bundleName);
bundleKey = bundleKey.substring(separatorIndex + 1, bundleKey.length());
} else {
// No specific bundle name. Using default bundle.
bundle = data.getDefaultI18nBundle();
}
if (bundle == null) {
throwError("I18N bundle not found for bundle line: " + rawLmlData);
}
try {
if (Strings.contains(rawLmlData, syntax.getBundleLineArgumentMarker())) {
return parseBundleLineWithArguments(bundle, bundleKey, actor);
}
return Nullables.toString(bundle.get(bundleKey));
} catch (final Exception exception) {
throwErrorIfStrict("Unable to find bundle line for data: " + rawLmlData, exception);
return Nullables.DEFAULT_NULL_STRING;
}
}
项目:gdx-lml
文件:AbstractLmlParser.java
/** @param bundle should contain the passed key.
* @param bundleKey contains at least one bundle argument marker and should be properly separated and parsed. Cannot
* begin with bundle key marker.
* @param actor might be required to parse some of the bundle arguments.
* @return formatted bundle line with arguments. */
protected String parseBundleLineWithArguments(final I18NBundle bundle, final String bundleKey, final Object actor) {
final String[] keyAndArguments = Strings.split(bundleKey, syntax.getBundleLineArgumentMarker());
final String key = keyAndArguments[0];
final String[] arguments = new String[keyAndArguments.length - 1];
for (int index = 1, length = keyAndArguments.length; index < length; index++) {
arguments[index - 1] = parseString(keyAndArguments[index], actor);
}
return Nullables.toString(bundle.format(key, (Object[]) arguments));
}
项目:gdx-lml
文件:InterfaceService.java
private void validateLocale() {
final Locale currentLocale = localeService.getCurrentLocale();
if (!currentLocale.equals(lastLocale)) {
saveLastLocale(currentLocale);
for (final Entry<String, FileHandle> bundleData : i18nBundleFiles) {
parser.getData().addI18nBundle(bundleData.key,
I18NBundle.createBundle(bundleData.value, currentLocale));
}
executeActionOnBundlesReload();
}
}
项目:gdx-lml
文件:InjectingAssetManager.java
/** Creates a new {@link InjectingAssetManager} using the {@link InternalFileHandleResolver}. */
public InjectingAssetManager() {
super(new InternalFileHandleResolver(), true); // Using default loaders.
final FileHandleResolver resolver = getFileHandleResolver();
setLoader(I18NBundle.class, new EagerI18NBundleLoader(resolver));
setLoader(Skin.class, new EagerSkinLoader(resolver));
setLoader(TextureAtlas.class, new EagerTextureAtlasLoader(resolver));
}