private void rebuildUsagesTable() {
    usagesTable.clear();
    usagesTable.left();
    usagesTable.defaults().left();

    for (FileItem item : items) {

      FileHandle file = item.getFile();
      boolean canAnalyze = usageAnalyzer.canAnalyzeUsages(file);

      if (canAnalyze == false) {
        usagesTable.add(new VisLabel("Can't analyze usages for: '" + file.name() + "'"));
        usagesTable.row();
      } else {
        AssetsUsages usages = usageAnalyzer.analyzeUsages(file);
        usagesTable.add(new VisLabel(usages.toPrettyString()));

        if (usages.count() > 0) {
          VisTextButton viewUsages = new VisTextButton("View " + usages.file.name() + " Usages");
          usagesTable.add(viewUsages);

          viewUsages.addListener(
              new VisChangeListener((event, actor) -> openSpecificUsagesTab(usages)));
        }

        usagesTable.row();
      }
    }
  }
  @Override
  public void fillTable(VisTable itemsTable) {
    getViews().clear(); // clear cache
    orderedViews.clear();
    gridGroup.clear();

    if (getItemsSorter() != null) sort(getItemsSorter());

    FileChooser.ViewMode viewMode = chooser.getViewMode();

    if (viewMode.isGridMode()) {
      viewMode.setupGridGroup(chooser.getSizes(), gridGroup);
      for (final FileHandle item : iterable()) {
        final FileChooser.FileItem view = getView(item);
        orderedViews.add(view);
        prepareViewBeforeAddingToTable(item, view);
        gridGroup.addActor(view);
      }

      itemsTable.add(gridGroup).growX().minWidth(0);
    } else {
      for (final FileHandle item : iterable()) {
        final FileChooser.FileItem view = getView(item);
        orderedViews.add(view);
        prepareViewBeforeAddingToTable(item, view);
        itemsTable.add(view).growX();
        itemsTable.row();
      }
    }
  }
  public void updateView(Map<String, FrameRange> frameRangeMap) {
    createNewAnimationTable();
    animationsList.clear();

    for (Map.Entry<String, FrameRange> entry : frameRangeMap.entrySet()) {
      String animationName = entry.getKey();
      FrameRange range = entry.getValue();

      VisTable row = new VisTable();

      VisImageButton trashBtn = new VisImageButton("trash-button");

      row.add(StandardWidgetsFactory.createLabel(animationName)).width(120).left();
      row.add(StandardWidgetsFactory.createLabel(range.startFrame + "")).width(50).left();
      row.add(StandardWidgetsFactory.createLabel(range.endFrame + "")).width(50).left();
      row.add(trashBtn).padLeft(10);
      row.row();

      animationsList.add(row).left();
      animationsList.row();

      trashBtn.addListener(
          new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
              facade.sendNotification(DELETE_BUTTON_PRESSED, animationName);
            }
          });
    }

    invalidateHeight();
  }
  private void createNewAnimationTable() {
    newAnimationTable.clear();
    nameField = StandardWidgetsFactory.createTextField();
    fromFrameField = StandardWidgetsFactory.createNumberSelector(0, 100);
    toFrameField = StandardWidgetsFactory.createNumberSelector(0, 100);
    addButton = new VisTextButton("Add");

    newAnimationTable.add(nameField).width(120);
    newAnimationTable.add(fromFrameField).padLeft(5);
    newAnimationTable.add(toFrameField).padLeft(5);
    newAnimationTable.add(addButton).padLeft(7).padRight(3);
    newAnimationTable.row();
    initListeners();
  }
  public AlignmentToolsDialog(ModuleInjector injector, Array<EntityProxy> selectedEntities) {
    injector.injectModules(this);
    this.selectedEntities = selectedEntities;

    setBackground(VisUI.getSkin().getDrawable("window-bg"));
    setTouchable(Touchable.enabled);
    setVisible(false);
    addListener(new EventStopper());

    top().left();
    defaults().left();
    TableUtils.setSpacingDefaults(this);

    VisTable horizontalAlign = new VisTable(true);

    VisImageButton alignLeft =
        new VisImageButton(Icons.ALIGN_LEFT.drawable(), "Align entities at left edge");
    VisImageButton alignRight =
        new VisImageButton(Icons.ALIGN_RIGHT.drawable(), "Align entities at right edge");
    VisImageButton alignCenterX =
        new VisImageButton(Icons.ALIGN_CENTER_X.drawable(), "Center entities at x axis");
    VisImageButton alignTop =
        new VisImageButton(Icons.ALIGN_BOTTOM.drawable(), "Align entities at top edge");
    VisImageButton alignBottom =
        new VisImageButton(Icons.ALIGN_TOP.drawable(), "Align entities at bottom edge");
    VisImageButton alignCenterY =
        new VisImageButton(Icons.ALIGN_CENTER_Y.drawable(), "Center entities at y axis");

    VisImageButton closeButton = new VisImageButton("close-window");

    horizontalAlign.add("Horizontal").width(70);
    horizontalAlign.add(alignLeft);
    horizontalAlign.add(alignRight);
    horizontalAlign.add(alignCenterX);

    VisTable verticalAlign = new VisTable(true);

    verticalAlign.add("Vertical").width(70);
    verticalAlign.add(alignTop);
    verticalAlign.add(alignBottom);
    verticalAlign.add(alignCenterY);

    add(new VisLabel("Alignment", Align.center)).expandX().fillX().top();
    add(closeButton).right().row();
    add(horizontalAlign).padLeft(3).colspan(2).row();
    add(verticalAlign).padLeft(3).colspan(2);

    pack();

    alignLeft.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.left)));
    alignRight.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.right)));
    alignCenterX.addListener(new VisChangeListener((event, actor) -> alignSelectedCenter(false)));
    alignTop.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.top)));
    alignBottom.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.bottom)));
    alignCenterY.addListener(new VisChangeListener((event, actor) -> alignSelectedCenter(true)));

    closeButton.addListener(new VisChangeListener((event, actor) -> setVisible(false)));
  }
  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;
  }
 public void setEmpty(String text) {
   animationsList.clear();
   VisLabel label = StandardWidgetsFactory.createLabel(text);
   label.setAlignment(Align.center);
   animationsList.add(label).pad(10).width(269).center();
   newAnimationTable.clear();
   invalidateHeight();
 }
  public TestFormValidator() {
    super("form validator");

    TableUtils.setSpacingDefaults(this);
    defaults().padRight(1);
    defaults().padLeft(1);
    columnDefaults(0).left();

    VisTextButton cancelButton = new VisTextButton("cancel");
    VisTextButton acceptButton = new VisTextButton("accept");

    VisValidableTextField firstNameField = new VisValidableTextField();
    VisValidableTextField lastNameField = new VisValidableTextField();
    VisValidableTextField age = new VisValidableTextField();

    VisLabel errorLabel = new VisLabel();
    errorLabel.setColor(Color.RED);

    VisTable buttonTable = new VisTable(true);
    buttonTable.add(errorLabel).expand().fill();
    buttonTable.add(cancelButton);
    buttonTable.add(acceptButton);

    add(new VisLabel("first name: "));
    add(firstNameField).expand().fill();
    row();
    add(new VisLabel("last name: "));
    add(lastNameField).expand().fill();
    row();
    add(new VisLabel("age: "));
    add(age).expand().fill();
    row();
    add(buttonTable).fill().expand().colspan(2).padBottom(3);

    SimpleFormValidator validator; // for GWT compatibility
    validator = new SimpleFormValidator(acceptButton, errorLabel);
    validator.notEmpty(firstNameField, "first name cannot be empty");
    validator.notEmpty(lastNameField, "last name cannot be empty");
    validator.notEmpty(age, "age cannot be empty");
    validator.integerNumber(age, "age must be a number");
    validator.valueGreaterThan(age, "you must be at least 18 years old", 18, true);

    pack();
    setSize(getWidth() + 60, getHeight());
    setPosition(548, 110);
  }
  public CreateNewResolutionDialog() {
    super("Create New Resolution");
    addCloseButton();
    VisTable mainTable = new VisTable();

    mainTable.padTop(6).padRight(6).padBottom(22);
    mainTable.add("Name:").padRight(5).right();
    nameVisTextField = createTextField("");
    mainTable.add(nameVisTextField).colspan(3).width(177).height(21);
    mainTable.row().padTop(10);
    mainTable.add("Resolution:").padRight(5).right().top();
    mainTable.add(getDimensionsTable()).left();
    mainTable.row().padTop(20);
    VisTextButton createBtn = new VisTextButton("Create", "orange");
    createBtn.addListener(new CrateButtonCliclListener());
    mainTable.add(createBtn).width(93).height(24).colspan(2);
    add(mainTable);
  }
  public EditSpriteAnimationDialog() {
    super("Edit Sprite Animation Ranges");
    addCloseButton();

    facade = Overlap2DFacade.getInstance();

    VisTable mainTable = new VisTable();

    animationsList = new VisTable();
    newAnimationTable = new VisTable();

    createNewAnimationTable();

    mainTable.add(animationsList);
    mainTable.row();
    mainTable.add(newAnimationTable);
    mainTable.row();

    add(mainTable);
  }
 public void init(Entity rootScene) {
   treeTable.clear();
   tree = new VisTree();
   VisScrollPane scroller = new VisScrollPane(tree);
   scroller.setFlickScroll(false);
   treeTable.add(scroller).width(166).maxHeight(570);
   //
   Node root = addTreeRoot(rootScene, null);
   root.setExpanded(true);
   tree.addListener(new TreeChangeListener());
 }
  public DeleteMultipleFilesTab(ModuleInjector injector, Array<FileItem> items) {
    super(false, true);
    this.injector = injector;
    this.items = items;
    injector.injectModules(this);

    table = new VisTable();
    table.setBackground(VisUI.getSkin().getDrawable("window-bg"));
    table.defaults().left();

    usagesTable = new VisTable(true);
    rebuildUsagesTable();

    VisScrollPane scrollPane = new VisScrollPane(usagesTable);
    scrollPane.setFadeScrollBars(false);

    table.add(scrollPane).expandX().fillX().pad(3).row();
    table.add().expand().fill().row();
    table.addSeparator();
    table.add(createButtonPane()).pad(3);
  }
  public PluginDetailsDialog(PluginDescriptor descriptor) {
    super("Plugin Details");

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

    VisTable contentTable = new VisTable(false);
    contentTable.defaults().spaceBottom(2).expand().left();

    contentTable.add(new VisLabel("Name: " + descriptor.name + " (" + descriptor.id + ")")).row();
    contentTable.add(new VisLabel("Description: " + descriptor.description)).row();
    contentTable.add(new VisLabel("Provider: " + descriptor.provider)).row();
    contentTable.add(new VisLabel("Version: " + descriptor.version)).row();
    contentTable
        .add(
            new VisLabel(
                "Compatibility: "
                    + descriptor.compatibility
                    + " "
                    + (descriptor.compatibility != App.PLUGIN_COMPATIBILITY_CODE
                        ? "(doesn't matches editor!)"
                        : "(matches editor)")))
        .row();

    VisTextButton okButton;

    add(contentTable).pad(3).expand().fill().row();
    add(okButton = new VisTextButton("OK")).right();

    okButton.addListener(new VisChangeListener((event, actor) -> fadeOut()));
    pack();
    setSize(getWidth(), getHeight());
    centerWindow();
  }
 private Table getDimensionsTable() {
   buttonGroup = new ButtonGroup<>();
   VisTextField.TextFieldFilter.DigitsOnlyFilter digitsOnlyFilter =
       new VisTextField.TextFieldFilter.DigitsOnlyFilter();
   VisTable dimensionsTable = new VisTable();
   widthVisTextField = createTextField("", digitsOnlyFilter);
   dimensionsTable.add(new VisLabel("Width:")).left().padRight(3);
   dimensionsTable.add(widthVisTextField).width(45).height(21).padRight(7);
   basedOnWidthRadioButton = new VisRadioButton(null);
   dimensionsTable.add(basedOnWidthRadioButton);
   dimensionsTable.add("Based on");
   dimensionsTable.row().padTop(10);
   heightVisTextField = createTextField("", digitsOnlyFilter);
   dimensionsTable.add(new VisLabel("Height:")).left().padRight(7);
   dimensionsTable.add(heightVisTextField).width(45).height(21).left();
   basedOnHeightRadioButton = new VisRadioButton(null);
   dimensionsTable.add(basedOnHeightRadioButton);
   dimensionsTable.add("Based on");
   buttonGroup.add(basedOnWidthRadioButton);
   buttonGroup.add(basedOnHeightRadioButton);
   return dimensionsTable;
 }
  private void rebuildLayersTable() {
    deselectAll();
    Array<Actor> actors = new Array<>(layersTable.getChildren());
    layersTable.clearChildren();

    for (Layer layer : scene.getLayers()) {
      LayerItem item = getItemForLayer(actors, layer);
      if (item == null) item = new LayerItem(layer);
      item.update();
      layersTable.add(item).expandX().fillX().row();

      if (layer == scene.getActiveLayer()) item.select();
    }

    if (scene.getLayers().size() == 1) {
      layerDownButton.setDisabled(true);
      layerUpButton.setDisabled(true);
      layerRemoveButton.setDisabled(true);
    } else layerRemoveButton.setDisabled(false);
  }
  private VisTable createButtonPane() {
    VisTable table = new VisTable(true);

    VisTextButton deleteAll = new VisTextButton("Delete All");
    VisTextButton reanalyze = new VisTextButton("Reanalyze");

    reanalyze.addListener(new VisChangeListener((event, actor) -> rebuildUsagesTable()));

    deleteAll.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            DialogUtils.showOptionDialog(
                event.getStage(),
                "Delete",
                "Are you sure?",
                OptionDialogType.YES_NO,
                new OptionDialogAdapter() {
                  @Override
                  public void yes() {
                    for (FileItem item : items) {
                      FileUtils.delete(item.getFile());
                      quickAccess.closeAllUsagesTabForFile(item.getFile());
                    }

                    removeFromTabPane();
                  }
                });
          }
        });

    table.add(deleteAll);
    table.add(reanalyze);

    return table;
  }
 public static VisTable build(String text, int labelWidth, Actor actor) {
   VisTable table = new VisTable(true);
   table.add(text).width(labelWidth);
   table.add(actor);
   return table;
 }
  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();
  }
Exemple #19
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());
          }
        });
  }
 public static VisTable build(VisTable target, Actor... actors) {
   for (Actor actor : actors) target.add(actor);
   return target;
 }