    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005
    006    @SideOnly(Side.CLIENT)
    007    public class ScreenChatOptions extends GuiScreen
    008    {
    009        /** An array of all EnumOptions which are to do with chat. */
    010        private static final EnumOptions[] allScreenChatOptions = new EnumOptions[] {EnumOptions.CHAT_VISIBILITY, EnumOptions.CHAT_COLOR, EnumOptions.CHAT_LINKS, EnumOptions.CHAT_OPACITY, EnumOptions.CHAT_LINKS_PROMPT};
    011        private static final EnumOptions[] field_82267_b = new EnumOptions[] {EnumOptions.SHOW_CAPE};
    012
    013        /** Instance of GuiScreen. */
    014        private final GuiScreen theGuiScreen;
    015
    016        /** Instance of GameSettings file. */
    017        private final GameSettings theSettings;
    018        private String theChatOptions;
    019        private String field_82268_n;
    020        private int field_82269_o = 0;
    021
    022        public ScreenChatOptions(GuiScreen par1GuiScreen, GameSettings par2GameSettings)
    023        {
    024            this.theGuiScreen = par1GuiScreen;
    025            this.theSettings = par2GameSettings;
    026        }
    027
    028        /**
    029         * Adds the buttons (and other controls) to the screen in question.
    030         */
    031        public void initGui()
    032        {
    033            StringTranslate var1 = StringTranslate.getInstance();
    034            int var2 = 0;
    035            this.theChatOptions = var1.translateKey("options.chat.title");
    036            this.field_82268_n = var1.translateKey("options.multiplayer.title");
    037            EnumOptions[] var3 = allScreenChatOptions;
    038            int var4 = var3.length;
    039            int var5;
    040            EnumOptions var6;
    041
    042            for (var5 = 0; var5 < var4; ++var5)
    043            {
    044                var6 = var3[var5];
    045
    046                if (var6.getEnumFloat())
    047                {
    048                    this.controlList.add(new GuiSlider(var6.returnEnumOrdinal(), this.width / 2 - 155 + var2 % 2 * 160, this.height / 6 + 24 * (var2 >> 1), var6, this.theSettings.getKeyBinding(var6), this.theSettings.getOptionFloatValue(var6)));
    049                }
    050                else
    051                {
    052                    this.controlList.add(new GuiSmallButton(var6.returnEnumOrdinal(), this.width / 2 - 155 + var2 % 2 * 160, this.height / 6 + 24 * (var2 >> 1), var6, this.theSettings.getKeyBinding(var6)));
    053                }
    054
    055                ++var2;
    056            }
    057
    058            if (var2 % 2 == 1)
    059            {
    060                ++var2;
    061            }
    062
    063            this.field_82269_o = this.height / 6 + 24 * (var2 >> 1);
    064            var2 += 2;
    065            var3 = field_82267_b;
    066            var4 = var3.length;
    067
    068            for (var5 = 0; var5 < var4; ++var5)
    069            {
    070                var6 = var3[var5];
    071
    072                if (var6.getEnumFloat())
    073                {
    074                    this.controlList.add(new GuiSlider(var6.returnEnumOrdinal(), this.width / 2 - 155 + var2 % 2 * 160, this.height / 6 + 24 * (var2 >> 1), var6, this.theSettings.getKeyBinding(var6), this.theSettings.getOptionFloatValue(var6)));
    075                }
    076                else
    077                {
    078                    this.controlList.add(new GuiSmallButton(var6.returnEnumOrdinal(), this.width / 2 - 155 + var2 % 2 * 160, this.height / 6 + 24 * (var2 >> 1), var6, this.theSettings.getKeyBinding(var6)));
    079                }
    080
    081                ++var2;
    082            }
    083
    084            this.controlList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done")));
    085        }
    086
    087        /**
    088         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    089         */
    090        protected void actionPerformed(GuiButton par1GuiButton)
    091        {
    092            if (par1GuiButton.enabled)
    093            {
    094                if (par1GuiButton.id < 100 && par1GuiButton instanceof GuiSmallButton)
    095                {
    096                    this.theSettings.setOptionValue(((GuiSmallButton)par1GuiButton).returnEnumOptions(), 1);
    097                    par1GuiButton.displayString = this.theSettings.getKeyBinding(EnumOptions.getEnumOptions(par1GuiButton.id));
    098                }
    099
    100                if (par1GuiButton.id == 200)
    101                {
    102                    this.mc.gameSettings.saveOptions();
    103                    this.mc.displayGuiScreen(this.theGuiScreen);
    104                }
    105            }
    106        }
    107
    108        /**
    109         * Draws the screen and all the components in it.
    110         */
    111        public void drawScreen(int par1, int par2, float par3)
    112        {
    113            this.drawDefaultBackground();
    114            this.drawCenteredString(this.fontRenderer, this.theChatOptions, this.width / 2, 20, 16777215);
    115            this.drawCenteredString(this.fontRenderer, this.field_82268_n, this.width / 2, this.field_82269_o + 7, 16777215);
    116            super.drawScreen(par1, par2, par3);
    117        }
    118    }