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:eu.rubenrosado.inmisericordia.LSGame.java

License:Open Source License

/**
 * Delete saved game/*from   w  w  w .j a  va  2 s. c  om*/
 */
public void deleteGame() {
    Preferences pref = Gdx.app.getPreferences(".sav");
    pref.putBoolean("savedgame", false);
    pref.flush();
    Gdx.files.local("hero.sav").delete();
    Gdx.files.local("monsters.sav").delete();
}

From source file:headmade.arttag.screens.IntroScreen.java

License:Apache License

@Override
public void preDraw(float delta) {
    super.preDraw(delta);

    if (!isInitialised) {
        Gdx.app.log(TAG, "Loading Prefs");
        isInitialised = true;/*w  ww  .  ja v  a  2  s  .  c  o m*/
        ArtTag.gameSettings = new GameSettings();
        final Preferences prefs = Gdx.app.getPreferences("ArtTreacheryPrefs");
        ArtTag.gameSettings.screenWidth = prefs.getInteger("screenWidth", 1280);
        ArtTag.gameSettings.screenHeight = prefs.getInteger("screenHeight", 1024);
        ArtTag.gameSettings.fullscreen = prefs.getBoolean("fullscreen", false);
        ArtTag.gameSettings.blur = prefs.getInteger("blur", 1);
        ArtTag.gameSettings.rays = prefs.getInteger("rays", 64);
        ArtTag.gameSettings.handleResAuto = prefs.getBoolean("handleResAuto", true);

        Gdx.app.log(TAG, "Saving Prefs");
        prefs.putInteger("screenWidth", ArtTag.gameSettings.screenWidth);
        prefs.putInteger("screenHeight", ArtTag.gameSettings.screenHeight);
        prefs.putBoolean("fullscreen", ArtTag.gameSettings.fullscreen);
        prefs.putInteger("blur", ArtTag.gameSettings.blur);
        prefs.putInteger("rays", ArtTag.gameSettings.rays);
        prefs.putBoolean("handleResAuto", ArtTag.gameSettings.handleResAuto);
        prefs.flush();

        if (Gdx.graphics.supportsDisplayModeChange() && ArtTag.gameSettings.handleResAuto == false) {
            Gdx.app.log(TAG, "Trying to set Displaymode");
            Gdx.graphics.setDisplayMode(ArtTag.gameSettings.screenWidth, ArtTag.gameSettings.screenHeight,
                    ArtTag.gameSettings.fullscreen);

            // Gdx.gl.glViewport(0, 0, ArtTag.gameSettings.screenWidth, ArtTag.gameSettings.screenHeight);
        }

    }

    Assets.assetsManager.update();
    if (!isStarted && MathUtils.isEqual(1f, Assets.assetsManager.getProgress())) {
        // done loading eh
        Assets.instance.onFinishLoading();

        startGame();
        isStarted = true;

        // final TextButton startButton = new TextButton("Start", Assets.instance.skin);
        // startButton.addListener(new InputListener() {
        //
        // @Override
        // public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
        // startGame();
        // return super.touchDown(event, x, y, pointer, button);
        // }
        // });
    }
}

From source file:io.piotrjastrzebski.dungen.DungenScreen.java

License:Apache License

public DungenScreen(DungenGame game) {
    super();/*from w  w w  .  j  av  a  2s. c  o  m*/
    this.game = game;

    genSettings = new GenSettings().setGridSize(.25f).setCount(150).setSpawnWidth(20).setSpawnHeight(10)
            .setRoomWidth(4).setRoomHeight(4).setMainRoomScale(1.15f).setReconnectChance(.2f)
            .setHallwaysWidth(2).setB2bIters(100);

    drawSettings = new DrawSettings().setDrawExtra(true).setDrawMain(true).setDrawHallWays(true)
            .setDrawUnused(true);

    generator = new DungeonGenerator();
    generator.init(genSettings);

    grid = new Grid();
    grid.setSize(genSettings.getGridSize());

    genGui = new GenSettingsGUI(this, this);
    genGui.setDefaults(genSettings);
    stage.addActor(genGui);
    genGui.setPosition(10, 10);

    drawGui = new DrawSettingsGUI(this);
    drawGui.setDefaults(drawSettings);
    stage.addActor(drawGui);
    drawGui.setPosition(10, stage.getHeight() - drawGui.getHeight() - 10);

    multiplexer.addProcessor(this);
    multiplexer.addProcessor(new GestureDetector(this));

    helpGUI = new HelpGUI();
    VisTable helpCont = new VisTable();
    helpCont.setFillParent(true);
    VisTextButton showHelp = new VisTextButton("Help!");
    showHelp.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            helpGUI.show(stage);
        }
    });
    helpCont.add(showHelp).right().top().expand().pad(10);
    stage.addActor(helpCont);

    Preferences dungen = Gdx.app.getPreferences("Dungen");
    if (!dungen.getBoolean("help-shown", false)) {
        helpGUI.show(stage);
        dungen.putBoolean("help-shown", true);
        dungen.flush();
    }
}

From source file:releasethekraken.screen.SettingsScreen.java

/**
 * Constructs a new PauseScreen//  w  w w  .j a v  a  2  s  .  co m
 * @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
}