Example usage for com.badlogic.gdx Preferences getInteger

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

Introduction

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

Prototype

public int getInteger(String key, int defValue);

Source Link

Usage

From source file:edu.lehigh.cse.lol.Facts.java

License:Open Source License

/**
 * Look up a fact that was stored for the current game session. If no such
 * fact exists, defaultVal will be returned.
 *
 * @param factName   The name used to store the fact
 * @param defaultVal The value to return if the fact does not exist
 * @return The integer value corresponding to the last value stored
 *//*from   w  w  w  .  j a v a2 s . c o  m*/
public static int getGameFact(String factName, int defaultVal) {
    Preferences prefs = Gdx.app.getPreferences(Lol.sGame.mStorageKey);
    return prefs.getInteger(factName, defaultVal);
}

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;//from   www.j a  v a2  s .com
        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);
        // }
        // });
    }
}