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