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 GuiConfirmOpenLink extends GuiYesNo
009{
010    /** Text to warn players from opening unsafe links. */
011    private String openLinkWarning;
012
013    /** Label for the Copy to Clipboard button. */
014    private String copyLinkButtonText;
015    private String field_92028_p;
016    private boolean field_92027_q = true;
017
018    public GuiConfirmOpenLink(GuiScreen par1GuiScreen, String par2Str, int par3)
019    {
020        super(par1GuiScreen, StringTranslate.getInstance().translateKey("chat.link.confirm"), par2Str, par3);
021        StringTranslate stringtranslate = StringTranslate.getInstance();
022        this.buttonText1 = stringtranslate.translateKey("gui.yes");
023        this.buttonText2 = stringtranslate.translateKey("gui.no");
024        this.copyLinkButtonText = stringtranslate.translateKey("chat.copy");
025        this.openLinkWarning = stringtranslate.translateKey("chat.link.warning");
026        this.field_92028_p = par2Str;
027    }
028
029    /**
030     * Adds the buttons (and other controls) to the screen in question.
031     */
032    public void initGui()
033    {
034        this.buttonList.add(new GuiButton(0, this.width / 3 - 83 + 0, this.height / 6 + 96, 100, 20, this.buttonText1));
035        this.buttonList.add(new GuiButton(2, this.width / 3 - 83 + 105, this.height / 6 + 96, 100, 20, this.copyLinkButtonText));
036        this.buttonList.add(new GuiButton(1, this.width / 3 - 83 + 210, this.height / 6 + 96, 100, 20, this.buttonText2));
037    }
038
039    /**
040     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
041     */
042    protected void actionPerformed(GuiButton par1GuiButton)
043    {
044        if (par1GuiButton.id == 2)
045        {
046            this.copyLinkToClipboard();
047        }
048
049        this.parentScreen.confirmClicked(par1GuiButton.id == 0, this.worldNumber);
050    }
051
052    /**
053     * Copies the link to the system clipboard.
054     */
055    public void copyLinkToClipboard()
056    {
057        setClipboardString(this.field_92028_p);
058    }
059
060    /**
061     * Draws the screen and all the components in it.
062     */
063    public void drawScreen(int par1, int par2, float par3)
064    {
065        super.drawScreen(par1, par2, par3);
066
067        if (this.field_92027_q)
068        {
069            this.drawCenteredString(this.fontRenderer, this.openLinkWarning, this.width / 2, 110, 16764108);
070        }
071    }
072
073    public void func_92026_h()
074    {
075        this.field_92027_q = false;
076    }
077}