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