本文整理匯總了Java中com.badlogic.gdx.Preferences類的典型用法代碼示例。如果您正苦於以下問題:Java Preferences類的具體用法?Java Preferences怎麽用?Java Preferences使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Preferences類屬於com.badlogic.gdx包,在下文中一共展示了Preferences類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeRequestEnklave
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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");
}
});
}
示例2: fetchHighScores
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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;
}
示例3: applyPrefs
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
示例4: loadProgress
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
示例5: loadSlot
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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();
}
示例6: saveSlot
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
示例7: tryToImportOldSave
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
示例8: moveAutosaveKeyToFirstPlace
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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();
}
示例9: data
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
示例10: saveFrameProperties
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
}
示例11: loadFrameProperties
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
示例12: saveWindowParams
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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();
}
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:20,代碼來源:WindowParamsPersistingApplicationWrapper.java
示例13: loadTempFilePath
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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;
}
示例14: GameManager
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}
示例15: loadConfiguration
import com.badlogic.gdx.Preferences; //導入依賴的package包/類
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);
}