Search in sources :

Example 1 with TabBuilder

use of main.gui.builders.TabBuilder in project Eidolons by IDemiurge.

the class AV_ButtonPanel method handleButtonClick.

public void handleButtonClick(boolean alt, String command) {
    switch(command) {
        case DEFAULTS:
            ModelManager.addDefaultValues(alt);
            break;
        case "Test":
            if (alt)
                DC_SoundMaster.preconstructEffectSounds();
            else
                AnimationConstructor.preconstructAllForAV();
            break;
        case "Test1":
            ItemGenerator.setGenerationOn(true);
            String playerParty = null;
            ObjType type = null;
            if (ArcaneVault.getSelectedOBJ_TYPE() == DC_TYPE.PARTY) {
                type = ArcaneVault.getSelectedType();
                playerParty = type.getProperty(PROPS.MEMBERS);
            } else if (ArcaneVault.getWorkspaceManager().getActiveWorkspace() != null) {
                type = DataManager.getType(ArcaneVault.getWorkspaceManager().getActiveWorkspace().getName(), DC_TYPE.PARTY);
                playerParty = type.getProperty(PROPS.MEMBERS);
            // default
            // for selected type(s)
            // for workspace
            }
            String enemyParty = UnitGroupMaster.getRandomReadyGroup(type.getLevel());
            // FAST_DC.main(args);
            break;
        case "Add WS":
            ArcaneVault.getWorkspaceManager().newWorkspaceForParty();
            break;
        case "Add Tab":
            {
                // boolean micro = true;
                // List<OBJ_TYPE> types = new ArrayList<>();
                // if (micro){
                // types = new ArrayList<>(Arrays.asList( OBJ_TYPES.values()));
                // }
                // types.removeAll( XML_Reader.getXmlMap().keySet());
                Class<?> ENUM_CLASS = DC_TYPE.class;
                String toAdd = ListChooser.chooseEnum(ENUM_CLASS, SELECTION_MODE.MULTIPLE);
                for (String sub : StringMaster.open(toAdd)) {
                    ArcaneVault.getMainBuilder().getTabBuilder().addTab(ENUM_CLASS, sub);
                }
                break;
            }
        case "Group":
            {
                UnitGroupMaster.createUnitGroup(null);
                break;
            }
        case "Edit":
            {
                // if (ArcaneVault.getSelectedType() != null)
                MapEditor.launch();
                // WorldEditor.editDefaultCampaign(); // ?
                break;
            }
        case "Clone":
            {
                final boolean alt_ = alt;
                new Thread(new Runnable() {

                    public void run() {
                        if (alt_) {
                            ArcaneVault.getSelectedType().copyValues(ArcaneVault.getPreviousSelectedType(), getCopyVals());
                        } else {
                            ArcaneVault.getSelectedType().cloneMapsWithExceptions(ArcaneVault.getPreviousSelectedType(), G_PROPS.NAME, G_PROPS.DISPLAYED_NAME, G_PROPS.IMAGE, G_PROPS.GROUP, ArcaneVault.getSelectedType().getOBJ_TYPE_ENUM().getGroupingKey(), ArcaneVault.getSelectedType().getOBJ_TYPE_ENUM().getSubGroupingKey());
                        }
                        refresh();
                    }
                }, "Clone thread").start();
                break;
            }
        case NEW_TREE:
            {
                OBJ_TYPE TYPE = ArcaneVault.getSelectedType().getOBJ_TYPE_ENUM();
                if (TYPE == DC_TYPE.SKILLS || (TYPE == DC_TYPE.CLASSES)) {
                    if (!alt) {
                        HC_Master.initTreeArg(ArcaneVault.getSelectedType());
                        HC_Master.initTreeView();
                        EditViewPanel panel = ArcaneVault.getMainBuilder().getEditViewPanel();
                        if (TYPE == DC_TYPE.SKILLS) {
                            panel.setSkillTreeViewComp(HC_Master.getAvTreeView());
                        } else {
                            panel.setClassTreeViewComp(HC_Master.getAvTreeView());
                        }
                        panel.setTreeView(true);
                        panel.refresh();
                        launchSelectionListeningThread(TYPE, null);
                    } else {
                        JFrame window = AV_T3View.showInNewWindow(true, TYPE == DC_TYPE.SKILLS);
                        // HC_Master.showHeroTreeInWindow(ArcaneVault
                        // .getSelectedType());
                        launchSelectionListeningThread(TYPE, window);
                    }
                    if (TYPE == DC_TYPE.SKILLS) {
                        if (skillSelectionListeningThreadRunning) {
                            return;
                        }
                    } else {
                        if (classSelectionListeningThreadRunning) {
                            return;
                        }
                    }
                    return;
                }
                if (!alt) {
                    ArcaneVault.getMainBuilder().getEditViewPanel().setTreeView(false);
                    ArcaneVault.getMainBuilder().getEditViewPanel().refresh();
                    return;
                }
                TabBuilder tabBuilder = new TabBuilder(null);
                JComponent comp = tabBuilder.build();
                ArcaneVault.addTree(tabBuilder);
                JFrame window = GuiManager.inNewWindow(comp, "Arcane Vault", new Dimension(ArcaneVault.TREE_WIDTH, ArcaneVault.TREE_HEIGHT));
                // window.isActive()
                break;
            }
        case "WS Add":
            {
                ModelManager.addToWorkspace(alt);
                break;
            }
        case "Toggle":
            {
                if (alt) {
                    int result = DialogMaster.optionChoice("What do I toggle?", "Inversion");
                    if (result == 0) {
                        ArcaneVault.setColorsInverted(!ArcaneVault.isColorsInverted());
                    }
                    break;
                }
                EditViewPanel panel = ArcaneVault.getMainBuilder().getEditViewPanel();
                if (panel.getTreeViewComp() != null) {
                    panel.setTreeView(!panel.isTreeView());
                    panel.refresh();
                }
                ModelManager.toggle();
                break;
            }
        case "Backup":
            {
                XML_Writer.createBackUpReserve();
                break;
            }
        case RENAME_SELECTED_TYPE:
            {
                renameType(ArcaneVault.getSelectedType());
                break;
            }
        case RENAME_TYPE:
            {
                type = DataManager.getType(JOptionPane.showInputDialog("Enter type name"));
                renameType(type);
                break;
            }
        case CLEAN_UP:
            {
                // cleanUp();
                break;
            }
        case RENAME_VALUE:
            {
                break;
            }
        case REMOVE_VALUE:
            {
                String values = JOptionPane.showInputDialog("Enter value names");
                if (values == null) {
                    values = (ListChooser.chooseEnum(PARAMETER.class, PROPERTY.class));
                }
                if (values == null) {
                    break;
                }
                String input = ListChooser.chooseEnum(DC_TYPE.class);
                if (input == null) {
                    break;
                }
                for (String typeName : StringMaster.open(input)) {
                    DC_TYPE TYPE = DC_TYPE.getType(typeName);
                    for (String valName : StringMaster.open(values)) {
                        VALUE val = ContentManager.getValue(valName);
                        boolean emptyOnly = JOptionPane.showConfirmDialog(null, "Empty only?") == JOptionPane.YES_OPTION;
                        XML_Transformer.removeValue(val, XML_Reader.getFile(TYPE), true, emptyOnly);
                    }
                }
                break;
            }
        case "Transform":
            {
                if (xmlTransformMenu == null) {
                    xmlTransformMenu = new XmlTransformMenu();
                } else {
                    xmlTransformMenu.setVisible(xmlTransformMenu.isVisible());
                }
            }
        case "Undo":
            {
                if (alt) {
                // while()
                }
                ModelManager.undo();
                break;
            }
        case "Upgrade":
            {
                if (alt) {
                    ModelManager.addParent();
                } else {
                    ModelManager.addUpgrade();
                }
                break;
            }
        case "New Hero":
            {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        CharacterCreator.addNewHero();
                    }
                });
                break;
            }
        case "Remove":
            {
                ModelManager.remove();
                break;
            }
        case "Reload":
            {
                Weaver.inNewThread(new Runnable() {

                    public void run() {
                        ModelManager.saveAll();
                        ModelManager.reload();
                        TableMouseListener.configureEditors();
                    }
                });
            }
        case "Add":
            {
                ModelManager.add();
                break;
            }
        case "Save":
            {
                ModelManager.save();
                break;
            }
        case "Save all":
            {
                ModelManager.saveAll();
                return;
            }
    }
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) EditViewPanel(main.gui.builders.EditViewPanel) TabBuilder(main.gui.builders.TabBuilder) ObjType(main.entity.type.ObjType) PARAMETER(main.content.values.parameters.PARAMETER)

