Search in sources :

Example 1 with StringNameValidator

use of games.rednblack.editor.view.ui.validator.StringNameValidator in project HyperLap2D by rednblackgames.

the class ValueParamBoxProducer method createValuePart.

private GraphBoxPartImpl<T> createValuePart(Skin skin, String name) {
    final VisValidatableTextField v1Input = new VisValidatableTextField(new StringNameValidator()) {

        @Override
        public float getPrefWidth() {
            return 80;
        }
    };
    v1Input.setText(name);
    v1Input.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            v1Input.fire(new GraphChangedEvent(false, true));
        }
    });
    HorizontalGroup horizontalGroup = new HorizontalGroup();
    horizontalGroup.addActor(new Label("Name: ", skin));
    horizontalGroup.addActor(v1Input);
    GraphBoxPartImpl<T> colorPart = new GraphBoxPartImpl<T>(horizontalGroup, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(Map<String, String> object) {
            object.put("v", v1Input.getText());
        }
    });
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
    return colorPart;
}
Also used : StringNameValidator(games.rednblack.editor.view.ui.validator.StringNameValidator) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Example 2 with StringNameValidator

use of games.rednblack.editor.view.ui.validator.StringNameValidator in project HyperLap2D by rednblackgames.

the class EventActionBoxProducer method createValuePart.

private GraphBoxPartImpl<T> createValuePart(Skin skin, String name) {
    final VisValidatableTextField v1Input = new VisValidatableTextField(new StringNameValidator()) {

        @Override
        public float getPrefWidth() {
            return 80;
        }
    };
    v1Input.setText(name);
    v1Input.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            v1Input.fire(new GraphChangedEvent(false, true));
        }
    });
    HorizontalGroup horizontalGroup = new HorizontalGroup();
    horizontalGroup.addActor(new Label("Name: ", skin));
    horizontalGroup.addActor(v1Input);
    GraphBoxPartImpl<T> colorPart = new GraphBoxPartImpl<T>(horizontalGroup, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(Map<String, String> object) {
            object.put("v", v1Input.getText());
        }
    });
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("action"));
    return colorPart;
}
Also used : StringNameValidator(games.rednblack.editor.view.ui.validator.StringNameValidator) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Example 3 with StringNameValidator

use of games.rednblack.editor.view.ui.validator.StringNameValidator 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)

Example 4 with StringNameValidator

use of games.rednblack.editor.view.ui.validator.StringNameValidator in project HyperLap2D by rednblackgames.

the class UISceneBoxMediator method handleNotification.

@Override
public void handleNotification(INotification notification) {
    super.handleNotification(notification);
    Sandbox sandbox = Sandbox.getInstance();
    switch(notification.getName()) {
        case ProjectManager.PROJECT_OPENED:
        case MsgAPI.SCENE_LOADED:
            viewComponent.update();
            break;
        case UISceneBox.CHANGE_SCENE_BTN_CLICKED:
            facade.sendNotification(MsgAPI.CHECK_EDITS_ACTION, (Runnable) () -> sandbox.loadScene(notification.getBody()));
            break;
        case UISceneBox.CREATE_NEW_SCENE_BTN_CLICKED:
            Dialogs.showInputDialog(sandbox.getUIStage(), "Create New Scene", "Scene Name : ", false, new StringNameValidator(), new InputDialogListener() {

                @Override
                public void finished(String input) {
                    if (input == null || input.equals("")) {
                        viewComponent.setCurrentScene();
                        return;
                    }
                    SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
                    sceneDataManager.createNewScene(input);
                    facade.sendNotification(MsgAPI.CHECK_EDITS_ACTION, (Runnable) () -> sandbox.loadScene(input));
                }

                @Override
                public void canceled() {
                    viewComponent.setCurrentScene();
                }
            });
            break;
        case UISceneBox.DELETE_CURRENT_SCENE_BTN_CLICKED:
            Dialogs.showConfirmDialog(sandbox.getUIStage(), "Delete Scene", "Do you really want to delete '" + notification.getBody() + "' scene?", new String[] { "Cancel", "Delete" }, new Integer[] { 0, 1 }, result -> {
                if (result == 1) {
                    SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
                    sceneDataManager.deleteCurrentScene();
                    sandbox.loadScene("MainScene");
                }
            }).padBottom(20).pack();
            break;
        default:
            break;
    }
}
Also used : StringNameValidator(games.rednblack.editor.view.ui.validator.StringNameValidator) InputDialogListener(com.kotcrab.vis.ui.util.dialog.InputDialogListener) SceneDataManager(games.rednblack.editor.proxy.SceneDataManager) Sandbox(games.rednblack.editor.view.stage.Sandbox)

Aggregations

StringNameValidator (games.rednblack.editor.view.ui.validator.StringNameValidator)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 InputDialogListener (com.kotcrab.vis.ui.util.dialog.InputDialogListener)2 VisValidatableTextField (com.kotcrab.vis.ui.widget.VisValidatableTextField)2 Json (com.badlogic.gdx.utils.Json)1 ProjectManager (games.rednblack.editor.proxy.ProjectManager)1 SceneDataManager (games.rednblack.editor.proxy.SceneDataManager)1 GraphVO (games.rednblack.editor.renderer.data.GraphVO)1 HyperJson (games.rednblack.editor.renderer.utils.HyperJson)1 Sandbox (games.rednblack.editor.view.stage.Sandbox)1