List of usage examples for com.badlogic.gdx Preferences getLong
public long getLong(String key, long defValue);
From source file:com.maplescot.loggerbill.misc.Profile.java
License:Creative Commons License
public void init(Preferences prefs) { ckSumV = prefs.getLong(CKSUMV, 0); soundOn = prefs.getBoolean(soundOnStr, true); musicOn = prefs.getBoolean(musicOnStr, true); totalPlays = prefs.getLong(totalPlaysStr, 0l); totalChunks = prefs.getLong(totalChunksStr, 0l); totalTime = prefs.getLong(totalTimeStr, 0l); bestChunks = prefs.getLong(bestChunksStr, 0l); bestCPS = prefs.getFloat(bestCPSStr, 0f); gplusId = prefs.getString(gplusStr, ""); ckSum = prefs.getString(CKSUM, null); loadAchievements(prefs.getString(achievementsStr, "")); if (totalPlays == 0 && totalChunks == 0 && bestCPS == 0f && bestChunks == 0 && totalTime == 0) { ckSum = makeCkSum();// w w w . java2 s.c om ckSumV = ckVersion; } if (!isCkSumValid()) reset(); }
From source file:com.theosirian.ppioo.util.GameData.java
License:Open Source License
public GameData load() { Preferences state = Gdx.app.getPreferences(saveName); money = state.getInteger("money", money); victories = state.getInteger("victories", victories); defeats = state.getInteger("defeats", defeats); JsonValue json = new JsonReader().parse(Gdx.files.internal("data.json")); JsonValue playersJson = json.get("players"); for (JsonValue playerJson : playersJson.iterator()) { Player player = new Player(); player.setId(playerJson.getString("id")); player.setFirstName(playerJson.getString("first_name")); player.setLastName(playerJson.getString("last_name")); player.setAge(playerJson.getInt("age")); player.setCountry(playerJson.getString("country")); player.setPrice(playerJson.getInt("price")); player.setQuality(playerJson.getFloat("quality")); player.setConfidence(playerJson.getFloat("confidence")); player.setOwned(state.getBoolean(player.getId(), playerJson.getBoolean("owned", false))); String key = "player-" + player.getId(); player.setDateAcquired(new Date(state.getLong(key + "-date_acquired", new Date().getTime()))); player.setVictories(state.getInteger(key + "-victories", 0)); player.setDefeats(state.getInteger(key + "-defeats", 0)); players.add(player);// w w w . ja v a 2s . c o m } JsonValue fansJson = json.get("fans"); for (JsonValue fanJson : fansJson.iterator()) { Fan fan = new Fan(); fan.setId(fanJson.getString("id")); fan.setName(fanJson.getString("name")); fan.setMinSupport(fanJson.getFloat("minSupport")); fan.setMaxSupport(fanJson.getFloat("maxSupport")); fan.setMinHuff(fanJson.getFloat("minHuff")); fan.setMaxHuff(fanJson.getFloat("maxHuff")); fan.setPrice(fanJson.getInt("price")); String key = "fan-" + fan.getId(); fan.setDateAcquired(new Date(state.getLong(key + "-date_acquired", new Date().getTime()))); fan.setVictories(state.getInteger(key + "-victories", 0)); fan.setDefeats(state.getInteger(key + "-defeats", 0)); fans.add(fan); } return this; }