Example usage for com.badlogic.gdx Preferences putBoolean

List of usage examples for com.badlogic.gdx Preferences putBoolean

Introduction

In this page you can find the example usage for com.badlogic.gdx Preferences putBoolean.

Prototype

public Preferences putBoolean(String key, boolean val);

Source Link

Usage

From source file:at.juggle.games.memory.GameOptions.java

License:Apache License

public void toggleSoundOn() {
    soundOn = !soundOn;//from w  w w  .j a  v  a2s  .  c  om
    Preferences preferences = Gdx.app.getPreferences("memory_free_hd.prefs");
    preferences.putBoolean("soundOn", soundOn);
    preferences.flush();
}

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 a2  s. 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.a2client.Config.java

License:Open Source License

public static void SaveOptions() {
    //        Preferences p = getPrefs();
    Preferences p = Gdx.app.getPreferences(CONFIG_FILE);
    p.putInteger("window_width", WindowWidth);
    p.putInteger("window_height", WindowHeight);
    p.putInteger("screen_width", ScreenWidth_to_save);
    p.putInteger("screen_height", ScreenHeight_to_save);
    p.putInteger("frame_rate", FrameFate);
    p.putBoolean("use_vsync", vSync);
    p.putBoolean("reduce_bg", ReduceInBackground);
    p.putBoolean("start_fullscreen", isFullscreen);
    //        AppSettings.put("sound_enabled", SoundEnabled);
    //        AppSettings.put("sound_vol", SoundVolume);
    //        AppSettings.put("music_vol", MusicVolume);
    //        AppSettings.put("debug_engine", DebugEngine);
    p.putString("language", current_lang);
    //        AppSettings.put("count_objs", count_objs);
    //        AppSettings.put("hide_overlapped", hide_overlapped);
    //        AppSettings.put("move_inst_left_mouse", move_inst_left_mouse);
    //        AppSettings.put("zoom_by_wheel", zoom_by_wheel);
    //        AppSettings.put("zoom_over_mouse", zoom_over_mouse);
    //        AppSettings.put("fullscreen_alt_enter", fullscreen_alt_enter);
    //        AppSettings.put("minimap_draw_objects", minimap_draw_objects);
    p.putString("account", account);
    if (save_pass) {
        p.putString("password", password);
    } else {//from w  ww . ja v a 2  s .  c  om
        p.putString("password", "");
    }
    p.putBoolean("save_pass", save_pass);

    p.flush();
}

From source file:com.digitale.screens.InGameOptions.java

License:Open Source License