Example 2 with TabBuilder

use of main.gui.builders.TabBuilder in project Eidolons by IDemiurge.

the class ModelManager method adjustTreeTabSelection.

public static void adjustTreeTabSelection(ObjType type, boolean select) {
    int code = // type.getOBJ_TYPE_ENUM().getCode();
    ListMaster.getIndexString(new ArrayList<>(ArcaneVault.getMainBuilder().getTabBuilder().getTabNames()), type.getOBJ_TYPE(), true);
    ArcaneVault.getMainBuilder().getTabBuilder().getTabbedPane().setSelectedIndex(code);
    // ArcaneVault.getMainBuilder().getEditViewPanel().selectType(type);
    // Class<?> ENUM_CLASS =
    // EnumMaster.findEnumClass(type.getOBJ_TYPE_ENUM().getGroupingKey().getName());
    List<String> list = EnumMaster.findEnumConstantNames(type.getOBJ_TYPE_ENUM().getGroupingKey().getName());
    int index = ListMaster.getIndexString(list, type.getGroupingKey(), true);
    if (type.getOBJ_TYPE_ENUM() == DC_TYPE.SKILLS) {
        if (index > 5) {
            index--;
        }
    }
    TabBuilder tb = ArcaneVault.getMainBuilder().getTabBuilder().getSubTabs(code);
    tb.getTabbedPane().setSelectedIndex(index);
    // getOrCreate path for node? I could keep some map from type to path...
    if (!select) {
        if (tb.getTree().getTreeSelectionListeners().length != 1) {
            return;
        }
        TreeSelectionListener listener = tb.getTree().getTreeSelectionListeners()[0];
        tb.getTree().removeTreeSelectionListener(listener);
        try {
            TreeMaster.collapseTree(tb.getTree());
            DefaultMutableTreeNode node = TreeMaster.findNode(tb.getTree(), type.getName());
            if (node == null) {
                // tb.getTabbedPane().setSelectedIndex(prevIndex);
                return;
            }
            tb.getTree().setSelectionPath(new TreePath(node.getPath()));
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        } finally {
            tb.getTree().addTreeSelectionListener(listener);
        }
        return;
    }
    TreeMaster.collapseTree(tb.getTree());
    DefaultMutableTreeNode node = TreeMaster.findNode(tb.getTree(), type.getName());
    tb.getTree().setSelectionPath(new TreePath(node.getPath()));
}
Also used : TabBuilder(main.gui.builders.TabBuilder) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) TreeSelectionListener(javax.swing.event.TreeSelectionListener)

