Example usage for com.badlogic.gdx.backends.lwjgl LwjglPreferences getBoolean

List of usage examples for com.badlogic.gdx.backends.lwjgl LwjglPreferences getBoolean

Introduction

In this page you can find the example usage for com.badlogic.gdx.backends.lwjgl LwjglPreferences getBoolean.

Prototype

@Override
    public boolean getBoolean(String key) 

Source Link

Usage

From source file:de.fgerbig.spacepeng.desktop.DesktopLauncher.java

License:Apache License

public static void main(String[] args) {
    boolean forceWindowMode = false;

    // handle command line options
    if (args.length == 1) {
        forceWindowMode = args[0].equalsIgnoreCase("-window");
    }//from   w  w w.  j  ava2 s .  com

    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.allowSoftwareMode = true;
    config.forceExit = true;

    // read full screen mode from preferences
    config.preferencesDirectory = PreferencesManager.PREFS_DIRNAME;
    LwjglPreferences preferences = new LwjglPreferences(PreferencesManager.PREFS_FILENAME,
            config.preferencesDirectory);
    config.fullscreen = preferences.getBoolean(PreferencesManager.PREF_FULLSCREEN_ENABLED);

    if (forceWindowMode) {
        System.out.println("Disabling full screen mode.");
        config.fullscreen = false;
        preferences.putBoolean(PreferencesManager.PREF_FULLSCREEN_ENABLED, false);
    }

    if (config.fullscreen) {
        System.out.println("Trying to set display mode to full screen.");
        System.out.println("(Start with command line option '-window') if this fails.)");

        // get desktop display mode
        Graphics.DisplayMode displayMode = LwjglApplicationConfiguration.getDesktopDisplayMode();

        // set screen size to desktop size
        config.width = displayMode.width;
        config.height = displayMode.height;

    } else {

        // set window size to default size
        config.width = Const.WIDTH;
        config.height = Const.HEIGHT;
    }

    new LwjglApplication(new SpacePeng(), config);
}