    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 field_82282_a = new RenderItem();
    010        private final GuiCreateWorld field_82277_b;
    011        private FlatGeneratorInfo field_82279_c = FlatGeneratorInfo.func_82649_e();
    012        private String field_82276_d;
    013        private String field_82285_m;
    014        private String field_82283_n;
    015        private GuiCreateFlatWorldListSlot field_82284_o;
    016        private GuiButton field_82281_p;
    017        private GuiButton field_82280_q;
    018        private GuiButton field_82278_r;
    019
    020        public GuiCreateFlatWorld(GuiCreateWorld par1, String par2Str)
    021        {
    022            this.field_82277_b = par1;
    023            this.func_82273_a(par2Str);
    024        }
    025
    026        public String func_82275_e()
    027        {
    028            return this.field_82279_c.toString();
    029        }
    030
    031        public void func_82273_a(String par1Str)
    032        {
    033            this.field_82279_c = 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.field_82276_d = StatCollector.translateToLocal("createWorld.customize.flat.title");
    043            this.field_82285_m = StatCollector.translateToLocal("createWorld.customize.flat.tile");
    044            this.field_82283_n = StatCollector.translateToLocal("createWorld.customize.flat.height");
    045            this.field_82284_o = new GuiCreateFlatWorldListSlot(this);
    046            this.controlList.add(this.field_82281_p = new GuiButton(2, this.width / 2 - 154, this.height - 52, 100, 20, StatCollector.translateToLocal("createWorld.customize.flat.addLayer") + " (NYI)"));
    047            this.controlList.add(this.field_82280_q = new GuiButton(3, this.width / 2 - 50, this.height - 52, 100, 20, StatCollector.translateToLocal("createWorld.customize.flat.editLayer") + " (NYI)"));
    048            this.controlList.add(this.field_82278_r = 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.field_82281_p.drawButton = this.field_82280_q.drawButton = false;
    053            this.field_82279_c.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.field_82279_c.func_82650_c().size() - this.field_82284_o.field_82454_a - 1;
    063
    064            if (par1GuiButton.id == 1)
    065            {
    066                this.mc.displayGuiScreen(this.field_82277_b);
    067            }
    068            else if (par1GuiButton.id == 0)
    069            {
    070                this.field_82277_b.field_82290_a = this.func_82275_e();
    071                this.mc.displayGuiScreen(this.field_82277_b);
    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.field_82279_c.func_82650_c().remove(var2);
    080                this.field_82284_o.field_82454_a = Math.min(this.field_82284_o.field_82454_a, this.field_82279_c.func_82650_c().size() - 1);
    081            }
    082
    083            this.field_82279_c.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.field_82278_r.enabled = var1;
    091            this.field_82280_q.enabled = var1;
    092            this.field_82280_q.enabled = false;
    093            this.field_82281_p.enabled = false;
    094        }
    095
    096        private boolean func_82272_i()
    097        {
    098            return this.field_82284_o.field_82454_a > -1 && this.field_82284_o.field_82454_a < this.field_82279_c.func_82650_c().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.field_82284_o.drawScreen(par1, par2, par3);
    108            this.drawCenteredString(this.fontRenderer, this.field_82276_d, this.width / 2, 8, 16777215);
    109            int var4 = this.width / 2 - 92 - 16;
    110            this.drawString(this.fontRenderer, this.field_82285_m, var4, 32, 16777215);
    111            this.drawString(this.fontRenderer, this.field_82283_n, var4 + 2 + 213 - this.fontRenderer.getStringWidth(this.field_82283_n), 32, 16777215);
    112            super.drawScreen(par1, par2, par3);
    113        }
    114
    115        static RenderItem func_82274_h()
    116        {
    117            return field_82282_a;
    118        }
    119
    120        static FlatGeneratorInfo func_82271_a(GuiCreateFlatWorld par0GuiCreateFlatWorld)
    121        {
    122            return par0GuiCreateFlatWorld.field_82279_c;
    123        }
    124    }