Search in sources :

Example 1 with GameModeFacade

use of pcgen.facade.core.GameModeFacade in project pcgen by PCGen.

the class InfoTabbedPane method updateTabsForCharacter.

/**
	 * Update the displayed tabs to reflect the settings of the game mode of the
	 * character to which we are switching.
	 *
	 * @param character The character being displayed.
	 */
private void updateTabsForCharacter(CharacterFacade character) {
    GameModeFacade gameMode = character.getDataSet().getGameMode();
    int tabIndex = 0;
    for (CharacterInfoTab charInfoTab : fullTabList) {
        TabTitle tabTitle = charInfoTab.getTabTitle();
        Tab tab = tabTitle.getTab();
        String newName = gameMode.getTabName(tab);
        if (!newName.equals(tabTitle.getValue(TabTitle.TITLE))) {
            tabTitle.putValue(TabTitle.TITLE, newName);
        }
        if (gameMode.getTabShown(tab)) {
            if (getComponentAt(tabIndex) != charInfoTab) {
                String title = (String) tabTitle.getValue(TabTitle.TITLE);
                String tooltip = (String) tabTitle.getValue(TabTitle.TOOLTIP);
                Icon icon = (Icon) tabTitle.getValue(TabTitle.ICON);
                insertTab(title, icon, (Component) charInfoTab, tooltip, tabIndex);
            }
            tabIndex++;
        } else {
            if (getComponentAt(tabIndex) == charInfoTab) {
                remove(tabIndex);
            }
        }
    }
}
Also used : GameModeFacade(pcgen.facade.core.GameModeFacade) DisplayAwareTab(pcgen.gui2.util.DisplayAwareTab) Tab(pcgen.util.enumeration.Tab) Icon(javax.swing.Icon)

Example 2 with GameModeFacade

use of pcgen.facade.core.GameModeFacade in project pcgen by PCGen.

the class CharacterManager method getRequiredSourcesForParty.

public static SourceSelectionFacade getRequiredSourcesForParty(File pcpFile, UIDelegate delegate) {
    PCGIOHandler ioHandler = new PCGIOHandler();
    List<File> files = ioHandler.readCharacterFileList(pcpFile);
    if ((files == null) || files.isEmpty()) {
        return null;
    }
    GameModeFacade gameMode = null;
    HashSet<CampaignFacade> campaignSet = new HashSet<>();
    for (final File file : files) {
        SourceSelectionFacade selection = getRequiredSourcesForCharacter(file, delegate);
        if (selection == null) {
            Logging.errorPrint("Failed to find sources in: " + file.getAbsolutePath());
            continue;
        }
        GameModeFacade game = selection.getGameMode().get();
        if (gameMode == null) {
            gameMode = game;
        } else if (gameMode != game) {
            Logging.errorPrint("Characters in " + pcpFile.getAbsolutePath() + " do not share the same game mode");
            return null;
        }
        for (final CampaignFacade campaign : selection.getCampaigns()) {
            campaignSet.add(campaign);
        }
    }
    return FacadeFactory.createSourceSelection(gameMode, new ArrayList<>(campaignSet));
}
Also used : PCGIOHandler(pcgen.io.PCGIOHandler) SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) GameModeFacade(pcgen.facade.core.GameModeFacade) PCGFile(pcgen.io.PCGFile) File(java.io.File) CampaignFacade(pcgen.facade.core.CampaignFacade) HashSet(java.util.HashSet)

Example 3 with GameModeFacade

use of pcgen.facade.core.GameModeFacade in project pcgen by PCGen.

the class FacadeFactory method initCampaigns.

private static void initCampaigns() {
    for (final CampaignFacade campaign : campaigns) {
        campaignMap.put(campaign.getName(), campaign);
        ListFacade<GameModeFacade> gameModeList = campaign.getGameModes();
        for (GameModeFacade gameModeFacade : gameModeList) {
            if (!campaignListMap.containsKey(gameModeFacade)) {
                campaignListMap.put(gameModeFacade, new DefaultListFacade<>());
            }
            DefaultListFacade<CampaignFacade> campaignList = campaignListMap.get(gameModeFacade);
            if (campaignList.containsElement(campaign)) {
                String sourceUri = ((CDOMObject) campaign).getSourceURI().toString();
                Logging.errorPrint("Campaign " + sourceUri + " lists GAMEMODE:" + gameModeFacade + " multiple times.");
            } else {
                campaignList.addElement(campaign);
            }
        }
        if (campaign.showInMenu() && !gameModeList.isEmpty()) {
            GameModeFacade game = gameModeList.getElementAt(0);
            ListFacade<CampaignFacade> list = new DefaultListFacade<>(Collections.singleton(campaign));
            quickSources.addElement(new BasicSourceSelectionFacade(campaign.getName(), list, game));
        }
    }
}
Also used : GameModeFacade(pcgen.facade.core.GameModeFacade) CampaignFacade(pcgen.facade.core.CampaignFacade) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

Example 4 with GameModeFacade

use of pcgen.facade.core.GameModeFacade in project pcgen by PCGen.

the class AdvancedSourceSelectionPanel method setSourceSelection.