public InGameOptions(Stage stage) {
    originalsfxVolume = Stardust3d.sfxVolume;
    originalMusicVolume = Stardust3d.musicVolume;
    originalaccellXsensitivity = Stardust3d.accelXsensitivity;
    originalaccellYsensitivity = Stardust3d.accelYsensitivity;
    originalDeadzoneX = Stardust3d.deadzoneX;
    originalDeadzoneY = Stardust3d.deadzoneY;
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));

    Gdx.input.setInputProcessor(stage);/*from   w w w .  java 2  s  .  c  o m*/

    // Group.debug = true;

    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonClose");
    final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "buttonCancel");
    ;
    final CheckBox checkBoxSFX = new CheckBox("Sound Effects", skin.getStyle(CheckBoxStyle.class), "checkbox");
    final CheckBox checkBoxFontsize = new CheckBox("Use Small Font", skin.getStyle(CheckBoxStyle.class),
            "checkboxfont");

    final Slider slidersfx = new Slider(0, 2, .1f, skin.getStyle(SliderStyle.class), "slidersfx");

    final Slider sliderdzy = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdzy");
    final Slider sliderdzx = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdzx");
    //sensitivty
    final Slider slidersy = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdsy");
    final Slider slidersx = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdsx");
    //stardust
    final Slider sliderdust = new Slider(20, 500, 10f, skin.getStyle(SliderStyle.class), "sliderdust");

    final Slider slidermusic = new Slider(0, 1, .01f, skin.getStyle(SliderStyle.class), "slidersmusic");
    final Slider slidergfxquality = new Slider(0, 10, 1, skin.getStyle(SliderStyle.class), "slidergfx");

    slidersfx.setValue(Stardust3d.sfxVolume);
    slidermusic.setValue(Stardust3d.musicVolume);
    sliderdzx.setValue(Stardust3d.deadzoneX);
    sliderdzy.setValue(Stardust3d.deadzoneY);
    sliderdust.setValue(Stardust3d.dustsize);
    slidersx.setValue(Stardust3d.accelXsensitivity);
    slidersy.setValue(Stardust3d.accelYsensitivity);
    final Label lablesfx = new Label("Sound effect volume", skin.getStyle(LabelStyle.class), "lablesfx");
    final Label lablemusic = new Label("Music volume", skin.getStyle(LabelStyle.class), "lablemusic");
    final Label lablegfx = new Label("Graphics quality", skin.getStyle(LabelStyle.class), "lablegfx");

    final Label lablesliderdzx = new Label("Horizontal Deadzone", skin.getStyle(LabelStyle.class),
            "lablesliderdzx");
    final Label lablesliderdzy = new Label("Vertical Deadzone", skin.getStyle(LabelStyle.class),
            "lablesliderdzy");
    final Label lableslidersx = new Label("Horizontal Sensitivity", skin.getStyle(LabelStyle.class),
            "lableslidersx");
    final Label lableslidersy = new Label("Vertical Sensitivity", skin.getStyle(LabelStyle.class),
            "lableslidersy");
    final Label lablesliderdust = new Label("Spacedust Density", skin.getStyle(LabelStyle.class),
            "lablesliderdust");
    final Preferences prefs = Gdx.app.getPreferences("stardustpreferences");
    final Label lablestilt = new Label("Android Tilt Settings", skin.getStyle(LabelStyle.class), "labletilt");

    Window window = new Window("Options Screen", skin.getStyle(WindowStyle.class), "optionsWindow");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.defaults().pad(2);
    window.setFillParent(true);
    window.setMovable(false);
    // build table
    window.row().fill().expandX().maxHeight(28);
    window.add();
    window.add();
    window.add(buttonCancel).colspan(1);
    window.add(buttonClose).colspan(1);
    // audio slider lables
    window.row().fill().expandX().maxHeight(28);
    window.add(checkBoxFontsize);
    window.add();
    window.add(lablestilt).maxWidth(350).fillX().colspan(2);

    window.row().fill().expandX().maxHeight(28);
    //top row 
    window.add(lablesfx).maxWidth(350).fillX().colspan(2);
    window.add(lablesliderdzx).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(slidersfx).fillX().colspan(2);
    window.add(sliderdzx).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add(lablemusic).maxWidth(350).fillX().colspan(2);
    window.add(lablesliderdzy).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(slidermusic).fillX().colspan(2);
    window.add(sliderdzy).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add(lablesliderdust).maxWidth(350).fillX().colspan(2);
    window.add(lableslidersx).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(sliderdust).fillX().colspan(2);
    window.add(slidersx).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add().minWidth(100).maxWidth(350).fillX().colspan(2);
    window.add(lableslidersy).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add().fillX().colspan(2);
    window.add(slidersy).fillX().colspan(2);
    window.row();
    // audio sliders

    window.pack();
    stage.addActor(window);

    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            prefs.putFloat("musicvolume", Stardust3d.musicVolume);
            prefs.putFloat("sfxvolume", Stardust3d.sfxVolume);

            prefs.putFloat("dzx", Stardust3d.deadzoneX);
            prefs.putFloat("dzy", Stardust3d.deadzoneY);
            prefs.putFloat("sx", Stardust3d.accelXsensitivity);
            prefs.putFloat("sy", Stardust3d.accelYsensitivity);

            prefs.putFloat("dustsize", Stardust3d.dustsize);
            Simulation.populateDust();
            prefs.flush();
            Stardust3d.stationScreen = 107;
        }
    });

    checkBoxFontsize.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            SoundManager.playuiclick();
            if (Stardust3d.DEBUG)
                System.out.println("smallfont");
            Stardust3d.tinyfont = checkBoxFontsize.isChecked();
            // if user wants to change fontsize
            prefs.putBoolean("fontsize", Stardust3d.tinyfont);
            prefs.flush();
        }
    });

    buttonCancel.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            resetSettings();
            Stardust3d.stationScreen = 107;
        }
    });

    slidersfx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.sfxVolume = value;
            SoundManager.setSFXVolume();
            SoundManager.playconfirm();
        }
    });

    slidermusic.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.musicVolume = value;

            SoundManager.setMusicVolume();

        }
    });

    sliderdzx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.deadzoneX = value;
        }
    });
    sliderdzy.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.deadzoneY = value;
        }
    });

    slidersx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.accelXsensitivity = value;
        }
    });

    slidersy.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.accelYsensitivity = value;
        }
    });
    sliderdust.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.dustsize = value;
            SoundManager.setMusicVolume();
        }
    });
}

