    001package net.minecraft.client.gui;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.util.StringTranslate;
    006
    007@SideOnly(Side.CLIENT)
    008public class GuiYesNo extends GuiScreen
    009{
    010    /**
    011     * A reference to the screen object that created this. Used for navigating between screens.
    012     */
    013    protected GuiScreen parentScreen;
    014
    015    /** First line of text. */
    016    private String message1;
    017
    018    /** Second line of text. */
    019    private String message2;
    020
    021    /** The text shown for the first button in GuiYesNo */
    022    protected String buttonText1;
    023
    024    /** The text shown for the second button in GuiYesNo */
    025    protected String buttonText2;
    026
    027    /** World number to be deleted. */
    028    protected int worldNumber;
    029
    030    public GuiYesNo(GuiScreen par1GuiScreen, String par2Str, String par3Str, int par4)
    031    {
    032        this.parentScreen = par1GuiScreen;
    033        this.message1 = par2Str;
    034        this.message2 = par3Str;
    035        this.worldNumber = par4;
    036        StringTranslate stringtranslate = StringTranslate.getInstance();
    037        this.buttonText1 = stringtranslate.translateKey("gui.yes");
    038        this.buttonText2 = stringtranslate.translateKey("gui.no");
    039    }
    040
    041    public GuiYesNo(GuiScreen par1GuiScreen, String par2Str, String par3Str, String par4Str, String par5Str, int par6)
    042    {
    043        this.parentScreen = par1GuiScreen;
    044        this.message1 = par2Str;
    045        this.message2 = par3Str;
    046        this.buttonText1 = par4Str;
    047        this.buttonText2 = par5Str;
    048        this.worldNumber = par6;
    049    }
    050
    051    /**
    052     * Adds the buttons (and other controls) to the screen in question.
    053     */
    054    public void initGui()
    055    {
    056        this.buttonList.add(new GuiSmallButton(0, this.width / 2 - 155, this.height / 6 + 96, this.buttonText1));
    057        this.buttonList.add(new GuiSmallButton(1, this.width / 2 - 155 + 160, this.height / 6 + 96, this.buttonText2));
    058    }
    059
    060    /**
    061     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    062     */
    063    protected void actionPerformed(GuiButton par1GuiButton)
    064    {
    065        this.parentScreen.confirmClicked(par1GuiButton.id == 0, this.worldNumber);
    066    }
    067
    068    /**
    069     * Draws the screen and all the components in it.
    070     */
    071    public void drawScreen(int par1, int par2, float par3)
    072    {
    073        this.drawDefaultBackground();
    074        this.drawCenteredString(this.fontRenderer, this.message1, this.width / 2, 70, 16777215);
    075        this.drawCenteredString(this.fontRenderer, this.message2, this.width / 2, 90, 16777215);
    076        super.drawScreen(par1, par2, par3);
    077    }
    078}