    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.client.FMLClientHandler;
    004    import cpw.mods.fml.common.Side;
    005    import cpw.mods.fml.common.asm.SideOnly;
    006    import java.io.BufferedReader;
    007    import java.io.File;
    008    import java.io.FileReader;
    009    import java.io.FileWriter;
    010    import java.io.PrintWriter;
    011    import net.minecraft.client.Minecraft;
    012    import org.lwjgl.input.Keyboard;
    013    import org.lwjgl.opengl.Display;
    014
    015    @SideOnly(Side.CLIENT)
    016    public class GameSettings
    017    {
    018        private static final String[] RENDER_DISTANCES = new String[] {"options.renderDistance.far", "options.renderDistance.normal", "options.renderDistance.short", "options.renderDistance.tiny"};
    019        private static final String[] DIFFICULTIES = new String[] {"options.difficulty.peaceful", "options.difficulty.easy", "options.difficulty.normal", "options.difficulty.hard"};
    020
    021        /** GUI scale values */
    022        private static final String[] GUISCALES = new String[] {"options.guiScale.auto", "options.guiScale.small", "options.guiScale.normal", "options.guiScale.large"};
    023        private static final String[] CHAT_VISIBILITIES = new String[] {"options.chat.visibility.full", "options.chat.visibility.system", "options.chat.visibility.hidden"};
    024        private static final String[] PARTICLES = new String[] {"options.particles.all", "options.particles.decreased", "options.particles.minimal"};
    025
    026        /** Limit framerate labels */
    027        private static final String[] LIMIT_FRAMERATES = new String[] {"performance.max", "performance.balanced", "performance.powersaver"};
    028        public float musicVolume = 1.0F;
    029        public float soundVolume = 1.0F;
    030        public float mouseSensitivity = 0.5F;
    031        public boolean invertMouse = false;
    032        public int renderDistance = 0;
    033        public boolean viewBobbing = true;
    034        public boolean anaglyph = false;
    035
    036        /** Advanced OpenGL */
    037        public boolean advancedOpengl = false;
    038        public int limitFramerate = 1;
    039        public boolean fancyGraphics = true;
    040
    041        /** Smooth Lighting */
    042        public boolean ambientOcclusion = true;
    043
    044        /** Clouds flag */
    045        public boolean clouds = true;
    046
    047        /** The name of the selected texture pack. */
    048        public String skin = "Default";
    049        public int chatVisibility = 0;
    050        public boolean chatColours = true;
    051        public boolean chatLinks = true;
    052        public boolean chatLinksPrompt = true;
    053        public float chatOpacity = 1.0F;
    054        public boolean serverTextures = true;
    055        public boolean snooperEnabled = true;
    056        public boolean fullScreen = false;
    057        public boolean enableVsync = true;
    058        public boolean hideServerAddress = false;
    059
    060        /**
    061         * Whether to show advanced information on item tooltips, toggled by F3+H
    062         */
    063        public boolean advancedItemTooltips = false;
    064
    065        /** Whether to pause when the game loses focus, toggled by F3+P */
    066        public boolean pauseOnLostFocus = true;
    067
    068        /** Whether to show your cape */
    069        public boolean showCape = true;
    070        public boolean field_85185_A = false;
    071        public KeyBinding keyBindForward = new KeyBinding("key.forward", 17);
    072        public KeyBinding keyBindLeft = new KeyBinding("key.left", 30);
    073        public KeyBinding keyBindBack = new KeyBinding("key.back", 31);
    074        public KeyBinding keyBindRight = new KeyBinding("key.right", 32);
    075        public KeyBinding keyBindJump = new KeyBinding("key.jump", 57);
    076        public KeyBinding keyBindInventory = new KeyBinding("key.inventory", 18);
    077        public KeyBinding keyBindDrop = new KeyBinding("key.drop", 16);
    078        public KeyBinding keyBindChat = new KeyBinding("key.chat", 20);
    079        public KeyBinding keyBindSneak = new KeyBinding("key.sneak", 42);
    080        public KeyBinding keyBindAttack = new KeyBinding("key.attack", -100);
    081        public KeyBinding keyBindUseItem = new KeyBinding("key.use", -99);
    082        public KeyBinding keyBindPlayerList = new KeyBinding("key.playerlist", 15);
    083        public KeyBinding keyBindPickBlock = new KeyBinding("key.pickItem", -98);
    084        public KeyBinding keyBindCommand = new KeyBinding("key.command", 53);
    085        public KeyBinding[] keyBindings;
    086        protected Minecraft mc;
    087        private File optionsFile;
    088        public int difficulty;
    089        public boolean hideGUI;
    090        public int thirdPersonView;
    091
    092        /** true if debug info should be displayed instead of version */
    093        public boolean showDebugInfo;
    094        public boolean showDebugProfilerChart;
    095
    096        /** The lastServer string. */
    097        public String lastServer;
    098
    099        /** No clipping for singleplayer */
    100        public boolean noclip;
    101
    102        /** Smooth Camera Toggle */
    103        public boolean smoothCamera;
    104        public boolean debugCamEnable;
    105
    106        /** No clipping movement rate */
    107        public float noclipRate;
    108
    109        /** Change rate for debug camera */
    110        public float debugCamRate;
    111        public float fovSetting;
    112        public float gammaSetting;
    113
    114        /** GUI scale */
    115        public int guiScale;
    116
    117        /** Determines amount of particles. 0 = All, 1 = Decreased, 2 = Minimal */
    118        public int particleSetting;
    119
    120        /** Game settings language */
    121        public String language;
    122
    123        public GameSettings(Minecraft par1Minecraft, File par2File)
    124        {
    125            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};
    126            this.difficulty = 2;
    127            this.hideGUI = false;
    128            this.thirdPersonView = 0;
    129            this.showDebugInfo = false;
    130            this.showDebugProfilerChart = false;
    131            this.lastServer = "";
    132            this.noclip = false;
    133            this.smoothCamera = false;
    134            this.debugCamEnable = false;
    135            this.noclipRate = 1.0F;
    136            this.debugCamRate = 1.0F;
    137            this.fovSetting = 0.0F;
    138            this.gammaSetting = 0.0F;
    139            this.guiScale = 0;
    140            this.particleSetting = 0;
    141            this.language = "en_US";
    142            this.mc = par1Minecraft;
    143            this.optionsFile = new File(par2File, "options.txt");
    144            this.loadOptions();
    145        }
    146
    147        public GameSettings()
    148        {
    149            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};
    150            this.difficulty = 2;
    151            this.hideGUI = false;
    152            this.thirdPersonView = 0;
    153            this.showDebugInfo = false;
    154            this.showDebugProfilerChart = false;
    155            this.lastServer = "";
    156            this.noclip = false;
    157            this.smoothCamera = false;
    158            this.debugCamEnable = false;
    159            this.noclipRate = 1.0F;
    160            this.debugCamRate = 1.0F;
    161            this.fovSetting = 0.0F;
    162            this.gammaSetting = 0.0F;
    163            this.guiScale = 0;
    164            this.particleSetting = 0;
    165            this.language = "en_US";
    166        }
    167
    168        public String getKeyBindingDescription(int par1)
    169        {
    170            StringTranslate var2 = StringTranslate.getInstance();
    171            return var2.translateKey(this.keyBindings[par1].keyDescription);
    172        }
    173
    174        /**
    175         * The string that appears inside the button/slider in the options menu.
    176         */
    177        public String getOptionDisplayString(int par1)
    178        {
    179            int var2 = this.keyBindings[par1].keyCode;
    180            return getKeyDisplayString(var2);
    181        }
    182
    183        /**
    184         * Represents a key or mouse button as a string. Args: key
    185         */
    186        public static String getKeyDisplayString(int par0)
    187        {
    188            return par0 < 0 ? StatCollector.translateToLocalFormatted("key.mouseButton", new Object[] {Integer.valueOf(par0 + 101)}): Keyboard.getKeyName(par0);
    189        }
    190
    191        /**
    192         * Sets a key binding.
    193         */
    194        public void setKeyBinding(int par1, int par2)
    195        {
    196            this.keyBindings[par1].keyCode = par2;
    197            this.saveOptions();
    198        }
    199
    200        /**
    201         * If the specified option is controlled by a slider (float value), this will set the float value.
    202         */
    203        public void setOptionFloatValue(EnumOptions par1EnumOptions, float par2)
    204        {
    205            if (par1EnumOptions == EnumOptions.MUSIC)
    206            {
    207                this.musicVolume = par2;
    208                this.mc.sndManager.onSoundOptionsChanged();
    209            }
    210
    211            if (par1EnumOptions == EnumOptions.SOUND)
    212            {
    213                this.soundVolume = par2;
    214                this.mc.sndManager.onSoundOptionsChanged();
    215            }
    216
    217            if (par1EnumOptions == EnumOptions.SENSITIVITY)
    218            {
    219                this.mouseSensitivity = par2;
    220            }
    221
    222            if (par1EnumOptions == EnumOptions.FOV)
    223            {
    224                this.fovSetting = par2;
    225            }
    226
    227            if (par1EnumOptions == EnumOptions.GAMMA)
    228            {
    229                this.gammaSetting = par2;
    230            }
    231
    232            if (par1EnumOptions == EnumOptions.CHAT_OPACITY)
    233            {
    234                this.chatOpacity = par2;
    235            }
    236        }
    237
    238        /**
    239         * For non-float options. Toggles the option on/off, or cycles through the list i.e. render distances.
    240         */
    241        public void setOptionValue(EnumOptions par1EnumOptions, int par2)
    242        {
    243            if (par1EnumOptions == EnumOptions.INVERT_MOUSE)
    244            {
    245                this.invertMouse = !this.invertMouse;
    246            }
    247
    248            if (par1EnumOptions == EnumOptions.RENDER_DISTANCE)
    249            {
    250                this.renderDistance = this.renderDistance + par2 & 3;
    251            }
    252
    253            if (par1EnumOptions == EnumOptions.GUI_SCALE)
    254            {
    255                this.guiScale = this.guiScale + par2 & 3;
    256            }
    257
    258            if (par1EnumOptions == EnumOptions.PARTICLES)
    259            {
    260                this.particleSetting = (this.particleSetting + par2) % 3;
    261            }
    262
    263            if (par1EnumOptions == EnumOptions.VIEW_BOBBING)
    264            {
    265                this.viewBobbing = !this.viewBobbing;
    266            }
    267
    268            if (par1EnumOptions == EnumOptions.RENDER_CLOUDS)
    269            {
    270                this.clouds = !this.clouds;
    271            }
    272
    273            if (par1EnumOptions == EnumOptions.ADVANCED_OPENGL)
    274            {
    275                this.advancedOpengl = !this.advancedOpengl;
    276                this.mc.renderGlobal.loadRenderers();
    277            }
    278
    279            if (par1EnumOptions == EnumOptions.ANAGLYPH)
    280            {
    281                this.anaglyph = !this.anaglyph;
    282                this.mc.renderEngine.refreshTextures();
    283            }
    284
    285            if (par1EnumOptions == EnumOptions.FRAMERATE_LIMIT)
    286            {
    287                this.limitFramerate = (this.limitFramerate + par2 + 3) % 3;
    288            }
    289
    290            if (par1EnumOptions == EnumOptions.DIFFICULTY)
    291            {
    292                this.difficulty = this.difficulty + par2 & 3;
    293            }
    294
    295            if (par1EnumOptions == EnumOptions.GRAPHICS)
    296            {
    297                this.fancyGraphics = !this.fancyGraphics;
    298                this.mc.renderGlobal.loadRenderers();
    299            }
    300
    301            if (par1EnumOptions == EnumOptions.AMBIENT_OCCLUSION)
    302            {
    303                this.ambientOcclusion = !this.ambientOcclusion;
    304                this.mc.renderGlobal.loadRenderers();
    305            }
    306
    307            if (par1EnumOptions == EnumOptions.CHAT_VISIBILITY)
    308            {
    309                this.chatVisibility = (this.chatVisibility + par2) % 3;
    310            }
    311
    312            if (par1EnumOptions == EnumOptions.CHAT_COLOR)
    313            {
    314                this.chatColours = !this.chatColours;
    315            }
    316
    317            if (par1EnumOptions == EnumOptions.CHAT_LINKS)
    318            {
    319                this.chatLinks = !this.chatLinks;
    320            }
    321
    322            if (par1EnumOptions == EnumOptions.CHAT_LINKS_PROMPT)
    323            {
    324                this.chatLinksPrompt = !this.chatLinksPrompt;
    325            }
    326
    327            if (par1EnumOptions == EnumOptions.USE_SERVER_TEXTURES)
    328            {
    329                this.serverTextures = !this.serverTextures;
    330            }
    331
    332            if (par1EnumOptions == EnumOptions.SNOOPER_ENABLED)
    333            {
    334                this.snooperEnabled = !this.snooperEnabled;
    335            }
    336
    337            if (par1EnumOptions == EnumOptions.SHOW_CAPE)
    338            {
    339                this.showCape = !this.showCape;
    340            }
    341
    342            if (par1EnumOptions == EnumOptions.TOUCHSCREEN)
    343            {
    344                this.field_85185_A = !this.field_85185_A;
    345            }
    346
    347            if (par1EnumOptions == EnumOptions.USE_FULLSCREEN)
    348            {
    349                this.fullScreen = !this.fullScreen;
    350
    351                if (this.mc.isFullScreen() != this.fullScreen)
    352                {
    353                    this.mc.toggleFullscreen();
    354                }
    355            }
    356
    357            if (par1EnumOptions == EnumOptions.ENABLE_VSYNC)
    358            {
    359                this.enableVsync = !this.enableVsync;
    360                Display.setVSyncEnabled(this.enableVsync);
    361            }
    362
    363            this.saveOptions();
    364        }
    365
    366        public float getOptionFloatValue(EnumOptions par1EnumOptions)
    367        {
    368            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 : 0.0F)))));
    369        }
    370
    371        public boolean getOptionOrdinalValue(EnumOptions par1EnumOptions)
    372        {
    373            switch (EnumOptionsHelper.enumOptionsMappingHelperArray[par1EnumOptions.ordinal()])
    374            {
    375                case 1:
    376                    return this.invertMouse;
    377                case 2:
    378                    return this.viewBobbing;
    379                case 3:
    380                    return this.anaglyph;
    381                case 4:
    382                    return this.advancedOpengl;
    383                case 5:
    384                    return this.ambientOcclusion;
    385                case 6:
    386                    return this.clouds;
    387                case 7:
    388                    return this.chatColours;
    389                case 8:
    390                    return this.chatLinks;
    391                case 9:
    392                    return this.chatLinksPrompt;
    393                case 10:
    394                    return this.serverTextures;
    395                case 11:
    396                    return this.snooperEnabled;
    397                case 12:
    398                    return this.fullScreen;
    399                case 13:
    400                    return this.enableVsync;
    401                case 14:
    402                    return this.showCape;
    403                case 15:
    404                    return this.field_85185_A;
    405                default:
    406                    return false;
    407            }
    408        }
    409
    410        /**
    411         * Returns the translation of the given index in the given String array. If the index is smaller than 0 or greater
    412         * than/equal to the length of the String array, it is changed to 0.
    413         */
    414        private static String getTranslation(String[] par0ArrayOfStr, int par1)
    415        {
    416            if (par1 < 0 || par1 >= par0ArrayOfStr.length)
    417            {
    418                par1 = 0;
    419            }
    420
    421            StringTranslate var2 = StringTranslate.getInstance();
    422            return var2.translateKey(par0ArrayOfStr[par1]);
    423        }
    424
    425        /**
    426         * Gets a key binding.
    427         */
    428        public String getKeyBinding(EnumOptions par1EnumOptions)
    429        {
    430            StringTranslate var2 = StringTranslate.getInstance();
    431            String var3 = var2.translateKey(par1EnumOptions.getEnumString()) + ": ";
    432
    433            if (par1EnumOptions.getEnumFloat())
    434            {
    435                float var5 = this.getOptionFloatValue(par1EnumOptions);
    436                return par1EnumOptions == EnumOptions.SENSITIVITY ? (var5 == 0.0F ? var3 + var2.translateKey("options.sensitivity.min") : (var5 == 1.0F ? var3 + var2.translateKey("options.sensitivity.max") : var3 + (int)(var5 * 200.0F) + "%")) : (par1EnumOptions == EnumOptions.FOV ? (var5 == 0.0F ? var3 + var2.translateKey("options.fov.min") : (var5 == 1.0F ? var3 + var2.translateKey("options.fov.max") : var3 + (int)(70.0F + var5 * 40.0F))) : (par1EnumOptions == EnumOptions.GAMMA ? (var5 == 0.0F ? var3 + var2.translateKey("options.gamma.min") : (var5 == 1.0F ? var3 + var2.translateKey("options.gamma.max") : var3 + "+" + (int)(var5 * 100.0F) + "%")) : (par1EnumOptions == EnumOptions.CHAT_OPACITY ? var3 + (int)(var5 * 90.0F + 10.0F) + "%" : (var5 == 0.0F ? var3 + var2.translateKey("options.off") : var3 + (int)(var5 * 100.0F) + "%"))));
    437            }
    438            else if (par1EnumOptions.getEnumBoolean())
    439            {
    440                boolean var4 = this.getOptionOrdinalValue(par1EnumOptions);
    441                return var4 ? var3 + var2.translateKey("options.on") : var3 + var2.translateKey("options.off");
    442            }
    443            else
    444            {
    445                return par1EnumOptions == EnumOptions.RENDER_DISTANCE ? var3 + getTranslation(RENDER_DISTANCES, this.renderDistance) : (par1EnumOptions == EnumOptions.DIFFICULTY ? var3 + getTranslation(DIFFICULTIES, this.difficulty) : (par1EnumOptions == EnumOptions.GUI_SCALE ? var3 + getTranslation(GUISCALES, this.guiScale) : (par1EnumOptions == EnumOptions.CHAT_VISIBILITY ? var3 + getTranslation(CHAT_VISIBILITIES, this.chatVisibility) : (par1EnumOptions == EnumOptions.PARTICLES ? var3 + getTranslation(PARTICLES, this.particleSetting) : (par1EnumOptions == EnumOptions.FRAMERATE_LIMIT ? var3 + getTranslation(LIMIT_FRAMERATES, this.limitFramerate) : (par1EnumOptions == EnumOptions.GRAPHICS ? (this.fancyGraphics ? var3 + var2.translateKey("options.graphics.fancy") : var3 + var2.translateKey("options.graphics.fast")) : var3))))));
    446            }
    447        }
    448
    449        /**
    450         * Loads the options from the options file. It appears that this has replaced the previous 'loadOptions'
    451         */
    452        public void loadOptions()
    453        {
    454            try
    455            {
    456                if (!this.optionsFile.exists())
    457                {
    458                    return;
    459                }
    460
    461                BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile));
    462                String var2 = "";
    463
    464                while ((var2 = var1.readLine()) != null)
    465                {
    466                    try
    467                    {
    468                        String[] var3 = var2.split(":");
    469
    470                        if (var3[0].equals("music"))
    471                        {
    472                            this.musicVolume = this.parseFloat(var3[1]);
    473                        }
    474
    475                        if (var3[0].equals("sound"))
    476                        {
    477                            this.soundVolume = this.parseFloat(var3[1]);
    478                        }
    479
    480                        if (var3[0].equals("mouseSensitivity"))
    481                        {
    482                            this.mouseSensitivity = this.parseFloat(var3[1]);
    483                        }
    484
    485                        if (var3[0].equals("fov"))
    486                        {
    487                            this.fovSetting = this.parseFloat(var3[1]);
    488                        }
    489
    490                        if (var3[0].equals("gamma"))
    491                        {
    492                            this.gammaSetting = this.parseFloat(var3[1]);
    493                        }
    494
    495                        if (var3[0].equals("invertYMouse"))
    496                        {
    497                            this.invertMouse = var3[1].equals("true");
    498                        }
    499
    500                        if (var3[0].equals("viewDistance"))
    501                        {
    502                            this.renderDistance = Integer.parseInt(var3[1]);
    503                        }
    504
    505                        if (var3[0].equals("guiScale"))
    506                        {
    507                            this.guiScale = Integer.parseInt(var3[1]);
    508                        }
    509
    510                        if (var3[0].equals("particles"))
    511                        {
    512                            this.particleSetting = Integer.parseInt(var3[1]);
    513                        }
    514
    515                        if (var3[0].equals("bobView"))
    516                        {
    517                            this.viewBobbing = var3[1].equals("true");
    518                        }
    519
    520                        if (var3[0].equals("anaglyph3d"))
    521                        {
    522                            this.anaglyph = var3[1].equals("true");
    523                        }
    524
    525                        if (var3[0].equals("advancedOpengl"))
    526                        {
    527                            this.advancedOpengl = var3[1].equals("true");
    528                        }
    529
    530                        if (var3[0].equals("fpsLimit"))
    531                        {
    532                            this.limitFramerate = Integer.parseInt(var3[1]);
    533                        }
    534
    535                        if (var3[0].equals("difficulty"))
    536                        {
    537                            this.difficulty = Integer.parseInt(var3[1]);
    538                        }
    539
    540                        if (var3[0].equals("fancyGraphics"))
    541                        {
    542                            this.fancyGraphics = var3[1].equals("true");
    543                        }
    544
    545                        if (var3[0].equals("ao"))
    546                        {
    547                            this.ambientOcclusion = var3[1].equals("true");
    548                        }
    549
    550                        if (var3[0].equals("clouds"))
    551                        {
    552                            this.clouds = var3[1].equals("true");
    553                        }
    554
    555                        if (var3[0].equals("skin"))
    556                        {
    557                            this.skin = var3[1];
    558                        }
    559
    560                        if (var3[0].equals("lastServer") && var3.length >= 2)
    561                        {
    562                            this.lastServer = var3[1];
    563                        }
    564
    565                        if (var3[0].equals("lang") && var3.length >= 2)
    566                        {
    567                            this.language = var3[1];
    568                        }
    569
    570                        if (var3[0].equals("chatVisibility"))
    571                        {
    572                            this.chatVisibility = Integer.parseInt(var3[1]);
    573                        }
    574
    575                        if (var3[0].equals("chatColors"))
    576                        {
    577                            this.chatColours = var3[1].equals("true");
    578                        }
    579
    580                        if (var3[0].equals("chatLinks"))
    581                        {
    582                            this.chatLinks = var3[1].equals("true");
    583                        }
    584
    585                        if (var3[0].equals("chatLinksPrompt"))
    586                        {
    587                            this.chatLinksPrompt = var3[1].equals("true");
    588                        }
    589
    590                        if (var3[0].equals("chatOpacity"))
    591                        {
    592                            this.chatOpacity = this.parseFloat(var3[1]);
    593                        }
    594
    595                        if (var3[0].equals("serverTextures"))
    596                        {
    597                            this.serverTextures = var3[1].equals("true");
    598                        }
    599
    600                        if (var3[0].equals("snooperEnabled"))
    601                        {
    602                            this.snooperEnabled = var3[1].equals("true");
    603                        }
    604
    605                        if (var3[0].equals("fullscreen"))
    606                        {
    607                            this.fullScreen = var3[1].equals("true");
    608                        }
    609
    610                        if (var3[0].equals("enableVsync"))
    611                        {
    612                            this.enableVsync = var3[1].equals("true");
    613                        }
    614
    615                        if (var3[0].equals("hideServerAddress"))
    616                        {
    617                            this.hideServerAddress = var3[1].equals("true");
    618                        }
    619
    620                        if (var3[0].equals("advancedItemTooltips"))
    621                        {
    622                            this.advancedItemTooltips = var3[1].equals("true");
    623                        }
    624
    625                        if (var3[0].equals("pauseOnLostFocus"))
    626                        {
    627                            this.pauseOnLostFocus = var3[1].equals("true");
    628                        }
    629
    630                        if (var3[0].equals("showCape"))
    631                        {
    632                            this.showCape = var3[1].equals("true");
    633                        }
    634
    635                        if (var3[0].equals("touchscreen"))
    636                        {
    637                            this.field_85185_A = var3[1].equals("true");
    638                        }
    639
    640                        for (int var4 = 0; var4 < this.keyBindings.length; ++var4)
    641                        {
    642                            if (var3[0].equals("key_" + this.keyBindings[var4].keyDescription))
    643                            {
    644                                this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]);
    645                            }
    646                        }
    647                    }
    648                    catch (Exception var5)
    649                    {
    650                        System.out.println("Skipping bad option: " + var2);
    651                    }
    652                }
    653
    654                KeyBinding.resetKeyBindingArrayAndHash();
    655                var1.close();
    656            }
    657            catch (Exception var6)
    658            {
    659                System.out.println("Failed to load options");
    660                var6.printStackTrace();
    661            }
    662        }
    663
    664        /**
    665         * Parses a string into a float.
    666         */
    667        private float parseFloat(String par1Str)
    668        {
    669            return par1Str.equals("true") ? 1.0F : (par1Str.equals("false") ? 0.0F : Float.parseFloat(par1Str));
    670        }
    671
    672        /**
    673         * Saves the options to the options file.
    674         */
    675        public void saveOptions()
    676        {
    677            if (FMLClientHandler.instance().isLoading()) return;
    678            try
    679            {
    680                PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile));
    681                var1.println("music:" + this.musicVolume);
    682                var1.println("sound:" + this.soundVolume);
    683                var1.println("invertYMouse:" + this.invertMouse);
    684                var1.println("mouseSensitivity:" + this.mouseSensitivity);
    685                var1.println("fov:" + this.fovSetting);
    686                var1.println("gamma:" + this.gammaSetting);
    687                var1.println("viewDistance:" + this.renderDistance);
    688                var1.println("guiScale:" + this.guiScale);
    689                var1.println("particles:" + this.particleSetting);
    690                var1.println("bobView:" + this.viewBobbing);
    691                var1.println("anaglyph3d:" + this.anaglyph);
    692                var1.println("advancedOpengl:" + this.advancedOpengl);
    693                var1.println("fpsLimit:" + this.limitFramerate);
    694                var1.println("difficulty:" + this.difficulty);
    695                var1.println("fancyGraphics:" + this.fancyGraphics);
    696                var1.println("ao:" + this.ambientOcclusion);
    697                var1.println("clouds:" + this.clouds);
    698                var1.println("skin:" + this.skin);
    699                var1.println("lastServer:" + this.lastServer);
    700                var1.println("lang:" + this.language);
    701                var1.println("chatVisibility:" + this.chatVisibility);
    702                var1.println("chatColors:" + this.chatColours);
    703                var1.println("chatLinks:" + this.chatLinks);
    704                var1.println("chatLinksPrompt:" + this.chatLinksPrompt);
    705                var1.println("chatOpacity:" + this.chatOpacity);
    706                var1.println("serverTextures:" + this.serverTextures);
    707                var1.println("snooperEnabled:" + this.snooperEnabled);
    708                var1.println("fullscreen:" + this.fullScreen);
    709                var1.println("enableVsync:" + this.enableVsync);
    710                var1.println("hideServerAddress:" + this.hideServerAddress);
    711                var1.println("advancedItemTooltips:" + this.advancedItemTooltips);
    712                var1.println("pauseOnLostFocus:" + this.pauseOnLostFocus);
    713                var1.println("showCape:" + this.showCape);
    714                var1.println("touchscreen:" + this.field_85185_A);
    715
    716                for (int var2 = 0; var2 < this.keyBindings.length; ++var2)
    717                {
    718                    var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode);
    719                }
    720
    721                var1.close();
    722            }
    723            catch (Exception var3)
    724            {
    725                System.out.println("Failed to save options");
    726                var3.printStackTrace();
    727            }
    728
    729            this.sendSettingsToServer();
    730        }
    731
    732        /**
    733         * Send a client info packet with settings information to the server
    734         */
    735        public void sendSettingsToServer()
    736        {
    737            if (this.mc.thePlayer != null)
    738            {
    739                this.mc.thePlayer.sendQueue.addToSendQueue(new Packet204ClientInfo(this.language, this.renderDistance, this.chatVisibility, this.chatColours, this.difficulty, this.showCape));
    740            }
    741        }
    742
    743        /**
    744         * Should render clouds
    745         */
    746        public boolean shouldRenderClouds()
    747        {
    748            return this.renderDistance < 2 && this.clouds;
    749        }
    750    }