List of usage examples for com.badlogic.gdx Preferences remove
public void remove(String key);
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.j a v a2s. c om*/ } 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.gamestudio24.martianrun.utils.GameManager.java
License:Apache License
public void submitSavedMaxScore() { Preferences preferences = getPreferences(); submitScore(preferences.getInteger(MAX_SCORE_PREFERENCE, 0)); preferences.remove(MAX_SCORE_PREFERENCE); preferences.flush();/*from ww w . j a v a 2 s .c om*/ }