Make menu items easier to click

Mention context menu ability select in CHANGES.txt
This commit is contained in:
drdev
2013-11-11 12:39:18 +00:00
parent 0b68e2ade6
commit 0bbd9c103a
3 changed files with 19 additions and 7 deletions

View File

@@ -8,6 +8,12 @@ Forge Beta: 11-##-2013 ver 1.5.5
Release Notes
-------------
- Select abilities using context menu -
Instead of displaying a dialog to select abilities, you'll now get a context menu when left or right clicking cards with multiple ability choices
Each ability will have a keyboard shortcut of 1-9 based on order
Unplayable activated abilities will still appear disabled so shortcuts are constant regardless of game state
- Commander 2013 cards -
Forge now includes many of the new Commander 2013 cards. It may take a few days/weeks before these new card pictures become available for downloading via the "Download LQ Card Pictures" button. The LQ set pictures tend to take a few more weeks/months to process before they become available for downloading via the "Download LQ Set Pictures" button. Please be patient. The Forge devs are not involved in maintaining the servers that house these pictures.

View File

@@ -17,6 +17,7 @@
*/
package forge.gui;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.event.ActionEvent;
@@ -100,6 +101,13 @@ public final class GuiUtils {
}
}
private static final int minItemWidth = 100;
private static final int itemHeight = 25;
public static void setMenuItemSize(JMenuItem item) {
item.setPreferredSize(new Dimension(Math.max(item.getPreferredSize().width, minItemWidth), itemHeight));
}
public static JMenuItem createMenuItem(String label, KeyStroke accelerator, final Runnable onClick, boolean enabled, boolean bold) {
JMenuItem item = new JMenuItem(label);
item.addActionListener(new ActionListener() {
@@ -115,9 +123,10 @@ public final class GuiUtils {
if (bold) {
item.setFont(item.getFont().deriveFont(Font.BOLD));
}
setMenuItemSize(item);
return item;
}
public static void addMenuItem(JPopupMenu parent, String label, KeyStroke accelerator, Runnable onClick) {
parent.add(createMenuItem(label, accelerator, onClick, true, false));
}

View File

@@ -1,6 +1,5 @@
package forge.gui.menus;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
@@ -16,12 +15,10 @@ import javax.swing.event.PopupMenuListener;
import forge.Singletons;
import forge.control.RestartUtil;
import forge.gui.GuiUtils;
import forge.util.TypeUtil;
public final class ForgeMenu {
private static final int minItemWidth = 100;
private static final int itemHeight = 25;
private JPopupMenu popupMenu;
private IMenuProvider provider;
private static HashMap<KeyStroke, JMenuItem> activeShortcuts = new HashMap<KeyStroke, JMenuItem>();
@@ -98,8 +95,8 @@ public final class ForgeMenu {
private void setupItem(JMenuItem item) {
if (item == null) { return; }
item.setPreferredSize(new Dimension(Math.max(item.getPreferredSize().width, minItemWidth), itemHeight));
GuiUtils.setMenuItemSize(item);
KeyStroke shortcut = item.getAccelerator();
if (shortcut != null) {
activeShortcuts.put(shortcut, item);