Beispiel #1
0
  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();
    }
  }
Beispiel #2
0
  @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);
  }
Beispiel #3
0
  @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();
    }
  }
  public static void setDistance(float dist) {
    distTemp = score.getFloat("distance");
    distTemp = distTemp + dist;

    score.putFloat("distance", distTemp);
    score.flush();
  }
  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);
      }
    }
  }
 public void setScore(int score) {
   scoreString.setScore(score);
   if (score > topScore) {
     topScore = score;
     preferences.putInteger(TOP_SCORE_PREF, topScore);
     preferences.flush();
     topScoreString.setScore(score);
   }
 }
Beispiel #7
0
  @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);
      // }
      // });
    }
  }
Beispiel #8
0
 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();
 }
  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();
  }
Beispiel #10
0
  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);
    }
  }
Beispiel #11
0
 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();
 }
Beispiel #12
0
  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;
  }
Beispiel #13
0
 public static void setHighScore(float score) {
   options.putFloat("highscore", score);
   options.flush();
 }
Beispiel #14
0
 public void setShowPing(boolean show) {
   preferences.putBoolean("showPing", show);
   preferences.flush();
 }
Beispiel #15
0
 public void setMusicVolume(float volume) {
   preferences.putFloat("musicVolume", volume);
   preferences.flush();
   music.setVolume(volume);
 }
Beispiel #16
0
 public void musicResume() {
   preferences.putBoolean("musicOn", true);
   preferences.flush();
   music.play();
 }
Beispiel #17
0
 private static void save() {
   prefs.flush();
 }
Beispiel #18
0
 public void toggleSound() {
   this.soundOn = !this.soundOn;
   Preferences p = Gdx.app.getPreferences(PREFS_NAME);
   p.putBoolean("soundOn", this.soundOn);
   p.flush();
 }
Beispiel #19
0
  @Override
  public void update(float dt) {
    if (!paused) {
      handleInput();
      if (!readyToFadeWhite) player.update(dt); // So player can be controlled upward from Sky
      else {
        // Lift player
        whiteOverlay += .3f * dt;
        player.getVelocity().add(0, -player.gravity / 2);
        player.getVelocity().scl(dt);
        player.getPosition().add(player.movement * dt, player.getVelocity().y);
        player.getVelocity().scl(1 / dt);
        float temp =
            player.normalize(
                -450, 200, (float) -Math.PI / 4f, (float) Math.PI / 4f, player.getVelocity().y);
        player.rotation = 25 * (float) Math.sin(temp);
        if (whiteOverlay > 1f) {
          dispose();
          Preferences p = Gdx.app.getPreferences(OwlCityTribute.GAME_PREFS);
          p.putInteger("level", 5);
          if (p.getInteger("maxlevel") < 5) {
            p.putInteger("maxlevel", 5);
          }
          p.flush();
          gsm.currentState = GameStateManager.SKY;
          this.gsm.setState(new Sky(this.gsm));
        }
      }
      fallen = player.getPosition().y == -OwlCityTribute.HEIGHT * .1f;

      if (!loss && fallen) {
        loss = true;
        gsm.push(new UponLoss(gsm));
      }

      note.update(dt);
      noteAnim.update(dt);
      noteRotation += 100f * dt;
      if (noteRotation > 360) noteRotation = 0;

      balloonFluctuation.update(dt);

      cam.position.x = player.getPosition().x + player.xOffset;
      float leftEdge = player.getPosition().x - (cam.viewportWidth / 2) + player.xOffset;

      // Check if note is hit
      if (!shrinking
          && Math.sqrt(
                  Math.pow(
                          (player.getPosition().x + player.getPlane().getWidth() * .75f)
                              - note.getPosition().x,
                          2)
                      + Math.pow(
                          (player.getPosition().y + (player.getPlane().getHeight() * .75f) / 2)
                              - (note.getPosition().y + noteAnim.getFrame().getRegionHeight() / 2),
                          2))
              < 40) {
        // Open textbox
        textCount++;
        textBox.prepare(
            sceneText.get(textCount).get(0),
            (sceneText.get(textCount).size() == 1) ? "" : sceneText.get(textCount).get(1),
            .1f);
        boxInitialized = true;

        // Set bounds
        int w = (int) font.getBounds(sceneText.get(textCount).get(0)).width;
        // int h = (int)(font.getBounds(sceneText.get(textCount).get(0)).height*2.5);
        int h =
            (int)
                (font.getBounds(sceneText.get(textCount).get(0)).height
                    * sceneText.get(textCount).size()
                    * 1.5);
        textBox.setBounds(
            w,
            h,
            (int) (OwlCityTribute.WIDTH * .65) - w / 2,
            (int) (OwlCityTribute.HEIGHT * .875) - h / 2);
        waiting = true;
        shrinking = true;
      } else if (note.getPosition().x < leftEdge - noteAnim.getFrame().getRegionWidth()
          && !waiting
          && textCount < sceneText.size() - 1
          && player.movement > player.maxMovement * .75) {
        note.getPosition().x = player.getPosition().x + cam.viewportWidth;
        note.setyOffset((int) (Math.random() * 100) + 200);
      }

      if (shrinking) {
        noteScale -= 2.5 * dt;
        if (noteScale < 0) {
          shrinking = false;
          noteScale = 1f;
          note.getPosition().x -= cam.viewportWidth;
        }
      }

      if (textBox.readyToUpdate) {
        if (!textBox.update(dt)) waiting = true;
        else {
          waiting = false;
          if (textCount < sceneText.size() - 1 && player.movement > player.maxMovement * .75) {
            note.getPosition().x = player.getPosition().x + cam.viewportWidth;
            note.setyOffset((int) (Math.random() * 100) + 200);
          }
        }
      }

      if (!fallen && boxInitialized && textCount == sceneText.size() - 1 && textBox.finished) {
        readyToFadeWhite = true;
      }

      // clouds
      for (int i = 0; i < clouds.size; i++) {
        clouds.get(i).update(dt);
        if (clouds.get(i).getPosition().x < leftEdge - cloud.getWidth()) {
          int index = (i == 0) ? clouds.size - 1 : i - 1;
          clouds.get(i).getPosition().x =
              (float) (clouds.get(index).getPosition().x + cam.viewportWidth * .8);
          clouds.get(i).yOffset =
              random.nextInt((int) (OwlCityTribute.HEIGHT * .1f))
                  + (int) (OwlCityTribute.HEIGHT * .75f);
        }
      }

      //        if(readyToFadeBlack){
      //            whiteValue  = (whiteValue > 0) ? whiteValue - .2f*dt : 0f;
      //            if(whiteValue == 0f){
      //                if(player.getPosition().y == -OwlCityTribute.HEIGHT*.1f){
      //                    dispose();
      //                    this.gsm.setState(new Sky(this.gsm));
      //                }
      //            }
      //        }
      // else{
      whiteValue = (whiteValue < 1f) ? whiteValue + .4f * dt : 1f;
      // }

      // Shimmer update
      for (int i = 0; i < NUM_SHIMMERS; i++) {
        shimmers.get(i).update(dt);
      }

      // Check brush
      for (int i = 0; i < brushmoving.size; i++) {
        brushmoving.get(i).MOVEMENT = -(player.movement / 5);
        brushmoving.get(i).update(dt);
        if (brushmoving.get(i).getPosition().x < leftEdge - brush.getWidth() * 1.5) {
          int index = (i == 0) ? brushmoving.size - 1 : i - 1;
          brushmoving.get(i).getPosition().x =
              brushmoving.get(index).getPosition().x + brush.getWidth();
          break;
        }
      }

      cam.update();
    }
  }
Beispiel #20
0
 public static void setIntroSkippable(boolean skippable) {
   options.putBoolean("introskip", skippable);
   options.flush();
 }
Beispiel #21
0
 public static void setHighScore(float val) {
   score.putFloat("highScore", val);
   score.flush();
 }
Beispiel #22
0
 public void saveFavorites(Array<FileHandle> favorites) {
   prefs.putString(keyName, json.toJson(new FavouriteData(favorites)));
   prefs.flush();
 }
