@Override public void saveProject() { Sandbox sandbox = Sandbox.getInstance(); SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME); SceneVO vo = sandbox.sceneVoFromItems(); sceneDataManager.saveScene(vo); }
@Override public void reLoadProject() { Sandbox sandbox = Sandbox.getInstance(); ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME); projectManager.openProjectAndLoadAllData(projectManager.getCurrentProjectVO().projectName); sandbox.loadCurrentProject(); facade.sendNotification(ProjectManager.PROJECT_DATA_UPDATED); }
public void initPlugin(O2DPlugin plugin) { if (plugins.contains(plugin)) return; registerPlugin(plugin); plugin.setAPI(this); plugin.setEngine(Sandbox.getInstance().getEngine()); plugin.setFacade(Overlap2DFacade.getInstance()); plugin.setStage(Sandbox.getInstance().getUIStage()); plugin.initPlugin(); }
private void applyItemTypeMutators(Array<String> actionsSet) { // generic mutators if (sandbox.getSelector().getCurrentSelection().size() == 1) { if (sandbox.getSelector().selectionIsComposite()) { actionsSet.add(Sandbox.SHOW_ADD_LIBRARY_DIALOG); actionsSet.add(Sandbox.ACTION_CAMERA_CHANGE_COMPOSITE); } actionsSet.add(Sandbox.ACTION_SET_GRID_SIZE_FROM_ITEM); } // external plugin mutators PluginManager pluginManager = facade.retrieveProxy(PluginManager.NAME); pluginManager.dropDownActionSets(sandbox.getSelector().getCurrentSelection(), actionsSet); }
@Override public void onRegister() { super.onRegister(); sandbox = Sandbox.getInstance(); actionSets.put(SCENE_ACTIONS_SET, new Array<>()); actionSets.get(SCENE_ACTIONS_SET).add(Sandbox.ACTION_PASTE); actionSets.put(RESOURCE_ACTION_SET, new Array<>()); actionSets.get(RESOURCE_ACTION_SET).add(Sandbox.ACTION_DELETE); actionSets.put(IMAGE_RESOURCE_ACTION_SET, new Array<>()); // actionSets.get(IMAGE_RESOURCE_ACTION_SET).add(Sandbox.ACTION_DELETE_RESOURCE); actionSets.put(ITEMS_ACTIONS_SET, new Array<>()); actionSets.get(ITEMS_ACTIONS_SET).add(Sandbox.ACTION_CUT); actionSets.get(ITEMS_ACTIONS_SET).add(Sandbox.ACTION_COPY); actionSets.get(ITEMS_ACTIONS_SET).add(Sandbox.ACTION_PASTE); actionSets.get(ITEMS_ACTIONS_SET).add(Sandbox.ACTION_DELETE); actionSets.get(ITEMS_ACTIONS_SET).add(Sandbox.ACTION_GROUP_ITEMS); actionSets.get(ITEMS_ACTIONS_SET).add(Sandbox.ACTION_CONVERT_TO_BUTTON); facade = Overlap2DFacade.getInstance(); }
@Override public void handleNotification(Notification notification) { super.handleNotification(notification); switch (notification.getName()) { case Overlap2D.SCENE_RIGHT_CLICK: Vector2 stageCoords = notification.getBody(); showPopup(SCENE_ACTIONS_SET, stageCoords); break; case Overlap2D.ITEM_RIGHT_CLICK: Array<String> actionsSet = new Array<>(actionSets.get(ITEMS_ACTIONS_SET)); applyItemTypeMutators(actionsSet); showPopup(actionsSet, sandbox.getSelector().getSelectedItem()); break; case UIResourcesBoxMediator.IMAGE_RIGHT_CLICK: showPopup(IMAGE_RESOURCE_ACTION_SET, notification.getBody()); break; case UIResourcesBoxMediator.ANIMATION_RIGHT_CLICK: showPopup(RESOURCE_ACTION_SET, notification.getBody()); break; case UIResourcesBoxMediator.LIBRARY_ITEM_RIGHT_CLICK: showPopup(RESOURCE_ACTION_SET, notification.getBody()); break; case UIResourcesBoxMediator.PARTICLE_EFFECT_RIGHT_CLICK: showPopup(RESOURCE_ACTION_SET, notification.getBody()); break; case UIDropDownMenu.ITEM_CLICKED: facade.sendNotification(notification.getBody(), currentObservable); break; default: break; } }
@Override public void doAction() { backup = CopyItemsCommand.getJsonStringFromEntities(sandbox.getSelector().getSelectedItems()); String data = CopyItemsCommand.getJsonStringFromEntities(sandbox.getSelector().getSelectedItems()); Object[] payload = new Object[2]; payload[0] = new Vector2( Sandbox.getInstance().getCamera().position.x, Sandbox.getInstance().getCamera().position.y); payload[1] = data; Sandbox.getInstance().copyToClipboard(payload); sandbox.getSelector().removeCurrentSelectedItems(); facade.sendNotification(DeleteItemsCommand.DONE); }
private void backup() { if (entityId == null) { Object[] payload = getNotification().getBody(); sourceName = (String) payload[0]; targetName = (String) payload[1]; entityId = EntityUtils.getEntityId(Sandbox.getInstance().getCurrentViewingEntity()); } }
private void showPopup(Array<String> actionsSet, Object observable) { Vector2 coordinates = new Vector2(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()); sandbox.getUIStage().addActor(viewComponent); viewComponent.setActionList(actionsSet); viewComponent.setX(coordinates.x); viewComponent.setY(coordinates.y); currentCoordinates = new Vector2(coordinates); currentObservable = observable; }
public SandboxCommand() { sandbox = Sandbox.getInstance(); facade = Overlap2DFacade.getInstance(); }