forked from External/mage
GUI enchancements (themes, sound notification, deck validation) (#6755)
GUI enchancements (themes, sound notification, deck validation)
This commit is contained in:
parent
8c4c2728d6
commit
99d5eafc8a
128 changed files with 1988 additions and 11320 deletions
|
|
@ -12,41 +12,48 @@ import mage.client.dialog.PreferencesDialog;
|
|||
*/
|
||||
public class KeyboundButton extends JButton {
|
||||
|
||||
private final String text;
|
||||
private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13);
|
||||
private final String text;
|
||||
private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13);
|
||||
|
||||
private boolean tinting = false;
|
||||
private boolean tinting = false;
|
||||
|
||||
public KeyboundButton(String key) {
|
||||
text = PreferencesDialog.getCachedKeyText(key);
|
||||
}
|
||||
public KeyboundButton(String key, boolean drawText) {
|
||||
if (drawText) {
|
||||
text = PreferencesDialog.getCachedKeyText(key);
|
||||
} else {
|
||||
text = "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (ui != null && g != null) {
|
||||
Graphics sg = g.create();
|
||||
try {
|
||||
ui.update(sg, this);
|
||||
if (tinting) {
|
||||
sg.setColor(new Color(0, 0, 0, 32));
|
||||
sg.fillRoundRect(2, 2, getWidth() - 4 , getHeight() - 4, 6, 6);
|
||||
}
|
||||
sg.setColor(tinting ? Color.lightGray : Color.white);
|
||||
sg.setFont(keyFont);
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (ui != null && g != null) {
|
||||
Graphics sg = g.create();
|
||||
try {
|
||||
ui.update(sg, this);
|
||||
|
||||
int textWidth = sg.getFontMetrics(keyFont).stringWidth(text);
|
||||
int centerX = (getWidth() - textWidth) / 2;
|
||||
if (tinting) {
|
||||
sg.setColor(new Color(0, 0, 0, 32));
|
||||
sg.fillRoundRect(2, 2, getWidth() - 4 , getHeight() - 4, 6, 6);
|
||||
}
|
||||
sg.setColor(tinting ? Color.lightGray : Color.white);
|
||||
|
||||
sg.drawString(text, centerX, 28);
|
||||
} finally {
|
||||
sg.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!text.isEmpty()) {
|
||||
sg.setFont(keyFont);
|
||||
|
||||
public void setTint(boolean tinting) {
|
||||
this.tinting = tinting;
|
||||
repaint();
|
||||
}
|
||||
int textWidth = sg.getFontMetrics(keyFont).stringWidth(text);
|
||||
int centerX = (getWidth() - textWidth) / 2;
|
||||
|
||||
sg.drawString(text, centerX, 28);
|
||||
}
|
||||
} finally {
|
||||
sg.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTint(boolean tinting) {
|
||||
this.tinting = tinting;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue