* Add option to rename Library Actions
* Improve `CommandManager` * Improve Auto Save
This commit is contained in:
+1
-1
Submodule hyperlap2d-common-api updated: e764fc4f3c...17e7125aa9
@@ -69,6 +69,7 @@ public class BootstrapCommand extends SimpleCommand {
|
||||
facade.registerCommand(MsgAPI.ACTION_REPLACE_SPINE_ANIMATION_DATA, ReplaceSpineCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_ADD_TO_LIBRARY, AddToLibraryCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_ADD_TO_LIBRARY_ACTION, AddToLibraryAction::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_CHANGE_LIBRARY_ACTION, ChangeLibraryActionCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_CONVERT_TO_BUTTON, ConvertToButtonCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_GROUP_ITEMS, ConvertToCompositeCommand::new);
|
||||
|
||||
@@ -114,6 +115,7 @@ public class BootstrapCommand extends SimpleCommand {
|
||||
facade.registerCommand(MsgAPI.ACTION_DUPLICATE_LIBRARY_ACTION, DuplicateLibraryAction::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_EXPORT_LIBRARY_ITEM, ExportLibraryItemCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_EXPORT_ACTION_ITEM, ExportActionCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_RENAME_ACTION_ITEM, RenameLibraryActionCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_DELETE_PARTICLE_EFFECT, DeleteParticleEffect::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_DELETE_TALOS_VFX, DeleteTalosVFX::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_DELETE_SPINE_ANIMATION_RESOURCE, DeleteSpineAnimation::new);
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.HashMap;
|
||||
/**
|
||||
* Created by azakhary on 4/28/2015.
|
||||
*/
|
||||
public class AddToLibraryCommand extends RevertibleCommand {
|
||||
public class AddToLibraryCommand extends HistoricRevertibleCommand {
|
||||
|
||||
private String createdLibraryItemName;
|
||||
private CompositeItemVO overwritten;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import java.util.HashMap;
|
||||
/**
|
||||
* Created by azakhary on 6/15/2015.
|
||||
*/
|
||||
public abstract class EntityModifyRevertibleCommand extends RevertibleCommand {
|
||||
public abstract class EntityModifyRevertibleCommand extends HistoricRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void callDoAction() {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
/**
|
||||
* Wrapper class to {@link RevertibleCommand} to tells {@link games.rednblack.editor.proxy.CommandManager} save command
|
||||
* in revertible history list.
|
||||
*/
|
||||
public abstract class HistoricRevertibleCommand extends RevertibleCommand {
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
import com.kotcrab.vis.ui.util.dialog.InputDialogAdapter;
|
||||
import games.rednblack.editor.controller.SandboxCommand;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
public class RenameLibraryActionCommand extends SandboxCommand {
|
||||
private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.resource.RenameActionCommand";
|
||||
public static final String DONE = CLASS_NAME + "DONE";
|
||||
|
||||
@Override
|
||||
public void execute(INotification notification) {
|
||||
super.execute(notification);
|
||||
|
||||
String libraryActionName = notification.getBody();
|
||||
|
||||
Dialogs.showInputDialog(sandbox.getUIStage(), "Rename Action", "Name", false, new InputDialogAdapter() {
|
||||
@Override
|
||||
public void finished(String input) {
|
||||
String[] payload = new String[2];
|
||||
payload[0] = libraryActionName;
|
||||
payload[1] = input;
|
||||
facade.sendNotification(MsgAPI.ACTION_CHANGE_LIBRARY_ACTION, payload);
|
||||
}
|
||||
}).setText(libraryActionName);
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,15 @@ import games.rednblack.h2d.common.HyperLog;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
public class ShowNotificationCommand extends SandboxCommand {
|
||||
private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.ShowNotificationCommand";
|
||||
public static final String TYPE_CLEAR_STACK = CLASS_NAME + ".CLEAR_STACK";
|
||||
|
||||
@Override
|
||||
public void execute(INotification notification) {
|
||||
if (TYPE_CLEAR_STACK.equals(notification.getType())) {
|
||||
sandbox.getToastManager().clear();
|
||||
}
|
||||
|
||||
String text = notification.getBody();
|
||||
final MessageToast messageToast = new MessageToast(text);
|
||||
messageToast.pad(10);
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.puremvc.java.interfaces.INotification;
|
||||
/**
|
||||
* Created by CyberJoe on 7/25/2015.
|
||||
*/
|
||||
public abstract class TransactiveCommand extends RevertibleCommand {
|
||||
public abstract class TransactiveCommand extends HistoricRevertibleCommand {
|
||||
|
||||
protected Array<RevertibleCommand> commands = new Array();
|
||||
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package games.rednblack.editor.controller.commands.resource;
|
||||
|
||||
import games.rednblack.editor.controller.commands.HistoricRevertibleCommand;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.renderer.data.GraphVO;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class ChangeLibraryActionCommand extends HistoricRevertibleCommand {
|
||||
|
||||
private final ProjectManager projectManager;
|
||||
|
||||
public ChangeLibraryActionCommand() {
|
||||
projectManager = facade.retrieveProxy(ProjectManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
String[] payload = notification.getBody();
|
||||
String oldName = payload[0];
|
||||
String newName = payload[1];
|
||||
|
||||
GraphVO action = projectManager.currentProjectInfoVO.libraryActions.get(oldName);
|
||||
if (action != null) {
|
||||
projectManager.currentProjectInfoVO.libraryActions.remove(oldName);
|
||||
projectManager.currentProjectInfoVO.libraryActions.put(newName, action);
|
||||
|
||||
facade.sendNotification(MsgAPI.LIBRARY_ACTIONS_UPDATED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
String[] payload = notification.getBody();
|
||||
String oldName = payload[0];
|
||||
String newName = payload[1];
|
||||
|
||||
GraphVO action = projectManager.currentProjectInfoVO.libraryActions.get(newName);
|
||||
if (action != null) {
|
||||
projectManager.currentProjectInfoVO.libraryActions.remove(newName);
|
||||
projectManager.currentProjectInfoVO.libraryActions.put(oldName, action);
|
||||
|
||||
facade.sendNotification(MsgAPI.LIBRARY_ACTIONS_UPDATED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,9 @@
|
||||
package games.rednblack.editor.proxy;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.controller.commands.HistoricRevertibleCommand;
|
||||
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 games.rednblack.h2d.common.MsgAPI;
|
||||
import org.puremvc.java.patterns.proxy.Proxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -54,8 +52,7 @@ public class CommandManager extends Proxy {
|
||||
}
|
||||
commands.add(revertibleCommand);
|
||||
cursor = commands.indexOf(revertibleCommand);
|
||||
if (revertibleCommand instanceof EntityModifyRevertibleCommand
|
||||
|| revertibleCommand instanceof TransactiveCommand) {
|
||||
if (revertibleCommand instanceof HistoricRevertibleCommand) {
|
||||
modifiedCursor++;
|
||||
autoSave();
|
||||
}
|
||||
@@ -75,8 +72,7 @@ public class CommandManager extends Proxy {
|
||||
}
|
||||
cursor--;
|
||||
|
||||
if (command instanceof EntityModifyRevertibleCommand
|
||||
|| command instanceof TransactiveCommand) {
|
||||
if (command instanceof HistoricRevertibleCommand) {
|
||||
modifiedCursor--;
|
||||
autoSave();
|
||||
}
|
||||
@@ -105,8 +101,7 @@ public class CommandManager extends Proxy {
|
||||
command.callDoAction();
|
||||
command.setStateDone(true);
|
||||
|
||||
if (command instanceof EntityModifyRevertibleCommand
|
||||
|| command instanceof TransactiveCommand) {
|
||||
if (command instanceof HistoricRevertibleCommand) {
|
||||
modifiedCursor++;
|
||||
autoSave();
|
||||
}
|
||||
@@ -131,6 +126,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, MenuAPI.FILE_MENU);
|
||||
facade.sendNotification(MsgAPI.AUTO_SAVE_PROJECT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import games.rednblack.editor.HyperLap2DApp;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.ShowNotificationCommand;
|
||||
import games.rednblack.editor.data.manager.PreferencesManager;
|
||||
import games.rednblack.editor.proxy.CommandManager;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
@@ -82,7 +83,8 @@ public class HyperLap2DMenuBarMediator extends Mediator<HyperLap2DMenuBar> {
|
||||
//General
|
||||
ProjectManager.PROJECT_OPENED,
|
||||
HyperLap2DMenuBar.RECENT_LIST_MODIFIED,
|
||||
MsgAPI.CREATE
|
||||
MsgAPI.CREATE,
|
||||
MsgAPI.AUTO_SAVE_PROJECT
|
||||
};
|
||||
}
|
||||
|
||||
@@ -113,6 +115,7 @@ public class HyperLap2DMenuBarMediator extends Mediator<HyperLap2DMenuBar> {
|
||||
}
|
||||
|
||||
private void handleGeneralNotification(INotification notification) {
|
||||
Sandbox sandbox = Sandbox.getInstance();
|
||||
switch (notification.getName()) {
|
||||
case ProjectManager.PROJECT_OPENED:
|
||||
onProjectOpened();
|
||||
@@ -120,6 +123,11 @@ public class HyperLap2DMenuBarMediator extends Mediator<HyperLap2DMenuBar> {
|
||||
case MsgAPI.CREATE:
|
||||
viewComponent.setProjectOpen(false);
|
||||
break;
|
||||
case MsgAPI.AUTO_SAVE_PROJECT:
|
||||
SceneVO vo = sandbox.sceneVoFromItems();
|
||||
projectManager.saveCurrentProject(vo);
|
||||
facade.sendNotification(MsgAPI.SHOW_NOTIFICATION, "Auto Save successfully", ShowNotificationCommand.TYPE_CLEAR_STACK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ public class UIDropDownMenu extends H2DPopupMenu {
|
||||
|
||||
actionNames.put(MsgAPI.ACTION_EXPORT_LIBRARY_ITEM, "Export");
|
||||
actionNames.put(MsgAPI.ACTION_EXPORT_ACTION_ITEM, "Export");
|
||||
actionNames.put(MsgAPI.ACTION_RENAME_ACTION_ITEM, "Rename");
|
||||
actionNames.put(MsgAPI.ACTION_DELETE_IMAGE_RESOURCE, "Delete");
|
||||
actionNames.put(MsgAPI.ACTION_DELETE_LIBRARY_ITEM, "Delete");
|
||||
actionNames.put(MsgAPI.ACTION_DELETE_PARTICLE_EFFECT, "Delete");
|
||||
|
||||
@@ -96,6 +96,7 @@ public class UIDropDownMenuMediator extends Mediator<UIDropDownMenu> {
|
||||
actionSets.get(LIBRARY_ACTION_ACTION_SET).add(MsgAPI.ACTION_DUPLICATE_LIBRARY_ACTION);
|
||||
actionSets.get(LIBRARY_ACTION_ACTION_SET).add(MsgAPI.ACTION_DELETE_LIBRARY_ACTION);
|
||||
actionSets.get(LIBRARY_ACTION_ACTION_SET).add(MsgAPI.ACTION_EXPORT_ACTION_ITEM);
|
||||
actionSets.get(LIBRARY_ACTION_ACTION_SET).add(MsgAPI.ACTION_RENAME_ACTION_ITEM);
|
||||
|
||||
actionSets.put(PARTICLE_ACTION_SET, new Array<>());
|
||||
actionSets.get(PARTICLE_ACTION_SET).add(MsgAPI.ACTION_DELETE_PARTICLE_EFFECT);
|
||||
|
||||
Reference in New Issue
Block a user