use of pcgen.core.Campaign in project pcgen by PCGen.
the class CampaignPanel method performAnalysis.
/**
* @see pcgen.gui2.converter.panel.ConvertSubPanel#performAnalysis(pcgen.cdom.base.CDOMObject)
*/
@Override
public boolean performAnalysis(CDOMObject pc) {
GameMode game = pc.get(ObjectKey.GAME_MODE);
List<String> gameModeList = new ArrayList<>();
gameModeList.addAll(game.getAllowedModes());
File sourceFolder = pc.get(ObjectKey.DIRECTORY);
folderName = sourceFolder.toURI().toString();
// Only add those campaigns in the user's chosen folder and game mode
List<Campaign> allCampaigns = Globals.getCampaignList();
gameModeCampaigns = new ArrayList<>();
for (Campaign campaign : allCampaigns) {
if (campaign.containsAnyInList(ListKey.GAME_MODE, gameModeList)) {
if (campaign.getSourceURI().toString().startsWith(folderName)) {
gameModeCampaigns.add(campaign);
}
}
}
return false;
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class CampaignPanel method setupDisplay.
/**
* @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
*/
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel introLabel = new JLabel("Please select the Campaign(s) to Convert:");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(25, 25, 5, 25);
panel.add(introLabel, gbc);
final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName);
final JTable table = new JTable(model) {
//Implement table cell tool tips.
@Override
public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint();
int rowIndex = rowAtPoint(p);
int colIndex = columnAtPoint(p);
String tip = String.valueOf(getValueAt(rowIndex, colIndex));
return tip;
}
};
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent event) {
pc.removeListFor(ListKey.CAMPAIGN);
int[] selRows = table.getSelectedRows();
if (selRows.length == 0) {
saveSourceSelection(pc);
fireProgressEvent(ProgressEvent.NOT_ALLOWED);
} else {
for (int row : selRows) {
Campaign selCampaign = (Campaign) model.getValueAt(row, 0);
pc.addToListFor(ListKey.CAMPAIGN, selCampaign);
}
saveSourceSelection(pc);
fireProgressEvent(ProgressEvent.ALLOWED);
}
}
});
JScrollPane listScroller = new JScrollPane(table);
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
gbc.fill = GridBagConstraints.BOTH;
panel.add(listScroller, gbc);
initSourceSelection(model, table);
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class LSTConverter method initCampaigns.
/**
* Initialise the list of campaigns. This will load the ability
* categories in advance of the conversion.
* @param campaigns The campaigns or sources to be converted.
*/
public void initCampaigns(List<Campaign> campaigns) {
List<CampaignSourceEntry> dataDefFileList = new ArrayList<>();
for (Campaign campaign : campaigns) {
// mode
try {
catLoader.loadLstFiles(context, campaign.getSafeListFor(ListKey.FILE_ABILITY_CATEGORY));
sizeLoader.loadLstFiles(context, campaign.getSafeListFor(ListKey.FILE_SIZE));
statLoader.loadLstFiles(context, campaign.getSafeListFor(ListKey.FILE_STAT));
savesLoader.loadLstFiles(context, campaign.getSafeListFor(ListKey.FILE_SAVE));
alignmentLoader.loadLstFiles(context, campaign.getSafeListFor(ListKey.FILE_ALIGNMENT));
alignmentLoader.loadLstFiles(Globals.getContext(), campaign.getSafeListFor(ListKey.FILE_ALIGNMENT));
} catch (PersistenceLayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dataDefFileList.addAll(campaign.getSafeListFor(ListKey.FILE_DATACTRL));
}
// Load using the new LstFileLoaders
try {
SourceFileLoader.addDefaultDataControlIfNeeded(dataDefFileList);
dataControlLoader.loadLstFiles(context, dataDefFileList);
SourceFileLoader.processFactDefinitions(context);
} catch (PersistenceLayerException e) {
// TODO Auto-generated catch block
Logging.errorPrint("LSTConverter.initCampaigns failed", e);
}
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class ObjectInjector method writeInjectedObjects.
public void writeInjectedObjects(List<Campaign> list) throws IOException {
List<URI> affectedURIs = new ArrayList<>();
boolean first = true;
for (Campaign campaign : list) {
for (Loader l : loaders) {
for (CampaignSourceEntry cse : l.getFiles(campaign)) {
first &= processWrite(campaign, campaignData, cse, first);
affectedURIs.add(cse.getURI());
}
}
}
for (URI uri : affectedURIs) {
Set<File> files = fileData.getSecondaryKeySet(uri);
if (files != null) {
for (File f : files) {
writeFile(f, fileData.getListFor(uri, f));
}
}
}
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class SummaryPanel method setupDisplay.
/**
* @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
*/
@Override
public void setupDisplay(JPanel panel, CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel introLabel = new JLabel("Ready to convert.");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(50, 25, 10, 25);
panel.add(introLabel, gbc);
JLabel instructLabel = new JLabel("Press Next to begin converting using the following settings:");
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(10, 25, 20, 25);
panel.add(instructLabel, gbc);
JLabel[] labels = new JLabel[4];
JComponent[] values = new JComponent[4];
labels[0] = new JLabel("Source Folder:");
labels[1] = new JLabel("Destination Folder:");
labels[2] = new JLabel("Game mode:");
labels[3] = new JLabel("Sources:");
values[0] = new JLabel(pc.get(ObjectKey.DIRECTORY).getAbsolutePath());
values[1] = new JLabel(pc.get(ObjectKey.WRITE_DIRECTORY).getAbsolutePath());
values[2] = new JLabel(pc.get(ObjectKey.GAME_MODE).getDisplayName());
List<Campaign> campaigns = pc.getSafeListFor(ListKey.CAMPAIGN);
StringBuilder campDisplay = new StringBuilder();
for (int i = 0; i < campaigns.size(); i++) {
campDisplay.append(campaigns.get(i).getDisplayName());
campDisplay.append("\n");
}
JTextArea campText = new JTextArea(campDisplay.toString());
campText.setEditable(false);
JScrollPane scrollPane = new JScrollPane(campText);
values[3] = scrollPane;
// Place the labels on the page and lay them out
Font plainFont = FontManipulation.plain(panel.getFont());
for (int i = 0; i < labels.length; i++) {
Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(10, 25, 10, 10);
panel.add(labels[i], gbc);
if (i < labels.length - 1) {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
} else {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
}
gbc.insets = new Insets(10, 10, 10, 25);
panel.add(values[i], gbc);
values[i].setFont(plainFont);
}
}
Aggregations