Search in sources :

Example 1 with GraphVO

use of games.rednblack.editor.renderer.data.GraphVO in project HyperLap2D by rednblackgames.

the class UIActionsTabMediator method initList.

@Override
protected void initList(String searchText) {
    searchText = searchText.toLowerCase();
    ProjectManager projectManager = HyperLap2DFacade.getInstance().retrieveProxy(ProjectManager.NAME);
    HashMap<String, GraphVO> items = projectManager.currentProjectInfoVO.libraryActions;
    itemArray.clear();
    for (String key : items.keySet()) {
        if (!key.toLowerCase().contains(searchText))
            continue;
        DraggableResource draggableResource = new DraggableResource(new LibraryActionResource(key));
        itemArray.add(draggableResource);
    }
    itemArray.sort();
    viewComponent.setItems(itemArray);
}
Also used : LibraryActionResource(games.rednblack.editor.view.ui.box.resourcespanel.draggable.list.LibraryActionResource) DraggableResource(games.rednblack.editor.view.ui.box.resourcespanel.draggable.DraggableResource) GraphVO(games.rednblack.editor.renderer.data.GraphVO) ProjectManager(games.rednblack.editor.proxy.ProjectManager)

Example 2 with GraphVO

use of games.rednblack.editor.renderer.data.GraphVO in project HyperLap2D by rednblackgames.

the class HyperLap2DActionAsset method importAsset.

@Override
public void importAsset(Array<FileHandle> files, ProgressHandler progressHandler, boolean skipRepack) {
    for (FileHandle fileHandle : new Array.ArrayIterator<>(files)) {
        GraphVO action = json.fromJson(GraphVO.class, fileHandle);
        projectManager.getCurrentProjectInfoVO().libraryActions.put(fileHandle.nameWithoutExtension(), action);
        projectManager.saveCurrentProject();
    }
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) GraphVO(games.rednblack.editor.renderer.data.GraphVO)

Example 3 with GraphVO

use of games.rednblack.editor.renderer.data.GraphVO in project HyperLap2D by rednblackgames.

the class AddToLibraryAction method doAction.

@Override
public void doAction() {
    Object[] payload = notification.getBody();
    String key = (String) payload[0];
    GraphVO data = (GraphVO) payload[1];
    libraryActions.put(key, data);
    HyperLap2DFacade.getInstance().sendNotification(MsgAPI.LIBRARY_ACTIONS_UPDATED);
}
Also used : GraphVO(games.rednblack.editor.renderer.data.GraphVO)

Example 4 with GraphVO

use of games.rednblack.editor.renderer.data.GraphVO in project HyperLap2D by rednblackgames.

the class GraphContainer method serializeGraph.

public GraphVO serializeGraph() {
    GraphVO graph = new GraphVO();
    graph.version = 1;
    Vector2 tmp = new Vector2();
    getCanvasPosition(tmp);
    for (GraphBox<T> graphBox : getGraphBoxes()) {
        Window window = getBoxWindow(graphBox.getId());
        GraphNodeVO object = new GraphNodeVO();
        object.id = graphBox.getId();
        object.type = graphBox.getType();
        object.x = tmp.x + window.getX();
        object.y = tmp.y + window.getY();
        HashMap<String, String> data = graphBox.getData();
        if (data != null)
            object.data = data;
        graph.nodes.add(object);
    }
    for (GraphConnection connection : getConnections()) {
        GraphConnectionVO conn = new GraphConnectionVO();
        conn.fromNode = connection.getNodeFrom();
        conn.fromField = connection.getFieldFrom();
        conn.toNode = connection.getNodeTo();
        conn.toField = connection.getFieldTo();
        graph.connections.add(conn);
    }
    for (NodeGroup nodeGroup : getNodeGroups()) {
        GraphGroupVO group = new GraphGroupVO();
        group.name = nodeGroup.getName();
        group.nodes.addAll(nodeGroup.getNodeIds());
        graph.groups.add(group);
    }
    return graph;
}
Also used : Window(com.badlogic.gdx.scenes.scene2d.ui.Window) VisWindow(com.kotcrab.vis.ui.widget.VisWindow) Vector2(com.badlogic.gdx.math.Vector2) GraphConnectionVO(games.rednblack.editor.renderer.data.GraphConnectionVO) GraphVO(games.rednblack.editor.renderer.data.GraphVO) GraphNodeVO(games.rednblack.editor.renderer.data.GraphNodeVO) GraphGroupVO(games.rednblack.editor.renderer.data.GraphGroupVO)

Example 5 with GraphVO

use of games.rednblack.editor.renderer.data.GraphVO in project HyperLap2D by rednblackgames.

the class DuplicateLibraryAction method doAction.

@Override
public void doAction() {
    String libraryActionName = notification.getBody();
    ProjectManager projectManager = HyperLap2DFacade.getInstance().retrieveProxy(ProjectManager.NAME);
    HashMap<String, GraphVO> libraryActions = projectManager.currentProjectInfoVO.libraryActions;
    GraphVO actionToDuplicate = libraryActions.get(libraryActionName);
    Dialogs.showInputDialog(Sandbox.getInstance().getUIStage(), "Duplicate " + libraryActionName, "New name : ", false, new StringNameValidator(), new InputDialogListener() {

        @Override
        public void finished(String input) {
            if (input == null || input.equals("")) {
                return;
            }
            Json json = HyperJson.getJson();
            GraphVO duplicated = json.fromJson(GraphVO.class, json.toJson(actionToDuplicate));
            Object[] payload = AddToLibraryAction.getPayload(input, duplicated);
            HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_ADD_TO_LIBRARY_ACTION, payload);
        }

        @Override
        public void canceled() {
            cancel();
        }
    });
}
Also used : StringNameValidator(games.rednblack.editor.view.ui.validator.StringNameValidator) InputDialogListener(com.kotcrab.vis.ui.util.dialog.InputDialogListener) GraphVO(games.rednblack.editor.renderer.data.GraphVO) HyperJson(games.rednblack.editor.renderer.utils.HyperJson) Json(com.badlogic.gdx.utils.Json) ProjectManager(games.rednblack.editor.proxy.ProjectManager)

Aggregations

GraphVO (games.rednblack.editor.renderer.data.GraphVO)8 ProjectManager (games.rednblack.editor.proxy.ProjectManager)3 GraphConnectionVO (games.rednblack.editor.renderer.data.GraphConnectionVO)2 GraphNodeVO (games.rednblack.editor.renderer.data.GraphNodeVO)2 FileHandle (com.badlogic.gdx.files.FileHandle)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Window (com.badlogic.gdx.scenes.scene2d.ui.Window)1 Json (com.badlogic.gdx.utils.Json)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 InputDialogListener (com.kotcrab.vis.ui.util.dialog.InputDialogListener)1 VisWindow (com.kotcrab.vis.ui.widget.VisWindow)1 ActionFieldType (games.rednblack.editor.graph.actions.ActionFieldType)1 GraphGroupVO (games.rednblack.editor.renderer.data.GraphGroupVO)1 HyperJson (games.rednblack.editor.renderer.utils.HyperJson)1 DraggableResource (games.rednblack.editor.view.ui.box.resourcespanel.draggable.DraggableResource)1 LibraryActionResource (games.rednblack.editor.view.ui.box.resourcespanel.draggable.list.LibraryActionResource)1 StringNameValidator (games.rednblack.editor.view.ui.validator.StringNameValidator)1 File (java.io.File)1