|
@@ -10,7 +10,7 @@ import javax.swing.JPopupMenu;
|
|
|
import javax.swing.JTable;
|
|
import javax.swing.JTable;
|
|
|
import javax.swing.ListSelectionModel;
|
|
import javax.swing.ListSelectionModel;
|
|
|
|
|
|
|
|
-import org.leumasjaffe.charsheet.controller.magic.ChooseSpellTuple;
|
|
|
|
|
|
|
+import org.leumasjaffe.charsheet.controller.magic.SpellPicker;
|
|
|
import org.leumasjaffe.charsheet.model.magic.DDSpell;
|
|
import org.leumasjaffe.charsheet.model.magic.DDSpell;
|
|
|
import org.leumasjaffe.charsheet.model.observable.BoolGate;
|
|
import org.leumasjaffe.charsheet.model.observable.BoolGate;
|
|
|
import org.leumasjaffe.charsheet.model.observable.IntValue;
|
|
import org.leumasjaffe.charsheet.model.observable.IntValue;
|
|
@@ -80,13 +80,12 @@ public class SelectSpellsPanel extends JPanel {
|
|
|
IntValue sharedValue;
|
|
IntValue sharedValue;
|
|
|
SelectSpellModel modelPrepared, modelKnown;
|
|
SelectSpellModel modelPrepared, modelKnown;
|
|
|
|
|
|
|
|
- public SelectSpellsPanel(ChooseSpellTuple info, BoolGate.Handle gate, int level,
|
|
|
|
|
- Collection<DDSpell> prepared, Collection<DDSpell> avail,
|
|
|
|
|
- boolean allowsDuplicates, IntValue sharedValue) {
|
|
|
|
|
- this.allowsDuplicates = allowsDuplicates;
|
|
|
|
|
|
|
+ public SelectSpellsPanel(SpellPicker pick, BoolGate.Handle gate, int level,
|
|
|
|
|
+ Collection<DDSpell> prepared, IntValue sharedValue) {
|
|
|
|
|
+ this.allowsDuplicates = pick.allowsDuplicates();
|
|
|
this.sharedValue = sharedValue;
|
|
this.sharedValue = sharedValue;
|
|
|
this.prepared = new ArrayList<>(prepared);
|
|
this.prepared = new ArrayList<>(prepared);
|
|
|
- final List<DDSpell> known = new ArrayList<>(avail);
|
|
|
|
|
|
|
+ final List<DDSpell> known = new ArrayList<>(pick.getAvailableSpells(level));
|
|
|
this.modelPrepared = new SelectSpellModel(createModel(prepared));
|
|
this.modelPrepared = new SelectSpellModel(createModel(prepared));
|
|
|
this.modelKnown = new SelectSpellModel(createModel(known));
|
|
this.modelKnown = new SelectSpellModel(createModel(known));
|
|
|
gate.set(countNone() == 0);
|
|
gate.set(countNone() == 0);
|
|
@@ -99,7 +98,7 @@ public class SelectSpellsPanel extends JPanel {
|
|
|
gridBagLayout.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
gridBagLayout.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
|
setLayout(gridBagLayout);
|
|
setLayout(gridBagLayout);
|
|
|
|
|
|
|
|
- JPanel panel = new ChooseSpellsPerDayHeader(level, info.spellBook, info.ability());
|
|
|
|
|
|
|
+ JPanel panel = new ChooseSpellsPerDayHeader(level, pick.getInfo().spellBook, pick.getInfo().ability());
|
|
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
|
|
gbc_panel.gridwidth = 3;
|
|
gbc_panel.gridwidth = 3;
|
|
|
gbc_panel.insets = new Insets(0, 0, 5, 5);
|
|
gbc_panel.insets = new Insets(0, 0, 5, 5);
|
|
@@ -157,8 +156,8 @@ public class SelectSpellsPanel extends JPanel {
|
|
|
JMenuItem mntmInfo = new JMenuItem("Info");
|
|
JMenuItem mntmInfo = new JMenuItem("Info");
|
|
|
mntmInfo.addActionListener( e -> {
|
|
mntmInfo.addActionListener( e -> {
|
|
|
DDSpell spell = known.get(tableKnown.getSelectedRow());
|
|
DDSpell spell = known.get(tableKnown.getSelectedRow());
|
|
|
- JFrame frame = new JFrame(spell.getName() + " (" + info.dclass.getName() + " " + level + ")");
|
|
|
|
|
- frame.add(new SpellInfoPanel(info.chara, info.dclass, spell));
|
|
|
|
|
|
|
+ JFrame frame = new JFrame(spell.getName() + " (" + pick.getInfo().dclass.getName() + " " + level + ")");
|
|
|
|
|
+ frame.add(new SpellInfoPanel(pick.getInfo().chara, pick.getInfo().dclass, spell));
|
|
|
frame.pack();
|
|
frame.pack();
|
|
|
frame.setVisible(true);
|
|
frame.setVisible(true);
|
|
|
});
|
|
});
|
|
@@ -225,11 +224,6 @@ public class SelectSpellsPanel extends JPanel {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public SelectSpellsPanel(ChooseSpellTuple info, BoolGate.Handle gate, int level,
|
|
|
|
|
- Collection<DDSpell> prepared, Collection<DDSpell> avail) {
|
|
|
|
|
- this(info, gate, level, prepared, avail, true, new IntValue(-1));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private boolean wouldHaveIllegalDuplicate(int row) {
|
|
private boolean wouldHaveIllegalDuplicate(int row) {
|
|
|
return !this.allowsDuplicates && Arrays.asList(modelPrepared.data).contains(modelKnown.data[row]);
|
|
return !this.allowsDuplicates && Arrays.asList(modelPrepared.data).contains(modelKnown.data[row]);
|
|
|
}
|
|
}
|