@Override public void preDraw(float delta) { super.preDraw(delta); if (!isInitialised) { Gdx.app.log(TAG, "Loading Prefs"); isInitialised = true; ArtTag.gameSettings = new GameSettings(); final Preferences prefs = Gdx.app.getPreferences("ArtTreacheryPrefs"); ArtTag.gameSettings.screenWidth = prefs.getInteger("screenWidth", 1280); ArtTag.gameSettings.screenHeight = prefs.getInteger("screenHeight", 1024); ArtTag.gameSettings.fullscreen = prefs.getBoolean("fullscreen", false); ArtTag.gameSettings.blur = prefs.getInteger("blur", 1); ArtTag.gameSettings.rays = prefs.getInteger("rays", 64); ArtTag.gameSettings.handleResAuto = prefs.getBoolean("handleResAuto", true); Gdx.app.log(TAG, "Saving Prefs"); prefs.putInteger("screenWidth", ArtTag.gameSettings.screenWidth); prefs.putInteger("screenHeight", ArtTag.gameSettings.screenHeight); prefs.putBoolean("fullscreen", ArtTag.gameSettings.fullscreen); prefs.putInteger("blur", ArtTag.gameSettings.blur); prefs.putInteger("rays", ArtTag.gameSettings.rays); prefs.putBoolean("handleResAuto", ArtTag.gameSettings.handleResAuto); prefs.flush(); if (Gdx.graphics.supportsDisplayModeChange() && ArtTag.gameSettings.handleResAuto == false) { Gdx.app.log(TAG, "Trying to set Displaymode"); Gdx.graphics.setDisplayMode( ArtTag.gameSettings.screenWidth, ArtTag.gameSettings.screenHeight, ArtTag.gameSettings.fullscreen); // Gdx.gl.glViewport(0, 0, ArtTag.gameSettings.screenWidth, // ArtTag.gameSettings.screenHeight); } } Assets.assetsManager.update(); if (!isStarted && MathUtils.isEqual(1f, Assets.assetsManager.getProgress())) { // done loading eh Assets.instance.onFinishLoading(); startGame(); isStarted = true; // final TextButton startButton = new TextButton("Start", Assets.instance.skin); // startButton.addListener(new InputListener() { // // @Override // public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { // startGame(); // return super.touchDown(event, x, y, pointer, button); // } // }); } }
public void save() { prefs.putBoolean("sound", sound); prefs.putBoolean("music", music); prefs.putFloat("volSound", volSound); prefs.putFloat("volMusic", volMusic); prefs.putInteger("charSkin", charSkin); prefs.putBoolean("showFpsCounter", showFpsCounter); prefs.putBoolean("useMonochromeShader", useMonochromeShader); // сохраняем в файл prefs.flush(); }
@Override public void queryPurchases(Preferences pref) { this.pref = pref; try { Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null); int response = ownedItems.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); for (int i = 0; i < ownedSkus.size(); i++) { String name = null; if (ownedSkus.get(i).equals("ryan")) name = "Ryan"; else if (ownedSkus.get(i).equals("ash")) name = "Ash"; else if (ownedSkus.get(i).equals("rob")) name = "Rob"; else if (ownedSkus.get(i).equals("battle_cat")) name = "BattleCat"; else if (ownedSkus.get(i).equals("xorp")) name = "Xorp"; else if (ownedSkus.get(i).equals("rootsworth")) name = "Rootsworth"; else if (ownedSkus.get(i).equals("snap")) name = "Snap"; else if (ownedSkus.get(i).equals("metatron")) name = "Metatron"; else if (ownedSkus.get(i).equals("abaddon")) name = "Abaddon"; pref.putBoolean(name, true); pref.flush(); } } } catch (RemoteException e) { e.printStackTrace(); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1001) { int responseCode = data.getIntExtra("RESPONSE_CODE", 0); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (resultCode == RESULT_OK) { try { JSONObject jo = new JSONObject(purchaseData); String sku = jo.getString("productId"); String name = null; if (sku.equals("ryan")) name = "Ryan"; else if (sku.equals("ash")) name = "Ash"; else if (sku.equals("rob")) name = "Rob"; else if (sku.equals("battle_cat")) name = "BattleCat"; else if (sku.equals("xorp")) name = "Xorp"; else if (sku.equals("rootsworth")) name = "Rootsworth"; else if (sku.equals("snap")) name = "Snap"; else if (sku.equals("metatron")) name = "Metatron"; else if (sku.equals("abaddon")) name = "Abaddon"; pref.putBoolean(name, true); pref.flush(); } catch (JSONException e) { // alert("Failed to parse purchase data."); e.printStackTrace(); } } } super.onActivityResult(requestCode, resultCode, data); _gameHelper.onActivityResult(requestCode, resultCode, data); }
public void setScanLineShaderEnabled(boolean scanLineShaderEnabled) { this.scanLineShaderEnabled = scanLineShaderEnabled; prefs.putBoolean("scanLineShaderEnabled", scanLineShaderEnabled); prefs.flush(); if (scanLineShaderEnabled) { App.batch.setShader(App.crtShader); } else { App.batch.setShader(App.defaultShader); } }
public void toggleMusic() { this.musicOn = !this.musicOn; Preferences p = Gdx.app.getPreferences(PREFS_NAME); p.putBoolean("musicOn", this.musicOn); p.flush(); }
public void toggleSound() { this.soundOn = !this.soundOn; Preferences p = Gdx.app.getPreferences(PREFS_NAME); p.putBoolean("soundOn", this.soundOn); p.flush(); }
public void rulesViewed() { this.rulesEverSeen = true; Preferences p = Gdx.app.getPreferences(PREFS_NAME); p.putBoolean("rulesEverSeen", this.rulesEverSeen); p.flush(); }
public void setShowPing(boolean show) { preferences.putBoolean("showPing", show); preferences.flush(); }
public void musicResume() { preferences.putBoolean("musicOn", true); preferences.flush(); music.play(); }
public void musicPause() { preferences.putBoolean("musicOn", false); preferences.flush(); music.pause(); }
public static void setIntroSkippable(boolean skippable) { options.putBoolean("introskip", skippable); options.flush(); }
public static void setSoundOn(boolean value) { options.putBoolean("sound", value); options.flush(); }
public void setDynamicLightingEnabled(boolean dynamicLightingEnabled) { this.dynamicLightingEnabled = dynamicLightingEnabled; prefs.putBoolean("dynamicLightingEnabled", dynamicLightingEnabled); prefs.flush(); }
public void setAudioEnabled(boolean audioEnabled) { this.audioEnabled = audioEnabled; prefs.putBoolean("audioEnabled", audioEnabled); prefs.flush(); }