Java 类com.badlogic.gdx.Preferences 实例源码

项目:enklave    文件:NearbyEnklave.java   
public void makeRequestEnklave(){
    Preferences pref = Gdx.app.getPreferences("informationLog");
    String acces = pref.getString("accesstoken");
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.GET).url(url + enkNearby).build();
    request.setHeader("Authorization", "Bearer " + acces);
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            String response = httpResponse.getResultAsString();
            JSONArray jsonArray = new JSONArray(response);
            ListEnklaves.getInstance().setListEnklave(jsonArray);
            Gdx.app.log("response enklave : " + httpResponse.getStatus().getStatusCode(), " message " +response);
        }

        @Override
        public void failed(Throwable t) {
            Gdx.app.log("response : " + t.getMessage(), "fdg " + t.getLocalizedMessage());
        }

        @Override
        public void cancelled() {
            Gdx.app.log("response ","cancelled");
        }
    });
}
项目:fluffybalance    文件:HighScoreController.java   
public static IntArray fetchHighScores() {
    Preferences prefs = Gdx.app.getPreferences(PREFERENCES_NAME);

    IntArray scores = new IntArray();

    for (int i = 0; i < MAX_NR_SCORES; i++) {
        int score = prefs.getInteger(PREFERENCES_SCORE_NAME + i, -1);

        if (score == -1) {
            break;
        }

        scores.add(score);
    }

    return scores;
}
项目:Antiyoy    文件:LoadingParameters.java   
public void applyPrefs(Preferences prefs) {
    turn = prefs.getInteger("save_turn");
    playersNumber = prefs.getInteger("save_player_number");
    colorNumber = prefs.getInteger("save_color_number");
    if (colorNumber > FieldController.NEUTRAL_LANDS_INDEX) {
        colorNumber = FieldController.NEUTRAL_LANDS_INDEX;
    }
    levelSize = prefs.getInteger("save_level_size");
    difficulty = prefs.getInteger("save_difficulty");
    GameRules.campaignMode = prefs.getBoolean("save_campaign_mode");
    campaignLevelIndex = prefs.getInteger("save_current_level");
    colorOffset = prefs.getInteger("save_color_offset", 0);
    slayRules = prefs.getBoolean("slay_rules", true);
    fogOfWar = prefs.getBoolean("fog_of_war", false);
    diplomacy = prefs.getBoolean("diplomacy", false);
}
项目:Antiyoy    文件:CampaignProgressManager.java   
private void loadProgress() {
    clearProgress();

    Preferences preferences = Gdx.app.getPreferences(PROGRESS_PREFS);
    String completedLevels = preferences.getString("completed_levels", "");

    StringTokenizer tokenizer = new StringTokenizer(completedLevels, " ");
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        int index = Integer.valueOf(token);
        if (index >= progress.length) break;
        progress[index] = true;
    }

    checkToImportOldProgress(preferences);
}
项目:Antiyoy    文件:LevelEditor.java   
public void loadSlot() {
    Preferences prefs = Gdx.app.getPreferences(EDITOR_PREFS);
    String fullLevel = prefs.getString(SLOT_NAME + currentSlotNumber, "");

    LoadingParameters instance = LoadingParameters.getInstance();

    if (fullLevel.length() < 3) {
        instance.mode = LoadingParameters.MODE_EDITOR_NEW;
        instance.levelSize = FieldController.SIZE_BIG;
        instance.playersNumber = 1;
        instance.colorNumber = 5;
        instance.colorOffset = 0;
        instance.difficulty = 1;
    } else {
        instance.mode = LoadingParameters.MODE_EDITOR_LOAD;
        instance.applyFullLevel(fullLevel);
        instance.colorOffset = 0;
    }

    LoadingManager.getInstance().startGame(instance);
    GameRules.editorChosenColor = prefs.getInteger("chosen_color" + currentSlotNumber);

    defaultValues();
}
项目:Antiyoy    文件:SaveSlotSelector.java   
private void saveSlot(String key, SaveSystem saveSystem) {
    if (key.equals(SaveSystem.AUTOSAVE_KEY)) return; // don't overwrite autosave in selector

    if (!saveSystem.containsKey(key, slotPrefsString)) {
        saveSystem.addKey(key, slotPrefsString);
    }

    saveSystem.saveGame(key);

    SaveSlotInfo saveSlotInfo = new SaveSlotInfo();

    Preferences slotPrefs = Gdx.app.getPreferences(key);
    saveSlotInfo.name = SaveSystem.getNameString(slotPrefs);
    saveSlotInfo.description = SaveSystem.getDescriptionString(slotPrefs);
    saveSlotInfo.key = key;

    saveSystem.editSlot(key, saveSlotInfo, slotPrefsString);
    updateSingleItem(saveSlotInfo.key);
}
项目:Antiyoy    文件:SaveSystem.java   
private void tryToImportOldSave(String key) {
    Preferences preferences = getPreferences(key);
    String activeHexes = preferences.getString("save_active_hexes", "");
    if (activeHexes.length() < 3) return; // empty slot

    addKey(key, SAVE_SLOT_PREFS);

    SaveSlotInfo saveSlotInfo = new SaveSlotInfo();
    saveSlotInfo.name = getNameString(preferences);
    if (saveSlotInfo.name.length() < 3) {
        saveSlotInfo.name = "slot";
    }
    saveSlotInfo.description = getDescriptionString(preferences);
    if (saveSlotInfo.description.length() < 3) {
        saveSlotInfo.description = "old save";
    }
    saveSlotInfo.key = key;

    editSlot(key, saveSlotInfo, SAVE_SLOT_PREFS);
}
项目:Antiyoy    文件:SaveSystem.java   
public void moveAutosaveKeyToFirstPlace() {
    if (!containsKey(AUTOSAVE_KEY, SAVE_SLOT_PREFS)) return;

    ArrayList<String> keys = getKeys(SAVE_SLOT_PREFS);
    keys.remove(AUTOSAVE_KEY);
    keys.add(0, AUTOSAVE_KEY);

    StringBuilder newKeys = new StringBuilder();
    for (String key : keys) {
        newKeys.append(key).append(" ");
    }

    Preferences preferences = getPreferences(SAVE_SLOT_PREFS);
    preferences.putString("keys", newKeys.toString());
    preferences.flush();
}
项目:Freaking-Math    文件:MyGame.java   
void data()
{
    //get a preferences instance
    Preferences prefs = Gdx.app.getPreferences("My Preferences");

    highScore=prefs.getInteger("score", 0);

    if(score>highScore)
    {
        //put some Integer
        prefs.putInteger("score", score);
        //persist preferences
        prefs.flush();
    }

    //get Integer from preferences, 0 is the default value.
    highScore=prefs.getInteger("score", 0);

}
项目:gdx-texture-packer-gui    文件:FramePropertiesPersister.java   
public static void saveFrameProperties(JFrame frame) {
    int extendedState = frame.getExtendedState();
    boolean extendedStateChanged = false;
    if (extendedState != Frame.NORMAL) {
        frame.setExtendedState(Frame.NORMAL);
        extendedStateChanged = true;
    }

    Preferences prefs = Gdx.app.getPreferences(PREF_NAME);
    prefs.putInteger("x", frame.getX());
    prefs.putInteger("y", frame.getY());
    prefs.putInteger("width", frame.getWidth());
    prefs.putInteger("height", frame.getHeight());
    prefs.putInteger("extendedState", extendedState != Frame.ICONIFIED ? extendedState : Frame.NORMAL); // Do not save Frame.ICONIFIED
    prefs.flush();

    if (extendedStateChanged) {
        frame.setExtendedState(extendedState);
    }
}
项目:gdx-texture-packer-gui    文件:FramePropertiesPersister.java   
public static void loadFrameProperties(JFrame frame) {
    Preferences prefs = Gdx.app.getPreferences(PREF_NAME);

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

    int width = MathUtils.clamp(prefs.getInteger("width", frame.getSize().width), 320, screenWidth);
    int height = MathUtils.clamp(prefs.getInteger("height", frame.getSize().height), 320, screenHeight);
    int x = MathUtils.clamp(prefs.getInteger("x", frame.getLocation().x), 0, screenWidth - width);
    int y = MathUtils.clamp(prefs.getInteger("y", frame.getLocation().y), 0, screenHeight - height);
    int extendedState = prefs.getInteger("extendedState", frame.getExtendedState());

    frame.setSize(width, height);
    frame.setLocation(x, y);
    frame.setExtendedState(extendedState);
}
项目:gdx-texture-packer-gui    文件:WindowParamsPersistingApplicationWrapper.java   
private void saveWindowParams() {
    int width = Display.getWidth();
    int height = Display.getHeight();
    int x = Display.getX();
    int y = Display.getY();

    //FIXME by some reason actual window position shifted by 6 pixels on Windows (by 12 at y when maximized)
    if (LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS) {
        x += 6;
        y += 6;
    }

    Preferences prefs = Gdx.app.getPreferences("window_params.xml");
    prefs.putInteger("x", x);
    prefs.putInteger("y", y);
    prefs.putInteger("width", width);
    prefs.putInteger("height", height);
    prefs.flush();
}
项目:gdx-texture-packer-gui    文件:KTXProcessor.java   
protected File loadTempFilePath() {
    try {
        Preferences preferences = Gdx.app.getPreferences(PREFERENCES_FILE);
        int revision = preferences.getInteger(prefKeyFileRevision, -1);
        // Check if the revisions are the same
        if (this.fileRevision != revision) return null;

        String absolutePath = preferences.getString(prefKeyFilePath, null);
        if (absolutePath != null) {
            return new File(absolutePath);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:gdx-texture-packer-gui    文件:KtxEtc2Processor.java   
protected File loadTempFilePath() {
    try {
        Preferences preferences = Gdx.app.getPreferences(PREFERENCES_FILE);
        int revision = preferences.getInteger(prefKeyFileRevision, -1);
        // Check if the revisions are the same
        if (this.fileRevision != revision) return null;

        String absolutePath = preferences.getString(prefKeyFilePath, null);
        if (absolutePath != null) {
            return new File(absolutePath);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:GoingUnder    文件:GameManager.java   
public GameManager() {
    isPlayerAlive = false;
    topScore = 0;
    currentScore = 0;
    //load top score, etc
    Preferences prefs = Gdx.app.getPreferences(GameSaves);
    topScore = prefs.getInteger("topscore");
    isSoundOn = prefs.getBoolean("sound_on", true);
    totalGamesPlayed = prefs.getInteger("total_games_played", 0);
    totalScoreSum = prefs.getInteger("total_score_sum", 0);

    // add all needed assets to queue
    assetManager.load("fonts/arial64.fnt", BitmapFont.class);
    assetManager.load("atlases/game.atlas", TextureAtlas.class);
    assetManager.load("atlases/widgets.atlas", TextureAtlas.class);
    assetManager.load("sounds/coin.wav", Sound.class);
    assetManager.load("sounds/move.wav", Sound.class);
    assetManager.load("sounds/die.wav", Sound.class);
    assetManager.load("sounds/intro.ogg", Music.class);
}
项目:SSTrain    文件:GlobalConfiguration.java   
public static void loadConfiguration() {
    Preferences prefs = Gdx.app.getPreferences("ss_train_config");
    offset = prefs.getInteger("offset", 0);
    inputOffset = prefs.getInteger("input_offset", 0);
    songVolume = prefs.getInteger("song_vol", 100);
    feedbackVolume = prefs.getInteger("feedback_vol", 100);
    pathToBeatmaps = prefs.getString("path_to_beatmaps", Gdx.files.getExternalStoragePath() + "sstrain");
    playHintSounds = prefs.getBoolean("play_hint_sounds", false);
    noteSpeed = prefs.getInteger("note_speed", 6);
    overallDifficulty = prefs.getInteger("overall_difficulty", 7);
    displayLine = prefs.getBoolean("display_line", true);
    // default to song name sorting
    sortMode = prefs.getInteger("sorting_mode", SongUtils.SORTING_MODE_SONG_NAME);
    // default ascending order
    sortOrder = prefs.getInteger("sorting_order", SongUtils.SORTING_MODE_ASCENDING);
    // sync mode
    syncMode = prefs.getInteger("sync_mode", SongUtils.SYNC_MODE_1);

}
项目:SSTrain    文件:GlobalConfiguration.java   
public static void storeConfiguration() {
    Preferences prefs = Gdx.app.getPreferences("ss_train_config");
    prefs.putInteger("offset", offset);
    prefs.putInteger("input_offset", inputOffset);
    prefs.putInteger("song_vol", songVolume);
    prefs.putInteger("feedback_vol", feedbackVolume);
    prefs.putString("path_to_beatmaps", pathToBeatmaps);
    prefs.putBoolean("play_hint_sounds", playHintSounds);
    prefs.putInteger("note_speed", noteSpeed);
    prefs.putInteger("overall_difficulty", overallDifficulty);
    prefs.putBoolean("display_line", displayLine);
    prefs.putInteger("sorting_mode", sortMode);
    prefs.putInteger("sorting_order", sortOrder);
    prefs.putInteger("sync_mode", syncMode);
    prefs.flush();
}
项目:killingspree    文件:ClientDiscoveryScreen.java   
private void joinGame (final String host) {
        // FIXME
//            LobbyScreen lobbyScreen = new LobbyScreen(game);
//            lobbyScreen.setHost(address);
//            lobbyScreen.setServer(false);
//            game.setScreen(lobbyScreen);
            GameScreen gameScreen = new GameScreen(game);
            final Preferences prefs = Gdx.app.getPreferences("profile");
            if (gameScreen.loadLevel("maps/retro-small.tmx", host, 
                    prefs.getString("name"))) {
                game.setScreen(gameScreen);
            } else {
                gameScreen.dispose();
            }

    }
项目:SIFTrain    文件:GlobalConfiguration.java   
public static void loadConfiguration() {
    Preferences prefs = Gdx.app.getPreferences("sif_train_config");
    offset = prefs.getInteger("offset", 0);
    inputOffset = prefs.getInteger("input_offset", 0);
    songVolume = prefs.getInteger("song_vol", 100);
    feedbackVolume = prefs.getInteger("feedback_vol", 100);
    pathToBeatmaps = prefs.getString("path_to_beatmaps", Gdx.files.getExternalStoragePath() + "beatmaps");
    playHintSounds = prefs.getBoolean("play_hint_sounds", false);
    noteSpeed = prefs.getInteger("note_speed", 6);
    overallDifficulty = prefs.getInteger("overall_difficulty", 7);
    // default to song name sorting
    sortMode = prefs.getInteger("sorting_mode", SongUtils.SORTING_MODE_SONG_NAME);
    sortOrder = prefs.getInteger("sorting_order", SongUtils.SORTING_MODE_ASCENDING);
    // default to the new mode
    randomMode = prefs.getInteger("random_mode", SongUtils.RANDOM_MODE_NEW);
    // sync mode
    syncMode = prefs.getInteger("sync_mode", SongUtils.SYNC_MODE_1);

}
项目:SIFTrain    文件:GlobalConfiguration.java   
public static void storeConfiguration() {
    Preferences prefs = Gdx.app.getPreferences("sif_train_config");
    prefs.putInteger("offset", offset);
    prefs.putInteger("input_offset", inputOffset);
    prefs.putInteger("song_vol", songVolume);
    prefs.putInteger("feedback_vol", feedbackVolume);
    prefs.putString("path_to_beatmaps", pathToBeatmaps);
    prefs.putBoolean("play_hint_sounds", playHintSounds);
    prefs.putInteger("note_speed", noteSpeed);
    prefs.putInteger("overall_difficulty", overallDifficulty);
    prefs.putInteger("sorting_mode", sortMode);
    prefs.putInteger("random_mode", randomMode);
    prefs.putInteger("sorting_order", sortOrder);
    prefs.putInteger("sync_mode", syncMode);
    prefs.flush();
}
项目:ArxxusGame    文件:Data.java   
public static void loadData() {
    Preferences prefScores = Gdx.app.getPreferences("Pref_Score");
    if (prefScores.contains("name")) {
        PLAYR_NAME = prefScores.getString("name");
        LEVEL = prefScores.getInteger("level");
        SCORE = prefScores.getInteger("score");
        BEST_SCORE = prefScores.getInteger("bestscore");
        BEST_PLAYR_NAME = prefScores.getString("bestplayer");
    } else {
        // if first application launch
        PLAYR_NAME = "Player";
        LEVEL = 1;
        SCORE = 0;
        BEST_SCORE = SCORE;
        BEST_PLAYR_NAME = PLAYR_NAME;
    }
    System.out.println(BEST_SCORE);
}
项目:abattle    文件:GameConfigurationData.java   
public GameConfigurationData(final Preferences properties) {
  baseGrowthPerTick = net.npg.abattle.common.configuration.Helper.getint(properties,"game.baseGrowthPerTick","200");
  townGrowthPerTick = net.npg.abattle.common.configuration.Helper.getint(properties,"game.townGrowthPerTick","100");
  maxCellStrength = net.npg.abattle.common.configuration.Helper.getint(properties,"game.maxCellStrength","10000");
  maxCellHeight = net.npg.abattle.common.configuration.Helper.getint(properties,"game.maxCellHeight","5");
  maxMovement = net.npg.abattle.common.configuration.Helper.getint(properties,"game.maxMovement","800");
  winCondition = net.npg.abattle.common.configuration.Helper.getint(properties,"game.winCondition","95");
  logic = net.npg.abattle.common.configuration.Helper.getString(properties,"game.logic","");
  randomBases = net.npg.abattle.common.configuration.Helper.getint(properties,"game.randomBases","10");
  terrainInfluence = net.npg.abattle.common.configuration.Helper.getint(properties,"game.terrainInfluence","70");
  peakCount = net.npg.abattle.common.configuration.Helper.getint(properties,"game.peakCount","10");
  fog = net.npg.abattle.common.configuration.Helper.getString(properties,"game.fog","");
  terrainCreator = net.npg.abattle.common.configuration.Helper.getString(properties,"game.terrainCreator","");
  xsize = net.npg.abattle.common.configuration.Helper.getint(properties,"game.xsize","8");
  ysize = net.npg.abattle.common.configuration.Helper.getint(properties,"game.ysize","8");
  playerCount = net.npg.abattle.common.configuration.Helper.getint(properties,"game.playerCount","2");
  dirty = false;
}
项目:Roguelike    文件:AndroidApplicationChanger.java   
@Override
public void updateApplication( Preferences pref )
{
    int width = pref.getInteger( "resolutionX" );
    int height = pref.getInteger( "resolutionY" );

    Global.TargetResolution[0] = width;
    Global.TargetResolution[1] = height;
    Global.FPS = pref.getInteger( "fps" );
    Global.AnimationSpeed = 1.0f / pref.getFloat( "animspeed" );

    Global.MovementTypePathfind = pref.getBoolean( "pathfindMovement" );
    Global.MusicVolume = pref.getFloat( "musicVolume" );
    Global.AmbientVolume = pref.getFloat( "ambientVolume" );
    Global.EffectVolume = pref.getFloat( "effectVolume" );
    Global.updateVolume();
}
项目:Roguelike    文件:LwjglApplicationChanger.java   
public void setDefaultPrefs( Preferences prefs )
{
    prefs.putBoolean( "pathfindMovement", false );

    prefs.putFloat( "musicVolume", 1 );
    prefs.putFloat( "ambientVolume", 1 );
    prefs.putFloat( "effectVolume", 1 );

    prefs.putInteger( "resolutionX", 800 );
    prefs.putInteger( "resolutionY", 600 );
    prefs.putBoolean( "fullscreen", false );
    prefs.putBoolean( "borderless", false );
    prefs.putBoolean( "vSync", true );
    prefs.putInteger( "fps", 0 );
    prefs.putFloat( "animspeed", 1 );
    prefs.putInteger( "msaa", 16 );

    Global.Controls.defaultArrow();
    for ( Controls.Keys key : Controls.Keys.values() )
    {
        prefs.putInteger( key.toString(), Global.Controls.getKeyCode( key ) );
    }
}
项目:ggvm    文件:KeyboardInputProcessor.java   
public void saveConfiguration() {
    Preferences buttonIndexToKeyCodePreferences = Gdx.app.getPreferences(BUTTON_INDEX_TO_KEY_CODE_PREFERENCES);
    Preferences buttonIndexToButtonPreferences = Gdx.app.getPreferences(BUTTON_INDEX_TO_BUTTON_PREFERENCES);
    buttonIndexToKeyCodePreferences.clear();
    buttonIndexToButtonPreferences.clear();

    for(com.gradualgames.ggvm.Controller.Buttons button: com.gradualgames.ggvm.Controller.Buttons.values()) {
        if (button.isConfigurable()) {
            if (buttonIndexToKeyCode.containsKey(button)) {
                buttonIndexToKeyCodePreferences.putInteger(button.name(), buttonIndexToKeyCode.get(button));
            }
            if (buttonIndexToButton.containsKey(button)) {
                buttonIndexToButtonPreferences.putInteger(button.name(), buttonIndexToButton.get(button));
            }
        }
    }
    buttonIndexToKeyCodePreferences.flush();
    buttonIndexToButtonPreferences.flush();

    Preferences actualAxisToAxisCodePreferences = Gdx.app.getPreferences(ACTUAL_AXIS_TO_AXIS_CODE_PREFERENCES);
    actualAxisToAxisCodePreferences.clear();
    for(Axis axis: Axis.values()) {
        if (actualAxisToAxisCode.containsKey(axis)) {
            actualAxisToAxisCodePreferences.putInteger(axis.name(), actualAxisToAxisCode.get(axis));
        }
    }
    actualAxisToAxisCodePreferences.flush();
}
项目:ggvm    文件:KeyboardInputProcessor.java   
public void loadConfiguration() {
    clear();
    Preferences buttonIndexToKeyCodePreferences = Gdx.app.getPreferences(BUTTON_INDEX_TO_KEY_CODE_PREFERENCES);
    Preferences buttonIndexToButtonPreferences = Gdx.app.getPreferences(BUTTON_INDEX_TO_BUTTON_PREFERENCES);
    for(com.gradualgames.ggvm.Controller.Buttons button: com.gradualgames.ggvm.Controller.Buttons.values()) {
        if (buttonIndexToKeyCodePreferences.contains(button.name())) {
            buttonIndexToKeyCode.put(button, buttonIndexToKeyCodePreferences.getInteger(button.name()));
        }
        if (buttonIndexToButtonPreferences.contains(button.name())) {
            buttonIndexToButton.put(button, buttonIndexToButtonPreferences.getInteger(button.name()));
        }
    }

    Preferences actualAxisToAxisCodePreferences = Gdx.app.getPreferences(ACTUAL_AXIS_TO_AXIS_CODE_PREFERENCES);
    for(Axis axis: Axis.values()) {
        if (actualAxisToAxisCodePreferences.contains(axis.name())) {
            actualAxisToAxisCode.put(axis, actualAxisToAxisCodePreferences.getInteger(axis.name()));
        }
    }

    //If all mappings are empty after attempting to load config, attempt auto config
    if (buttonIndexToKeyCode.isEmpty() &&
        buttonIndexToButton.isEmpty() &&
        actualAxisToAxisCode.isEmpty()) {
        autoConfigure();
    }
}
项目:libgdx_ui_editor    文件:Config.java   
public static String getProjectPath(){
    Preferences preferences = Gdx.app.getPreferences("white-projectPath");
    String path = preferences.getString("project","");
    StringBuilder stringBuilder =  new StringBuilder();
    stringBuilder.append(path);
    if (!path.endsWith("/")){
        stringBuilder.append("/");
    }

    return stringBuilder.toString();
}
项目:Caramelos    文件:CaramelosScreen.java   
@Override
public void pause() {
    Preferences prefs = Gdx.app.getPreferences("MyPreferences");
    prefs.putInteger("level", level);
    prefs.putInteger("score", score);
    prefs.putInteger("maxscore", maxscore);
    prefs.putInteger("movements", movements);
    prefs.putInteger("maxmovements", maxmovements);
    prefs.flush();
}
项目:Caramelos    文件:CaramelosScreen.java   
@Override
public void resume() {
    Preferences prefs = Gdx.app.getPreferences("MyPreferences");
    level = prefs.getInteger("level");
    score = prefs.getInteger("score");
    maxscore = prefs.getInteger("maxscore");
    movements = prefs.getInteger("movements");
    maxmovements = prefs.getInteger("maxmovements");
}
项目:Caramelos    文件:CaramelosGame.java   
public void InitPreferences()
{
    Preferences prefs = Gdx.app.getPreferences("MyPreferences");
    if(!prefs.contains("sound"))
    {
        prefs.putBoolean("sound",true);
        prefs.flush();
    }
}
项目:Caramelos    文件:StatusScreen.java   
public StatusScreen(CaramelosGame game, boolean victory,int level)
{
    this.game = game;
    this.victory = victory;
    this.level = level;

    Preferences prefs = Gdx.app.getPreferences("My Preferences");
    flagSound = prefs.getBoolean("sound");
    if(victory)
        mp3Music = Gdx.audio.newMusic(Gdx.files.internal("Music/Victory.mp3"));
    else{
        mp3Music = Gdx.audio.newMusic(Gdx.files.internal("Music/GameOver.mp3"));
    }
    mp3Music.setLooping(true);
    if(flagSound){
        mp3Music.play();
    }

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Vollkorn/Vollkorn-Regular.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 24;
    font12 = generator.generateFont(parameter); // font size 12 pixels
    generator.dispose(); // don't forget to dispose to avoid memory leaks!

    FileHandle baseFileHandle = Gdx.files.internal("Messages/menus");
    String localeLanguage =java.util.Locale.getDefault().toString();
    Locale locale = new Locale(localeLanguage);
    I18NBundle myBundle = I18NBundle.createBundle(baseFileHandle, locale,"UTF-8");
    menulevel = myBundle.get("menulevel");
    menuvictory = myBundle.get("menuvictory");
    menuchampion = myBundle.get("menuchampion");
    menucontinue = myBundle.get("menucontinue");
    menugameover = myBundle.get("menugameover");
}
项目:enklave    文件:SendFaction.java   
public void sendMessage(String message){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    String acces = pref.getString("accesstoken");
    JSONObject json = new JSONObject();
    json.accumulate("txt",message);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(json.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            //Gdx.app.log("response :"+httpResponse.getStatus().getStatusCode(),"message "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {
            //Gdx.app.log("response :","failed "+t);
        }

        @Override
        public void cancelled() {
            //Gdx.app.log("response :","cancel ");
        }
    });
}
项目:enklave    文件:SendLocation.java   
public void sendMessage(String message){
        final Preferences pref = Gdx.app.getPreferences("informationLog");
        String acces = pref.getString("accesstoken");
        JSONObject json = new JSONObject();
        json.accumulate("txt",message);
        HttpRequestBuilder builder = new HttpRequestBuilder();
        Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
        request.setHeader("Authorization", "Bearer " + acces);
        request.setHeader("Content-type", "application/json");
        request.setContent(json.toString());
        Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
            @Override
            public void handleHttpResponse(Net.HttpResponse httpResponse) {
//                Gdx.app.log("response :"+httpResponse.getStatus().getStatusCode(),"message "+httpResponse.getResultAsString());
            }

            @Override
            public void failed(Throwable t) {
                //Gdx.app.log("response :","failed "+t);
            }

            @Override
            public void cancelled() {
                //Gdx.app.log("response :","cancel ");
            }
        });
    }
项目:enklave    文件:JoinFaction.java   
public void makeRequest(int id){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    String acces = pref.getString("accesstoken");
    JSONObject json = new JSONObject();
    json.accumulate("faction_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(json.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            //Gdx.app.log("response :","message "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {
            //Gdx.app.log("response :","failed ");
        }

        @Override
        public void cancelled() {
            //Gdx.app.log("response :","cancel ");
        }
    });
}
项目:enklave    文件:HitEnklave.java   
public void makeRequest(int id, final ScreenCombat screenCombat){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject parameters = new JSONObject();
    parameters.accumulate("enklave_combat_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(parameters.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            screenCombat.showCover();
            Gdx.app.log("raspuns hit Enklave cod :"+httpResponse.getStatus().getStatusCode()," message : "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {

        }

        @Override
        public void cancelled() {

        }
    });
}
项目:enklave    文件:StartCombat.java   
public void makeRequest(int id, final ScreenCombat screenCombat){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject jsonObject = new JSONObject();
    jsonObject.accumulate("enklave_id", id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(jsonObject.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            String res = httpResponse.getResultAsString();
            Gdx.app.log("raspuns start code "+httpResponse.getStatus().getStatusCode(),"rasp mess: "+res);
            if(httpResponse.getStatus().getStatusCode()<300){
                JSONObject j = new JSONObject(res);
                informationProfile.getDateUserGame().setEnklaveCombatId(j.getInt("enklave_combatant_id"));
                InformationEnklave.getInstance().setCombatId(j.getInt("enklave_combat_id"));
                informationProfile.getDateUserGame().setInCombat(true);
            }else{
                JSONObject json = new JSONObject(res);
                if(json.getString("detail").contentEquals("You already joined this combat once"))
                    InformationProfile.getInstance().getDateUserGame().setEnklaveCombatId(-1);
                informationProfile.getDateUserGame().setInCombat(true);
                screenCombat.dialogExit(json.getString("detail").substring(0,20)+"\n"+json.getString("detail").substring(21));
            }
        }

        @Override
        public void failed(Throwable t) {
            Gdx.app.log("error parse data : ","err: "+t);
        }

        @Override
        public void cancelled() {

        }
    });
}
项目:enklave    文件:UnsubscribeCombat.java   
public void makeRequest(int id){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject parameters = new JSONObject();
    parameters.accumulate("enklave_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(parameters.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            Gdx.app.log("raspuns unsubscribe cod :"," message : "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {

        }

        @Override
        public void cancelled() {

        }
    });
}
项目:enklave    文件:HitUser.java   
public void makeRequest(int id, final ScreenCombat screenCombat){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject parameters = new JSONObject();
    parameters.accumulate("enklave_combatant_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(parameters.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            screenCombat.showCover();
            Gdx.app.log("raspuns hit user cod :"+httpResponse.getStatus().getStatusCode()," message : "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {

        }

        @Override
        public void cancelled() {

        }
    });
}
项目:enklave    文件:SubscribeCombat.java   
public void makeRequest(final int id){
        final Preferences pref = Gdx.app.getPreferences("informationLog");
        final String acces = pref.getString("accesstoken");
        JSONObject parameters = new JSONObject();
        parameters.accumulate("enklave_id",id);
        HttpRequestBuilder builder = new HttpRequestBuilder();
        Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
        request.setHeader("Authorization", "Bearer " + acces);
        request.setHeader("Content-type", "application/json");
        request.setContent(parameters.toString());
        Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
            @Override
            public void handleHttpResponse(Net.HttpResponse httpResponse) {
//                Gdx.app.log("response "+httpResponse.getStatus().getStatusCode()," subscribe "+httpResponse.getResultAsString());
                if(httpResponse.getStatus().getStatusCode()<300){
                    new CheckStatus().makeRequest(id);
                }else{

                }
            }

            @Override
            public void failed(Throwable t) {

            }

            @Override
            public void cancelled() {

            }
        });
    }
项目:fluffybalance    文件:HighScoreController.java   
public static void setUserName(String name) {
    Preferences prefs = Gdx.app.getPreferences(PREFERENCES_NAME);

    // make sure the name is correct
    if (name.length() < MIN_NAME_LENGTH) {
        name = name + "---";
    } else if (name.length() > MAX_NAME_LENGTH){
        name += name.substring(0, MAX_NAME_LENGTH - 1);
    }

    prefs.putString(PREFERENCES_USER_NAME, name.trim());
    prefs.flush();
}