From source file:com.digitale.screens.Options.java

License:Open Source License

public Options() {
    originalsfxVolume = Stardust3d.sfxVolume;
    originalMusicVolume = Stardust3d.musicVolume;

    batch = new SpriteBatch();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    background = new Texture(Gdx.files.internal("data/bgpland.jpg"));

    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    Gdx.input.setInputProcessor(stage);//  w ww  .java 2 s.c o  m

    // Group.debug = true;

    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonClose");
    final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "buttonCancel");
    ;
    final CheckBox checkBoxSFX = new CheckBox("Sound Effects", skin.getStyle(CheckBoxStyle.class), "checkbox");
    final CheckBox checkBoxFontsize = new CheckBox("Use Small Font", skin.getStyle(CheckBoxStyle.class),
            "checkboxfont");
    final Slider slidersfx = new Slider(0, 1, .01f, skin.getStyle(SliderStyle.class), "slidersfx");
    final Slider slidermusic = new Slider(0, 1, .01f, skin.getStyle(SliderStyle.class), "slidersmusic");
    final Slider slidergfxquality = new Slider(0, 10, 1, skin.getStyle(SliderStyle.class), "slidergfx");
    slidersfx.setValue(Stardust3d.sfxVolume);
    slidermusic.setValue(Stardust3d.musicVolume);
    final Label lablesfx = new Label("Sound effect volume", skin.getStyle(LabelStyle.class), "lablesfx");
    final Label lablemusic = new Label("Music volume", skin.getStyle(LabelStyle.class), "lablemusic");
    final Label lablegfx = new Label("Graphics quality", skin.getStyle(LabelStyle.class), "lablegfx");

    final Preferences prefs = Gdx.app.getPreferences("stardustpreferences");

    Window window = new Window("Options Screen", skin.getStyle(WindowStyle.class), "window");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.defaults().pad(5);
    window.setFillParent(true);
    window.setMovable(false);
    //build table
    window.row().expandX().fill();
    window.add();
    window.add();
    window.add(buttonCancel).colspan(1);
    window.add(buttonClose).colspan(1);
    //audio slider lables
    window.row();
    window.add(checkBoxFontsize);
    window.row();
    window.row();
    window.row();
    window.row();
    window.add(lablesfx).minWidth(100).colspan(2);
    window.add(lablemusic).minWidth(100).colspan(2);
    // audio sliders
    window.row().expand();
    window.add(slidersfx).minWidth(100).maxWidth(350).fillX().colspan(2);
    window.add(slidermusic).minWidth(100).maxWidth(350).fillX().colspan(2);

    window.row();

    window.pack();
    stage.addActor(window);

    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            prefs.putFloat("musicvolume", Stardust3d.musicVolume);
            prefs.putFloat("sfxvolume", Stardust3d.sfxVolume);
            prefs.flush();
            if (Stardust3d.mloginOK) {
                Stardust3d.gameMode = 4;

                doneflag = true;
            } else {
                Stardust3d.gameMode = 2;
                doneflag = true;
            }
        }
    });
    checkBoxFontsize.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            SoundManager.playuiclick();
            if (Stardust3d.DEBUG)
                System.out.println("smallfont");
            Stardust3d.tinyfont = checkBoxFontsize.isChecked();
            //if user wants to change fontsize
            prefs.putBoolean("fontsize", Stardust3d.tinyfont);
            prefs.flush();
        }
    });
    buttonCancel.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            if (Stardust3d.mloginOK) {
                Stardust3d.gameMode = 4;
                resetSettings();
                doneflag = true;
            } else {
                Stardust3d.gameMode = 2;
                doneflag = true;
            }
        }
    });
    slidersfx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.sfxVolume = value;
            Gdx.app.log("Options", "sfxslider: " + value);
            SoundManager.setSFXVolume();
            SoundManager.playconfirm();
        }
    });
    slidermusic.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.musicVolume = value;
            Gdx.app.log("Options", "musicslider: " + value);
            SoundManager.setMusicVolume();

        }
    });
}

