public boolean build() {
    scrollPaneTable.clearChildren();

    if (properties.getProxies().first() instanceof GroupEntityProxy) {
      return false;
    }

    boolean atLeastOneComponentAdded = false;

    for (Class<? extends Component> clazz : componentClasses) {
      if (EntityUtils.isComponentCommon(clazz, properties.getProxies()) == false) {
        VisTextButton button = new VisTextButton(clazz.getSimpleName(), buttonStyle);
        button.setFocusBorderEnabled(false);
        scrollPaneTable.add(button).expandX().fillX().row();

        button.addListener(
            new VisChangeListener(
                (event, actor) -> {
                  listener.selected(clazz);
                  remove();
                }));

        atLeastOneComponentAdded = true;
      }
    }

    invalidateHierarchy();

    return atLeastOneComponentAdded;
  }
 @Override
 protected void setStage(Stage stage) {
   super.setStage(stage);
   if (stage != null) {
     properties.addListener(inputListener);
     stage.addListener(inputListener);
   }
 }
Example #3
0
  /**
   * Creates integer or float number selector depending on precision, see {@link #setPrecision(int)}
   *
   * @param name may be null
   */
  public NumberSelector(
      NumberSelectorStyle style,
      final Sizes sizes,
      String name,
      float initialValue,
      float min,
      float max,
      float step,
      int precision) {
    this.current = initialValue;
    this.max = max;
    this.min = min;
    this.step = step;

    valueText =
        new VisValidatableTextField() {
          @Override
          public float getPrefWidth() {
            return sizes.numberSelectorFieldSize;
          }
        };

    valueText.setProgrammaticChangeEvents(false);
    setPrecision(precision);
    valueText.setText(valueOf(current));

    VisTable buttonsTable = new VisTable();
    VisImageButton upButton = new VisImageButton(style.up);
    VisImageButton downButton = new VisImageButton(style.down);

    buttonsTable.add(upButton).height(sizes.numberSelectorButtonSize).row();
    buttonsTable.add(downButton).height(sizes.numberSelectorButtonSize);

    labelCell = add(new VisLabel(""));
    setSelectorName(name);

    add(valueText).fillX().expandX().height(sizes.numberSelectorButtonSize * 2).padRight(1);
    add(buttonsTable).width(sizes.numberSelectorButtonsWidth);

    addButtonsListeners(upButton, downButton);
    addTextFieldListeners();
  }
  public ComponentSelectDialog(
      EntityProperties properties, ComponentSelectDialogListener listener) {
    super(false);
    this.properties = properties;
    this.listener = listener;
    setBackground(VisUI.getSkin().getDrawable("tooltip-bg"));

    // TODO: [plugin] plugin entry point
    componentClasses.add(ShaderComponent.class);
    componentClasses.add(PolygonComponent.class);
    componentClasses.add(PhysicsPropertiesComponent.class);
    componentClasses.add(VariablesComponent.class);

    buttonStyle = new VisTextButtonStyle(VisUI.getSkin().get(VisTextButtonStyle.class));

    scrollPaneTable = new VisTable(false);
    scrollPaneTable.top();

    VisScrollPane scrollPane = new VisScrollPane(scrollPaneTable);
    scrollPane.setScrollingDisabled(false, true);
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);

    VisImageButton closeButton = new VisImageButton("close");

    add(new VisLabel("Select component"));
    add(closeButton).right().row();

    addSeparator().colspan(2);
    add(scrollPane).colspan(2).expand().fill().padLeft(3).padRight(3);
    setSize(220, 200);

    closeButton.addListener(new VisChangeListener((event, actor) -> remove()));

    inputListener =
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (contains(event.getStageX(), event.getStageY()) == false) {
              remove();
              return true;
            }

            return false;
          }
        };
  }
  public DefaultExporterSettingsDialog(
      EditorSettingsIOModule settingsIO, DefaultExporterSettings settings) {
    super("Settings");
    this.settingsIO = settingsIO;
    this.settings = settings;

    TableUtils.setSpacingDefaults(this);
    setModal(true);
    closeOnEscape();
    addCloseButton();

    left();
    defaults().left();

    VisTextButton cancelButton = new VisTextButton("Cancel");
    VisTextButton okButton = new VisTextButton("OK");
    VisTable buttonTable = new VisTable(true);
    buttonTable.add(cancelButton);
    buttonTable.add(okButton);

    skipDefaultCheck = new VisCheckBox("Skip default values");

    VisImage skipDefaultHelpImage = new VisImage(Icons.QUESTION_BIG.drawable());
    new Tooltip.Builder(
            "Reduces output file size by skipping default values like '0' or 'null'.\n"
                + "Typically there is no need to disable it but you can do it if you want to inspect\n"
                + "output scene file.",
            Align.left)
        .target(skipDefaultHelpImage)
        .build();
    add(skipDefaultCheck);
    add(skipDefaultHelpImage).size(22).row();

    minimalOutputCheck = new VisCheckBox("Use minimal output type");
    VisImage minimalOutputHelpImage = new VisImage(Icons.QUESTION_BIG.drawable());
    new Tooltip.Builder(
            "If checked output JSON will use minimal format, unnecessary double quotes\n"
                + "will be skipped unless needed. This format may not be supported by all JSON parsers.\nUncheck"
                + "this to disable minimal format.",
            Align.left)
        .target(minimalOutputHelpImage)
        .build();
    add(minimalOutputCheck);
    add(minimalOutputHelpImage).size(22).row();

    packageSeparateAtlasForEachSceneCheck =
        new VisCheckBox("Package separate atlas for each scene");
    VisImage packageSeparateAtlasForEachSceneHelpImage =
        new VisImage(Icons.QUESTION_BIG.drawable());
    new Tooltip.Builder(
            "If checked each exported scene will have it's own separate texture atlas. This is useful\n"
                + "when you have many texture assets but they are split between scenes.\nNote when this is checked 'master'"
                + "atlas containing all texture will not be created.",
            Align.left)
        .target(packageSeparateAtlasForEachSceneHelpImage)
        .build();
    add(packageSeparateAtlasForEachSceneCheck);
    add(packageSeparateAtlasForEachSceneHelpImage).size(22).row();

    migFilterSelectBox =
        new EnumSelectBox<>(Texture.TextureFilter.class, new DefaultEnumNameProvider<>());
    magFilterSelectBox =
        new EnumSelectBox<>(Texture.TextureFilter.class, new DefaultEnumNameProvider<>());
    add(TableBuilder.build(new VisLabel("Mig Texture Filter"), migFilterSelectBox)).row();
    add(TableBuilder.build(new VisLabel("Mag Texture Filter"), magFilterSelectBox)).row();

    add(buttonTable).right().colspan(2);

    cancelButton.addListener(
        new VisChangeListener(
            (event1, actor1) -> {
              setUIFromSettings();
              fadeOut();
            }));

    okButton.addListener(
        new VisChangeListener(
            (event, actor) -> {
              setToSettings();
              fadeOut();
            }));

    setUIFromSettings();

    pack();
    centerWindow();
  }
