commit
b64061aa90
|
@ -50,12 +50,12 @@ public class AmidstMenuBuilder {
|
|||
JMenu result = new JMenu("File");
|
||||
result.setMnemonic(KeyEvent.VK_F);
|
||||
// @formatter:off
|
||||
Menus.item(result, actions::newFromSeed, "New from seed", KeyEvent.VK_N, "N");
|
||||
Menus.item(result, actions::newFromRandom, "New from random seed", KeyEvent.VK_R, "R");
|
||||
Menus.item(result, actions::openSaveGame, "Open save game ...", KeyEvent.VK_O, "O");
|
||||
Menus.item(result, actions::newFromSeed, "New from seed", KeyEvent.VK_N, "menu N");
|
||||
Menus.item(result, actions::newFromRandom, "New from random seed", KeyEvent.VK_R, "menu R");
|
||||
Menus.item(result, actions::openSaveGame, "Open save game ...", KeyEvent.VK_O, "menu O");
|
||||
result.addSeparator();
|
||||
Menus.item(result, actions::switchProfile, "Switch profile ...", KeyEvent.VK_P, "W");
|
||||
Menus.item(result, actions::exit, "Exit", KeyEvent.VK_X, "Q");
|
||||
Menus.item(result, actions::switchProfile, "Switch profile ...", KeyEvent.VK_P, "menu W");
|
||||
Menus.item(result, actions::exit, "Exit", KeyEvent.VK_X, "menu Q");
|
||||
// @formatter:on
|
||||
return result;
|
||||
}
|
||||
|
@ -65,21 +65,21 @@ public class AmidstMenuBuilder {
|
|||
result.setEnabled(false);
|
||||
result.setMnemonic(KeyEvent.VK_W);
|
||||
// @formatter:off
|
||||
Menus.item(result, actions::goToCoordinate, "Go to Coordinate", KeyEvent.VK_C, "shift C");
|
||||
Menus.item(result, actions::goToSpawn, "Go to World Spawn", KeyEvent.VK_S, "shift S");
|
||||
Menus.item(result, actions::goToStronghold, "Go to Stronghold", KeyEvent.VK_H, "shift H");
|
||||
Menus.item(result, actions::goToPlayer, "Go to Player", KeyEvent.VK_P, "shift P");
|
||||
Menus.item(result, actions::goToCoordinate, "Go to Coordinate", KeyEvent.VK_C, "menu shift C");
|
||||
Menus.item(result, actions::goToSpawn, "Go to World Spawn", KeyEvent.VK_S, "menu shift S");
|
||||
Menus.item(result, actions::goToStronghold, "Go to Stronghold", KeyEvent.VK_H, "menu shift H");
|
||||
Menus.item(result, actions::goToPlayer, "Go to Player", KeyEvent.VK_P, "menu shift P");
|
||||
result.addSeparator();
|
||||
savePlayerLocationsMenu =
|
||||
Menus.item(result, actions::savePlayerLocations, "Save player locations", KeyEvent.VK_V, "S");
|
||||
Menus.item(result, actions::savePlayerLocations, "Save player locations", KeyEvent.VK_V, "menu S");
|
||||
savePlayerLocationsMenu.setEnabled(false);
|
||||
reloadPlayerLocationsMenu =
|
||||
Menus.item(result, actions::reloadPlayerLocations, "Reload player locations", KeyEvent.VK_R, "@F5");
|
||||
Menus.item(result, actions::reloadPlayerLocations, "Reload player locations", KeyEvent.VK_R, "F5");
|
||||
reloadPlayerLocationsMenu.setEnabled(false);
|
||||
Menus.item(result, actions::howCanIMoveAPlayer, "How can I move a player?", KeyEvent.VK_M);
|
||||
result.addSeparator();
|
||||
Menus.item(result, actions::copySeedToClipboard, "Copy Seed to Clipboard", KeyEvent.VK_B, "C");
|
||||
Menus.item(result, actions::saveCaptureImage, "Save capture image ...", KeyEvent.VK_I, "T");
|
||||
Menus.item(result, actions::copySeedToClipboard, "Copy Seed to Clipboard", KeyEvent.VK_B, "menu C");
|
||||
Menus.item(result, actions::saveCaptureImage, "Save capture image ...", KeyEvent.VK_I, "menu T");
|
||||
// @formatter:on
|
||||
return result;
|
||||
}
|
||||
|
@ -100,11 +100,11 @@ public class AmidstMenuBuilder {
|
|||
}
|
||||
result.addSeparator();
|
||||
// @formatter:off
|
||||
Menus.checkbox(result, settings.smoothScrolling, "Smooth Scrolling", "I");
|
||||
Menus.checkbox(result, settings.smoothScrolling, "Smooth Scrolling", "menu I");
|
||||
Menus.checkbox(result, settings.fragmentFading, "Fragment Fading");
|
||||
Menus.checkbox(result, settings.maxZoom, "Restrict Maximum Zoom", "Z");
|
||||
Menus.checkbox(result, settings.showFPS, "Show Framerate", "L");
|
||||
Menus.checkbox(result, settings.showScale, "Show Scale", "K");
|
||||
Menus.checkbox(result, settings.maxZoom, "Restrict Maximum Zoom", "menu Z");
|
||||
Menus.checkbox(result, settings.showFPS, "Show Framerate", "menu L");
|
||||
Menus.checkbox(result, settings.showScale, "Show Scale", "menu K");
|
||||
Menus.checkbox(result, settings.showDebug, "Show Debug Information");
|
||||
// @formatter:on
|
||||
return result;
|
||||
|
@ -120,7 +120,9 @@ public class AmidstMenuBuilder {
|
|||
|
||||
private JMenu create_Settings_BiomeProfile() {
|
||||
JMenu result = new JMenu("Biome profile");
|
||||
new BiomeProfileMenuFactory(result, actions, biomeProfileDirectory);
|
||||
// @formatter:off
|
||||
new BiomeProfileMenuFactory(result, actions, biomeProfileDirectory, "Reload biome profiles", KeyEvent.VK_R, "menu B");
|
||||
// @formatter:on
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,11 @@ package amidst.gui.main.menu;
|
|||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import amidst.documentation.NotThreadSafe;
|
||||
|
@ -114,12 +111,19 @@ public class BiomeProfileMenuFactory {
|
|||
private final JMenu parentMenu;
|
||||
private final Actions actions;
|
||||
private final BiomeProfileDirectory biomeProfileDirectory;
|
||||
private final String reloadText;
|
||||
private final int reloadMnemonic;
|
||||
private final String reloadAccelerator;
|
||||
|
||||
public BiomeProfileMenuFactory(JMenu parentMenu, Actions actions,
|
||||
BiomeProfileDirectory biomeProfileDirectory) {
|
||||
BiomeProfileDirectory biomeProfileDirectory, String reloadText,
|
||||
int reloadMnemonic, String reloadAccelerator) {
|
||||
this.parentMenu = parentMenu;
|
||||
this.actions = actions;
|
||||
this.biomeProfileDirectory = biomeProfileDirectory;
|
||||
this.reloadText = reloadText;
|
||||
this.reloadMnemonic = reloadMnemonic;
|
||||
this.reloadAccelerator = reloadAccelerator;
|
||||
Log.i("Checking for additional biome profiles.");
|
||||
initParentMenu();
|
||||
}
|
||||
|
@ -131,21 +135,13 @@ public class BiomeProfileMenuFactory {
|
|||
parentMenu, actions);
|
||||
biomeProfileDirectory.visitProfiles(visitor);
|
||||
parentMenu.addSeparator();
|
||||
parentMenu.add(createReloadMenuItem());
|
||||
Menus.item(parentMenu, this::doReload, reloadText, reloadMnemonic,
|
||||
reloadAccelerator);
|
||||
visitor.selectFirstProfile();
|
||||
}
|
||||
|
||||
private JMenuItem createReloadMenuItem() {
|
||||
final JMenuItem result = new JMenuItem("Reload biome profiles");
|
||||
result.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B,
|
||||
InputEvent.CTRL_DOWN_MASK));
|
||||
result.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg) {
|
||||
Log.i("Reloading additional biome profiles.");
|
||||
initParentMenu();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
private void doReload() {
|
||||
Log.i("Reloading additional biome profiles.");
|
||||
initParentMenu();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,40 +90,40 @@ public class LayersMenu {
|
|||
private void createOverworldAndEndLayers(Dimension dimension) {
|
||||
// @formatter:off
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
Menus.radio( menu, dimensionSetting, group, Dimension.OVERWORLD, "shift 1");
|
||||
Menus.radio( menu, dimensionSetting, group, Dimension.OVERWORLD, "menu shift 1");
|
||||
createOverworldLayers(dimension);
|
||||
menu.addSeparator();
|
||||
Menus.radio( menu, dimensionSetting, group, Dimension.END, "shift 2");
|
||||
endLayer( settings.showEndCities, "End City Icons", getIcon("end_city.png"), "9", dimension, LayerIds.END_CITY);
|
||||
Menus.radio( menu, dimensionSetting, group, Dimension.END, "menu shift 2");
|
||||
endLayer( settings.showEndCities, "End City Icons", getIcon("end_city.png"), "menu 9", dimension, LayerIds.END_CITY);
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private void createOverworldLayers(Dimension dimension) {
|
||||
// @formatter:off
|
||||
overworldLayer(settings.showSlimeChunks, "Slime Chunks", getIcon("slime.png"), "1", dimension, LayerIds.SLIME);
|
||||
overworldLayer(settings.showSpawn, "Spawn Location Icon", getIcon("spawn.png"), "2", dimension, LayerIds.SPAWN);
|
||||
overworldLayer(settings.showStrongholds, "Stronghold Icons", getIcon("stronghold.png"), "3", dimension, LayerIds.STRONGHOLD);
|
||||
overworldLayer(settings.showVillages, "Village Icons", getIcon("village.png"), "4", dimension, LayerIds.VILLAGE);
|
||||
overworldLayer(settings.showTemples, "Temple/Witch Hut Icons", getIcon("desert.png"), "5", dimension, LayerIds.TEMPLE);
|
||||
overworldLayer(settings.showMineshafts, "Mineshaft Icons", getIcon("mineshaft.png"), "6", dimension, LayerIds.MINESHAFT);
|
||||
overworldLayer(settings.showOceanMonuments, "Ocean Monument Icons", getIcon("ocean_monument.png"), "7", dimension, LayerIds.OCEAN_MONUMENT);
|
||||
overworldLayer(settings.showNetherFortresses, "Nether Fortress Icons", getIcon("nether_fortress.png"), "8", dimension, LayerIds.NETHER_FORTRESS);
|
||||
overworldLayer(settings.showSlimeChunks, "Slime Chunks", getIcon("slime.png"), "menu 1", dimension, LayerIds.SLIME);
|
||||
overworldLayer(settings.showSpawn, "Spawn Location Icon", getIcon("spawn.png"), "menu 2", dimension, LayerIds.SPAWN);
|
||||
overworldLayer(settings.showStrongholds, "Stronghold Icons", getIcon("stronghold.png"), "menu 3", dimension, LayerIds.STRONGHOLD);
|
||||
overworldLayer(settings.showVillages, "Village Icons", getIcon("village.png"), "menu 4", dimension, LayerIds.VILLAGE);
|
||||
overworldLayer(settings.showTemples, "Temple/Witch Hut Icons", getIcon("desert.png"), "menu 5", dimension, LayerIds.TEMPLE);
|
||||
overworldLayer(settings.showMineshafts, "Mineshaft Icons", getIcon("mineshaft.png"), "menu 6", dimension, LayerIds.MINESHAFT);
|
||||
overworldLayer(settings.showOceanMonuments, "Ocean Monument Icons", getIcon("ocean_monument.png"), "menu 7", dimension, LayerIds.OCEAN_MONUMENT);
|
||||
overworldLayer(settings.showNetherFortresses, "Nether Fortress Icons", getIcon("nether_fortress.png"), "menu 8", dimension, LayerIds.NETHER_FORTRESS);
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private void createAllDimensions() {
|
||||
// @formatter:off
|
||||
Menus.checkbox(menu, settings.showGrid, "Grid", getIcon("grid.png"), "G");
|
||||
Menus.checkbox(menu, settings.showPlayers, "Player Icons", getIcon("player.png"), "P");
|
||||
Menus.checkbox(menu, settings.showGrid, "Grid", getIcon("grid.png"), "menu G");
|
||||
Menus.checkbox(menu, settings.showPlayers, "Player Icons", getIcon("player.png"), "menu P");
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private void createEnableAllLayers() {
|
||||
// @formatter:off
|
||||
Menus.checkbox(menu, enableAllLayersSetting, "Enable All Layers", "E");
|
||||
Menus.checkbox(menu, enableAllLayersSetting, "Enable All Layers", "menu E");
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
|
|
|
@ -116,9 +116,7 @@ public enum Menus {
|
|||
public static JMenuItem item(JMenu menu, Runnable runnable, String text,
|
||||
int mnemonic, String accelerator) {
|
||||
JMenuItem menuItem = new JMenuItem(text);
|
||||
|
||||
menuItem.setAccelerator(getAcceleratorKeyStroke(accelerator));
|
||||
|
||||
return item(menu, runnable, menuItem, mnemonic);
|
||||
}
|
||||
|
||||
|
@ -129,24 +127,26 @@ public enum Menus {
|
|||
menu.add(menuItem);
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
|
||||
public static KeyStroke getAcceleratorKeyStroke(String accelerator) {
|
||||
if(accelerator == null)
|
||||
return null;
|
||||
|
||||
boolean addMenuMask = true;
|
||||
if(accelerator.startsWith("@")) {
|
||||
accelerator = accelerator.substring(1);
|
||||
boolean addMenuMask;
|
||||
if (accelerator.contains("menu")) {
|
||||
accelerator = accelerator.replace("menu", "");
|
||||
addMenuMask = true;
|
||||
} else {
|
||||
addMenuMask = false;
|
||||
}
|
||||
|
||||
KeyStroke shortcut = KeyStroke.getKeyStroke(accelerator);
|
||||
return getPlatformSpecificKeyStroke(accelerator, addMenuMask);
|
||||
}
|
||||
|
||||
int keycode = shortcut.getKeyCode();
|
||||
int keymask = shortcut.getModifiers();
|
||||
if(addMenuMask)
|
||||
private static KeyStroke getPlatformSpecificKeyStroke(String accelerator,
|
||||
boolean addMenuMask) {
|
||||
KeyStroke keyStroke = KeyStroke.getKeyStroke(accelerator);
|
||||
int keycode = keyStroke.getKeyCode();
|
||||
int keymask = keyStroke.getModifiers();
|
||||
if (addMenuMask) {
|
||||
keymask |= Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
|
||||
return KeyStroke.getKeyStroke(keycode, keymask);
|
||||
}
|
||||
return KeyStroke.getKeyStroke(keycode, keymask);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue