001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 import java.util.ArrayList; 006 import java.util.Arrays; 007 import java.util.HashMap; 008 import java.util.Iterator; 009 import java.util.List; 010 import org.lwjgl.input.Keyboard; 011 012 @SideOnly(Side.CLIENT) 013 public class GuiFlatPresets extends GuiScreen 014 { 015 private static RenderItem field_82305_a = new RenderItem(); 016 private static final List field_82301_b = new ArrayList(); 017 private final GuiCreateFlatWorld field_82302_c; 018 private String field_82300_d; 019 private String field_82308_m; 020 private String field_82306_n; 021 private GuiFlatPresetsListSlot field_82307_o; 022 private GuiButton field_82304_p; 023 private GuiTextField field_82303_q; 024 025 public GuiFlatPresets(GuiCreateFlatWorld par1) 026 { 027 this.field_82302_c = par1; 028 } 029 030 /** 031 * Adds the buttons (and other controls) to the screen in question. 032 */ 033 public void initGui() 034 { 035 this.controlList.clear(); 036 Keyboard.enableRepeatEvents(true); 037 this.field_82300_d = StatCollector.translateToLocal("createWorld.customize.presets.title"); 038 this.field_82308_m = StatCollector.translateToLocal("createWorld.customize.presets.share"); 039 this.field_82306_n = StatCollector.translateToLocal("createWorld.customize.presets.list"); 040 this.field_82303_q = new GuiTextField(this.fontRenderer, 50, 40, this.width - 100, 20); 041 this.field_82307_o = new GuiFlatPresetsListSlot(this); 042 this.field_82303_q.setMaxStringLength(1230); 043 this.field_82303_q.setText(this.field_82302_c.func_82275_e()); 044 this.controlList.add(this.field_82304_p = new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, StatCollector.translateToLocal("createWorld.customize.presets.select"))); 045 this.controlList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, StatCollector.translateToLocal("gui.cancel"))); 046 this.func_82296_g(); 047 } 048 049 /** 050 * Called when the screen is unloaded. Used to disable keyboard repeat events 051 */ 052 public void onGuiClosed() 053 { 054 Keyboard.enableRepeatEvents(false); 055 } 056 057 /** 058 * Called when the mouse is clicked. 059 */ 060 protected void mouseClicked(int par1, int par2, int par3) 061 { 062 this.field_82303_q.mouseClicked(par1, par2, par3); 063 super.mouseClicked(par1, par2, par3); 064 } 065 066 /** 067 * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). 068 */ 069 protected void keyTyped(char par1, int par2) 070 { 071 if (!this.field_82303_q.textboxKeyTyped(par1, par2)) 072 { 073 super.keyTyped(par1, par2); 074 } 075 } 076 077 /** 078 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). 079 */ 080 protected void actionPerformed(GuiButton par1GuiButton) 081 { 082 if (par1GuiButton.id == 0 && this.func_82293_j()) 083 { 084 this.field_82302_c.func_82273_a(this.field_82303_q.getText()); 085 this.mc.displayGuiScreen(this.field_82302_c); 086 } 087 else if (par1GuiButton.id == 1) 088 { 089 this.mc.displayGuiScreen(this.field_82302_c); 090 } 091 } 092 093 /** 094 * Draws the screen and all the components in it. 095 */ 096 public void drawScreen(int par1, int par2, float par3) 097 { 098 this.drawDefaultBackground(); 099 this.field_82307_o.drawScreen(par1, par2, par3); 100 this.drawCenteredString(this.fontRenderer, this.field_82300_d, this.width / 2, 8, 16777215); 101 this.drawString(this.fontRenderer, this.field_82308_m, 50, 30, 10526880); 102 this.drawString(this.fontRenderer, this.field_82306_n, 50, 70, 10526880); 103 this.field_82303_q.drawTextBox(); 104 super.drawScreen(par1, par2, par3); 105 } 106 107 /** 108 * Called from the main game loop to update the screen. 109 */ 110 public void updateScreen() 111 { 112 this.field_82303_q.updateCursorCounter(); 113 super.updateScreen(); 114 } 115 116 public void func_82296_g() 117 { 118 boolean var1 = this.func_82293_j(); 119 this.field_82304_p.enabled = var1; 120 } 121 122 private boolean func_82293_j() 123 { 124 return this.field_82307_o.field_82459_a > -1 && this.field_82307_o.field_82459_a < field_82301_b.size() || this.field_82303_q.getText().length() > 1; 125 } 126 127 public static void func_82297_a(String par0Str, int par1, BiomeGenBase par2BiomeGenBase, FlatLayerInfo ... par3ArrayOfFlatLayerInfo) 128 { 129 func_82294_a(par0Str, par1, par2BiomeGenBase, (List)null, par3ArrayOfFlatLayerInfo); 130 } 131 132 public static void func_82294_a(String par0Str, int par1, BiomeGenBase par2BiomeGenBase, List par3List, FlatLayerInfo ... par4ArrayOfFlatLayerInfo) 133 { 134 FlatGeneratorInfo var5 = new FlatGeneratorInfo(); 135 136 for (int var6 = par4ArrayOfFlatLayerInfo.length - 1; var6 >= 0; --var6) 137 { 138 var5.func_82650_c().add(par4ArrayOfFlatLayerInfo[var6]); 139 } 140 141 var5.func_82647_a(par2BiomeGenBase.biomeID); 142 var5.func_82645_d(); 143 144 if (par3List != null) 145 { 146 Iterator var8 = par3List.iterator(); 147 148 while (var8.hasNext()) 149 { 150 String var7 = (String)var8.next(); 151 var5.func_82644_b().put(var7, new HashMap()); 152 } 153 } 154 155 field_82301_b.add(new GuiFlatPresetsItem(par1, par0Str, var5.toString())); 156 } 157 158 static RenderItem func_82299_h() 159 { 160 return field_82305_a; 161 } 162 163 static List func_82295_i() 164 { 165 return field_82301_b; 166 } 167 168 static GuiFlatPresetsListSlot func_82292_a(GuiFlatPresets par0GuiFlatPresets) 169 { 170 return par0GuiFlatPresets.field_82307_o; 171 } 172 173 static GuiTextField func_82298_b(GuiFlatPresets par0GuiFlatPresets) 174 { 175 return par0GuiFlatPresets.field_82303_q; 176 } 177 178 static 179 { 180 func_82294_a("Classic Flat", Block.grass.blockID, BiomeGenBase.plains, Arrays.asList(new String[] {"village"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Block.grass.blockID), new FlatLayerInfo(2, Block.dirt.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); 181 func_82294_a("Tunnelers\' Dream", Block.stone.blockID, BiomeGenBase.extremeHills, Arrays.asList(new String[] {"biome_1", "dungeon", "decoration", "stronghold", "mineshaft"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Block.grass.blockID), new FlatLayerInfo(5, Block.dirt.blockID), new FlatLayerInfo(230, Block.stone.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); 182 func_82294_a("Water World", Block.waterMoving.blockID, BiomeGenBase.plains, Arrays.asList(new String[] {"village", "biome_1"}), new FlatLayerInfo[] {new FlatLayerInfo(90, Block.waterStill.blockID), new FlatLayerInfo(5, Block.sand.blockID), new FlatLayerInfo(5, Block.dirt.blockID), new FlatLayerInfo(5, Block.stone.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); 183 func_82294_a("Overworld", Block.tallGrass.blockID, BiomeGenBase.plains, Arrays.asList(new String[] {"village", "biome_1", "decoration", "stronghold", "mineshaft", "dungeon", "lake", "lava_lake"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Block.grass.blockID), new FlatLayerInfo(3, Block.dirt.blockID), new FlatLayerInfo(59, Block.stone.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); 184 func_82294_a("Snowy Kingdom", Block.snow.blockID, BiomeGenBase.icePlains, Arrays.asList(new String[] {"village", "biome_1"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Block.snow.blockID), new FlatLayerInfo(1, Block.grass.blockID), new FlatLayerInfo(3, Block.dirt.blockID), new FlatLayerInfo(59, Block.stone.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); 185 func_82294_a("Bottomless Pit", Item.feather.shiftedIndex, BiomeGenBase.plains, Arrays.asList(new String[] {"village", "biome_1"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Block.grass.blockID), new FlatLayerInfo(3, Block.dirt.blockID), new FlatLayerInfo(2, Block.cobblestone.blockID)}); 186 func_82294_a("Desert", Block.sand.blockID, BiomeGenBase.desert, Arrays.asList(new String[] {"village", "biome_1", "decoration", "stronghold", "mineshaft", "dungeon"}), new FlatLayerInfo[] {new FlatLayerInfo(8, Block.sand.blockID), new FlatLayerInfo(52, Block.sandStone.blockID), new FlatLayerInfo(3, Block.stone.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); 187 func_82297_a("Redstone Ready", Item.redstone.shiftedIndex, BiomeGenBase.desert, new FlatLayerInfo[] {new FlatLayerInfo(52, Block.sandStone.blockID), new FlatLayerInfo(3, Block.stone.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); 188 } 189 }