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);
}
}
}
}
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));
}
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));
}
}
}
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);
}
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);
}
}
Aggregations