Search in sources :

Example 6 with PointBuyMethod

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);
}
Also used : GameMode(pcgen.core.GameMode) PointBuyMethod(pcgen.core.PointBuyMethod) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Collection(java.util.Collection)

Aggregations

PointBuyMethod (pcgen.core.PointBuyMethod)6 GameMode (pcgen.core.GameMode)2 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 Collection (java.util.Collection)1 ButtonGroup (javax.swing.ButtonGroup)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JRadioButton (javax.swing.JRadioButton)1 Border (javax.swing.border.Border)1 TitledBorder (javax.swing.border.TitledBorder)1 RollMethod (pcgen.cdom.content.RollMethod)1 PCClass (pcgen.core.PCClass)1 BonusObj (pcgen.core.bonus.BonusObj)1 JComboBoxEx (pcgen.gui2.util.JComboBoxEx)1