public void setSourceSelection(SourceSelectionFacade sources) {
    if (sources == null || sources.getGameMode() == null) {
        Logging.errorPrint("Invalid source selection " + sources + "- ignoring.");
        return;
    }
    GameModeFacade selectedGame = sources.getGameMode().get();
    for (int i = 0; i < gameModeList.getModel().getSize(); i++) {
        GameModeDisplayFacade gmdf = (GameModeDisplayFacade) gameModeList.getModel().getElementAt(i);
        if (gmdf.getGameMode() == selectedGame) {
            gameModeList.setSelectedItem(gmdf);
        }
    }
    List<CampaignFacade> wrap = new ArrayList<>(ListFacades.wrap(sources.getCampaigns()));
    wrap.sort(Comparators.toStringIgnoreCaseCollator());
    selectedCampaigns.setContents(wrap);
}
Also used : GameModeFacade(pcgen.facade.core.GameModeFacade) ArrayList(java.util.ArrayList) CampaignFacade(pcgen.facade.core.CampaignFacade) GameModeDisplayFacade(pcgen.facade.core.GameModeDisplayFacade)

Example 5 with GameModeFacade

use of pcgen.facade.core.GameModeFacade in project pcgen by PCGen.

the class SourceSelectionDialog method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if (command.equals(SAVE_COMMAND)) {
        final JList sourcesList = new JList();
        final JTextField nameField = new JTextField();
        ListFacade<SourceSelectionFacade> sources = new SortedListFacade<>(Comparators.toStringIgnoreCaseCollator(), FacadeFactory.getCustomSourceSelections());
        sourcesList.setModel(new FacadeListModel(sources));
        sourcesList.addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent lse) {
                nameField.setText(sourcesList.getSelectedValue().toString());
            }
        });
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new JScrollPane(sourcesList), BorderLayout.CENTER);
        panel.add(nameField, BorderLayout.SOUTH);
        int ret = JOptionPane.showOptionDialog(this, panel, "Save the source selection as...", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
        if (ret == JOptionPane.OK_OPTION) {
            String name = nameField.getText();
            List<CampaignFacade> selectedCampaigns = advancedPanel.getSelectedCampaigns();
            GameModeFacade selectedGameMode = advancedPanel.getSelectedGameMode();
            SourceSelectionFacade selection = null;
            for (SourceSelectionFacade sourceSelectionFacade : sources) {
                if (sourceSelectionFacade.toString().equals(name)) {
                    selection = sourceSelectionFacade;
                    break;
                }
            }
            if (selection == null) {
                selection = FacadeFactory.createCustomSourceSelection(name);
            }
            selection.setCampaigns(selectedCampaigns);
            selection.setGameMode(selectedGameMode);
            basicPanel.setSourceSelection(selection);
        }
    } else if (command.equals(DELETE_COMMAND)) {
        FacadeFactory.deleteCustomSourceSelection(basicPanel.getSourceSelection());
    } else if (command.equals(LOAD_COMMAND)) {
        fireSourceLoad();
    } else if (command.equals(INSTALLDATA_COMMAND)) {
        // Swap to the install data dialog.
        setVisible(false);
        DataInstaller di = new DataInstaller();
        di.setVisible(true);
    } else if (command.equals(HIDEUNHIDE_COMMAND)) {
        SourcesTableModel model = new SourcesTableModel();
        JTableEx table = new JTableEx(model);
        JTable rowTable = TableUtils.createDefaultTable();
        JScrollPane pane = TableUtils.createCheckBoxSelectionPane(table, rowTable);
        table.setShowGrid(false);
        table.setFocusable(false);
        table.setRowSelectionAllowed(false);
        rowTable.setRowSelectionAllowed(false);
        pane.setPreferredSize(new Dimension(300, 200));
        int ret = JOptionPane.showOptionDialog(this, pane, "Select Sources to be visible", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
        if (ret == JOptionPane.OK_OPTION) {
            FacadeFactory.setDisplayedSources(model.getDisplayedSources());
        }
        model.dispose();
    } else {
        //must be the cancel command
        setVisible(false);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DataInstaller(pcgen.gui2.dialog.DataInstaller) SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) GameModeFacade(pcgen.facade.core.GameModeFacade) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) CampaignFacade(pcgen.facade.core.CampaignFacade) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) JTableEx(pcgen.gui2.util.JTableEx) JTable(javax.swing.JTable) SortedListFacade(pcgen.facade.util.SortedListFacade) JList(javax.swing.JList) FacadeListModel(pcgen.gui2.util.FacadeListModel)

Aggregations

GameModeFacade (pcgen.facade.core.GameModeFacade)5 CampaignFacade (pcgen.facade.core.CampaignFacade)4 SourceSelectionFacade (pcgen.facade.core.SourceSelectionFacade)2 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Icon (javax.swing.Icon)1 JList (javax.swing.JList)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 JTextField (javax.swing.JTextField)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 GameModeDisplayFacade (pcgen.facade.core.GameModeDisplayFacade)1 DefaultListFacade (pcgen.facade.util.DefaultListFacade)1 SortedListFacade (pcgen.facade.util.SortedListFacade)1