Add MenuAPI
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
Submodule hyperlap2d-common-api updated: 0ff9a1d30d...4d1f0936d5
+2
-2
@@ -1,5 +1,6 @@
|
||||
package games.rednblack.editor.plugin.performance;
|
||||
|
||||
import games.rednblack.h2d.common.MenuAPI;
|
||||
import games.rednblack.h2d.common.plugins.H2DPluginAdapter;
|
||||
import net.mountainblade.modular.annotations.Implementation;
|
||||
|
||||
@@ -8,7 +9,6 @@ public class PerformancePlugin extends H2DPluginAdapter {
|
||||
public static final String CLASS_NAME = "games.rednblack.editor.plugin.performance";
|
||||
|
||||
public static final String PANEL_OPEN = CLASS_NAME + ".PANEL_OPEN";
|
||||
public static final String WINDOWS_MENU = "games.rednblack.editor.view.HyperLap2DMenuBar.WINDOW_MENU";
|
||||
|
||||
private final PerformancePanelMediator performancePanelMediator;
|
||||
|
||||
@@ -20,6 +20,6 @@ public class PerformancePlugin extends H2DPluginAdapter {
|
||||
@Override
|
||||
public void initPlugin() {
|
||||
facade.registerMediator(performancePanelMediator);
|
||||
pluginAPI.addMenuItem(WINDOWS_MENU, "Performance", PANEL_OPEN);
|
||||
pluginAPI.addMenuItem(MenuAPI.WINDOW_MENU, "Performance", PANEL_OPEN);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,6 @@
|
||||
package games.rednblack.editor.plugin.skincomposer;
|
||||
|
||||
import games.rednblack.h2d.common.MenuAPI;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.h2d.common.plugins.H2DPluginAdapter;
|
||||
import net.mountainblade.modular.annotations.Implementation;
|
||||
@@ -9,7 +10,6 @@ public class SkinComposerPlugin extends H2DPluginAdapter {
|
||||
public static final String CLASS_NAME = "games.rednblack.editor.plugin.skincomposer";
|
||||
|
||||
public static final String PANEL_OPEN = CLASS_NAME + ".PANEL_OPEN";
|
||||
public static final String WINDOWS_MENU = "games.rednblack.editor.view.HyperLap2DMenuBar.WINDOW_MENU";
|
||||
public static final String DOWNLOAD_JAR = CLASS_NAME + ".DOWNLOAD_JAR";
|
||||
|
||||
private final SkinComposerMediator skinComposerMediator;
|
||||
@@ -23,7 +23,7 @@ public class SkinComposerPlugin extends H2DPluginAdapter {
|
||||
@Override
|
||||
public void initPlugin() {
|
||||
facade.registerMediator(skinComposerMediator);
|
||||
pluginAPI.addMenuItem(WINDOWS_MENU, "Skin Composer", PANEL_OPEN);
|
||||
pluginAPI.addMenuItem(MenuAPI.WINDOW_MENU, "Skin Composer", PANEL_OPEN);
|
||||
SkinComposerSettings settings = new SkinComposerSettings(facade, this);
|
||||
|
||||
settingsVO.fromStorage(getStorage());
|
||||
|
||||
@@ -25,6 +25,7 @@ import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.controller.commands.RevertibleCommand;
|
||||
import games.rednblack.editor.controller.commands.TransactiveCommand;
|
||||
import games.rednblack.editor.view.menu.FileMenu;
|
||||
import games.rednblack.h2d.common.MenuAPI;
|
||||
import org.puremvc.java.patterns.proxy.Proxy;
|
||||
|
||||
public class CommandManager extends Proxy {
|
||||
@@ -130,6 +131,6 @@ public class CommandManager extends Proxy {
|
||||
private void autoSave() {
|
||||
SettingsManager settingsManager = facade.retrieveProxy(SettingsManager.NAME);
|
||||
if (settingsManager.editorConfigVO.autoSave)
|
||||
facade.sendNotification(FileMenu.SAVE_PROJECT, null, FileMenu.FILE_MENU);
|
||||
facade.sendNotification(FileMenu.SAVE_PROJECT, null, MenuAPI.FILE_MENU);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import games.rednblack.editor.proxy.SettingsManager;
|
||||
import games.rednblack.editor.utils.KeyBindingsLayout;
|
||||
import games.rednblack.editor.view.menu.FileMenu;
|
||||
import games.rednblack.editor.view.ui.widget.actors.basic.WhitePixel;
|
||||
import games.rednblack.h2d.common.MenuAPI;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.view.ui.widget.actors.basic.SandboxBackUI;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
@@ -177,14 +178,14 @@ public class HyperLap2DScreen implements Screen, InputProcessor {
|
||||
public boolean keyDown(int keycode) {
|
||||
switch (KeyBindingsLayout.mapAction(keycode)) {
|
||||
case KeyBindingsLayout.NEW_PROJECT:
|
||||
facade.sendNotification(FileMenu.NEW_PROJECT, null, FileMenu.FILE_MENU);
|
||||
facade.sendNotification(FileMenu.NEW_PROJECT, null, MenuAPI.FILE_MENU);
|
||||
break;
|
||||
case KeyBindingsLayout.OPEN_PROJECT:
|
||||
facade.sendNotification(FileMenu.OPEN_PROJECT, null, FileMenu.FILE_MENU);
|
||||
facade.sendNotification(FileMenu.OPEN_PROJECT, null, MenuAPI.FILE_MENU);
|
||||
break;
|
||||
case KeyBindingsLayout.SAVE_PROJECT:
|
||||
if (sandbox.sceneControl.getCurrentSceneVO() != null) {
|
||||
facade.sendNotification(FileMenu.SAVE_PROJECT, null, FileMenu.FILE_MENU);
|
||||
facade.sendNotification(FileMenu.SAVE_PROJECT, null, MenuAPI.FILE_MENU);
|
||||
}
|
||||
break;
|
||||
case KeyBindingsLayout.EXPORT_PROJECT:
|
||||
@@ -194,11 +195,11 @@ public class HyperLap2DScreen implements Screen, InputProcessor {
|
||||
break;
|
||||
case KeyBindingsLayout.IMPORT_TO_LIBRARY:
|
||||
if (sandbox.sceneControl.getCurrentSceneVO() != null) {
|
||||
facade.sendNotification(FileMenu.IMPORT_TO_LIBRARY, null, FileMenu.FILE_MENU);
|
||||
facade.sendNotification(FileMenu.IMPORT_TO_LIBRARY, null, MenuAPI.FILE_MENU);
|
||||
}
|
||||
break;
|
||||
case KeyBindingsLayout.OPEN_SETTINGS:
|
||||
facade.sendNotification(FileMenu.SETTINGS, null, FileMenu.FILE_MENU);
|
||||
facade.sendNotification(FileMenu.SETTINGS, null, MenuAPI.FILE_MENU);
|
||||
break;
|
||||
case KeyBindingsLayout.EXIT_APP:
|
||||
HyperLap2DApp.getInstance().hyperlap2D.closeRequested();
|
||||
|
||||
@@ -4,9 +4,10 @@ import com.kotcrab.vis.ui.widget.MenuItem;
|
||||
import games.rednblack.editor.event.MenuItemListener;
|
||||
import games.rednblack.editor.utils.KeyBindingsLayout;
|
||||
|
||||
import static games.rednblack.h2d.common.MenuAPI.EDIT_MENU;
|
||||
|
||||
public class EditMenu extends H2DMenu {
|
||||
|
||||
public static final String EDIT_MENU = HyperLap2DMenuBar.prefix + ".EDIT_MENU";
|
||||
public static final String CUT = HyperLap2DMenuBar.prefix + ".CUT";
|
||||
public static final String COPY = HyperLap2DMenuBar.prefix + ".COPY";
|
||||
public static final String PASTE = HyperLap2DMenuBar.prefix + ".PASTE";
|
||||
|
||||
@@ -10,9 +10,10 @@ import games.rednblack.editor.utils.KeyBindingsLayout;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static games.rednblack.h2d.common.MenuAPI.FILE_MENU;
|
||||
|
||||
public class FileMenu extends H2DMenu {
|
||||
|
||||
public static final String FILE_MENU = HyperLap2DMenuBar.prefix + ".FILE_MENU";
|
||||
public static final String NEW_PROJECT = HyperLap2DMenuBar.prefix + ".NEW_PROJECT";
|
||||
public static final String OPEN_PROJECT = HyperLap2DMenuBar.prefix + ".OPEN_PROJECT";
|
||||
public static final String SAVE_PROJECT = HyperLap2DMenuBar.prefix + ".SAVE_PROJECT";
|
||||
|
||||
@@ -6,9 +6,10 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.kotcrab.vis.ui.widget.MenuItem;
|
||||
import games.rednblack.editor.event.MenuItemListener;
|
||||
|
||||
import static games.rednblack.h2d.common.MenuAPI.HELP_MENU;
|
||||
|
||||
public class HelpMenu extends H2DMenu {
|
||||
|
||||
public static final String HELP_MENU = HyperLap2DMenuBar.prefix + ".ABOUT_MENU";
|
||||
public static final String ABOUT_DIALOG_OPEN = HyperLap2DMenuBar.prefix + ".ABOUT_DIALOG_OPEN";
|
||||
|
||||
public HelpMenu() {
|
||||
|
||||
@@ -20,9 +20,12 @@ package games.rednblack.editor.view.menu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.kotcrab.vis.ui.widget.MenuItem;
|
||||
import games.rednblack.editor.event.MenuItemListener;
|
||||
import games.rednblack.editor.view.ui.widget.CustomMenu;
|
||||
import games.rednblack.editor.view.ui.widget.CustomMenuBar;
|
||||
import games.rednblack.h2d.common.MenuAPI;
|
||||
|
||||
public class HyperLap2DMenuBar extends CustomMenuBar {
|
||||
|
||||
@@ -35,15 +38,18 @@ public class HyperLap2DMenuBar extends CustomMenuBar {
|
||||
private final EditMenu editMenu;
|
||||
private final WindowMenu windowMenu;
|
||||
private final HelpMenu helpMenu;
|
||||
private final ResourceMenu resourceMenu;
|
||||
|
||||
public HyperLap2DMenuBar() {
|
||||
fileMenu = new FileMenu();
|
||||
editMenu = new EditMenu();
|
||||
resourceMenu = new ResourceMenu();
|
||||
windowMenu = new WindowMenu();
|
||||
helpMenu = new HelpMenu();
|
||||
|
||||
addMenu(fileMenu);
|
||||
addMenu(editMenu);
|
||||
addMenu(resourceMenu);
|
||||
addMenu(windowMenu);
|
||||
addMenu(helpMenu);
|
||||
setProjectOpen(false);
|
||||
@@ -54,23 +60,26 @@ public class HyperLap2DMenuBar extends CustomMenuBar {
|
||||
}
|
||||
|
||||
public void setProjectOpen(boolean open) {
|
||||
fileMenu.setProjectOpen(open);
|
||||
editMenu.setProjectOpen(open);
|
||||
windowMenu.setProjectOpen(open);
|
||||
helpMenu.setProjectOpen(open);
|
||||
for (CustomMenu m : new Array.ArrayIterator<>(menus)) {
|
||||
H2DMenu menu = (H2DMenu) m;
|
||||
menu.setProjectOpen(open);
|
||||
}
|
||||
}
|
||||
|
||||
public void addMenuItem(String menu, String subMenuName, String notificationName) {
|
||||
if(menu.equals(FileMenu.FILE_MENU)) {
|
||||
if(menu.equals(MenuAPI.FILE_MENU)) {
|
||||
fileMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
|
||||
}
|
||||
if(menu.equals(EditMenu.EDIT_MENU)) {
|
||||
if(menu.equals(MenuAPI.EDIT_MENU)) {
|
||||
editMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
|
||||
}
|
||||
if(menu.equals(WindowMenu.WINDOW_MENU)) {
|
||||
if(menu.equals(MenuAPI.RESOURCE_MENU)) {
|
||||
resourceMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
|
||||
}
|
||||
if(menu.equals(MenuAPI.WINDOW_MENU)) {
|
||||
windowMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
|
||||
}
|
||||
if(menu.equals(HelpMenu.HELP_MENU)) {
|
||||
if(menu.equals(MenuAPI.HELP_MENU)) {
|
||||
helpMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import games.rednblack.editor.HyperLap2DApp;
|
||||
import games.rednblack.editor.proxy.SettingsManager;
|
||||
import games.rednblack.h2d.common.MenuAPI;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.data.manager.PreferencesManager;
|
||||
@@ -98,10 +99,10 @@ public class HyperLap2DMenuBarMediator extends Mediator<HyperLap2DMenuBar> {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case FileMenu.FILE_MENU:
|
||||
case MenuAPI.FILE_MENU:
|
||||
handleFileMenuNotification(notification);
|
||||
break;
|
||||
case EditMenu.EDIT_MENU:
|
||||
case MenuAPI.EDIT_MENU:
|
||||
handleEditMenuNotification(notification);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package games.rednblack.editor.view.menu;
|
||||
|
||||
public class ResourceMenu extends H2DMenu {
|
||||
public ResourceMenu() {
|
||||
super("Resource");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectOpen(boolean open) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package games.rednblack.editor.view.menu;
|
||||
import com.kotcrab.vis.ui.widget.MenuItem;
|
||||
import games.rednblack.editor.event.MenuItemListener;
|
||||
|
||||
public class WindowMenu extends H2DMenu {
|
||||
import static games.rednblack.h2d.common.MenuAPI.WINDOW_MENU;
|
||||
|
||||
public static final String WINDOW_MENU = HyperLap2DMenuBar.prefix + ".WINDOW_MENU";
|
||||
public class WindowMenu extends H2DMenu {
|
||||
|
||||
public static final String SPRITE_ANIMATIONS_EDITOR_OPEN = HyperLap2DMenuBar.prefix + ".SPRITE_ANIMATIONS_EDITOR_OPEN";
|
||||
public static final String CUSTOM_VARIABLES_EDITOR_OPEN = HyperLap2DMenuBar.prefix + ".CUSTOM_VARIABLES_EDITOR_OPEN";
|
||||
|
||||
@@ -15,12 +15,12 @@ public class CustomMenuBar {
|
||||
private static final Drawable BUTTTON_DEFAULT = VisUI.getSkin().getDrawable("menu-bg-up");
|
||||
public Drawable defaultStyle = VisUI.getSkin().getDrawable("menu-bg-up");
|
||||
|
||||
private Table mainTable;
|
||||
private Table menuItems;
|
||||
private final Table mainTable;
|
||||
private final Table menuItems;
|
||||
|
||||
private CustomMenu currentMenu;
|
||||
|
||||
private Array<CustomMenu> menus = new Array<>();
|
||||
protected final Array<CustomMenu> menus = new Array<>();
|
||||
|
||||
public CustomMenuBar () {
|
||||
Skin skin = VisUI.getSkin();
|
||||
@@ -65,7 +65,7 @@ public class CustomMenuBar {
|
||||
|
||||
private void rebuild () {
|
||||
menuItems.clear();
|
||||
for (CustomMenu menu : menus)
|
||||
for (CustomMenu menu : new Array.ArrayIterator<>(menus))
|
||||
menuItems.add(menu.getOpenButton());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user