use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterStatsPanel method applyOptionValuesToControls.
/**
* @see pcgen.gui2.prefs.PCGenPrefsPanel#applyOptionValuesToControls()
*/
@Override
public void applyOptionValuesToControls() {
stopListeners();
final GameMode gameMode = SettingsHandler.getGame();
boolean bValid = true;
final int rollMethod = gameMode.getRollMethod();
switch(rollMethod) {
case Constants.CHARACTER_STAT_METHOD_USER:
abilitiesUserRolledButton.setSelected(true);
break;
case Constants.CHARACTER_STAT_METHOD_ALL_THE_SAME:
abilitiesAllSameButton.setSelected(true);
break;
case Constants.CHARACTER_STAT_METHOD_PURCHASE:
if (!abilitiesPurchasedButton.isVisible() || (pMode.length == 0)) {
bValid = false;
} else {
abilitiesPurchasedButton.setSelected(true);
}
break;
case Constants.CHARACTER_STAT_METHOD_ROLLED:
if (abilitiesRolledButton == null) {
bValid = false;
} else {
abilitiesRolledButton.setSelected(true);
abilityRolledModeCombo.setSelectedItem(gameMode.getRollMethodExpressionName());
}
break;
default:
bValid = false;
break;
}
if (!bValid) {
abilitiesUserRolledButton.setSelected(true);
gameMode.setRollMethod(Constants.CHARACTER_STAT_METHOD_USER);
}
int allStatsValue = Math.min(gameMode.getStatMax(), gameMode.getAllStatsValue());
allStatsValue = Math.max(gameMode.getStatMin(), allStatsValue);
gameMode.setAllStatsValue(allStatsValue);
abilityScoreCombo.setSelectedIndex(allStatsValue - gameMode.getStatMin());
if ((pMode != null) && (pModeMethodName != null)) {
final String methodName = gameMode.getPurchaseModeMethodName();
for (int i = 0; i < pMode.length; ++i) {
if (pModeMethodName[i].equals(methodName)) {
abilityPurchaseModeCombo.setSelectedIndex(i);
}
}
}
startListeners();
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class CharacterStatsPanel method showPurchaseModeConfiguration.
/**
* Create and display purchase mode stats popup frame.
*/
private void showPurchaseModeConfiguration() {
if (pmsFrame == null) {
pmsFrame = new PurchaseModeFrame(parent);
final GameMode gameMode = SettingsHandler.getGame();
pmsFrame.setStatMin(gameMode.getStatMin());
pmsFrame.setStatMax(gameMode.getStatMax());
// add a listener to know when the window has closed
pmsFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
final int purchaseMethodCount = methods.size();
pMode = new String[purchaseMethodCount];
pModeMethodName = new String[purchaseMethodCount];
final String methodName = SettingsHandler.getGame().getPurchaseModeMethodName();
abilityPurchaseModeCombo.removeAllItems();
int i = 0;
for (PointBuyMethod pbm : methods) {
pMode[i] = pbm.getDescription();
pModeMethodName[i] = pbm.getDisplayName();
abilityPurchaseModeCombo.addItem(pMode[i]);
if (pModeMethodName[i].equals(methodName)) {
abilityPurchaseModeCombo.setSelectedIndex(i);
}
i++;
}
// free resources
pmsFrame = null;
//
// If user has added at least one method, then make the controls visible. Otherwise
// it is not a valid choice and cannot be selected, so hide it.
//
abilityPurchaseModeCombo.setVisible(purchaseMethodCount != 0);
abilitiesPurchasedButton.setVisible(purchaseMethodCount != 0);
//
if (!abilitiesPurchasedButton.isVisible() && abilitiesPurchasedButton.isSelected()) {
abilitiesUserRolledButton.setSelected(true);
}
}
});
}
Utility.centerComponent(pmsFrame);
// ensure the frame is visible (in case user selects menu item again).
pmsFrame.setVisible(true);
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class HouseRulesPanel method setOptionsBasedOnControls.
/**
* @see pcgen.gui2.prefs.PreferencesPanel#applyPreferences()
*/
@Override
public void setOptionsBasedOnControls() {
final GameMode gameMode = SettingsHandler.getGame();
for (int i = 0; i < hrBoxes.length; i++) {
if (hrBoxes[i] != null) {
String aKey = hrBoxes[i].getActionCommand();
boolean aBool = hrBoxes[i].isSelected();
// Save settings
if (gameMode.getModeContext().getReferenceContext().containsConstructedCDOMObject(RuleCheck.class, aKey)) {
SettingsHandler.setRuleCheck(aKey, aBool);
}
}
}
for (int i = 0; i < hrRadio.length; i++) {
if (hrRadio[i] != null) {
String aKey = hrRadio[i].getActionCommand();
boolean aBool = hrRadio[i].isSelected();
// Save settings
if (gameMode.getModeContext().getReferenceContext().containsConstructedCDOMObject(RuleCheck.class, aKey)) {
SettingsHandler.setRuleCheck(aKey, aBool);
}
}
}
}
Aggregations