use of pcgen.core.GameMode in project pcgen by PCGen.
the class GameModeFileLoader method loadGameModes.
private void loadGameModes(String[] gameFiles) {
SystemCollections.clearGameModeList();
File gameModeDir = new File(ConfigurationSettings.getSystemsDir(), "gameModes");
int progress = 0;
for (final String gameFile : gameFiles) {
File specGameModeDir = new File(gameModeDir, gameFile);
File miscInfoFile = new File(specGameModeDir, "miscinfo.lst");
final GameMode gm = GameModeFileLoader.loadGameModeMiscInfo(gameFile, miscInfoFile.toURI());
if (gm != null) {
String gmName = gm.getName();
//SettingsHandler.setGame(gmName);
LoadContext context = gm.getModeContext();
loadGameModeInfoFile(gm, new File(specGameModeDir, "level.lst").toURI(), "level");
loadGameModeInfoFile(gm, new File(specGameModeDir, "rules.lst").toURI(), "rules");
// Load equipmentslot.lst
GameModeFileLoader.loadGameModeLstFile(context, eqSlotLoader, gmName, gameFile, "equipmentslots.lst");
// Load paperInfo.lst
GameModeFileLoader.loadGameModeLstFile(context, paperLoader, gmName, gameFile, "paperInfo.lst");
// Load bio files
GameModeFileLoader.loadGameModeLstFile(context, traitLoader, gmName, gameFile, "bio" + File.separator + "traits.lst");
GameModeFileLoader.loadGameModeLstFile(context, locationLoader, gmName, gameFile, "bio" + File.separator + "locations.lst");
// Load load.lst and check for completeness
GameModeFileLoader.loadGameModeLstFile(context, loadInfoLoader, gmName, gameFile, "load.lst");
// Load sizeAdjustment.lst
GameModeFileLoader.loadGameModeLstFile(context, sizeLoader, gmName, gameFile, "sizeAdjustment.lst");
// Load statsandchecks.lst
GameModeFileLoader.loadGameModeLstFile(context, statCheckLoader, gmName, gameFile, "statsandchecks.lst");
// Load equipIcons.lst
GameModeFileLoader.loadGameModeLstFile(context, equipIconLoader, gmName, gameFile, "equipIcons.lst");
GameModeFileLoader.loadGameModeLstFile(context, codeControlLoader, gmName, gameFile, "codeControl.lst");
// Load pointbuymethods.lst
loadPointBuyFile(context, gameFile, gmName);
for (final PointBuyCost pbc : context.getReferenceContext().getConstructedCDOMObjects(PointBuyCost.class)) {
gm.addPointBuyStatCost(pbc);
}
// Load migration.lst
GameModeFileLoader.loadGameModeLstFile(context, migrationLoader, gmName, gameFile, "migration.lst");
GameModeFileLoader.loadGameModeLstFile(context, bioLoader, gmName, gameFile, "bio" + File.separator + "biosettings.lst");
}
try {
GameModeFileLoader.addDefaultWieldCategories(gm.getModeContext());
} catch (final PersistenceLayerException ple) {
Logging.errorPrint("Error Initializing PreParserFactory");
Logging.errorPrint(" " + ple.getMessage(), ple);
throw new UnreachableError();
}
progress++;
setProgress(progress);
}
SystemCollections.sortGameModeList();
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class GameModeFileLoader method loadGameModeMiscInfo.
private static GameMode loadGameModeMiscInfo(String aName, URI uri) {
GameMode gameMode = null;
String data;
try {
data = LstFileLoader.readFromURI(uri).toString();
} catch (final PersistenceLayerException ple) {
Logging.errorPrint(LanguageBundle.getFormattedString(//$NON-NLS-1$
"Errors.LstSystemLoader.loadGameModeInfoFile", uri, ple.getMessage()));
return gameMode;
}
String[] fileLines = data.split(LstFileLoader.LINE_SEPARATOR_REGEXP);
for (int i = 0; i < fileLines.length; i++) {
String aLine = fileLines[i];
// Ignore commented-out and empty lines
if (((!aLine.isEmpty()) && (aLine.charAt(0) == '#')) || aLine.isEmpty()) {
continue;
}
if (gameMode == null) {
gameMode = new GameMode(aName);
SystemCollections.addToGameModeList(gameMode);
gameMode.getModeContext().getReferenceContext().importObject(AbilityCategory.FEAT);
}
GameModeLoader.parseMiscGameInfoLine(gameMode, aLine, uri, i + 1);
}
// Record how the FEAT category was configured
AbilityCategory feat = new AbilityCategory();
feat.copyFields(AbilityCategory.FEAT);
gameMode.setFeatTemplate(feat);
int[] dieSizes = gameMode.getDieSizes();
if (dieSizes == null || dieSizes.length == 0) {
final int[] defaultDieSizes = { 1, 2, 3, 4, 6, 8, 10, 12, 20, 100, 1000 };
gameMode.setDieSizes(defaultDieSizes);
Logging.log(Logging.LST_ERROR, "GameMode (" + gameMode.getName() + ") : MiscInfo.lst did not contain any valid DIESIZES. " + "Using the system default DIESIZES.");
}
addDefaultUnitSet(gameMode);
addDefaultTabInfo(gameMode);
gameMode.applyPreferences();
return gameMode;
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterStatsPanel method setOptionsBasedOnControls.
/**
* @see pcgen.gui2.prefs.PCGenPrefsPanel#setOptionsBasedOnControls()
*/
@Override
public void setOptionsBasedOnControls() {
final GameMode gameMode = SettingsHandler.getGame();
gameMode.setAllStatsValue(abilityScoreCombo.getSelectedIndex() + gameMode.getStatMin());
if (abilitiesUserRolledButton.isSelected()) {
gameMode.setRollMethod(Constants.CHARACTER_STAT_METHOD_USER);
} else if (abilitiesAllSameButton.isSelected()) {
gameMode.setRollMethod(Constants.CHARACTER_STAT_METHOD_ALL_THE_SAME);
} else if (abilitiesPurchasedButton.isSelected()) {
if (abilityPurchaseModeCombo.isVisible() && (abilityPurchaseModeCombo.getSelectedIndex() >= 0)) {
gameMode.setPurchaseMethodName(pModeMethodName[abilityPurchaseModeCombo.getSelectedIndex()]);
} else {
gameMode.setRollMethod(Constants.CHARACTER_STAT_METHOD_USER);
}
} else if ((abilitiesRolledButton != null) && (abilitiesRolledButton.isSelected())) {
if (abilityRolledModeCombo.getSelectedIndex() >= 0) {
gameMode.setRollMethodExpressionByName(abilityRolledModeCombo.getSelectedItem().toString());
} else {
gameMode.setRollMethod(Constants.CHARACTER_STAT_METHOD_USER);
}
}
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterStatsPanel method initComponents.
/**
* Build and initialise the user interface.
*/
private void initComponents() {
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
JLabel label;
ButtonGroup exclusiveGroup;
Border etched = null;
TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_abilities);
title1.setTitleJustification(TitledBorder.LEFT);
this.setBorder(title1);
this.setLayout(gridbag);
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
c.insets = new Insets(2, 2, 2, 2);
final GameMode gameMode = SettingsHandler.getGame();
int row = 0;
exclusiveGroup = new ButtonGroup();
Utility.buildConstraints(c, 0, row++, 3, 1, 0, 0);
label = new JLabel(LanguageBundle.getFormattedString("in_Prefs_abilitiesGenLabel", //$NON-NLS-1$
gameMode.getDisplayName()));
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 0, row, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesUserRolledButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesUserRolled"));
gridbag.setConstraints(abilitiesUserRolledButton, c);
this.add(abilitiesUserRolledButton);
exclusiveGroup.add(abilitiesUserRolledButton);
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesAllSameButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesAllSame") + ": ");
gridbag.setConstraints(abilitiesAllSameButton, c);
this.add(abilitiesAllSameButton);
exclusiveGroup.add(abilitiesAllSameButton);
Utility.buildConstraints(c, 1, row, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
abilityScoreCombo = new JComboBoxEx();
for (int i = gameMode.getStatMin(); i <= gameMode.getStatMax(); ++i) {
abilityScoreCombo.addItem(String.valueOf(i));
}
gridbag.setConstraints(abilityScoreCombo, c);
this.add(abilityScoreCombo);
ReferenceManufacturer<RollMethod> mfg = gameMode.getModeContext().getReferenceContext().getManufacturer(RollMethod.class);
List<RollMethod> rollMethods = mfg.getOrderSortedObjects();
if (!rollMethods.isEmpty()) {
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesRolledButton = new JRadioButton("Rolled:");
gridbag.setConstraints(abilitiesRolledButton, c);
this.add(abilitiesRolledButton);
exclusiveGroup.add(abilitiesRolledButton);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
abilityRolledModeCombo = new JComboBoxEx();
for (RollMethod rm : rollMethods) {
abilityRolledModeCombo.addItem(rm.getDisplayName());
}
gridbag.setConstraints(abilityRolledModeCombo, c);
this.add(abilityRolledModeCombo);
}
Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
final int purchaseMethodCount = methods.size();
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesPurchasedButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesPurchased") + ": ");
gridbag.setConstraints(abilitiesPurchasedButton, c);
this.add(abilitiesPurchasedButton);
exclusiveGroup.add(abilitiesPurchasedButton);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
pMode = new String[purchaseMethodCount];
pModeMethodName = new String[purchaseMethodCount];
int i = 0;
for (PointBuyMethod pbm : methods) {
pMode[i] = pbm.getDescription();
pModeMethodName[i] = pbm.getDisplayName();
i++;
}
abilityPurchaseModeCombo = new JComboBoxEx(pMode);
gridbag.setConstraints(abilityPurchaseModeCombo, c);
this.add(abilityPurchaseModeCombo);
//
if (purchaseMethodCount == 0) {
abilityPurchaseModeCombo.setVisible(false);
abilitiesPurchasedButton.setVisible(false);
}
Utility.buildConstraints(c, 1, row++, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 1, row++, 3, 1, 0, 0);
JButton purchaseModeButton = new JButton(LanguageBundle.getString("in_Prefs_purchaseModeConfig"));
gridbag.setConstraints(purchaseModeButton, c);
this.add(purchaseModeButton);
purchaseModeButton.addActionListener(new PurchaseModeButtonListener());
Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class DefaultsPanel method applyOptionValuesToControls.
/**
* @see pcgen.gui2.prefs.PreferencesPanel#initPreferences()
*/
@Override
public void applyOptionValuesToControls() {
final GameMode gameMode = SettingsHandler.getGame();
final String xpTableName = gameMode.getDefaultXPTableName();
List<String> xpTableNames = gameMode.getXPTableNames();
xpTableCombo.removeAllItems();
for (String name : xpTableNames) {
xpTableCombo.addItem(name);
}
xpTableCombo.setSelectedItem(xpTableName);
final String characterType = gameMode.getDefaultCharacterType();
List<String> characterTypes = gameMode.getCharacterTypeList();
characterTypeCombo.removeAllItems();
for (String name : characterTypes) {
characterTypeCombo.addItem(name);
}
characterTypeCombo.setSelectedItem(characterType);
final String previewSheet = UIPropertyContext.getInstance().initProperty(DEFAULT_PREVIEW_SHEET_KEY + gameMode, gameMode.getDefaultPreviewSheet());
String previewDir = ConfigurationSettings.getPreviewDir();
File sheetDir = new File(previewDir, gameMode.getCharSheetDir());
if (sheetDir.exists() && sheetDir.isDirectory()) {
String[] files = sheetDir.list((path, filename) -> {
File file = new File(path, filename);
return file.isFile() && !file.isHidden();
});
//String[] files = sheetDir.list();
previewSheetCombo.removeAllItems();
previewSheetCombo.setModel(new DefaultComboBoxModel(files));
previewSheetCombo.sortItems();
previewSheetCombo.setSelectedItem(previewSheet);
}
}
Aggregations