use of pcgen.cdom.content.RollMethod 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);
}
Aggregations