mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- autofocus on first duel/challenge when opening the Duels/Challenges page
- allow Enter to start the match when focused on an opponent
This commit is contained in:
@@ -3,10 +3,13 @@ package forge.gui.home.quest;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.ButtonGroup;
|
import javax.swing.ButtonGroup;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
@@ -93,6 +96,15 @@ public enum CSubmenuChallenges implements ICDoc {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final KeyAdapter _startOnEnter = new KeyAdapter() {
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (KeyEvent.VK_ENTER == e.getKeyChar()) {
|
||||||
|
VSubmenuChallenges.SINGLETON_INSTANCE.getBtnStart().doClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.control.home.IControlSubmenu#update()
|
* @see forge.control.home.IControlSubmenu#update()
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +126,13 @@ public enum CSubmenuChallenges implements ICDoc {
|
|||||||
for (int i = 0; i < challenges.size(); i++) {
|
for (int i = 0; i < challenges.size(); i++) {
|
||||||
final PnlEvent temp = new PnlEvent(challenges.get(i));
|
final PnlEvent temp = new PnlEvent(challenges.get(i));
|
||||||
grp.add(temp.getRad());
|
grp.add(temp.getRad());
|
||||||
if (i == 0) { temp.getRad().setSelected(true); }
|
if (i == 0) {
|
||||||
|
temp.getRad().setSelected(true);
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override public void run() { temp.getRad().requestFocusInWindow(); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
temp.getRad().addKeyListener(_startOnEnter);
|
||||||
view.getPnlChallenges().add(temp, "w 96%!, h 135px!, gap 2% 0 15px 15px");
|
view.getPnlChallenges().add(temp, "w 96%!, h 135px!, gap 2% 0 15px 15px");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +145,9 @@ public enum CSubmenuChallenges implements ICDoc {
|
|||||||
lbl.setBorder(new EmptyBorder(10, 10, 10, 10));
|
lbl.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
lbl.setOpaque(true);
|
lbl.setOpaque(true);
|
||||||
view.getPnlChallenges().add(lbl, "w 50%!, h 30px!, gap 25% 0 50px 0");
|
view.getPnlChallenges().add(lbl, "w 50%!, h 30px!, gap 25% 0 50px 0");
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override public void run() { view.getBtnTravel().requestFocusInWindow(); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Singletons.getView().getFrame().validate();
|
Singletons.getView().getFrame().validate();
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package forge.gui.home.quest;
|
|||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.ButtonGroup;
|
import javax.swing.ButtonGroup;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
@@ -75,6 +78,15 @@ public enum CSubmenuDuels implements ICDoc {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final KeyAdapter _startOnEnter = new KeyAdapter() {
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (KeyEvent.VK_ENTER == e.getKeyChar()) {
|
||||||
|
VSubmenuDuels.SINGLETON_INSTANCE.getBtnStart().doClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.control.home.IControlSubmenu#update()
|
* @see forge.control.home.IControlSubmenu#update()
|
||||||
*/
|
*/
|
||||||
@@ -95,7 +107,13 @@ public enum CSubmenuDuels implements ICDoc {
|
|||||||
for (int i = 0; i < duels.size(); i++) {
|
for (int i = 0; i < duels.size(); i++) {
|
||||||
final PnlEvent temp = new PnlEvent(duels.get(i));
|
final PnlEvent temp = new PnlEvent(duels.get(i));
|
||||||
grp.add(temp.getRad());
|
grp.add(temp.getRad());
|
||||||
if (i == 0) { temp.getRad().setSelected(true); }
|
if (i == 0) {
|
||||||
|
temp.getRad().setSelected(true);
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override public void run() { temp.getRad().requestFocusInWindow(); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
temp.getRad().addKeyListener(_startOnEnter);
|
||||||
view.getPnlDuels().add(temp, "w 96%!, h 135px!, gap 2% 0 15px 15px");
|
view.getPnlDuels().add(temp, "w 96%!, h 135px!, gap 2% 0 15px 15px");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,10 +149,9 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
|
|||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblInfo, "h 30px!, span 2");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblInfo, "h 30px!, span 2");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblCurrentDeck, "span 2");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblCurrentDeck, "span 2");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblNextChallengeInWins, "span 2, gap 0 0 0 20px");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblNextChallengeInWins, "span 2, gap 0 0 0 20px");
|
||||||
|
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(scrChallenges, "w 88% - 175px!, pushy, growy");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(scrChallenges, "w 88% - 175px!, pushy, growy");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStats, "w 185px!, pushy, growy, gap 4% 4% 0 0, span 1 2");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStats, "w 185px!, pushy, growy, gap 4% 4% 0 0, span 1 2");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStart, "gap 0 0 50px 50px, ax center");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStart, "gap 0 0 30px 30px, ax center");
|
||||||
|
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().repaintSelf();
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().repaintSelf();
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().revalidate();
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().revalidate();
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
|
|||||||
private final JButton btnStart = new StartButton();
|
private final JButton btnStart = new StartButton();
|
||||||
private final JComboBox cbxPet = new JComboBox();
|
private final JComboBox cbxPet = new JComboBox();
|
||||||
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
||||||
private final JLabel lblZep = new FLabel.Builder().text("Launch Zeppelin")
|
private final JLabel lblZep = new FLabel.Builder().text("Launch Zeppelin").fontSize(14).build();
|
||||||
.fontSize(14).build();
|
|
||||||
|
|
||||||
private final FLabel lblWorld = new FLabel.Builder()
|
private final FLabel lblWorld = new FLabel.Builder()
|
||||||
.icon(FSkin.getIcon(FSkin.QuestIcons.ICO_MAP))
|
.icon(FSkin.getIcon(FSkin.QuestIcons.ICO_MAP))
|
||||||
@@ -147,11 +146,9 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
|
|||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblInfo, "h 30px!, span 2");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblInfo, "h 30px!, span 2");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblCurrentDeck, "span 2");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblCurrentDeck, "span 2");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblNextChallengeInWins, "span 2, gap 0 0 0 20px");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblNextChallengeInWins, "span 2, gap 0 0 0 20px");
|
||||||
|
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(scrDuels, "w 88% - 175px!, pushy, growy");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(scrDuels, "w 88% - 175px!, pushy, growy");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStats, "w 185px!, pushy, growy, gap 4% 4% 0 0, span 1 2");
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStats, "w 185px!, pushy, growy, gap 4% 4% 0 0, span 1 2");
|
||||||
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStart, "gap 0 0 30px 30px, ax center");
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStart, "gap 0 0 50px 50px, ax center");
|
|
||||||
|
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().repaintSelf();
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().repaintSelf();
|
||||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().revalidate();
|
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().revalidate();
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package forge.gui.toolbox;
|
package forge.gui.toolbox;
|
||||||
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
|
|
||||||
import javax.swing.JRadioButton;
|
import javax.swing.JRadioButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,21 +17,7 @@ public class FRadioButton extends JRadioButton {
|
|||||||
super();
|
super();
|
||||||
this.setText(s0);
|
this.setText(s0);
|
||||||
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||||
this.setBackground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
|
|
||||||
this.setFont(FSkin.getFont(14));
|
this.setFont(FSkin.getFont(14));
|
||||||
this.setOpaque(false);
|
this.setOpaque(false);
|
||||||
|
|
||||||
this.addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
setOpaque(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
setOpaque(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user