Beispiel #23
0
 // Receives an integer and maps it to the String highScore in prefs
 public static void setHighScore(int val) {
   prefs.putInteger("highScore", val);
   prefs.flush();
 }
  public void touched(float x, float y) {

    if (menuNumber == this.MENU_SPLASH) // splash
    {
      this.isSplash = false;
      try {
        System.out.println("Trying to get the prefs to login");
        Preferences prefs = Gdx.app.getPreferences("LOGIN");
        String username = prefs.getString("USERNAME_HASHED");
        String password = prefs.getString("PASSWORD_HASHED");
        if (username.length() > 0 && password.length() > 0) {
          System.out.println("gonna log in with " + username + " " + password);
          this.processSignInHASHED(
              username,
              password); // this should do the this.welcome at the end of it, so this should be ok.
        } else {
          this
              .signIn(); // if they are there, but they are length 0 cause they have logged out
                         // before.
        }
      } catch (Exception e) {
        System.out.println("ERROR: " + e);
        System.out.println("nope, going to sign in instead");
        this.signIn();
      }

    } else if (menuNumber == this.MENU_SIGNIN) // sign in
    {

      if (menuComponents.get(0).containsXY(x, y)) // LETS GO
      {
        menuComponents.get(0).texture = Assets.menuButtonSmallDarkRegion;
        this.processSignIn(
            menuTextFields.get("usernameTF").getText(), menuTextFields.get("passwordTF").getText());
      } else if (menuComponents.get(1).containsXY(x, y)) // SIGN UP
      {
        menuComponents.get(1).texture = Assets.menuButtonSmallDarkRegion;
        this.signUp();
      } else if (menuComponents.get(2).containsXY(x, y)) // shortcut to sign in as spence95
      {
        this.processSignIn("spence95", "abc");
      }

    } else if (menuNumber == this.MENU_WELCOME) // welcome
    {
      this.mainMenu();
    } else if (menuNumber == this.MENU_SIGNUP) // signup
    {

      if (menuComponents.get(0).containsXY(x, y)) // submit
      {
        // this.processSignUp(menuTextFields.get("usernameTF").getText(),
        // menuTextFields.get("passwordTF").getText(), menuTextFields.get("emailTF").getText(),
        // charityID);
        this.processSignUp(
            menuTextFields.get("usernameTF").getText(),
            menuTextFields.get("passwordTF").getText(),
            "",
            charityID);

        this.processSignIn(
            menuTextFields.get("usernameTF").getText(), menuTextFields.get("passwordTF").getText());
      } else if (menuComponents.get(1).containsXY(x, y)) // return
      {
        this.splash();
      }

    } else if (menuNumber == this.MENU_MAINMENU) // main menu
    {
      if (menuComponents.get(0).containsXY(x, y)) // play!
      {
        // goes to lobby (loading), lobby goes to game when ready
        this.pickClass();
        // game.setScreen(new LobbyScreen(game));
      } else if (menuComponents.get(1).containsXY(x, y)) // oiptions buttons
      {
        System.out.println("options clicked");
        this.options();

      } else if (menuComponents.get(2).containsXY(x, y)) // profile button
      {
        System.out.println("profile clicked");
      }

    } else if (menuNumber == this.MENU_OPTIONS) // options
    {
      if (menuComponents.get(0).containsXY(x, y)) // return button
      {
        this.mainMenu();
      } else if (menuComponents.get(4).containsXY(x, y)) // log out button
      {
        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.splash();
      }
    } else if (menuNumber == this.MENU_GAMEOVER) // game over
    {
      this.mainMenu();
    } else if (menuNumber == this.MENU_PICK_CLASS) {
      if (menuComponents.get(0).containsXY(x, y)) // continue
      {
        game.setScreen(new LobbyScreen(game, "Rocketman"));
      } else if (menuComponents.get(1).containsXY(x, y)) // return
      {
        this.mainMenu();
      }
    }
  }