Example 3 with TabBuilder

use of main.gui.builders.TabBuilder in project Eidolons by IDemiurge.

the class AV_TreeSelectionListener method valueChanged.

@Override
public void valueChanged(TreeSelectionEvent e1) {
    if (e1 == null) {
        return;
    }
    tree.requestFocusInWindow();
    boolean dtFlag = ArcaneVault.isDirty();
    if (((JTree) e1.getSource()).getSelectionPath() == null) {
        return;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) (((JTree) e1.getSource()).getSelectionPath().getLastPathComponent());
    if (node == null) {
        return;
    }
    String name = (String) node.getUserObject();
    String tab;
    if (panel.isLevelEditor()) {
        tab = LevelEditor.getSimulation().getSelectedEntity().getOBJ_TYPE();
    } else {
        tab = ArcaneVault.getMainBuilder().getSelectedTabName();
    }
    if (tab == null) {
        Workspace workspace = ArcaneVault.getWorkspaceManager().getWorkspaceByTab((G_Panel) SwingMaster.getParentOfClass(tree, G_Panel.class));
        if (workspace != null) {
            try {
                tab = workspace.getOBJ_TYPE(name, tab).getName();
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
    }
    if (SimulationManager.isUnitType(tab) && ArcaneVault.isSimulationOn()) {
        try {
            SimulationManager.initUnitObj(name);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    ObjType type = DataManager.getType(name, tab);
    if (type == null) {
        for (TabBuilder t : ArcaneVault.getAdditionalTrees()) {
            type = DataManager.getType(name, t.getSelectedTabName());
            if (type != null) {
                break;
            }
        }
    }
    if (type == null) {
        type = DataManager.getType(name);
    }
    if (type == null) {
        return;
    }
    selectType(type, tab);
    List<ObjType> types = new ArrayList<>();
    int length = 1;
    try {
        length = e1.getPaths().length;
    } catch (Exception e) {
    }
    if (length > 2) {
        // TODO
        try {
            for (TreePath p : e1.getPaths()) {
                node = (DefaultMutableTreeNode) p.getLastPathComponent();
                if (node == null) {
                    continue;
                }
                name = (String) node.getUserObject();
                type = DataManager.getType(name, tab);
                if (type != null) {
                    types.add(type);
                }
            }
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    } else {
        types.add(type);
    }
    ArcaneVault.setSelectedTypes(types);
    ArcaneVault.setDirty(dtFlag);
}
Also used : TabBuilder(main.gui.builders.TabBuilder) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) ObjType(main.entity.type.ObjType) ArrayList(java.util.ArrayList) Workspace(main.utilities.workspace.Workspace)

Aggregations

TabBuilder (main.gui.builders.TabBuilder)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 TreePath (javax.swing.tree.TreePath)2 ObjType (main.entity.type.ObjType)2 ArrayList (java.util.ArrayList)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 PARAMETER (main.content.values.parameters.PARAMETER)1 PROPERTY (main.content.values.properties.PROPERTY)1 EditViewPanel (main.gui.builders.EditViewPanel)1 Workspace (main.utilities.workspace.Workspace)1