use of pcgen.core.PointBuyMethod 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);
}
Aggregations