mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Make the text on the playing buttons update with the current keybinds
This commit is contained in:
parent
d9ebceec20
commit
5ea636126f
9 changed files with 61 additions and 14 deletions
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.client.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.JButton;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Campbell Suter <znix@znix.xyz>
|
||||
*/
|
||||
public class KeyboundButton extends JButton {
|
||||
|
||||
private final String key;
|
||||
private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13);
|
||||
|
||||
public KeyboundButton(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (ui != null && g != null) {
|
||||
Graphics sg = g.create();
|
||||
try {
|
||||
ui.update(sg, this);
|
||||
sg.setColor(Color.white);
|
||||
sg.setFont(keyFont);
|
||||
|
||||
String text = PreferencesDialog.getCachedKeyText(key);
|
||||
int textWidth = sg.getFontMetrics(keyFont).stringWidth(text);
|
||||
int centerX = (getWidth() - textWidth) / 2;
|
||||
|
||||
sg.drawString(text, centerX, 28);
|
||||
} finally {
|
||||
sg.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,6 +90,7 @@ import mage.client.cards.BigCard;
|
|||
import mage.client.chat.ChatPanelBasic;
|
||||
import mage.client.combat.CombatManager;
|
||||
import mage.client.components.HoverButton;
|
||||
import mage.client.components.KeyboundButton;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.components.ext.dlg.DialogManager;
|
||||
import mage.client.components.layout.RelativeLayout;
|
||||
|
|
@ -1353,13 +1354,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
txtHoldPriority.setToolTipText("Holding priority after the next spell cast or ability activation");
|
||||
txtHoldPriority.setVisible(false);
|
||||
|
||||
btnCancelSkip = new javax.swing.JButton(); // F3
|
||||
btnSkipToNextTurn = new javax.swing.JButton(); // F4
|
||||
btnSkipToEndTurn = new javax.swing.JButton(); // F5
|
||||
btnSkipToNextMain = new javax.swing.JButton(); // F7
|
||||
btnSkipStack = new javax.swing.JButton(); // F8
|
||||
btnSkipToYourTurn = new javax.swing.JButton(); // F9
|
||||
btnSkipToEndStepBeforeYourTurn = new javax.swing.JButton(); // F11
|
||||
btnCancelSkip = new KeyboundButton(KEY_CONTROL_CANCEL_SKIP); // F3
|
||||
btnSkipToNextTurn = new KeyboundButton(KEY_CONTROL_NEXT_TURN); // F4
|
||||
btnSkipToEndTurn = new KeyboundButton(KEY_CONTROL_END_STEP); // F5
|
||||
btnSkipToNextMain = new KeyboundButton(KEY_CONTROL_MAIN_STEP); // F7
|
||||
btnSkipStack = new KeyboundButton(KEY_CONTROL_SKIP_STACK); // F10
|
||||
btnSkipToYourTurn = new KeyboundButton(KEY_CONTROL_YOUR_TURN); // F9
|
||||
btnSkipToEndStepBeforeYourTurn = new KeyboundButton(KEY_CONTROL_PRIOR_END); // F11
|
||||
|
||||
btnConcede = new javax.swing.JButton();
|
||||
btnSwitchHands = new javax.swing.JButton();
|
||||
|
|
@ -2410,13 +2411,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
private mage.client.cards.BigCard bigCard;
|
||||
|
||||
// private JPanel cancelSkipPanel;
|
||||
private javax.swing.JButton btnCancelSkip;
|
||||
private javax.swing.JButton btnSkipToNextTurn; // F4
|
||||
private javax.swing.JButton btnSkipToEndTurn; // F5
|
||||
private javax.swing.JButton btnSkipToNextMain; // F7
|
||||
private javax.swing.JButton btnSkipStack; // F8
|
||||
private javax.swing.JButton btnSkipToYourTurn; // F9
|
||||
private javax.swing.JButton btnSkipToEndStepBeforeYourTurn; // F11
|
||||
private KeyboundButton btnCancelSkip;
|
||||
private KeyboundButton btnSkipToNextTurn; // F4
|
||||
private KeyboundButton btnSkipToEndTurn; // F5
|
||||
private KeyboundButton btnSkipToNextMain; // F7
|
||||
private KeyboundButton btnSkipStack; // F8
|
||||
private KeyboundButton btnSkipToYourTurn; // F9
|
||||
private KeyboundButton btnSkipToEndStepBeforeYourTurn; // F11
|
||||
|
||||
private javax.swing.JButton btnConcede;
|
||||
private javax.swing.JButton btnSwitchHands;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue