public String getActionForKeyBinding(KeyBinding kb) {
   Iterator it = this.keyBindingsActions.iterator();
   while (it.hasNext()) {
     KeyBindingAction keyBindingAction = (KeyBindingAction) it.next();
     if (keyBindingAction.getKeyBinding() != null
         && kb.isSameAs(keyBindingAction.getKeyBinding())) {
       if (isKeyBindingAvailable(keyBindingAction)) {
         return keyBindingAction.getAction();
       }
     }
   }
   return null;
 }
  /**
   * Loads the options from the options file. It appears that this has replaced the previous
   * 'loadOptions'
   */
  public void loadOptions() {
    try {
      if (!optionsFile.exists()) {
        return;
      }

      BufferedReader bufferedreader = new BufferedReader(new FileReader(optionsFile));

      for (String s = ""; (s = bufferedreader.readLine()) != null; ) {
        try {
          String as[] = s.split(":");

          if (as[0].equals("music")) {
            musicVolume = parseFloat(as[1]);
          }

          if (as[0].equals("sound")) {
            soundVolume = parseFloat(as[1]);
          }

          if (as[0].equals("mouseSensitivity")) {
            mouseSensitivity = parseFloat(as[1]);
          }

          if (as[0].equals("fov")) {
            fovSetting = parseFloat(as[1]);
          }

          if (as[0].equals("gamma")) {
            gammaSetting = parseFloat(as[1]);
          }

          if (as[0].equals("invertYMouse")) {
            invertMouse = as[1].equals("true");
          }

          if (as[0].equals("viewDistance")) {
            renderDistance = Integer.parseInt(as[1]);
          }

          if (as[0].equals("guiScale")) {
            guiScale = Integer.parseInt(as[1]);
          }

          if (as[0].equals("particles")) {
            particleSetting = Integer.parseInt(as[1]);
          }

          if (as[0].equals("bobView")) {
            viewBobbing = as[1].equals("true");
          }

          if (as[0].equals("anaglyph3d")) {
            anaglyph = as[1].equals("true");
          }

          if (as[0].equals("advancedOpengl")) {
            advancedOpengl = as[1].equals("true");
          }

          if (as[0].equals("fpsLimit")) {
            limitFramerate = Integer.parseInt(as[1]);
          }

          if (as[0].equals("difficulty")) {
            difficulty = Integer.parseInt(as[1]);
          }

          if (as[0].equals("fancyGraphics")) {
            fancyGraphics = as[1].equals("true");
          }

          if (as[0].equals("ao")) {
            ambientOcclusion = as[1].equals("true");
          }

          if (as[0].equals("clouds")) {
            clouds = as[1].equals("true");
          }

          if (as[0].equals("skin")) {
            skin = as[1];
          }

          if (as[0].equals("lastServer") && as.length >= 2) {
            lastServer = as[1];
          }

          if (as[0].equals("lang") && as.length >= 2) {
            language = as[1];
          }

          int i = 0;

          while (i < keyBindings.length) {
            if (as[0].equals(
                (new StringBuilder())
                    .append("key_")
                    .append(keyBindings[i].keyDescription)
                    .toString())) {
              keyBindings[i].keyCode = Integer.parseInt(as[1]);
            }

            i++;
          }
        } catch (Exception exception1) {
          System.out.println(
              (new StringBuilder()).append("Skipping bad option: ").append(s).toString());
        }
      }

      KeyBinding.resetKeyBindingArrayAndHash();
      bufferedreader.close();
    } catch (Exception exception) {
      System.out.println("Failed to load options");
      exception.printStackTrace();
    }
  }
