Advertisement
AcidLizard11

GameSettings.java

Sep 9th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.22 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.FileReader;
  6. import java.io.FileWriter;
  7. import java.io.PrintWriter;
  8. import org.lwjgl.input.Keyboard;
  9. import org.lwjgl.input.Mouse;
  10. import org.lwjgl.opengl.Display;
  11.  
  12. public class GameSettings
  13. {
  14. private static final String[] RENDER_DISTANCES = new String[] {"options.renderDistance.far", "options.renderDistance.normal", "options.renderDistance.short", "options.renderDistance.tiny"};
  15. private static final String[] DIFFICULTIES = new String[] {"options.difficulty.peaceful", "options.difficulty.easy", "options.difficulty.normal", "options.difficulty.hard"};
  16.  
  17. /** GUI scale values */
  18. private static final String[] GUISCALES = new String[] {"options.guiScale.auto", "options.guiScale.small", "options.guiScale.normal", "options.guiScale.large"};
  19. private static final String[] CHAT_VISIBILITIES = new String[] {"options.chat.visibility.full", "options.chat.visibility.system", "options.chat.visibility.hidden"};
  20. private static final String[] PARTICLES = new String[] {"options.particles.all", "options.particles.decreased", "options.particles.minimal"};
  21.  
  22. /** Limit framerate labels */
  23. private static final String[] LIMIT_FRAMERATES = new String[] {"performance.max", "performance.balanced", "performance.powersaver"};
  24. private static final String[] AMBIENT_OCCLUSIONS = new String[] {"options.ao.off", "options.ao.min", "options.ao.max"};
  25. public float musicVolume = 1.0F;
  26. public float soundVolume = 1.0F;
  27. public float mouseSensitivity = 0.5F;
  28. public boolean invertMouse;
  29. public int renderDistance;
  30. public boolean viewBobbing = true;
  31. public boolean anaglyph;
  32.  
  33. /** Advanced OpenGL */
  34. public boolean advancedOpengl;
  35. public int limitFramerate = 1;
  36. public boolean fancyGraphics = true;
  37.  
  38. /** Smooth Lighting */
  39. public int ambientOcclusion = 2;
  40.  
  41. /** Clouds flag */
  42. public boolean clouds = true;
  43.  
  44. /** The name of the selected texture pack. */
  45. public String skin = "Default";
  46. public int chatVisibility;
  47. public boolean chatColours = true;
  48. public boolean chatLinks = true;
  49. public boolean chatLinksPrompt = true;
  50. public float chatOpacity = 1.0F;
  51. public boolean serverTextures = true;
  52. public boolean snooperEnabled = true;
  53. public boolean fullScreen;
  54. public boolean enableVsync = true;
  55. public boolean hideServerAddress;
  56.  
  57. /**
  58. * Whether to show advanced information on item tooltips, toggled by F3+H
  59. */
  60. public boolean advancedItemTooltips;
  61.  
  62. /** Whether to pause when the game loses focus, toggled by F3+P */
  63. public boolean pauseOnLostFocus = true;
  64.  
  65. /** Whether to show your cape */
  66. public boolean showCape = true;
  67. public boolean touchscreen;
  68. public int overrideWidth;
  69. public int overrideHeight;
  70. public boolean heldItemTooltips = true;
  71. public float chatScale = 1.0F;
  72. public float chatWidth = 1.0F;
  73. public float chatHeightUnfocused = 0.44366196F;
  74. public float chatHeightFocused = 1.0F;
  75. public KeyBinding keyBindForward = new KeyBinding("key.forward", 17);
  76. public KeyBinding keyBindLeft = new KeyBinding("key.left", 30);
  77. public KeyBinding keyBindBack = new KeyBinding("key.back", 31);
  78. public KeyBinding keyBindRight = new KeyBinding("key.right", 32);
  79. public KeyBinding keyBindJump = new KeyBinding("key.jump", 57);
  80. public KeyBinding keyBindInventory = new KeyBinding("key.inventory", 18);
  81. public KeyBinding keyBindDrop = new KeyBinding("key.drop", 16);
  82. public KeyBinding keyBindChat = new KeyBinding("key.chat", 20);
  83. public KeyBinding keyBindSneak = new KeyBinding("key.sneak", 42);
  84. public KeyBinding keyBindAttack = new KeyBinding("key.attack", -100);
  85. public KeyBinding keyBindUseItem = new KeyBinding("key.use", -99);
  86. public KeyBinding keyBindPlayerList = new KeyBinding("key.playerlist", 15);
  87. public KeyBinding keyBindPickBlock = new KeyBinding("key.pickItem", -98);
  88. public KeyBinding keyBindCommand = new KeyBinding("key.command", 53);
  89. public KeyBinding[] keyBindings;
  90. protected Minecraft mc;
  91. private File optionsFile;
  92. public int difficulty;
  93. public boolean hideGUI;
  94. public int thirdPersonView;
  95.  
  96. /** true if debug info should be displayed instead of version */
  97. public boolean showDebugInfo;
  98. public boolean showDebugProfilerChart;
  99.  
  100. /** The lastServer string. */
  101. public String lastServer;
  102.  
  103. /** No clipping for singleplayer */
  104. public boolean noclip;
  105.  
  106. /** Smooth Camera Toggle */
  107. public boolean smoothCamera;
  108. public boolean debugCamEnable;
  109.  
  110. /** No clipping movement rate */
  111. public float noclipRate;
  112.  
  113. /** Change rate for debug camera */
  114. public float debugCamRate;
  115. public float fovSetting;
  116. public float gammaSetting;
  117.  
  118. /** GUI scale */
  119. public int guiScale;
  120.  
  121. /** Determines amount of particles. 0 = All, 1 = Decreased, 2 = Minimal */
  122. public int particleSetting;
  123.  
  124. /** Game settings language */
  125. public String language;
  126. public int ofRenderDistanceFine;
  127.  
  128. public GameSettings(Minecraft par1Minecraft, File par2File)
  129. {
  130. this.keyBindings = new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand};
  131. this.difficulty = 2;
  132. this.lastServer = "";
  133. this.noclipRate = 1.0F;
  134. this.debugCamRate = 1.0F;
  135. this.language = "en_US";
  136. this.mc = par1Minecraft;
  137. this.optionsFile = new File(par2File, "options.txt");
  138. this.loadOptions();
  139. }
  140.  
  141. public GameSettings()
  142. {
  143. this.keyBindings = new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand};
  144. this.difficulty = 2;
  145. this.lastServer = "";
  146. this.noclipRate = 1.0F;
  147. this.debugCamRate = 1.0F;
  148. this.language = "en_US";
  149. }
  150.  
  151. public String getKeyBindingDescription(int par1)
  152. {
  153. return I18n.func_135053_a(this.keyBindings[par1].keyDescription);
  154. }
  155.  
  156. /**
  157. * The string that appears inside the button/slider in the options menu.
  158. */
  159. public String getOptionDisplayString(int par1)
  160. {
  161. int var2 = this.keyBindings[par1].keyCode;
  162. return getKeyDisplayString(var2);
  163. }
  164.  
  165. /**
  166. * Represents a key or mouse button as a string. Args: key
  167. */
  168. public static String getKeyDisplayString(int par0)
  169. {
  170. return par0 < 0 ? I18n.func_135052_a("key.mouseButton", new Object[] {Integer.valueOf(par0 + 101)}): Keyboard.getKeyName(par0);
  171. }
  172.  
  173. /**
  174. * Returns whether the specified key binding is currently being pressed.
  175. */
  176. public static boolean isKeyDown(KeyBinding par0KeyBinding)
  177. {
  178. return par0KeyBinding.keyCode < 0 ? Mouse.isButtonDown(par0KeyBinding.keyCode + 100) : Keyboard.isKeyDown(par0KeyBinding.keyCode);
  179. }
  180.  
  181. /**
  182. * Sets a key binding.
  183. */
  184. public void setKeyBinding(int par1, int par2)
  185. {
  186. this.keyBindings[par1].keyCode = par2;
  187. this.saveOptions();
  188. }
  189.  
  190. /**
  191. * If the specified option is controlled by a slider (float value), this will set the float value.
  192. */
  193. public void setOptionFloatValue(EnumOptions par1EnumOptions, float par2)
  194. {
  195. if (par1EnumOptions == EnumOptions.MUSIC)
  196. {
  197. this.musicVolume = par2;
  198. this.mc.sndManager.onSoundOptionsChanged();
  199. }
  200.  
  201. if (par1EnumOptions == EnumOptions.SOUND)
  202. {
  203. this.soundVolume = par2;
  204. this.mc.sndManager.onSoundOptionsChanged();
  205. }
  206.  
  207. if (par1EnumOptions == EnumOptions.SENSITIVITY)
  208. {
  209. this.mouseSensitivity = par2;
  210. }
  211.  
  212. if (par1EnumOptions == EnumOptions.FOV)
  213. {
  214. this.fovSetting = par2;
  215. }
  216.  
  217. if (par1EnumOptions == EnumOptions.GAMMA)
  218. {
  219. this.gammaSetting = par2;
  220. }
  221.  
  222. if (par1EnumOptions == EnumOptions.CHAT_OPACITY)
  223. {
  224. this.chatOpacity = par2;
  225. this.mc.ingameGUI.getChatGUI().func_96132_b();
  226. }
  227.  
  228. if (par1EnumOptions == EnumOptions.CHAT_HEIGHT_FOCUSED)
  229. {
  230. this.chatHeightFocused = par2;
  231. this.mc.ingameGUI.getChatGUI().func_96132_b();
  232. }
  233.  
  234. if (par1EnumOptions == EnumOptions.CHAT_HEIGHT_UNFOCUSED)
  235. {
  236. this.chatHeightUnfocused = par2;
  237. this.mc.ingameGUI.getChatGUI().func_96132_b();
  238. }
  239.  
  240. if (par1EnumOptions == EnumOptions.CHAT_WIDTH)
  241. {
  242. this.chatWidth = par2;
  243. this.mc.ingameGUI.getChatGUI().func_96132_b();
  244. }
  245.  
  246. if (par1EnumOptions == EnumOptions.CHAT_SCALE)
  247. {
  248. this.chatScale = par2;
  249. this.mc.ingameGUI.getChatGUI().func_96132_b();
  250. }
  251. }
  252.  
  253. /**
  254. * For non-float options. Toggles the option on/off, or cycles through the list i.e. render distances.
  255. */
  256. public void setOptionValue(EnumOptions par1EnumOptions, int par2)
  257. {
  258. if (par1EnumOptions == EnumOptions.INVERT_MOUSE)
  259. {
  260. this.invertMouse = !this.invertMouse;
  261. }
  262.  
  263. if (par1EnumOptions == EnumOptions.RENDER_DISTANCE)
  264. {
  265. this.renderDistance = this.renderDistance + par2 & 3;
  266. }
  267.  
  268. if (par1EnumOptions == EnumOptions.GUI_SCALE)
  269. {
  270. this.guiScale = this.guiScale + par2 & 3;
  271. }
  272.  
  273. if (par1EnumOptions == EnumOptions.PARTICLES)
  274. {
  275. this.particleSetting = (this.particleSetting + par2) % 3;
  276. }
  277.  
  278. if (par1EnumOptions == EnumOptions.VIEW_BOBBING)
  279. {
  280. this.viewBobbing = !this.viewBobbing;
  281. }
  282.  
  283. if (par1EnumOptions == EnumOptions.RENDER_CLOUDS)
  284. {
  285. this.clouds = !this.clouds;
  286. }
  287.  
  288. if (par1EnumOptions == EnumOptions.ADVANCED_OPENGL)
  289. {
  290. this.advancedOpengl = !this.advancedOpengl;
  291. this.mc.renderGlobal.loadRenderers();
  292. }
  293.  
  294. if (par1EnumOptions == EnumOptions.ANAGLYPH)
  295. {
  296. this.anaglyph = !this.anaglyph;
  297. this.mc.func_110436_a();
  298. }
  299.  
  300. if (par1EnumOptions == EnumOptions.FRAMERATE_LIMIT)
  301. {
  302. this.limitFramerate = (this.limitFramerate + par2 + 3) % 3;
  303. }
  304.  
  305. if (par1EnumOptions == EnumOptions.DIFFICULTY)
  306. {
  307. this.difficulty = this.difficulty + par2 & 3;
  308. }
  309.  
  310. if (par1EnumOptions == EnumOptions.GRAPHICS)
  311. {
  312. this.fancyGraphics = !this.fancyGraphics;
  313. this.mc.renderGlobal.loadRenderers();
  314. }
  315.  
  316. if (par1EnumOptions == EnumOptions.AMBIENT_OCCLUSION)
  317. {
  318. this.ambientOcclusion = (this.ambientOcclusion + par2) % 3;
  319. this.mc.renderGlobal.loadRenderers();
  320. }
  321.  
  322. if (par1EnumOptions == EnumOptions.CHAT_VISIBILITY)
  323. {
  324. this.chatVisibility = (this.chatVisibility + par2) % 3;
  325. }
  326.  
  327. if (par1EnumOptions == EnumOptions.CHAT_COLOR)
  328. {
  329. this.chatColours = !this.chatColours;
  330. }
  331.  
  332. if (par1EnumOptions == EnumOptions.CHAT_LINKS)
  333. {
  334. this.chatLinks = !this.chatLinks;
  335. }
  336.  
  337. if (par1EnumOptions == EnumOptions.CHAT_LINKS_PROMPT)
  338. {
  339. this.chatLinksPrompt = !this.chatLinksPrompt;
  340. }
  341.  
  342. if (par1EnumOptions == EnumOptions.USE_SERVER_TEXTURES)
  343. {
  344. this.serverTextures = !this.serverTextures;
  345. }
  346.  
  347. if (par1EnumOptions == EnumOptions.SNOOPER_ENABLED)
  348. {
  349. this.snooperEnabled = !this.snooperEnabled;
  350. }
  351.  
  352. if (par1EnumOptions == EnumOptions.SHOW_CAPE)
  353. {
  354. this.showCape = !this.showCape;
  355. }
  356.  
  357. if (par1EnumOptions == EnumOptions.TOUCHSCREEN)
  358. {
  359. this.touchscreen = !this.touchscreen;
  360. }
  361.  
  362. if (par1EnumOptions == EnumOptions.USE_FULLSCREEN)
  363. {
  364. this.fullScreen = !this.fullScreen;
  365.  
  366. if (this.mc.isFullScreen() != this.fullScreen)
  367. {
  368. this.mc.toggleFullscreen();
  369. }
  370. }
  371.  
  372. if (par1EnumOptions == EnumOptions.ENABLE_VSYNC)
  373. {
  374. this.enableVsync = !this.enableVsync;
  375. Display.setVSyncEnabled(this.enableVsync);
  376. }
  377.  
  378. this.saveOptions();
  379. }
  380.  
  381. public float getOptionFloatValue(EnumOptions par1EnumOptions)
  382. {
  383. return par1EnumOptions == EnumOptions.FOV ? this.fovSetting : (par1EnumOptions == EnumOptions.GAMMA ? this.gammaSetting : (par1EnumOptions == EnumOptions.MUSIC ? this.musicVolume : (par1EnumOptions == EnumOptions.SOUND ? this.soundVolume : (par1EnumOptions == EnumOptions.SENSITIVITY ? this.mouseSensitivity : (par1EnumOptions == EnumOptions.CHAT_OPACITY ? this.chatOpacity : (par1EnumOptions == EnumOptions.CHAT_HEIGHT_FOCUSED ? this.chatHeightFocused : (par1EnumOptions == EnumOptions.CHAT_HEIGHT_UNFOCUSED ? this.chatHeightUnfocused : (par1EnumOptions == EnumOptions.CHAT_SCALE ? this.chatScale : (par1EnumOptions == EnumOptions.CHAT_WIDTH ? this.chatWidth : 0.0F)))))))));
  384. }
  385.  
  386. public boolean getOptionOrdinalValue(EnumOptions par1EnumOptions)
  387. {
  388. switch (EnumOptionsHelper.enumOptionsMappingHelperArray[par1EnumOptions.ordinal()])
  389. {
  390. case 1:
  391. return this.invertMouse;
  392.  
  393. case 2:
  394. return this.viewBobbing;
  395.  
  396. case 3:
  397. return this.anaglyph;
  398.  
  399. case 4:
  400. return this.advancedOpengl;
  401.  
  402. case 5:
  403. return this.clouds;
  404.  
  405. case 6:
  406. return this.chatColours;
  407.  
  408. case 7:
  409. return this.chatLinks;
  410.  
  411. case 8:
  412. return this.chatLinksPrompt;
  413.  
  414. case 9:
  415. return this.serverTextures;
  416.  
  417. case 10:
  418. return this.snooperEnabled;
  419.  
  420. case 11:
  421. return this.fullScreen;
  422.  
  423. case 12:
  424. return this.enableVsync;
  425.  
  426. case 13:
  427. return this.showCape;
  428.  
  429. case 14:
  430. return this.touchscreen;
  431.  
  432. default:
  433. return false;
  434. }
  435. }
  436.  
  437. /**
  438. * Returns the translation of the given index in the given String array. If the index is smaller than 0 or greater
  439. * than/equal to the length of the String array, it is changed to 0.
  440. */
  441. private static String getTranslation(String[] par0ArrayOfStr, int par1)
  442. {
  443. if (par1 < 0 || par1 >= par0ArrayOfStr.length)
  444. {
  445. par1 = 0;
  446. }
  447.  
  448. return I18n.func_135053_a(par0ArrayOfStr[par1]);
  449. }
  450.  
  451. /**
  452. * Gets a key binding.
  453. */
  454. public String getKeyBinding(EnumOptions par1EnumOptions)
  455. {
  456. String var2 = I18n.func_135053_a(par1EnumOptions.getEnumString()) + ": ";
  457.  
  458. if (par1EnumOptions.getEnumFloat())
  459. {
  460. float var5 = this.getOptionFloatValue(par1EnumOptions);
  461. return par1EnumOptions == EnumOptions.SENSITIVITY ? (var5 == 0.0F ? var2 + I18n.func_135053_a("options.sensitivity.min") : (var5 == 1.0F ? var2 + I18n.func_135053_a("options.sensitivity.max") : var2 + (int)(var5 * 200.0F) + "%")) : (par1EnumOptions == EnumOptions.FOV ? (var5 == 0.0F ? var2 + I18n.func_135053_a("options.fov.min") : (var5 == 1.0F ? var2 + I18n.func_135053_a("options.fov.max") : var2 + (int)(70.0F + var5 * 40.0F))) : (par1EnumOptions == EnumOptions.GAMMA ? (var5 == 0.0F ? var2 + I18n.func_135053_a("options.gamma.min") : (var5 == 1.0F ? var2 + I18n.func_135053_a("options.gamma.max") : var2 + "+" + (int)(var5 * 100.0F) + "%")) : (par1EnumOptions == EnumOptions.CHAT_OPACITY ? var2 + (int)(var5 * 90.0F + 10.0F) + "%" : (par1EnumOptions == EnumOptions.CHAT_HEIGHT_UNFOCUSED ? var2 + GuiNewChat.func_96130_b(var5) + "px" : (par1EnumOptions == EnumOptions.CHAT_HEIGHT_FOCUSED ? var2 + GuiNewChat.func_96130_b(var5) + "px" : (par1EnumOptions == EnumOptions.CHAT_WIDTH ? var2 + GuiNewChat.func_96128_a(var5) + "px" : (var5 == 0.0F ? var2 + I18n.func_135053_a("options.off") : var2 + (int)(var5 * 100.0F) + "%")))))));
  462. }
  463. else if (par1EnumOptions.getEnumBoolean())
  464. {
  465. boolean var4 = this.getOptionOrdinalValue(par1EnumOptions);
  466. return var4 ? var2 + I18n.func_135053_a("options.on") : var2 + I18n.func_135053_a("options.off");
  467. }
  468. else if (par1EnumOptions == EnumOptions.RENDER_DISTANCE)
  469. {
  470. return var2 + getTranslation(RENDER_DISTANCES, this.renderDistance);
  471. }
  472. else if (par1EnumOptions == EnumOptions.DIFFICULTY)
  473. {
  474. return var2 + getTranslation(DIFFICULTIES, this.difficulty);
  475. }
  476. else if (par1EnumOptions == EnumOptions.GUI_SCALE)
  477. {
  478. return var2 + getTranslation(GUISCALES, this.guiScale);
  479. }
  480. else if (par1EnumOptions == EnumOptions.CHAT_VISIBILITY)
  481. {
  482. return var2 + getTranslation(CHAT_VISIBILITIES, this.chatVisibility);
  483. }
  484. else if (par1EnumOptions == EnumOptions.PARTICLES)
  485. {
  486. return var2 + getTranslation(PARTICLES, this.particleSetting);
  487. }
  488. else if (par1EnumOptions == EnumOptions.FRAMERATE_LIMIT)
  489. {
  490. return var2 + getTranslation(LIMIT_FRAMERATES, this.limitFramerate);
  491. }
  492. else if (par1EnumOptions == EnumOptions.AMBIENT_OCCLUSION)
  493. {
  494. return var2 + getTranslation(AMBIENT_OCCLUSIONS, this.ambientOcclusion);
  495. }
  496. else if (par1EnumOptions == EnumOptions.GRAPHICS)
  497. {
  498. if (this.fancyGraphics)
  499. {
  500. return var2 + I18n.func_135053_a("options.graphics.fancy");
  501. }
  502. else
  503. {
  504. String var3 = "options.graphics.fast";
  505. return var2 + I18n.func_135053_a("options.graphics.fast");
  506. }
  507. }
  508. else
  509. {
  510. return var2;
  511. }
  512. }
  513.  
  514. /**
  515. * Loads the options from the options file. It appears that this has replaced the previous 'loadOptions'
  516. */
  517. public void loadOptions()
  518. {
  519. try
  520. {
  521. if (!this.optionsFile.exists())
  522. {
  523. return;
  524. }
  525.  
  526. BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile));
  527. String var2 = "";
  528.  
  529. while ((var2 = var1.readLine()) != null)
  530. {
  531. try
  532. {
  533. String[] var3 = var2.split(":");
  534.  
  535. if (var3[0].equals("music"))
  536. {
  537. this.musicVolume = this.parseFloat(var3[1]);
  538. }
  539.  
  540. if (var3[0].equals("sound"))
  541. {
  542. this.soundVolume = this.parseFloat(var3[1]);
  543. }
  544.  
  545. if (var3[0].equals("mouseSensitivity"))
  546. {
  547. this.mouseSensitivity = this.parseFloat(var3[1]);
  548. }
  549.  
  550. if (var3[0].equals("fov"))
  551. {
  552. this.fovSetting = this.parseFloat(var3[1]);
  553. }
  554.  
  555. if (var3[0].equals("gamma"))
  556. {
  557. this.gammaSetting = this.parseFloat(var3[1]);
  558. }
  559.  
  560. if (var3[0].equals("invertYMouse"))
  561. {
  562. this.invertMouse = var3[1].equals("true");
  563. }
  564.  
  565. if (var3[0].equals("viewDistance"))
  566. {
  567. this.renderDistance = Integer.parseInt(var3[1]);
  568. }
  569.  
  570. if (var3[0].equals("guiScale"))
  571. {
  572. this.guiScale = Integer.parseInt(var3[1]);
  573. }
  574.  
  575. if (var3[0].equals("particles"))
  576. {
  577. this.particleSetting = Integer.parseInt(var3[1]);
  578. }
  579.  
  580. if (var3[0].equals("bobView"))
  581. {
  582. this.viewBobbing = var3[1].equals("true");
  583. }
  584.  
  585. if (var3[0].equals("anaglyph3d"))
  586. {
  587. this.anaglyph = var3[1].equals("true");
  588. }
  589.  
  590. if (var3[0].equals("advancedOpengl"))
  591. {
  592. this.advancedOpengl = var3[1].equals("true");
  593. }
  594.  
  595. if (var3[0].equals("fpsLimit"))
  596. {
  597. this.limitFramerate = Integer.parseInt(var3[1]);
  598. }
  599.  
  600. if (var3[0].equals("difficulty"))
  601. {
  602. this.difficulty = Integer.parseInt(var3[1]);
  603. }
  604.  
  605. if (var3[0].equals("fancyGraphics"))
  606. {
  607. this.fancyGraphics = var3[1].equals("true");
  608. }
  609.  
  610. if (var3[0].equals("ao"))
  611. {
  612. if (var3[1].equals("true"))
  613. {
  614. this.ambientOcclusion = 2;
  615. }
  616. else if (var3[1].equals("false"))
  617. {
  618. this.ambientOcclusion = 0;
  619. }
  620. else
  621. {
  622. this.ambientOcclusion = Integer.parseInt(var3[1]);
  623. }
  624. }
  625.  
  626. if (var3[0].equals("clouds"))
  627. {
  628. this.clouds = var3[1].equals("true");
  629. }
  630.  
  631. if (var3[0].equals("skin"))
  632. {
  633. this.skin = var3[1];
  634. }
  635.  
  636. if (var3[0].equals("lastServer") && var3.length >= 2)
  637. {
  638. this.lastServer = var2.substring(var2.indexOf(58) + 1);
  639. }
  640.  
  641. if (var3[0].equals("lang") && var3.length >= 2)
  642. {
  643. this.language = var3[1];
  644. }
  645.  
  646. if (var3[0].equals("chatVisibility"))
  647. {
  648. this.chatVisibility = Integer.parseInt(var3[1]);
  649. }
  650.  
  651. if (var3[0].equals("chatColors"))
  652. {
  653. this.chatColours = var3[1].equals("true");
  654. }
  655.  
  656. if (var3[0].equals("chatLinks"))
  657. {
  658. this.chatLinks = var3[1].equals("true");
  659. }
  660.  
  661. if (var3[0].equals("chatLinksPrompt"))
  662. {
  663. this.chatLinksPrompt = var3[1].equals("true");
  664. }
  665.  
  666. if (var3[0].equals("chatOpacity"))
  667. {
  668. this.chatOpacity = this.parseFloat(var3[1]);
  669. }
  670.  
  671. if (var3[0].equals("serverTextures"))
  672. {
  673. this.serverTextures = var3[1].equals("true");
  674. }
  675.  
  676. if (var3[0].equals("snooperEnabled"))
  677. {
  678. this.snooperEnabled = var3[1].equals("true");
  679. }
  680.  
  681. if (var3[0].equals("fullscreen"))
  682. {
  683. this.fullScreen = var3[1].equals("true");
  684. }
  685.  
  686. if (var3[0].equals("enableVsync"))
  687. {
  688. this.enableVsync = var3[1].equals("true");
  689. }
  690.  
  691. if (var3[0].equals("hideServerAddress"))
  692. {
  693. this.hideServerAddress = var3[1].equals("true");
  694. }
  695.  
  696. if (var3[0].equals("advancedItemTooltips"))
  697. {
  698. this.advancedItemTooltips = var3[1].equals("true");
  699. }
  700.  
  701. if (var3[0].equals("pauseOnLostFocus"))
  702. {
  703. this.pauseOnLostFocus = var3[1].equals("true");
  704. }
  705.  
  706. if (var3[0].equals("showCape"))
  707. {
  708. this.showCape = var3[1].equals("true");
  709. }
  710.  
  711. if (var3[0].equals("touchscreen"))
  712. {
  713. this.touchscreen = var3[1].equals("true");
  714. }
  715.  
  716. if (var3[0].equals("overrideHeight"))
  717. {
  718. this.overrideHeight = Integer.parseInt(var3[1]);
  719. }
  720.  
  721. if (var3[0].equals("overrideWidth"))
  722. {
  723. this.overrideWidth = Integer.parseInt(var3[1]);
  724. }
  725.  
  726. if (var3[0].equals("heldItemTooltips"))
  727. {
  728. this.heldItemTooltips = var3[1].equals("true");
  729. }
  730.  
  731. if (var3[0].equals("chatHeightFocused"))
  732. {
  733. this.chatHeightFocused = this.parseFloat(var3[1]);
  734. }
  735.  
  736. if (var3[0].equals("chatHeightUnfocused"))
  737. {
  738. this.chatHeightUnfocused = this.parseFloat(var3[1]);
  739. }
  740.  
  741. if (var3[0].equals("chatScale"))
  742. {
  743. this.chatScale = this.parseFloat(var3[1]);
  744. }
  745.  
  746. if (var3[0].equals("chatWidth"))
  747. {
  748. this.chatWidth = this.parseFloat(var3[1]);
  749. }
  750.  
  751. for (int var4 = 0; var4 < this.keyBindings.length; ++var4)
  752. {
  753. if (var3[0].equals("key_" + this.keyBindings[var4].keyDescription))
  754. {
  755. this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]);
  756. }
  757. }
  758. }
  759. catch (Exception var5)
  760. {
  761. this.mc.getLogAgent().logWarning("Skipping bad option: " + var2);
  762. }
  763. }
  764.  
  765. KeyBinding.resetKeyBindingArrayAndHash();
  766. var1.close();
  767. }
  768. catch (Exception var6)
  769. {
  770. this.mc.getLogAgent().logWarning("Failed to load options");
  771. var6.printStackTrace();
  772. }
  773. }
  774.  
  775. /**
  776. * Parses a string into a float.
  777. */
  778. private float parseFloat(String par1Str)
  779. {
  780. return par1Str.equals("true") ? 1.0F : (par1Str.equals("false") ? 0.0F : Float.parseFloat(par1Str));
  781. }
  782.  
  783. /**
  784. * Saves the options to the options file.
  785. */
  786. public void saveOptions()
  787. {
  788. try
  789. {
  790. PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile));
  791. var1.println("music:" + this.musicVolume);
  792. var1.println("sound:" + this.soundVolume);
  793. var1.println("invertYMouse:" + this.invertMouse);
  794. var1.println("mouseSensitivity:" + this.mouseSensitivity);
  795. var1.println("fov:" + this.fovSetting);
  796. var1.println("gamma:" + this.gammaSetting);
  797. var1.println("viewDistance:" + this.renderDistance);
  798. var1.println("guiScale:" + this.guiScale);
  799. var1.println("particles:" + this.particleSetting);
  800. var1.println("bobView:" + this.viewBobbing);
  801. var1.println("anaglyph3d:" + this.anaglyph);
  802. var1.println("advancedOpengl:" + this.advancedOpengl);
  803. var1.println("fpsLimit:" + this.limitFramerate);
  804. var1.println("difficulty:" + this.difficulty);
  805. var1.println("fancyGraphics:" + this.fancyGraphics);
  806. var1.println("ao:" + this.ambientOcclusion);
  807. var1.println("clouds:" + this.clouds);
  808. var1.println("skin:" + this.skin);
  809. var1.println("lastServer:" + this.lastServer);
  810. var1.println("lang:" + this.language);
  811. var1.println("chatVisibility:" + this.chatVisibility);
  812. var1.println("chatColors:" + this.chatColours);
  813. var1.println("chatLinks:" + this.chatLinks);
  814. var1.println("chatLinksPrompt:" + this.chatLinksPrompt);
  815. var1.println("chatOpacity:" + this.chatOpacity);
  816. var1.println("serverTextures:" + this.serverTextures);
  817. var1.println("snooperEnabled:" + this.snooperEnabled);
  818. var1.println("fullscreen:" + this.fullScreen);
  819. var1.println("enableVsync:" + this.enableVsync);
  820. var1.println("hideServerAddress:" + this.hideServerAddress);
  821. var1.println("advancedItemTooltips:" + this.advancedItemTooltips);
  822. var1.println("pauseOnLostFocus:" + this.pauseOnLostFocus);
  823. var1.println("showCape:" + this.showCape);
  824. var1.println("touchscreen:" + this.touchscreen);
  825. var1.println("overrideWidth:" + this.overrideWidth);
  826. var1.println("overrideHeight:" + this.overrideHeight);
  827. var1.println("heldItemTooltips:" + this.heldItemTooltips);
  828. var1.println("chatHeightFocused:" + this.chatHeightFocused);
  829. var1.println("chatHeightUnfocused:" + this.chatHeightUnfocused);
  830. var1.println("chatScale:" + this.chatScale);
  831. var1.println("chatWidth:" + this.chatWidth);
  832.  
  833. for (int var2 = 0; var2 < this.keyBindings.length; ++var2)
  834. {
  835. var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode);
  836. }
  837.  
  838. var1.close();
  839. }
  840. catch (Exception var3)
  841. {
  842. this.mc.getLogAgent().logWarning("Failed to save options");
  843. var3.printStackTrace();
  844. }
  845.  
  846. this.sendSettingsToServer();
  847. }
  848.  
  849. /**
  850. * Send a client info packet with settings information to the server
  851. */
  852. public void sendSettingsToServer()
  853. {
  854. if (this.mc.thePlayer != null)
  855. {
  856. this.mc.thePlayer.sendQueue.addToSendQueue(new Packet204ClientInfo(this.language, this.renderDistance, this.chatVisibility, this.chatColours, this.difficulty, this.showCape));
  857. }
  858. }
  859.  
  860. /**
  861. * Should render clouds
  862. */
  863. public boolean shouldRenderClouds()
  864. {
  865. return this.renderDistance < 2 && this.clouds;
  866. }
  867. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement