Java 类com.badlogic.gdx.backends.lwjgl.LwjglPreferences 实例源码

项目:PixelDungeonTC    文件:DesktopLauncher.java   
public static void main (String[] arg) {
    String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
    if (version == null) {
        version = "1.0";
    }
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    if (SharedLibraryLoader.isMac) {
        config.preferencesDirectory = "Library/Application Support/Pixel Dungeon/";
    } else if (SharedLibraryLoader.isLinux) {
        config.preferencesDirectory = ".watabou/pixel-dungeon/";
    } else if (SharedLibraryLoader.isWindows) {
        config.preferencesDirectory = "Saved Games/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(Preferences.FILE_NAME, config.preferencesDirectory);

    boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
    config.fullscreen = isFullscreen;
    if (!isFullscreen) {
        config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
        config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.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 = "Pixel Dungeon";

    new LwjglApplication(new PixelDungeon(
            new DesktopSupport(version, config.preferencesDirectory, new DesktopInputProcessor())
    ), config);
}
项目:gdx-texture-packer-gui    文件:CustomLwjglCanvas.java   
@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;
    }
}
项目:gdx-texture-packer-gui    文件:WindowParamsPersistingApplicationWrapper.java   
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);
}
项目:pixel-dungeon-rebirth    文件:DesktopLauncher.java   
public static void main (String[] arg) {
    String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
    if (version == null) {
        version = "???";
    }
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    if (SharedLibraryLoader.isMac) {
        config.preferencesDirectory = "Library/Application Support/BravePixel/Pixel Dungeon/";
    } else if (SharedLibraryLoader.isLinux) {
        config.preferencesDirectory = ".bravepixel/pixel-dungeon/";
    } else if (SharedLibraryLoader.isWindows) {
        config.preferencesDirectory = "Saved Games/BravePixel/PixelDungeon";
    }
    // FIXME: This is a hack to get access to the preferences before we have an application setup
    com.badlogic.gdx.Preferences prefs = new LwjglPreferences(Preferences.FILE_NAME, config.preferencesDirectory);

    boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
    config.fullscreen = isFullscreen;
    if (!isFullscreen) {
        config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
        config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.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 = "Pixel Dungeon";

    new LwjglApplication(new PixelDungeon(
            new DesktopSupport(version, config.preferencesDirectory, new DesktopInputProcessor())
    ), config);
}
项目:dice-heroes    文件:LocalGameServices.java   
public LocalGameServices() {
    prefs = new LwjglPreferences("dice.local.game-services", ".prefs/");
    dispatcher.setState(ServicesState.valueOf(prefs.getString(KEY, ServicesState.DISCONNECTED.toString())));
}
项目:origin    文件:Config.java   
static protected Preferences getPrefs()
{
    return new LwjglPreferences(CONFIG_FILE, ".prefs/");
}
项目:Roguelike    文件:LwjglApplicationChanger.java   
public LwjglApplicationChanger()
{
    super( new LwjglPreferences( "game-settings", "settings" ) );
}
项目:shattered-pixel-dungeon-gdx    文件:DesktopLauncher.java   
public static void main (String[] arg) {
    String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
    if (version == null) {
        version = "0.6.2d";
    }

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

    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(Preferences.FILE_NAME, config.preferencesDirectory);

    boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
    //config.fullscreen = isFullscreen;
    if (!isFullscreen) {
        config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
        config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.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);
}
项目:c2d-engine    文件:C2dDesktop.java   
public TestList() {
    setLayout(new BorderLayout());


    final JList list = new JList(C2dTests.getNames());
    final JButton button = new JButton("Run Test");
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.setLeadAnchorNotificationEnabled(false);
    list.setSelectionModel(m);

    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) button.doClick();
        }
    });

    final Preferences prefs = new LwjglPreferences(new FileHandle(new LwjglFiles().getExternalStoragePath() + ".prefs/c2d-tests"));
    list.setSelectedValue(prefs.getString("last", null), true);

    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String testName = (String) list.getSelectedValue();
            Engine test = C2dTests.newTest(testName);
            LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
            config.fullscreen = false;
            config.width = (int) Engine.getWidth();
            config.height = (int) Engine.getHeight();
            config.title = testName;
            config.vSyncEnabled = true;

            prefs.putString("last", testName);
            prefs.flush();

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

    add(pane, BorderLayout.CENTER);
    add(button, BorderLayout.SOUTH);
}