com.badlogic.gdx.backends.lwjgl.LwjglPreferences Java Examples

The following examples show how to use com.badlogic.gdx.backends.lwjgl.LwjglPreferences. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomLwjglCanvas.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public Preferences getPreferences(String name) {
    if (preferences.containsKey(name)) {
        return preferences.get(name);
    } else {
        Preferences prefs = new LwjglPreferences(new LwjglFileHandle(new File(prefersDir, name), prefsFileType));
        preferences.put(name, prefs);
        return prefs;
    }
}
 
Example #2
Source File: WindowParamsPersistingApplicationWrapper.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
private void loadWindowParams(LwjglApplicationConfiguration configuration) {
    FileHandle file = new FileHandle(LwjglFiles.externalPath + configuration.preferencesDirectory + "/window_params.xml");
    if (!file.exists()) return;

    DisplayMode displayMode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
    int screenWidth = displayMode.getWidth();
    int screenHeight = displayMode.getHeight();

    Preferences prefs = new LwjglPreferences(file);
    configuration.width = MathUtils.clamp(prefs.getInteger("width", configuration.width), 320, screenWidth);
    configuration.height = MathUtils.clamp(prefs.getInteger("height", configuration.height), 320, screenHeight);
    configuration.x = MathUtils.clamp(prefs.getInteger("x", configuration.x), 0, screenWidth - configuration.width);
    configuration.y = MathUtils.clamp(prefs.getInteger("y", configuration.y), 0, screenHeight - configuration.height);
}
 
Example #3
Source File: LocalGameServices.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
public LocalGameServices() {
    prefs = new LwjglPreferences("dice.local.game-services", ".prefs/");
    dispatcher.setState(ServicesState.valueOf(prefs.getString(KEY, ServicesState.DISCONNECTED.toString())));
}
 
Example #4
Source File: DesktopLauncher.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public static void main (String[] arg) {
	String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
	if (version == null) {
		version = "0.7.5f";
	}

	int versionCode;
	try {
		versionCode = Integer.parseInt(DesktopLauncher.class.getPackage().getImplementationVersion());
	} catch (NumberFormatException e) {
		versionCode = 383;
	}

	LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

	if (SharedLibraryLoader.isMac) {
		config.preferencesDirectory = "Library/Application Support/Shattered Pixel Dungeon/";
	} else if (SharedLibraryLoader.isLinux) {
		config.preferencesDirectory = ".shatteredpixel/shattered-pixel-dungeon/";
	} else if (SharedLibraryLoader.isWindows) {
		String winVer = System.getProperties().getProperty("os.name");
		if (winVer.contains("XP")) {
			config.preferencesDirectory = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/";
		} else {
			config.preferencesDirectory = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/";
		}
	}
	// FIXME: This is a hack to get access to the preferences before we have an application setup
	com.badlogic.gdx.Preferences prefs = new LwjglPreferences(SPDSettings.FILE_NAME, config.preferencesDirectory);

	boolean isFullscreen = prefs.getBoolean(SPDSettings.KEY_WINDOW_FULLSCREEN, false);
	//config.fullscreen = isFullscreen;
	if (!isFullscreen) {
		config.width = prefs.getInteger(SPDSettings.KEY_WINDOW_WIDTH, SPDSettings.DEFAULT_WINDOW_WIDTH);
		config.height = prefs.getInteger(SPDSettings.KEY_WINDOW_HEIGHT, SPDSettings.DEFAULT_WINDOW_HEIGHT);
	}

	config.addIcon( "ic_launcher_128.png", Files.FileType.Internal );
	config.addIcon( "ic_launcher_32.png", Files.FileType.Internal );
	config.addIcon( "ic_launcher_16.png", Files.FileType.Internal );

	// TODO: It have to be pulled from build.gradle, but I don't know how it can be done
	config.title = "Shattered Pixel Dungeon";

	new LwjglApplication(new ShatteredPixelDungeon(
			new DesktopSupport(version, versionCode, config.preferencesDirectory, new DesktopInputProcessor())
	), config);
}