From source file:com.gamestudio24.martianrun.utils.AudioUtils.java

License:Apache License

private void saveBoolean(String key, boolean value) {
    Preferences preferences = getPreferences();
    preferences.putBoolean(key, value);
    preferences.flush();/*from   w  w w  .  java  2 s.com*/
}

From source file:com.maplescot.loggerbill.misc.Profile.java

License:Creative Commons License

public void save(Preferences prefs) {
    ckSum = makeCkSum();/*  w  ww.  ja v a 2s .co m*/
    ckSumV = ckVersion;
    prefs.putBoolean(soundOnStr, soundOn);
    prefs.putBoolean(musicOnStr, musicOn);
    prefs.putLong(totalPlaysStr, totalPlays);
    prefs.putLong(totalChunksStr, totalChunks);
    prefs.putLong(totalTimeStr, totalTime);
    prefs.putLong(bestChunksStr, bestChunks);
    prefs.putFloat(bestCPSStr, bestCPS);
    prefs.putString(gplusStr, gplusId);
    prefs.putString(CKSUM, ckSum);
    prefs.putLong(CKSUMV, ckSumV);

    prefs.putString(achievementsStr, saveAchievements());
}

From source file:com.subzero.runners.android.AndroidLauncher.java

License:Open Source License

@Override
public void queryPurchases(Preferences pref) {
    this.pref = pref;
    try {/*ww w.  j  av a2s  . co  m*/
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0) {
            ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

            for (int i = 0; i < ownedSkus.size(); i++) {
                String name = null;

                if (ownedSkus.get(i).equals("ryan"))
                    name = "Ryan";
                else if (ownedSkus.get(i).equals("ash"))
                    name = "Ash";
                else if (ownedSkus.get(i).equals("rob"))
                    name = "Rob";
                else if (ownedSkus.get(i).equals("battle_cat"))
                    name = "BattleCat";
                else if (ownedSkus.get(i).equals("xorp"))
                    name = "Xorp";
                else if (ownedSkus.get(i).equals("rootsworth"))
                    name = "Rootsworth";
                else if (ownedSkus.get(i).equals("snap"))
                    name = "Snap";
                else if (ownedSkus.get(i).equals("metatron"))
                    name = "Metatron";
                else if (ownedSkus.get(i).equals("abaddon"))
                    name = "Abaddon";

                pref.putBoolean(name, true);
                pref.flush();
            }
        }
    } catch (RemoteException e) {
        e.printStackTrace();
    }

}

From source file:com.theosirian.ppioo.util.GameData.java

License:Open Source License

public GameData save() {
    Preferences state = Gdx.app.getPreferences(saveName);
    for (Player player : players) {
        if (player.isOwned()) {
            String key = "player-" + player.getId();
            state.putBoolean(key, true);
            state.putLong(key + "-date_acquired", player.getDateAcquired().getTime());
            state.putInteger(key + "-victories", player.getVictories());
            state.putInteger(key + "-defeats", player.getDefeats());
        }/*from w w  w .jav  a2s .co m*/
    }
    for (Fan fan : fans) {
        if (fan.isOwned()) {
            String key = "fan-" + fan.getId();
            state.putBoolean(key, true);
            state.putLong(key + "-date_acquired", fan.getDateAcquired().getTime());
            state.putInteger(key + "-victories", fan.getVictories());
            state.putInteger(key + "-defeats", fan.getDefeats());
        }
    }
    state.putInteger("money", money);
    state.putInteger("victories", victories);
    state.putInteger("defeats", defeats);
    state.flush();
    return this;
}

From source file:eu.rubenrosado.inmisericordia.LSGame.java

License:Open Source License

/**
 * Save the game in JSon/*from   w  ww.  ja  v a2 s .  com*/
 */
public void saveGame() {
    Json json = new Json();
    String hero = json.toJson(PlayGame.hero, Hero.class);
    String monsters = json.toJson(PlayGame.monsters, Monster.class);

    FileHandle file = Gdx.files.local("hero.sav");
    file.writeString(hero, false);
    file = Gdx.files.local("monsters.sav");
    file.writeString(monsters, false);

    Preferences pref = Gdx.app.getPreferences(".sav");
    if (!pref.getBoolean("savedgame", false)) {
        pref.putBoolean("savedgame", true);
    }
    pref.flush();
}