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 GuiCreateFlatWorld extends GuiScreen
008 {
009 private static RenderItem theRenderItem = new RenderItem();
010 private final GuiCreateWorld createWorldGui;
011 private FlatGeneratorInfo theFlatGeneratorInfo = FlatGeneratorInfo.func_82649_e();
012 private String customizationTitle;
013 private String layerMaterialLabel;
014 private String heightLabel;
015 private GuiCreateFlatWorldListSlot createFlatWorldListSlotGui;
016 private GuiButton buttonAddLayer;
017 private GuiButton buttonEditLayer;
018 private GuiButton buttonRemoveLayer;
019
020 public GuiCreateFlatWorld(GuiCreateWorld par1, String par2Str)
021 {
022 this.createWorldGui = par1;
023 this.func_82273_a(par2Str);
024 }
025
026 public String func_82275_e()
027 {
028 return this.theFlatGeneratorInfo.toString();
029 }
030
031 public void func_82273_a(String par1Str)
032 {
033 this.theFlatGeneratorInfo = FlatGeneratorInfo.func_82651_a(par1Str);
034 }
035
036 /**
037 * Adds the buttons (and other controls) to the screen in question.
038 */
039 public void initGui()
040 {
041 this.controlList.clear();
042 this.customizationTitle = StatCollector.translateToLocal("createWorld.customize.flat.title");
043 this.layerMaterialLabel = StatCollector.translateToLocal("createWorld.customize.flat.tile");
044 this.heightLabel = StatCollector.translateToLocal("createWorld.customize.flat.height");
045 this.createFlatWorldListSlotGui = new GuiCreateFlatWorldListSlot(this);
046 this.controlList.add(this.buttonAddLayer = new GuiButton(2, this.width / 2 - 154, this.height - 52, 100, 20, StatCollector.translateToLocal("createWorld.customize.flat.addLayer") + " (NYI)"));
047 this.controlList.add(this.buttonEditLayer = new GuiButton(3, this.width / 2 - 50, this.height - 52, 100, 20, StatCollector.translateToLocal("createWorld.customize.flat.editLayer") + " (NYI)"));
048 this.controlList.add(this.buttonRemoveLayer = new GuiButton(4, this.width / 2 - 155, this.height - 52, 150, 20, StatCollector.translateToLocal("createWorld.customize.flat.removeLayer")));
049 this.controlList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, StatCollector.translateToLocal("gui.done")));
050 this.controlList.add(new GuiButton(5, this.width / 2 + 5, this.height - 52, 150, 20, StatCollector.translateToLocal("createWorld.customize.presets")));
051 this.controlList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, StatCollector.translateToLocal("gui.cancel")));
052 this.buttonAddLayer.drawButton = this.buttonEditLayer.drawButton = false;
053 this.theFlatGeneratorInfo.func_82645_d();
054 this.func_82270_g();
055 }
056
057 /**
058 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
059 */
060 protected void actionPerformed(GuiButton par1GuiButton)
061 {
062 int var2 = this.theFlatGeneratorInfo.getFlatLayers().size() - this.createFlatWorldListSlotGui.field_82454_a - 1;
063
064 if (par1GuiButton.id == 1)
065 {
066 this.mc.displayGuiScreen(this.createWorldGui);
067 }
068 else if (par1GuiButton.id == 0)
069 {
070 this.createWorldGui.field_82290_a = this.func_82275_e();
071 this.mc.displayGuiScreen(this.createWorldGui);
072 }
073 else if (par1GuiButton.id == 5)
074 {
075 this.mc.displayGuiScreen(new GuiFlatPresets(this));
076 }
077 else if (par1GuiButton.id == 4 && this.func_82272_i())
078 {
079 this.theFlatGeneratorInfo.getFlatLayers().remove(var2);
080 this.createFlatWorldListSlotGui.field_82454_a = Math.min(this.createFlatWorldListSlotGui.field_82454_a, this.theFlatGeneratorInfo.getFlatLayers().size() - 1);
081 }
082
083 this.theFlatGeneratorInfo.func_82645_d();
084 this.func_82270_g();
085 }
086
087 public void func_82270_g()
088 {
089 boolean var1 = this.func_82272_i();
090 this.buttonRemoveLayer.enabled = var1;
091 this.buttonEditLayer.enabled = var1;
092 this.buttonEditLayer.enabled = false;
093 this.buttonAddLayer.enabled = false;
094 }
095
096 private boolean func_82272_i()
097 {
098 return this.createFlatWorldListSlotGui.field_82454_a > -1 && this.createFlatWorldListSlotGui.field_82454_a < this.theFlatGeneratorInfo.getFlatLayers().size();
099 }
100
101 /**
102 * Draws the screen and all the components in it.
103 */
104 public void drawScreen(int par1, int par2, float par3)
105 {
106 this.drawDefaultBackground();
107 this.createFlatWorldListSlotGui.drawScreen(par1, par2, par3);
108 this.drawCenteredString(this.fontRenderer, this.customizationTitle, this.width / 2, 8, 16777215);
109 int var4 = this.width / 2 - 92 - 16;
110 this.drawString(this.fontRenderer, this.layerMaterialLabel, var4, 32, 16777215);
111 this.drawString(this.fontRenderer, this.heightLabel, var4 + 2 + 213 - this.fontRenderer.getStringWidth(this.heightLabel), 32, 16777215);
112 super.drawScreen(par1, par2, par3);
113 }
114
115 static RenderItem getRenderItem()
116 {
117 return theRenderItem;
118 }
119
120 static FlatGeneratorInfo func_82271_a(GuiCreateFlatWorld par0GuiCreateFlatWorld)
121 {
122 return par0GuiCreateFlatWorld.theFlatGeneratorInfo;
123 }
124 }