List of usage examples for com.badlogic.gdx Preferences getBoolean
public boolean getBoolean(String key);
From source file:at.juggle.games.memory.AssetManager.java
License:Apache License
public AssetManager(GameOptions options) { this.options = options; Preferences preferences = Gdx.app.getPreferences("memory_free_hd.prefs"); if (preferences.contains("soundOn")) { options.soundOn = preferences.getBoolean("soundOn"); }/*from w ww. j ava 2s . c o m*/ font = new BitmapFont(getFileHandle("berlin_64.fnt"), false); smallFont = new BitmapFont(getFileHandle("berlin_42.fnt"), false); card = new Texture(getFileHandle("card-front.png")); cardBack = new Texture(getFileHandle("card-back.png")); cardBackMark = new Texture(getFileHandle("card-back-mark.png")); check = new Texture(getFileHandle("Check_32x32.png")); positive = new Texture(getFileHandle("Positive_256x256.png")); grey = new Texture(getFileHandle("grey.png")); background = new Texture(getFileHandle("background.jpg")); gradientTop = new Texture(getFileHandle("gradient_oben.png")); gradientBottom = new Texture(getFileHandle("gradient_unten.png")); if (GameOptions.isFreeVersion) { logo = new Texture(getFileHandle("Logo.png")); } else { logo = new Texture(getFileHandle("Logo_donated.png")); } cardBack.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); cardBackMark.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); logo.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); Texture vehiclesTexture = new Texture(getFileHandle("vehicles.png")); vehiclesTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); TextureRegion[][] veh = TextureRegion.split(vehiclesTexture, 256, 256); icons = new TextureRegion[24]; icons[0] = new TextureRegion(loadTexture("animals/Butterfly_128x128.png")); icons[1] = new TextureRegion(loadTexture("animals/Dolphin_128x128.png")); icons[2] = new TextureRegion(loadTexture("animals/Elephant_128x128.png")); icons[3] = new TextureRegion(loadTexture("animals/Hippopotamus_128x128.png")); icons[4] = new TextureRegion(loadTexture("animals/Panda_128x128.png")); icons[5] = new TextureRegion(loadTexture("animals/Turtle_128x128.png")); icons[6] = new TextureRegion(loadTexture("vacation/surfboard_256x256.png")); icons[7] = new TextureRegion(loadTexture("vacation/umbrella_256x256.png")); int count = 0; for (int i = 0; i < veh.length; i++) { TextureRegion[] textureRegions = veh[i]; for (int j = 0; j < textureRegions.length; j++) { icons[8 + count] = textureRegions[j]; count++; } } // Particle effects fireworks = new ParticleEffect(); fireworks.load(getFileHandle("fireworks"), getFileHandle("")); // sounds sndFlipCard = Gdx.audio.newSound(getFileHandle("flipcard.ogg")); sndCheer = Gdx.audio.newSound(getFileHandle("drums.ogg")); sndDing = Gdx.audio.newSound(getFileHandle("ding.ogg")); }
From source file:at.therefactory.jewelthief.input.MenuScreenInputAdapter.java
License:Open Source License
@Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { super.touchUp(screenX, screenY, pointer, button); Preferences prefs = JewelThief.getInstance().getPreferences(); numTouches = Math.max(0, numTouches - 1); if (menuScreen.buttonExitToMainMenu.isPressed()) { menuScreen.buttonExitToMainMenu.release(); menuScreen.setShowLicenseYOffset(0); menuScreen.setState(MenuScreen.MenuState.ShowMenu); } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowAbout)) { if (menuScreen.buttonShowLicense.isPressed()) { menuScreen.buttonShowLicense.release(); if (menuScreen.getShowLicenseYOffset() == 0) { menuScreen.setShowLicenseYOffset(54); } else { menuScreen.setShowLicenseYOffset(0); }//from w w w .java 2s. c o m } else if (menuScreen.buttonSoundtrack.isPressed()) { menuScreen.buttonSoundtrack.release(); Gdx.net.openURI(URL_TO_SOUNDTRACK); } else if (menuScreen.buttonRate.isPressed()) { menuScreen.buttonRate.release(); Gdx.net.openURI(URL_TO_PLAY_STORE); } } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowHighscores)) { if (menuScreen.buttonUpdateHighscores.isPressed()) { menuScreen.buttonUpdateHighscores.release(); menuScreen.setFetchingHighscores(true); HttpServer.fetchHighscores(menuScreen, prefs.getString(PrefsKeys.ID), prefs.getString(PrefsKeys.PLAYER_NAME), prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_JEWELS), prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_SECONDS)); } } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowSettings)) { if (menuScreen.buttonChangePlayername.isPressed()) { menuScreen.buttonChangePlayername.release(); Gdx.input.getTextInput(listener, bundle.get(PLEASE_ENTER_YOUR_NAME), prefs.getString(PrefsKeys.PLAYER_NAME), ""); } else if (menuScreen.buttonToggleSound.isPressed()) { menuScreen.buttonToggleSound.release(); menuScreen.buttonToggleSound.nextState(); prefs.putBoolean(PrefsKeys.ENABLE_SOUND, !prefs.getBoolean(PrefsKeys.ENABLE_SOUND)); prefs.flush(); } else if (menuScreen.buttonToggleMusic.isPressed()) { menuScreen.buttonToggleMusic.release(); menuScreen.buttonToggleMusic.nextState(); prefs.putBoolean(PrefsKeys.ENABLE_MUSIC, !prefs.getBoolean(PrefsKeys.ENABLE_MUSIC)); prefs.flush(); if (prefs.getBoolean(PrefsKeys.ENABLE_MUSIC)) { JewelThief.getInstance().playMusicFile(true); } else { JewelThief.getInstance().pauseMusic(); } } else if (menuScreen.buttonChangeLanguage.isPressed()) { menuScreen.buttonChangeLanguage.release(); menuScreen.buttonChangeLanguage.nextState(); bundle = JewelThief.getInstance() .setLocale(menuScreen.buttonChangeLanguage.getState() == 0 ? "en" : "de"); menuScreen.setBundle(bundle); } else if (menuScreen.buttonResetHighscore.isPressed()) { menuScreen.buttonResetHighscore.release(); if (timestampLastClickOnResetHighscoreSettingButton > System.currentTimeMillis() - 1000) { timestampLastClickOnResetHighscoreSettingButton = 0; prefs.remove(PrefsKeys.MY_RANK); prefs.remove(PrefsKeys.BEST_SCORE); prefs.remove(PrefsKeys.BEST_SCORE_NUM_JEWELS); prefs.remove(PrefsKeys.BEST_SCORE_NUM_SECONDS); JewelThief.getInstance().toast(bundle.get(HIGHSCORE_IS_RESET), true); } else { timestampLastClickOnResetHighscoreSettingButton = System.currentTimeMillis(); JewelThief.getInstance().toast(bundle.get(TAP_AGAIN_TO_RESET_HIGHSCORE), false); } } } // main menu else { if (menuScreen.buttonStartSinglePlayerGame.isPressed()) { JewelThief.getInstance().showIntroScreen(); menuScreen.buttonStartSinglePlayerGame.release(); } else if (menuScreen.buttonShowHighscores.isPressed()) { deltaY = 0; menuScreen.setScrollbarPositionY(Config.INITIAL_SCROLLBAR_POSITION_Y); if (prefs.contains(PrefsKeys.CACHED_HIGHSCORES)) { menuScreen.setHighscores(prefs.getString(PrefsKeys.CACHED_HIGHSCORES).split("\n")); } menuScreen.setState(MenuScreen.MenuState.ShowHighscores); menuScreen.buttonShowHighscores.release(); } else if (menuScreen.buttonShowSettings.isPressed()) { menuScreen.setState(MenuScreen.MenuState.ShowSettings); menuScreen.buttonShowSettings.release(); } else if (menuScreen.buttonShowAbout.isPressed()) { menuScreen.setState(MenuScreen.MenuState.ShowAbout); menuScreen.buttonShowAbout.release(); } } lastDeltaY = -deltaY; touchDragging = false; return true; }
From source file:com.vlaaad.dice.util.DicePreferences.java
License:Open Source License
public DicePreferences(Preferences preferences, App app) { this.preferences = preferences; this.app = app; volume = preferences.getFloat("volume", 0.5f); language = preferences.getString("language", Locale.getDefault().getLanguage()); scale = preferences.getInteger("scale", (int) ScreenHelper.scaleFor(Gdx.graphics.getWidth(), Gdx.app.getType() == Application.ApplicationType.Desktop)); rated = preferences.getBoolean("rated"); music = preferences.getBoolean("music", true); servicesPaneShownByDefault = preferences.getBoolean("services-pane", false); applyVolume();/*from w w w . j ava 2 s. com*/ applyMusic(); }
From source file:de.r2soft.empires.client.maps.hex.R2HexMapRenderer.java
License:Apache License
public void checkDebugRendering() { Preferences prefs = Gdx.app.getPreferences(Values.PREFERENCE_FILE_NAME); useDebugRendering = prefs.getBoolean(Values.PREFERENCE_USE_HEXAGON_DEBUGGING); }
From source file:io.github.deathsbreedgames.spacerun.screens.SplashScreen.java
public SplashScreen(AssetManager manager) { super("MainMenu", manager); // Splash/* w ww .ja va 2 s.c o m*/ 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"); }
From source file:net.bplaced.therefactory.voraciousviper.screens.TitleScreen.java
License:Open Source License
private void synchronizeCheckedStatesOfSettingsButtons() { Preferences prefs = SettingsManager.getInstance().get(); buttonsSettings[0][0].setChecked(prefs.getString(PrefsKeys.Language).equals(Locale.ENGLISH.toString())); buttonsSettings[0][1].setChecked(prefs.getString(PrefsKeys.Language).equals(Locale.GERMAN.toString())); buttonsSettings[1][0].setChecked(prefs.getBoolean(PrefsKeys.Music)); ((RetroImageToggleButton) buttonsSettings[1][0]).setToggled(prefs.getBoolean(PrefsKeys.Music)); buttonsSettings[1][1].setChecked(prefs.getBoolean(PrefsKeys.Sound)); ((RetroImageToggleButton) buttonsSettings[1][1]).setToggled(prefs.getBoolean(PrefsKeys.Sound)); buttonsSettings[3][0].setChecked(prefs.getString(PrefsKeys.Controls).equals(PrefsKeys.ControlsTouchAreas)); buttonsSettings[3][1].setChecked(prefs.getString(PrefsKeys.Controls).equals(PrefsKeys.ControlsTouchPad)); buttonsSettings[3][2].setChecked(prefs.getString(PrefsKeys.Controls).equals(PrefsKeys.ControlsRelative)); for (RetroTextButton button : buttonsMainMenu) { button.autoSize();//from ww w . j a v a 2 s . co m } ((RetroTextButton) buttonsSettings[2][0]).autoSize(); updatePlayernameText(); }
From source file:releasethekraken.screen.SettingsScreen.java
/** * Constructs a new PauseScreen/*from ww w .ja v a 2 s.c om*/ * @param rtk The ReleaseTheKraken instance. This is final so that the * anonymous inner classes can access it. */ public SettingsScreen(final ReleaseTheKraken rtk) { super(rtk); final Preferences settings = Gdx.app.getPreferences("ReleaseTheKraken_Settings.xml"); boolean fullscreen = settings.getBoolean("fullscreen"); this.renderer = new UiRenderer(); float scrWidth = Gdx.graphics.getWidth(); float scrHeight = Gdx.graphics.getHeight(); float textWidth = 0.2F; float textHeight = 0.2F; this.renderer.uiObjects.add(new UiText(this.renderer, scrWidth / 2, scrHeight * 0.75F, textWidth, textHeight, "Welcome to the settings menu!")); float buttonWidth = 0.3F; float buttonHeight = 0.08F; float buttonY = 0.5F; //Add the resume button UiButton backButton = new UiButton(this.renderer, scrWidth / 2 - (scrWidth * buttonWidth / 2), scrHeight * buttonY, buttonWidth, buttonHeight, "Back", Color.GRAY) { @Override public void onClick(int mouseButton) { super.onClick(mouseButton); //Go back by popping this screen, and disposing it rtk.popScreen().dispose(); } }; backButton.setToolTip(new TextToolTip(this.renderer, "Return to Previous Screen")); this.renderer.uiObjects.add(backButton); buttonY = 0.3F; //Add the main menu button UiButton screenSize = new UiButton(this.renderer, scrWidth / 2 - (scrWidth * buttonWidth / 2), scrHeight * buttonY, buttonWidth, buttonHeight, fullscreen ? "Disable Fullscreen" : "Enable Fullscreen", Color.GRAY) { @Override public void onClick(int mouseButton) { super.onClick(mouseButton); //This alters the settings folder and crashes the game on mac. Needs some work. boolean fullscreen = settings.getBoolean("fullscreen"); fullscreen = !fullscreen; settings.putBoolean("fullscreen", fullscreen); settings.flush(); this.text = fullscreen ? "Disable Fullscreen" : "Enable Fullscreen"; } }; screenSize.setToolTip(new TextToolTip(this.renderer, "Requires you to restart the game")); this.renderer.uiObjects.add(screenSize); this.renderer.uiObjects.sort(); //Sort the UI objects once they are all added ReleaseTheKraken.inputHandler.registerKeyListener(this); //Register as a key listener }