Example #6
0
  public void buildNodeController() {
    List<VisTextButton> actionBtns = getButtons(AActionNode.class);
    List<VisTextButton> dataBtns = getButtons(ADataNode.class);
    List<VisTextButton> utilBtns = getButtons(AUtilNode.class);

    VisTextButton actionTableToggle = new VisTextButton("Action nodes");
    VisTextButton dataTableToggle = new VisTextButton("Data nodes");
    VisTextButton utilTableToggle = new VisTextButton("Util nodes");
    VisTable actionTable = new VisTable(true);
    VisTable dataTable = new VisTable(true);
    VisTable utilTable = new VisTable(true);

    CollapsibleWidget actionWidget = new CollapsibleWidget(actionTable);
    CollapsibleWidget dataWidget = new CollapsibleWidget(dataTable);
    CollapsibleWidget utilWidget = new CollapsibleWidget(utilTable);
    actionWidget.setCollapsed(true, false);
    dataWidget.setCollapsed(true, false);
    utilWidget.setCollapsed(true, false);

    for (VisTextButton actBtn : actionBtns) {
      actionTable.add(actBtn).fillX();
      actionTable.row();
    }
    for (VisTextButton dataBtn : dataBtns) {
      dataTable.add(dataBtn).fillX();
      dataTable.row();
    }
    for (VisTextButton utilBtn : utilBtns) {
      utilTable.add(utilBtn).fillX();
      utilTable.row();
    }

    actionTableToggle.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            actionWidget.setCollapsed(!actionWidget.isCollapsed(), true);
          }
        });
    dataTableToggle.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            dataWidget.setCollapsed(!dataWidget.isCollapsed(), true);
          }
        });
    utilTableToggle.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            utilWidget.setCollapsed(!utilWidget.isCollapsed(), true);
          }
        });

    addNodeTable.add(actionTableToggle).fillX();
    addNodeTable.row();
    addNodeTable.add(actionWidget).fillX();
    addNodeTable.row();
    addNodeTable.add(dataTableToggle).fillX();
    addNodeTable.row();
    addNodeTable.add(dataWidget).fillX();
    addNodeTable.row();
    addNodeTable.add(utilTableToggle).fillX();
    addNodeTable.row();
    addNodeTable.add(utilWidget).fillX();
    addNodeTable.row();
    addNodeTable.addSeparator();
    addNodeTable.row();
    addNodeTable.add(compileGraph).fillX();

    compileGraph.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            //                graphBase.targetComponent =
            // Launcher.instance().editorScreen.getComponentAtLocation(0, 0, 0);
            if (graphBase.getTargetComponent() == null) {
              Dialogs.showErrorDialog(getStage(), "No component selected");
              return;
            }
            graphBase
                .getTargetComponent()
                .setActionGraph(graphBase.compiler.compileGraph(graphBase));
            graphBase.getTargetComponent().setActionGraphData(graphBase.compileToData());
          }
        });
  }