diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/ChangeAvatarImageButtons.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/ChangeAvatarImageButtons.java')
| -rw-r--r-- | NET/worlds/scape/ChangeAvatarImageButtons.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/NET/worlds/scape/ChangeAvatarImageButtons.java b/NET/worlds/scape/ChangeAvatarImageButtons.java new file mode 100644 index 0000000..56bd29e --- /dev/null +++ b/NET/worlds/scape/ChangeAvatarImageButtons.java @@ -0,0 +1,42 @@ +package NET.worlds.scape; + +import NET.worlds.console.Console; +import NET.worlds.console.ImageButtons; +import NET.worlds.console.ImageButtonsCallback; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Rectangle; + +class ChangeAvatarImageButtons extends ImageButtons { + private static final int textBoxX = 0; + private static final int textBoxY = 0; + private static final int textBoxW = 177; + private static final int textBoxH = 23; + private static Font font = new Font(Console.message("AvatarFont"), 0, 12); + private static int textWidth; + private static int textX; + private static int textY; + private String text; + + public ChangeAvatarImageButtons(String texture, Rectangle[] rects, ImageButtonsCallback cb, String text) { + super(texture, rects, cb); + this.text = text; + } + + @Override + public void paint(Graphics g) { + super.paint(g); + g.setFont(font); + g.setColor(Color.white); + if (textWidth == 0) { + FontMetrics fm = g.getFontMetrics(); + textWidth = fm.stringWidth(this.text); + textX = (177 - textWidth) / 2; + textY = 23 - (23 - fm.getAscent()) / 2; + } + + g.drawString(this.text, textX, textY); + } +} |