Example #3
0
  /**
   * Loads the options from the options file. It appears that this has replaced the previous
   * 'loadOptions'
   */
  public void loadOptions() {
    try {
      if (!this.optionsFile.exists()) {
        return;
      }

      BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile));
      String var2 = "";

      while ((var2 = var1.readLine()) != null) {
        try {
          String[] var3 = var2.split(":");

          if (var3[0].equals("music")) {
            this.musicVolume = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("sound")) {
            this.soundVolume = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("mouseSensitivity")) {
            this.mouseSensitivity = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("fov")) {
            this.fovSetting = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("gamma")) {
            this.gammaSetting = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("invertYMouse")) {
            this.invertMouse = var3[1].equals("true");
          }

          if (var3[0].equals("viewDistance")) {
            this.renderDistance = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("guiScale")) {
            this.guiScale = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("particles")) {
            this.particleSetting = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("bobView")) {
            this.viewBobbing = var3[1].equals("true");
          }

          if (var3[0].equals("anaglyph3d")) {
            this.anaglyph = var3[1].equals("true");
          }

          if (var3[0].equals("advancedOpengl")) {
            this.advancedOpengl = var3[1].equals("true");
          }

          if (var3[0].equals("fpsLimit")) {
            this.limitFramerate = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("difficulty")) {
            this.difficulty = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("fancyGraphics")) {
            this.fancyGraphics = var3[1].equals("true");
          }

          if (var3[0].equals("ao")) {
            if (var3[1].equals("true")) {
              this.ambientOcclusion = 2;
            } else if (var3[1].equals("false")) {
              this.ambientOcclusion = 0;
            } else {
              this.ambientOcclusion = Integer.parseInt(var3[1]);
            }
          }

          if (var3[0].equals("clouds")) {
            this.clouds = var3[1].equals("true");
          }

          if (var3[0].equals("skin")) {
            this.skin = var3[1];
          }

          if (var3[0].equals("lastServer") && var3.length >= 2) {
            this.lastServer = var2.substring(var2.indexOf(58) + 1);
          }

          if (var3[0].equals("lang") && var3.length >= 2) {
            this.language = var3[1];
          }

          if (var3[0].equals("chatVisibility")) {
            this.chatVisibility = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("chatColors")) {
            this.chatColours = var3[1].equals("true");
          }

          if (var3[0].equals("chatLinks")) {
            this.chatLinks = var3[1].equals("true");
          }

          if (var3[0].equals("chatLinksPrompt")) {
            this.chatLinksPrompt = var3[1].equals("true");
          }

          if (var3[0].equals("chatOpacity")) {
            this.chatOpacity = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("serverTextures")) {
            this.serverTextures = var3[1].equals("true");
          }

          if (var3[0].equals("snooperEnabled")) {
            this.snooperEnabled = var3[1].equals("true");
          }

          if (var3[0].equals("fullscreen")) {
            this.fullScreen = var3[1].equals("true");
          }

          if (var3[0].equals("enableVsync")) {
            this.enableVsync = var3[1].equals("true");
          }

          if (var3[0].equals("hideServerAddress")) {
            this.hideServerAddress = var3[1].equals("true");
          }

          if (var3[0].equals("advancedItemTooltips")) {
            this.advancedItemTooltips = var3[1].equals("true");
          }

          if (var3[0].equals("pauseOnLostFocus")) {
            this.pauseOnLostFocus = var3[1].equals("true");
          }

          if (var3[0].equals("showCape")) {
            this.showCape = var3[1].equals("true");
          }

          if (var3[0].equals("touchscreen")) {
            this.touchscreen = var3[1].equals("true");
          }

          if (var3[0].equals("overrideHeight")) {
            this.overrideHeight = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("overrideWidth")) {
            this.overrideWidth = Integer.parseInt(var3[1]);
          }

          if (var3[0].equals("heldItemTooltips")) {
            this.heldItemTooltips = var3[1].equals("true");
          }

          if (var3[0].equals("chatHeightFocused")) {
            this.chatHeightFocused = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("chatHeightUnfocused")) {
            this.chatHeightUnfocused = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("chatScale")) {
            this.chatScale = this.parseFloat(var3[1]);
          }

          if (var3[0].equals("chatWidth")) {
            this.chatWidth = this.parseFloat(var3[1]);
          }

          for (int var4 = 0; var4 < this.keyBindings.length; ++var4) {
            if (var3[0].equals("key_" + this.keyBindings[var4].keyDescription)) {
              this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]);
            }
          }
          // Spout Start
          for (int key = 0; key < this.spoutcraftBindings.length; ++key) {
            if (var3[0].equals("key_" + this.spoutcraftBindings[key].keyDescription)) {
              this.spoutcraftBindings[key].keyCode = Integer.parseInt(var3[1]);
            }
          }
          // Spout End
        } catch (Exception var5) {
          this.mc.getLogAgent().logWarning("Skipping bad option: " + var2);
        }
      }

      KeyBinding.resetKeyBindingArrayAndHash();
      var1.close();
    } catch (Exception var6) {
      this.mc.getLogAgent().logWarning("Failed to load options");
      var6.printStackTrace();
    }
  }