public static void setDistance(float dist) { distTemp = score.getFloat("distance"); distTemp = distTemp + dist; score.putFloat("distance", distTemp); score.flush(); }
public void Game_Finished(int level) { game_finished = true; this.level = level; if (simulation.game_won()) { prefs.putInteger("Level_26_Game", 2); if (prefs.getInteger("Level_10_Game", 0) == 2) { } else { prefs.putInteger("Level_10_Game", 1); } if (prefs.getInteger("Level_21_Game", 0) == 2) { } else { prefs.putInteger("Level_21_Game", 1); } if (prefs.getInteger("Level_27_Game", 0) == 2) { } else { prefs.putInteger("Level_27_Game", 1); } if (prefs.getInteger("Level_31_Game", 0) == 2) { } else { prefs.putInteger("Level_31_Game", 1); } 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 Settings() { prefs = Gdx.app.getPreferences("appsettings"); scanLineShaderEnabled = prefs.getBoolean("scanLineShaderEnabled", false); audioEnabled = prefs.getBoolean("audioEnabled", false); dynamicLightingEnabled = prefs.getBoolean("dynamicLightingEnabled", false); }
public void processSignInHASHED( String username, String password) // this is for when we do the auto login cause we getting the hashed prefs { String url = "http://45.33.62.187/api/v1/player/?username_hash=" + username + "&password_hash=" + password + "&format=json"; String getPlayer = apiCall.httpGet(url, httpReturns.size()); System.out.println("trying to sign in hashed with " + username + " " + password); if (getPlayer.equalsIgnoreCase("FAILED") || getPlayer.equalsIgnoreCase("CANCELLED") || getPlayer.equalsIgnoreCase("EMPTY")) { // menuComponents.add(3, new MenuComponent(300, 400, 100, 50, Assets.menuFailedRegion)); System.out.println("login with hash " + getPlayer); Preferences prefs = Gdx.app.getPreferences("LOGIN"); prefs.putString("USERNAME_HASHED", ""); prefs.putString("PASSWORD_HASHED", ""); prefs.flush(); // saves the blank hashes to the prefs file this.signIn(); } else { System.out.println("JSON NOT MEPTY"); JSONObject json = new JSONObject(getPlayer); JSONArray playerArray = json.getJSONArray("objects"); JSONObject player0 = playerArray.getJSONObject(0); int wins = player0.getInt("wins"); int losses = player0.getInt("losses"); String usernameS = player0.getString("username"); String charityURL = player0.getString("charity"); // store players id during this playing session in proofOfConcept (best place I can think of // at the moment) int id = player0.getInt("id"); game.setPlayerID(id); String getCharity = apiCall.httpGet("http://45.33.62.187" + charityURL + "?format=json", httpReturns.size()); if (getCharity.equalsIgnoreCase("FAILED") || getCharity.equalsIgnoreCase("CANCELLED") || getCharity.equalsIgnoreCase("EMPTY")) { // menuComponents.add(new MenuComponent(300, 400, 100, 50, Assets.menuFailedRegion)); // //should be 3 unless 3 is already there, then it will be 4 } else { JSONObject jsonCharity = new JSONObject(getCharity); String charityName = jsonCharity.getString("name"); int charityIcon = jsonCharity.getInt("icon"); int charityID = jsonCharity.getInt("id"); game.setCharityID(charityID); System.out.println("Go to welcome"); this.welcome(usernameS, wins, losses, charityName, charityIcon); } } }
/** Ladataan nykyinen kieli. * */ public void load(Preferences preferences) { if (preferences.contains("Locale")) currentLocaleIndex = preferences.getInteger("Locale"); else currentLocaleIndex = 0; languageBundle = I18NBundle.createBundle(Gdx.files.internal("Resources\\strings"), getCurrentLocale()); }
/** * Will load font from file. If that fails, font will be generated and saved to file. * * @param fontFile the actual font (.otf, .ttf) * @param fontName the name of the font, i.e. "arial-small", "arial-large", "monospace-10" This * will be used for creating the font file names * @param fontSize fontSize of font when screen width equals referenceScreenWidth */ public AnimvsBitmapFont createFont( FileHandle fontFile, String fontName, int fontSize, String characters, String language, int pageSize) { if (pageSize < 50) throw new RuntimeException("Page fontSize too small during font generation: " + pageSize); AnimvsBitmapFont font = null; // if fonts are already generated, just load from file Preferences fontPrefs = Gdx.app.getPreferences(propertyName); String lastVersionTag = fontPrefs.getString("tag"); int displayWidth = fontPrefs.getInteger("display-width", 0); int displayHeight = fontPrefs.getInteger("display-height", 0); String lastUsedLanguage = fontPrefs.getString("lang"); boolean loaded = false; if (displayWidth != Gdx.graphics.getWidth() || displayHeight != Gdx.graphics.getHeight()) Gdx.app.debug(TAG, "Screen fontSize change detected, regenerating fonts"); else if (!lastUsedLanguage.equals(language)) Gdx.app.debug(TAG, "Language change detected, regenerating fonts"); else if (!lastVersionTag.equals(versionTag)) Gdx.app.debug(TAG, "Version change detected, regenerating fonts"); else if (!forceGeneration) { try { // try to load from file Gdx.app.debug(TAG, "Loading generated font from file cache"); font = new AnimvsBitmapFont(getFontFile(fontName + ".fnt")); setDefaultFilter(font); loaded = true; // arquivosFonte.add(fontFile.path()); } catch (GdxRuntimeException e) { Gdx.app.error(TAG, e.getMessage()); Gdx.app.debug(TAG, "Couldn't load pre-generated fonts. Will generate fonts."); } } if (!loaded || forceGeneration) { forceGeneration = false; // float width = Gdx.graphics.getWidth(); // float ratio = width / referenceScreenWidth; // use 1920x1280 as // float baseSize = 28f; // for 28 sized fonts at baseline width // above Gdx.app.log( TAG, "Generating Font - Name: " + fontName + " Size: " + fontSize + " characters: " + characters); font = generateFontWriteFiles(fontName, fontFile, fontSize, pageSize, pageSize, characters); // arquivosFonte.add(fontFile.path()); } return font; }
public void setScore(int score) { scoreString.setScore(score); if (score > topScore) { topScore = score; preferences.putInteger(TOP_SCORE_PREF, topScore); preferences.flush(); topScoreString.setScore(score); } }
public void load() { sound = prefs.getBoolean("sound", true); music = prefs.getBoolean("music", true); // если нет записи в "volSound" берем значение 0.5 и проверяем на границы от 0.0 до 1.0 volSound = MathUtils.clamp(prefs.getFloat("volSound", 0.5f), 0.0f, 1.0f); volMusic = MathUtils.clamp(prefs.getFloat("volMusic", 0.5f), 0.0f, 1.0f); charSkin = MathUtils.clamp(prefs.getInteger("charSkin", 0), 0, 2); showFpsCounter = prefs.getBoolean("showFpsCounter", false); useMonochromeShader = prefs.getBoolean("useMonochromeShader", false); }
public void setSolitaireBest(final String table, int score) { for (TableInfo ti : this.tables) { if (ti.getName().equals(table)) { ti.setHighScore(score); } } Preferences p = Gdx.app.getPreferences(PREFS_NAME); p.putInteger(table, score); p.flush(); }
private void initMusic() { music = AssetsLoader.getMusic(); boolean musicOn = preferences.getBoolean("musicOn", true); float musicVolume = preferences.getFloat("musicVolume", 1); music.setLooping(true); if (musicOn) { music.play(); } music.setVolume(musicVolume); }
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); } }
protected void loadAccessToken() { String token = preferences.getString("access_token", null); long expiresAt = preferences.getLong("expires_at", 0); if (token != null && expiresAt > 0) { Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Loaded existing accessToken: " + token); accessToken = new GDXFacebookAccessToken(token, expiresAt); } else { Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Could not load existing accessToken"); } }
private void initLabels() { Label.LabelStyle estilo = new Label.LabelStyle(); estilo.font = fonteTitulo; lbTitulo = new Label("SPACE INVADERS", estilo); palco.addActor(lbTitulo); Preferences preferencias = Gdx.app.getPreferences("SpaceInvaders"); int pontuacaoMaxima = preferencias.getInteger("pontuacao_maxima", 0); estilo = new Label.LabelStyle(); estilo.font = foneBotoes; lbPontuacao = new Label("Pontuação Máxima: " + pontuacaoMaxima + " Pontos", estilo); palco.addActor(lbPontuacao); }
public TestList() { setLayout(new BorderLayout()); final JList list = new JList(C2dTests.getNames()); final JButton button = new JButton("Run Test"); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m); list.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) button.doClick(); } }); final Preferences prefs = new LwjglPreferences( new FileHandle(new LwjglFiles().getExternalStoragePath() + ".prefs/c2d-tests")); list.setSelectedValue(prefs.getString("last", null), true); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String testName = (String) list.getSelectedValue(); Engine test = C2dTests.newTest(testName); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.fullscreen = false; config.width = (int) Engine.getWidth(); config.height = (int) Engine.getHeight(); config.title = testName; config.vSyncEnabled = true; prefs.putString("last", testName); prefs.flush(); new LwjglApplication(test, config); } }); add(pane, BorderLayout.CENTER); add(button, BorderLayout.SOUTH); }
public static void load() { texture = new Texture(Gdx.files.internal("data/texture.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); bg = new TextureRegion(texture, 0, 0, 136, 43); bg.flip(false, true); grass = new TextureRegion(texture, 0, 43, 143, 11); grass.flip(false, true); birdDown = new TextureRegion(texture, 136, 0, 17, 12); birdDown.flip(false, true); bird = new TextureRegion(texture, 153, 0, 17, 12); bird.flip(false, true); birdUp = new TextureRegion(texture, 170, 0, 17, 12); birdUp.flip(false, true); TextureRegion[] birds = {birdDown, bird, birdUp}; birdAnimation = new Animation(0.06f, birds); birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG); skullUp = new TextureRegion(texture, 192, 0, 24, 14); skullDown = new TextureRegion(skullUp); skullDown.flip(false, true); bar = new TextureRegion(texture, 136, 16, 22, 3); bar.flip(false, true); prefs = Gdx.app.getPreferences("ZombieBird"); if (!prefs.contains("highScore")) { prefs.putInteger("highScore", 0); } font = new BitmapFont(Gdx.files.internal("data/text.fnt")); shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt")); dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav")); flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav")); coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav")); }
public ScoresScreen(VeryAngryRobotsGame game) { super(game); scoreCam = CameraHelper.createCamera2( ViewportMode.PIXEL_PERFECT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, Assets.pixelDensity); spriteBatch = new SpriteBatch(); spriteBatch.setProjectionMatrix(scoreCam.combined); scoreString = new ScoreString(); topScoreString = new ScoreString(); preferences = Gdx.app.getPreferences(VERY_ANGRY_ROBOTS); topScore = preferences.getInteger(TOP_SCORE_PREF, 1000); topScoreString.setScore(topScore); stateTime = 0.0f; }
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(); }
public final void updateFontsProperties(String language) { Preferences fontPrefs = Gdx.app.getPreferences(propertyName); // store screen width for detecting screen fontSize change // on later startups, which will require font regeneration fontPrefs.putString("tag", versionTag); fontPrefs.putInteger("display-width", Gdx.graphics.getWidth()); fontPrefs.putInteger("display-height", Gdx.graphics.getHeight()); fontPrefs.putString("lang", language); fontPrefs.flush(); }
private Settings() { loadTables(); // NOTES: on desktop, file is store in /Users/[username]/.prefs/[name] Preferences p = Gdx.app.getPreferences(PREFS_NAME); if (p.contains("soundOn")) { this.soundOn = p.getBoolean("soundOn"); } if (p.contains("musicOn")) { this.musicOn = p.getBoolean("musicOn"); } if (p.contains("rulesEverSeen")) { this.rulesEverSeen = p.getBoolean("rulesEverSeen"); } // look for best scores on all of the tables // best score is stored as a key matching the map file for (TableInfo ti : this.tables) { if (p.contains(ti.getName())) { ti.setHighScore(p.getInteger(ti.getName())); } } }
public void saveState() { System.out.println("SAVE"); hasFlushed = false; int currentHighScore = prefs.getInteger("highscore"); prefs.clear(); for (int i = 0; i < grid.getBlocks().size; i++) { prefs.putFloat("x" + i, grid.getBlocks().get(i).getX()); prefs.putFloat("y" + i, grid.getBlocks().get(i).getY()); prefs.putFloat("val" + i, grid.getBlocks().get(i).getValue()); } prefs.putInteger("score", grid.getScore()); if (highScore >= currentHighScore) { prefs.putInteger("highscore", highScore); } else { prefs.putInteger("highscore", currentHighScore); } prefs.flush(); hasFlushed = true; }
public GameState(TitleState title) { this.title = title; this.title.reset(); prefs = Gdx.app.getPreferences("highscore"); adsController = MainGame.adsController; restartButton = new RestartButton(MainGame.WIDTH / 2 - 78, MainGame.HEIGHT / 2 - 100); menuButton = new MenuButton(MainGame.WIDTH / 2 - 125, MainGame.HEIGHT / 2); unpauseButton = new UnpauseButton(MainGame.WIDTH / 2 - 78, MainGame.HEIGHT / 2 + 100); highScore = prefs.getInteger("highscore", 0); gameOverOverlay = new Sprite(new Texture(Gdx.files.internal("gui/gameoverlay.png"))); gameOverOverlay.setPosition(0, MainGame.HEIGHT / 2 - (gameOverOverlay.getHeight() / 2)); backGroundFade = new Sprite(new Texture(Gdx.files.internal("gui/bgfade.png"))); backGroundFade.setPosition(0, 0); backGroundFade.setSize(MainGame.WIDTH, MainGame.HEIGHT); backGroundFade.setAlpha(0.6f); grid = new Grid(15, 15, 390, 390, prefs); parameter.size = 20; parameter.shadowColor = new Color(0, 0, 0, 1f); parameter.shadowOffsetX = 1; parameter.shadowOffsetY = 1; score = grid.getScore(); scoreFont = generator.generateFont(parameter); highscoreFont = generator.generateFont(parameter); redCounter = new Sprite(new Texture(Gdx.files.internal("gui/score/scorecounter.png"))); redCounter.setSize(144, 26.4f); redCounter.setPosition(18, MainGame.HEIGHT - redCounter.getHeight() - 260); blueCounter = new Sprite(new Texture(Gdx.files.internal("gui/score/highscorecounter.png"))); blueCounter.setSize(144, 26.4f); blueCounter.setPosition( MainGame.WIDTH - blueCounter.getWidth() - 18, MainGame.HEIGHT - blueCounter.getHeight() - 260); scoreFont.setColor(Color.WHITE); scoreFont.setFixedWidthGlyphs("0123456789"); highscoreFont.setFixedWidthGlyphs("0123456789"); grid.setPaused(false); }
public void setShowPing(boolean show) { preferences.putBoolean("showPing", show); preferences.flush(); }
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(); }
@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 boolean showFPS() { boolean getFps = preferences.getBoolean("showFPS", false); return getFps; }
public boolean showPing() { boolean getPing = preferences.getBoolean("showPing", true); return getPing; }