    001    package net.minecraft.client.gui;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import net.minecraft.client.settings.EnumOptions;
    006    import net.minecraft.client.settings.GameSettings;
    007    import net.minecraft.util.StatCollector;
    008    import net.minecraft.util.StringTranslate;
    009
    010    @SideOnly(Side.CLIENT)
    011    public class GuiVideoSettings extends GuiScreen
    012    {
    013        private GuiScreen parentGuiScreen;
    014
    015        /** The title string that is displayed in the top-center of the screen. */
    016        protected String screenTitle = "Video Settings";
    017
    018        /** GUI game settings */
    019        private GameSettings guiGameSettings;
    020
    021        /**
    022         * True if the system is 64-bit (using a simple indexOf test on a system property)
    023         */
    024        private boolean is64bit = false;
    025
    026        /** An array of all of EnumOption's video options. */
    027        private static EnumOptions[] videoOptions = new EnumOptions[] {EnumOptions.GRAPHICS, EnumOptions.RENDER_DISTANCE, EnumOptions.AMBIENT_OCCLUSION, EnumOptions.FRAMERATE_LIMIT, EnumOptions.ANAGLYPH, EnumOptions.VIEW_BOBBING, EnumOptions.GUI_SCALE, EnumOptions.ADVANCED_OPENGL, EnumOptions.GAMMA, EnumOptions.RENDER_CLOUDS, EnumOptions.PARTICLES, EnumOptions.USE_SERVER_TEXTURES, EnumOptions.USE_FULLSCREEN, EnumOptions.ENABLE_VSYNC};
    028
    029        public GuiVideoSettings(GuiScreen par1GuiScreen, GameSettings par2GameSettings)
    030        {
    031            this.parentGuiScreen = par1GuiScreen;
    032            this.guiGameSettings = par2GameSettings;
    033        }
    034
    035        /**
    036         * Adds the buttons (and other controls) to the screen in question.
    037         */
    038        public void initGui()
    039        {
    040            StringTranslate var1 = StringTranslate.getInstance();
    041            this.screenTitle = var1.translateKey("options.videoTitle");
    042            this.controlList.clear();
    043            this.controlList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done")));
    044            this.is64bit = false;
    045            String[] var2 = new String[] {"sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch"};
    046            String[] var3 = var2;
    047            int var4 = var2.length;
    048
    049            for (int var5 = 0; var5 < var4; ++var5)
    050            {
    051                String var6 = var3[var5];
    052                String var7 = System.getProperty(var6);
    053
    054                if (var7 != null && var7.contains("64"))
    055                {
    056                    this.is64bit = true;
    057                    break;
    058                }
    059            }
    060
    061            int var9 = 0;
    062            var4 = this.is64bit ? 0 : -15;
    063            EnumOptions[] var10 = videoOptions;
    064            int var11 = var10.length;
    065
    066            for (int var12 = 0; var12 < var11; ++var12)
    067            {
    068                EnumOptions var8 = var10[var12];
    069
    070                if (var8.getEnumFloat())
    071                {
    072                    this.controlList.add(new GuiSlider(var8.returnEnumOrdinal(), this.width / 2 - 155 + var9 % 2 * 160, this.height / 7 + var4 + 24 * (var9 >> 1), var8, this.guiGameSettings.getKeyBinding(var8), this.guiGameSettings.getOptionFloatValue(var8)));
    073                }
    074                else
    075                {
    076                    this.controlList.add(new GuiSmallButton(var8.returnEnumOrdinal(), this.width / 2 - 155 + var9 % 2 * 160, this.height / 7 + var4 + 24 * (var9 >> 1), var8, this.guiGameSettings.getKeyBinding(var8)));
    077                }
    078
    079                ++var9;
    080            }
    081        }
    082
    083        /**
    084         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    085         */
    086        protected void actionPerformed(GuiButton par1GuiButton)
    087        {
    088            if (par1GuiButton.enabled)
    089            {
    090                int var2 = this.guiGameSettings.guiScale;
    091
    092                if (par1GuiButton.id < 100 && par1GuiButton instanceof GuiSmallButton)
    093                {
    094                    this.guiGameSettings.setOptionValue(((GuiSmallButton)par1GuiButton).returnEnumOptions(), 1);
    095                    par1GuiButton.displayString = this.guiGameSettings.getKeyBinding(EnumOptions.getEnumOptions(par1GuiButton.id));
    096                }
    097
    098                if (par1GuiButton.id == 200)
    099                {
    100                    this.mc.gameSettings.saveOptions();
    101                    this.mc.displayGuiScreen(this.parentGuiScreen);
    102                }
    103
    104                if (this.guiGameSettings.guiScale != var2)
    105                {
    106                    ScaledResolution var3 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
    107                    int var4 = var3.getScaledWidth();
    108                    int var5 = var3.getScaledHeight();
    109                    this.setWorldAndResolution(this.mc, var4, var5);
    110                }
    111            }
    112        }
    113
    114        /**
    115         * Draws the screen and all the components in it.
    116         */
    117        public void drawScreen(int par1, int par2, float par3)
    118        {
    119            this.drawDefaultBackground();
    120            this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, this.is64bit ? 20 : 5, 16777215);
    121
    122            if (!this.is64bit && this.guiGameSettings.renderDistance == 0)
    123            {
    124                this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("options.farWarning1"), this.width / 2, this.height / 6 + 144 + 1, 11468800);
    125                this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("options.farWarning2"), this.width / 2, this.height / 6 + 144 + 13, 11468800);
    126            }
    127
    128            super.drawScreen(par1, par2, par3);
    129        }
    130    }