001package net.minecraft.client.gui; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import net.minecraft.client.mco.McoClient; 006import net.minecraft.client.mco.McoServer; 007import net.minecraft.util.StringTranslate; 008import org.lwjgl.input.Keyboard; 009 010@SideOnly(Side.CLIENT) 011public class GuiScreenEditOnlineWorld extends GuiScreen 012{ 013 private GuiScreen field_96204_a; 014 private GuiScreen field_96202_b; 015 private GuiTextField field_96203_c; 016 private GuiTextField field_96201_d; 017 private McoServer field_96205_n; 018 private GuiButton field_96206_o; 019 020 public GuiScreenEditOnlineWorld(GuiScreen par1GuiScreen, GuiScreen par2GuiScreen, McoServer par3McoServer) 021 { 022 this.field_96204_a = par1GuiScreen; 023 this.field_96202_b = par2GuiScreen; 024 this.field_96205_n = par3McoServer; 025 } 026 027 /** 028 * Called from the main game loop to update the screen. 029 */ 030 public void updateScreen() 031 { 032 this.field_96201_d.updateCursorCounter(); 033 this.field_96203_c.updateCursorCounter(); 034 } 035 036 /** 037 * Adds the buttons (and other controls) to the screen in question. 038 */ 039 public void initGui() 040 { 041 StringTranslate stringtranslate = StringTranslate.getInstance(); 042 Keyboard.enableRepeatEvents(true); 043 this.buttonList.clear(); 044 this.buttonList.add(this.field_96206_o = new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, stringtranslate.translateKey("mco.configure.world.buttons.done"))); 045 this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, stringtranslate.translateKey("gui.cancel"))); 046 this.field_96201_d = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 66, 200, 20); 047 this.field_96201_d.setFocused(true); 048 this.field_96201_d.setMaxStringLength(32); 049 this.field_96201_d.setText(this.field_96205_n.func_96398_b()); 050 this.field_96203_c = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 106, 200, 20); 051 this.field_96203_c.setMaxStringLength(32); 052 this.field_96203_c.setText(this.field_96205_n.func_96397_a()); 053 } 054 055 /** 056 * Called when the screen is unloaded. Used to disable keyboard repeat events 057 */ 058 public void onGuiClosed() 059 { 060 Keyboard.enableRepeatEvents(false); 061 } 062 063 /** 064 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). 065 */ 066 protected void actionPerformed(GuiButton par1GuiButton) 067 { 068 if (par1GuiButton.enabled) 069 { 070 if (par1GuiButton.id == 1) 071 { 072 this.mc.displayGuiScreen(this.field_96204_a); 073 } 074 else if (par1GuiButton.id == 0) 075 { 076 this.func_96200_g(); 077 } 078 } 079 } 080 081 private void func_96200_g() 082 { 083 McoClient mcoclient = new McoClient(this.mc.session); 084 085 try 086 { 087 String s = this.field_96203_c.getText() != null && !this.field_96203_c.getText().trim().equals("") ? this.field_96203_c.getText() : ""; 088 mcoclient.func_96384_a(this.field_96205_n.field_96408_a, this.field_96201_d.getText(), s); 089 this.field_96205_n.func_96399_a(this.field_96201_d.getText()); 090 this.field_96205_n.func_96400_b(this.field_96203_c.getText()); 091 this.mc.displayGuiScreen(new GuiScreenConfigureWorld(this.field_96202_b, this.field_96205_n)); 092 } 093 catch (Exception exception) 094 { 095 ; 096 } 097 } 098 099 /** 100 * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). 101 */ 102 protected void keyTyped(char par1, int par2) 103 { 104 this.field_96201_d.textboxKeyTyped(par1, par2); 105 this.field_96203_c.textboxKeyTyped(par1, par2); 106 107 if (par1 == 9) 108 { 109 if (this.field_96201_d.isFocused()) 110 { 111 this.field_96201_d.setFocused(false); 112 this.field_96203_c.setFocused(true); 113 } 114 else 115 { 116 this.field_96201_d.setFocused(true); 117 this.field_96203_c.setFocused(false); 118 } 119 } 120 121 if (par1 == 13) 122 { 123 this.func_96200_g(); 124 } 125 126 this.field_96206_o.enabled = this.field_96201_d.getText() != null && !this.field_96201_d.getText().trim().equals(""); 127 } 128 129 /** 130 * Called when the mouse is clicked. 131 */ 132 protected void mouseClicked(int par1, int par2, int par3) 133 { 134 super.mouseClicked(par1, par2, par3); 135 this.field_96203_c.mouseClicked(par1, par2, par3); 136 this.field_96201_d.mouseClicked(par1, par2, par3); 137 } 138 139 /** 140 * Draws the screen and all the components in it. 141 */ 142 public void drawScreen(int par1, int par2, float par3) 143 { 144 StringTranslate stringtranslate = StringTranslate.getInstance(); 145 this.drawDefaultBackground(); 146 this.drawCenteredString(this.fontRenderer, stringtranslate.translateKey("mco.configure.world.edit.title"), this.width / 2, 17, 16777215); 147 this.drawString(this.fontRenderer, stringtranslate.translateKey("mco.configure.world.name"), this.width / 2 - 100, 53, 10526880); 148 this.drawString(this.fontRenderer, stringtranslate.translateKey("mco.configure.world.description"), this.width / 2 - 100, 94, 10526880); 149 this.field_96201_d.drawTextBox(); 150 this.field_96203_c.drawTextBox(); 151 super.drawScreen(par1, par2, par3); 152 } 153}