|
|
@@ -6,19 +6,27 @@ import java.awt.Component;
|
|
|
import javax.swing.Box;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import java.awt.Insets;
|
|
|
-import java.util.Collection;
|
|
|
|
|
|
import org.jdesktop.swingx.VerticalLayout;
|
|
|
import org.leumasjaffe.charsheet.model.DDCharacterClass;
|
|
|
-import org.leumasjaffe.charsheet.model.magic.DDSpell;
|
|
|
|
|
|
+import lombok.AccessLevel;
|
|
|
+import lombok.experimental.FieldDefaults;
|
|
|
+
|
|
|
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
public class SpellLevelPanel extends JPanel {
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
+ JPanel panel;
|
|
|
+ DDCharacterClass dclass;
|
|
|
+ int level;
|
|
|
|
|
|
- public SpellLevelPanel(JPanel header, DDCharacterClass dclass, Collection<DDSpell> spells) {
|
|
|
+ public SpellLevelPanel(JPanel header, DDCharacterClass dclass, int level) {
|
|
|
+ this.dclass = dclass;
|
|
|
+ this.level = level;
|
|
|
+
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
|
|
|
@@ -34,14 +42,14 @@ public class SpellLevelPanel extends JPanel {
|
|
|
gbc_panel_1.gridy = 0;
|
|
|
add(header, gbc_panel_1);
|
|
|
|
|
|
- JPanel panel = new JPanel(new VerticalLayout());
|
|
|
+ panel = new JPanel(new VerticalLayout());
|
|
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
|
|
gbc_panel.insets = new Insets(0, 0, 5, 0);
|
|
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
|
|
gbc_panel.gridx = 1;
|
|
|
gbc_panel.gridy = 1;
|
|
|
add(panel, gbc_panel);
|
|
|
- spells.forEach(spell -> panel.add(new SpellLine(dclass, spell)));
|
|
|
+ reload();
|
|
|
|
|
|
Component horizontalStrut = Box.createHorizontalStrut(20);
|
|
|
GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
|
|
|
@@ -50,5 +58,13 @@ public class SpellLevelPanel extends JPanel {
|
|
|
gbc_horizontalStrut.gridy = 2;
|
|
|
add(horizontalStrut, gbc_horizontalStrut);
|
|
|
}
|
|
|
+
|
|
|
+ public boolean isCastableFromHere() { return false; }
|
|
|
+
|
|
|
+ protected void reload() {
|
|
|
+ panel.removeAll();
|
|
|
+ dclass.getSpellBook().get().spellsPreparedAtLevel(level).forEach(spell -> panel.add(new SpellLine(this.dclass, spell, isCastableFromHere())));
|
|
|
+ panel.repaint();
|
|
|
+ }
|
|
|
|
|
|
}
|