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