Beispiel #25
0
 protected void storeNewToken(GDXFacebookAccessToken token) {
   Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Storing new accessToken: " + token.getToken());
   preferences.putString("access_token", token.getToken());
   preferences.putLong("expires_at", token.getExpiresAt());
   preferences.flush();
 }
  void loadSkeleton(final FileHandle skeletonFile) {
    if (skeletonFile == null) return;

    try {
      // Setup a texture atlas that uses a white image for images not found in the atlas.
      Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
      pixmap.setColor(new Color(1, 1, 1, 0.33f));
      pixmap.fill();
      final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
      pixmap.dispose();

      String atlasFileName = skeletonFile.nameWithoutExtension();
      if (atlasFileName.endsWith(".json"))
        atlasFileName = new FileHandle(atlasFileName).nameWithoutExtension();
      FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas");
      if (!atlasFile.exists()) atlasFile = skeletonFile.sibling(atlasFileName + ".atlas.txt");
      TextureAtlasData data =
          !atlasFile.exists() ? null : new TextureAtlasData(atlasFile, atlasFile.parent(), false);
      TextureAtlas atlas =
          new TextureAtlas(data) {
            public AtlasRegion findRegion(String name) {
              AtlasRegion region = super.findRegion(name);
              if (region == null) {
                // Look for separate image file.
                FileHandle file = skeletonFile.sibling(name + ".png");
                if (file.exists()) {
                  Texture texture = new Texture(file);
                  texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
                  region = new AtlasRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
                  region.name = name;
                }
              }
              return region != null ? region : fake;
            }
          };

      // Load skeleton data.
      String extension = skeletonFile.extension();
      if (extension.equalsIgnoreCase("json") || extension.equalsIgnoreCase("txt")) {
        SkeletonJson json = new SkeletonJson(atlas);
        json.setScale(ui.scaleSlider.getValue());
        skeletonData = json.readSkeletonData(skeletonFile);
      } else {
        SkeletonBinary binary = new SkeletonBinary(atlas);
        binary.setScale(ui.scaleSlider.getValue());
        skeletonData = binary.readSkeletonData(skeletonFile);
        if (skeletonData.getBones().size == 0) throw new Exception("No bones in skeleton data.");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      ui.toast("Error loading skeleton: " + skeletonFile.name());
      lastModifiedCheck = 5;
      return;
    }

    skeleton = new Skeleton(skeletonData);
    skeleton.setToSetupPose();
    skeleton = new Skeleton(skeleton); // Tests copy constructors.
    skeleton.updateWorldTransform();

    state = new AnimationState(new AnimationStateData(skeletonData));
    state.addListener(
        new AnimationStateAdapter() {
          public void event(TrackEntry entry, Event event) {
            ui.toast(event.getData().getName());
          }
        });

    this.skeletonFile = skeletonFile;
    prefs.putString("lastFile", skeletonFile.path());
    prefs.flush();
    lastModified = skeletonFile.lastModified();
    lastModifiedCheck = checkModifiedInterval;

    // Populate UI.

    ui.window.getTitleLabel().setText(skeletonFile.name());
    {
      Array<String> items = new Array();
      for (Skin skin : skeletonData.getSkins()) items.add(skin.getName());
      ui.skinList.setItems(items);
    }
    {
      Array<String> items = new Array();
      for (Animation animation : skeletonData.getAnimations()) items.add(animation.getName());
      ui.animationList.setItems(items);
    }
    ui.trackButtons.getButtons().first().setChecked(true);

    // Configure skeleton from UI.

    if (ui.skinList.getSelected() != null) skeleton.setSkin(ui.skinList.getSelected());
    setAnimation();

    // ui.animationList.clearListeners();
    // state.setAnimation(0, "walk", true);
  }
Beispiel #27
0
 public void rulesViewed() {
   this.rulesEverSeen = true;
   Preferences p = Gdx.app.getPreferences(PREFS_NAME);
   p.putBoolean("rulesEverSeen", this.rulesEverSeen);
   p.flush();
 }
Beispiel #28
0
 public void musicPause() {
   preferences.putBoolean("musicOn", false);
   preferences.flush();
   music.pause();
 }
Beispiel #29
0
 public void toggleMusic() {
   this.musicOn = !this.musicOn;
   Preferences p = Gdx.app.getPreferences(PREFS_NAME);
   p.putBoolean("musicOn", this.musicOn);
   p.flush();
 }
Beispiel #30
0
 public final void deleteTokenData() {
   preferences.remove("access_token");
   preferences.remove("expires_at");
   preferences.flush();
 }