本文整理汇总了Java中com.badlogic.gdx.Preferences.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Preferences.getString方法的具体用法?Java Preferences.getString怎么用?Java Preferences.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.Preferences
的用法示例。
在下文中一共展示了Preferences.getString方法的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: 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);
}
示例3: 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();
}
示例4: 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);
}
示例5: 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;
}
示例6: 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);
}
示例7: loadConfiguration
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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);
}
示例8: loadData
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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);
}
示例9: parsePreference
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
/** @param rawLmlData unparsed LML data that might or might not start with preference key (which will be stripped).
* @return parsed preference value. */
protected String parsePreference(final String rawLmlData) {
String preferenceKey = LmlUtilities.stripMarker(rawLmlData, syntax.getPreferenceMarker());
final Preferences preferences;
if (Strings.contains(rawLmlData, syntax.getIdSeparatorMarker())) {
// Preferences name is given, as preference key contains separator. Extracting specific preferences.
final int separatorIndex = preferenceKey.indexOf(syntax.getIdSeparatorMarker());
final String preferencesName = preferenceKey.substring(0, separatorIndex);
preferences = data.getPreferences(preferencesName);
preferenceKey = preferenceKey.substring(separatorIndex + 1, preferenceKey.length());
} else {
// No specific preferences name. Using default preferences.
preferences = data.getDefaultPreferences();
}
if (preferences == null) {
throwError("Preferences container not found for preference: " + rawLmlData);
}
return preferences.getString(preferenceKey, Nullables.DEFAULT_NULL_STRING);
}
示例10: getProjectPath
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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();
}
示例11: sendMessage
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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 ");
}
});
}
示例12: sendMessage
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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 ");
}
});
}
示例13: makeRequest
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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 ");
}
});
}
示例14: makeRequest
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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() {
}
});
}
示例15: makeRequest
import com.badlogic.gdx.Preferences; //导入方法依赖的package包/类
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() {
}
});
}