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