diff --git a/sigIRCv2.jar b/sigIRCv2.jar index 7c9fea3..9580cd9 100644 Binary files a/sigIRCv2.jar and b/sigIRCv2.jar differ diff --git a/src/sig/modules/Controller/ClickableButton.java b/src/sig/modules/Controller/ClickableButton.java index a0dfdcb..0dcdc6e 100644 --- a/src/sig/modules/Controller/ClickableButton.java +++ b/src/sig/modules/Controller/ClickableButton.java @@ -14,9 +14,13 @@ import sig.utils.TextUtils; public class ClickableButton { protected int x,y,width,height; protected String label; - protected Module module; + protected ControllerModule module; - public ClickableButton(Rectangle position, String button_label, Module parent_module) { + public ClickableButton(Rectangle position, String button_label) { + this(position,button_label,null); + } + + public ClickableButton(Rectangle position, String button_label, ControllerModule parent_module) { this.x = (int)position.getX(); this.y = (int)position.getY(); this.width = (int)position.getWidth(); diff --git a/src/sig/modules/Controller/clickablebutton/CopyClickableButton.java b/src/sig/modules/Controller/clickablebutton/CopyClickableButton.java index e6f2bf7..89d7923 100644 --- a/src/sig/modules/Controller/clickablebutton/CopyClickableButton.java +++ b/src/sig/modules/Controller/clickablebutton/CopyClickableButton.java @@ -17,7 +17,7 @@ public class CopyClickableButton extends ClickableButton{ public void onClickEvent(MouseEvent ev) { super.onClickEvent(ev); - if (mouseInsideBounds(ev)) {; + if (mouseInsideBounds(ev)) { module.resetDragPoints(); } } diff --git a/src/sig/modules/RabiRace/ClickableButton.java b/src/sig/modules/RabiRace/ClickableButton.java new file mode 100644 index 0000000..178c94c --- /dev/null +++ b/src/sig/modules/RabiRace/ClickableButton.java @@ -0,0 +1,55 @@ +package sig.modules.RabiRace; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; + +import sig.Module; +import sig.sigIRC; +import sig.modules.ControllerModule; +import sig.modules.RabiRaceModule; +import sig.utils.DrawUtils; +import sig.utils.TextUtils; + +public class ClickableButton { + protected int x,y,width,height; + protected String label; + protected RabiRaceModule module; + + public ClickableButton(Rectangle position, String button_label, RabiRaceModule parent_module) { + this.x = (int)position.getX(); + this.y = (int)position.getY(); + this.width = (int)position.getWidth(); + this.height = (int)position.getHeight(); + this.label=button_label; + this.module = parent_module; + } + + public void onClickEvent(MouseEvent ev) { + /*if (mouseInsideBounds(ev)) { + //System.out.println("Click performed!"); + }*/ + } + + public void setButtonLabel(String text) { + this.label = text; + } + + public boolean mouseInsideBounds(MouseEvent ev) { + return ev.getX()>=module.getPosition().getX()+x && ev.getX()<=module.getPosition().getX()+x+width && + ev.getY()>=module.getPosition().getY()+y && ev.getY()<=module.getPosition().getY()+y+height; + } + + public void draw(Graphics g) { + Color color_identity = g.getColor(); + g.setColor(Color.WHITE); + g.drawRect((int)module.getPosition().getX()+x, + (int)module.getPosition().getY()+y, width, height); + g.setColor(Color.BLACK); + g.fillRect((int)module.getPosition().getX()+x+1, + (int)module.getPosition().getY()+y+1, width-1, height-1); + DrawUtils.drawTextFont(g, sigIRC.panel.userFont, module.getPosition().getX()+x-TextUtils.calculateStringBoundsFont(label, sigIRC.panel.userFont).getWidth()/2+width/2, module.getPosition().getY()+y+height-1, Color.WHITE, label); + g.setColor(color_identity); + } +} diff --git a/src/sig/modules/RabiRace/CreateButton.java b/src/sig/modules/RabiRace/CreateButton.java index 89a5cbd..7a96346 100644 --- a/src/sig/modules/RabiRace/CreateButton.java +++ b/src/sig/modules/RabiRace/CreateButton.java @@ -5,12 +5,11 @@ import java.awt.event.MouseEvent; import sig.Module; import sig.modules.RabiRaceModule; -import sig.modules.Controller.ClickableButton; public class CreateButton extends ClickableButton{ - public CreateButton(Rectangle position, String button_label, Module parent_module) { - super(position, button_label, parent_module); + public CreateButton(Rectangle position, String button_label, RabiRaceModule module) { + super(position, button_label, module); } public void onClickEvent(MouseEvent ev) { diff --git a/src/sig/modules/RabiRace/JoinButton.java b/src/sig/modules/RabiRace/JoinButton.java index 907abcf..7bb525d 100644 --- a/src/sig/modules/RabiRace/JoinButton.java +++ b/src/sig/modules/RabiRace/JoinButton.java @@ -10,12 +10,11 @@ import java.net.URL; import sig.Module; import sig.sigIRC; import sig.modules.RabiRaceModule; -import sig.modules.Controller.ClickableButton; public class JoinButton extends ClickableButton{ - public JoinButton(Rectangle position, String button_label, Module parent_module) { - super(position, button_label, parent_module); + public JoinButton(Rectangle position, String button_label, RabiRaceModule module) { + super(position,button_label,module); } public void onClickEvent(MouseEvent ev) { diff --git a/src/sig/modules/RabiRaceModule.java b/src/sig/modules/RabiRaceModule.java index 0f7f719..6cdc7da 100644 --- a/src/sig/modules/RabiRaceModule.java +++ b/src/sig/modules/RabiRaceModule.java @@ -31,7 +31,7 @@ import com.sun.jna.platform.win32.WinNT.HANDLE; import sig.FileManager; import sig.Module; import sig.sigIRC; -import sig.modules.Controller.ClickableButton; +import sig.modules.RabiRace.ClickableButton; import sig.modules.RabiRace.ColorCycler; import sig.modules.RabiRace.CreateButton; import sig.modules.RabiRace.JoinButton;