    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.GameSettings;
    006    import net.minecraft.util.StringTranslate;
    007
    008    @SideOnly(Side.CLIENT)
    009    public class GuiLanguage extends GuiScreen
    010    {
    011        /** This GUI's parent GUI. */
    012        protected GuiScreen parentGui;
    013
    014        /**
    015         * Timer used to update texture packs, decreases every tick and is reset to 20 and updates texture packs upon
    016         * reaching 0.
    017         */
    018        private int updateTimer = -1;
    019
    020        /** This GUI's language list. */
    021        private GuiSlotLanguage languageList;
    022
    023        /** For saving the user's language selection to disk. */
    024        private final GameSettings theGameSettings;
    025
    026        /** This GUI's 'Done' button. */
    027        private GuiSmallButton doneButton;
    028
    029        public GuiLanguage(GuiScreen par1GuiScreen, GameSettings par2GameSettings)
    030        {
    031            this.parentGui = par1GuiScreen;
    032            this.theGameSettings = 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.controlList.add(this.doneButton = new GuiSmallButton(6, this.width / 2 - 75, this.height - 38, var1.translateKey("gui.done")));
    042            this.languageList = new GuiSlotLanguage(this);
    043            this.languageList.registerScrollButtons(this.controlList, 7, 8);
    044        }
    045
    046        /**
    047         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    048         */
    049        protected void actionPerformed(GuiButton par1GuiButton)
    050        {
    051            if (par1GuiButton.enabled)
    052            {
    053                switch (par1GuiButton.id)
    054                {
    055                    case 5:
    056                        break;
    057                    case 6:
    058                        this.mc.displayGuiScreen(this.parentGui);
    059                        break;
    060                    default:
    061                        this.languageList.actionPerformed(par1GuiButton);
    062                }
    063            }
    064        }
    065
    066        /**
    067         * Draws the screen and all the components in it.
    068         */
    069        public void drawScreen(int par1, int par2, float par3)
    070        {
    071            this.languageList.drawScreen(par1, par2, par3);
    072
    073            if (this.updateTimer <= 0)
    074            {
    075                this.mc.texturePackList.updateAvaliableTexturePacks();
    076                this.updateTimer += 20;
    077            }
    078
    079            StringTranslate var4 = StringTranslate.getInstance();
    080            this.drawCenteredString(this.fontRenderer, var4.translateKey("options.language"), this.width / 2, 16, 16777215);
    081            this.drawCenteredString(this.fontRenderer, "(" + var4.translateKey("options.languageWarning") + ")", this.width / 2, this.height - 56, 8421504);
    082            super.drawScreen(par1, par2, par3);
    083        }
    084
    085        /**
    086         * Called from the main game loop to update the screen.
    087         */
    088        public void updateScreen()
    089        {
    090            super.updateScreen();
    091            --this.updateTimer;
    092        }
    093
    094        /**
    095         * Gets the relevant instance of GameSettings. Synthetic method for use in GuiSlotLanguage
    096         */
    097        static GameSettings getGameSettings(GuiLanguage par0GuiLanguage)
    098        {
    099            return par0GuiLanguage.theGameSettings;
    100        }
    101
    102        /**
    103         * Returns the private doneButton field.
    104         */
    105        static GuiSmallButton getDoneButton(GuiLanguage par0GuiLanguage)
    106        {
    107            return par0GuiLanguage.doneButton;
    108        }
    109    }