    001    package net.minecraft.client.gui;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.util.StringTranslate;
    006
    007    @SideOnly(Side.CLIENT)
    008    public abstract 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
    016        public GuiConfirmOpenLink(GuiScreen par1GuiScreen, String par2Str, int par3)
    017        {
    018            super(par1GuiScreen, StringTranslate.getInstance().translateKey("chat.link.confirm"), par2Str, par3);
    019            StringTranslate var4 = StringTranslate.getInstance();
    020            this.buttonText1 = var4.translateKey("gui.yes");
    021            this.buttonText2 = var4.translateKey("gui.no");
    022            this.copyLinkButtonText = var4.translateKey("chat.copy");
    023            this.openLinkWarning = var4.translateKey("chat.link.warning");
    024        }
    025
    026        /**
    027         * Adds the buttons (and other controls) to the screen in question.
    028         */
    029        public void initGui()
    030        {
    031            this.controlList.add(new GuiButton(0, this.width / 3 - 83 + 0, this.height / 6 + 96, 100, 20, this.buttonText1));
    032            this.controlList.add(new GuiButton(2, this.width / 3 - 83 + 105, this.height / 6 + 96, 100, 20, this.copyLinkButtonText));
    033            this.controlList.add(new GuiButton(1, this.width / 3 - 83 + 210, this.height / 6 + 96, 100, 20, this.buttonText2));
    034        }
    035
    036        /**
    037         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    038         */
    039        protected void actionPerformed(GuiButton par1GuiButton)
    040        {
    041            if (par1GuiButton.id == 2)
    042            {
    043                this.copyLinkToClipboard();
    044                super.actionPerformed((GuiButton)this.controlList.get(1));
    045            }
    046            else
    047            {
    048                super.actionPerformed(par1GuiButton);
    049            }
    050        }
    051
    052        /**
    053         * Copies the link to the system clipboard.
    054         */
    055        public abstract void copyLinkToClipboard();
    056
    057        /**
    058         * Draws the screen and all the components in it.
    059         */
    060        public void drawScreen(int par1, int par2, float par3)
    061        {
    062            super.drawScreen(par1, par2, par3);
    063            this.drawCenteredString(this.fontRenderer, this.openLinkWarning, this.width / 2, 110, 16764108);
    064        }
    065    }