浏览代码

Initial state of a prepare spells panel hierarchy.

Sam Jaffe 8 年之前
父节点
当前提交
4c56312706

+ 3 - 0
src/org/leumasjaffe/charsheet/model/magic/DDSpellbook.java

@@ -11,6 +11,9 @@ import lombok.NonNull;
 public interface DDSpellbook {
 	@NonNull Collection<DDSpell> spellsKnownAtLevel( int level );
 	@NonNull List<DDSpell> spellsPreparedAtLevel( int level );
+	
+	@NonNull default List<DDSpell> getSpellsPreparedPreviouslyForLevel(int level) { return spellsPreparedAtLevel(level); }	
+
 
 	default boolean preparesSpells() { return false; }
 	

+ 1 - 3
src/org/leumasjaffe/charsheet/model/magic/impl/Prepared.java

@@ -11,7 +11,5 @@ public interface Prepared extends DDSpellbook {
 	@Override
 	default boolean preparesSpells() { return true; }
 
-	@NonNull List<DDSpell> getSpellsPreparedPreviouslyForLevel(int level);
-	
-	void prepareSpells(int level, List<DDSpell> spells);
+	@NonNull List<DDSpell> getSpellsPreparedPreviouslyForLevel(int level);	
 }

+ 2 - 1
src/org/leumasjaffe/charsheet/view/D20Sheet.java

@@ -23,6 +23,7 @@ import javax.swing.UIManager;
 
 import org.leumasjaffe.charsheet.model.DDCharacter;
 import org.leumasjaffe.charsheet.model.DDCharacterClass;
+import org.leumasjaffe.charsheet.view.builders.DialogBuilder;
 import org.leumasjaffe.charsheet.view.dev.DeveloperMenu;
 
 import java.awt.event.KeyEvent;
@@ -124,7 +125,7 @@ public class D20Sheet extends JFrame {
 			for (DDCharacterClass dclass : model.getClasses()) {
 				dclass.getSpellBook().ifPresent(sb -> {
 					if (sb.preparesSpells()) {
-						// TODO: dialogue
+						DialogBuilder.createPrepareSpellsDialog(dclass);
 					} else {
 						for (int i = 0; i < dclass.getHighestSpellLevel(); ++i) {
 							sb.prepareSpells(i, null);

+ 5 - 0
src/org/leumasjaffe/charsheet/view/builders/DialogBuilder.java

@@ -5,6 +5,7 @@ import javax.swing.JPanel;
 
 import org.leumasjaffe.charsheet.model.DDCharacter;
 import org.leumasjaffe.charsheet.model.DDCharacterClass;
+import org.leumasjaffe.charsheet.view.magic.PrepareSpellsDialog;
 import org.leumasjaffe.charsheet.view.skills.SkillLevelUpDialog;
 
 import lombok.experimental.UtilityClass;
@@ -25,4 +26,8 @@ public class DialogBuilder {
 	public void createSkillDialog(DDCharacter chara, DDCharacterClass dclass) {
 		createDialogue("Level Up - Skill Allocation", 510, 600, new SkillLevelUpDialog(chara, dclass));
 	}
+	
+	public void createPrepareSpellsDialog(DDCharacterClass dclass) {
+		createDialogue("Prepare Spells - " + dclass.getName(), 400, 600, new PrepareSpellsDialog(dclass));
+	}
 }

+ 48 - 0
src/org/leumasjaffe/charsheet/view/magic/PrepareSpellsDialog.java

@@ -0,0 +1,48 @@
+package org.leumasjaffe.charsheet.view.magic;
+
+import javax.swing.JPanel;
+
+import org.jdesktop.swingx.VerticalLayout;
+import org.leumasjaffe.charsheet.model.DDCharacterClass;
+import org.leumasjaffe.charsheet.model.magic.impl.Prepared;
+import java.awt.GridBagLayout;
+import javax.swing.JScrollPane;
+import java.awt.GridBagConstraints;
+
+public class PrepareSpellsDialog extends JPanel {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	public PrepareSpellsDialog(DDCharacterClass dclass) {
+		GridBagLayout gridBagLayout = new GridBagLayout();
+		gridBagLayout.columnWidths = new int[]{0, 0};
+		gridBagLayout.rowHeights = new int[]{0, 0};
+		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
+		gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
+		setLayout(gridBagLayout);
+		
+		JScrollPane scrollPane = new JScrollPane();
+		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
+		gbc_scrollPane.fill = GridBagConstraints.BOTH;
+		gbc_scrollPane.gridx = 0;
+		gbc_scrollPane.gridy = 0;
+		add(scrollPane, gbc_scrollPane);
+		
+		JPanel panel = new JPanel(new VerticalLayout(5));
+		scrollPane.setViewportView(panel);
+		
+//		final List<List<DDSpell>> prepare = new ArrayList<>();
+//		final List<Collection<DDSpell>> known = new ArrayList<>();
+//		
+		final Prepared spellBook = (Prepared) dclass.getSpellBook().get();
+		for (int i = 0; i < dclass.getHighestSpellLevel(); ++i) {
+//			prepare.add(spellBook.getSpellsPreparedPreviouslyForLevel(i));
+//			known.add(spellBook.spellsKnownAtLevel(i));
+			panel.add(new SelectPreparedSpellsPanel(spellBook.getSpellsPreparedPreviouslyForLevel(i), spellBook.spellsKnownAtLevel(i)));
+		}
+	}
+
+}

+ 29 - 0
src/org/leumasjaffe/charsheet/view/magic/SelectPreparedSpellsPanel.java

@@ -0,0 +1,29 @@
+package org.leumasjaffe.charsheet.view.magic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.swing.JPanel;
+
+import org.leumasjaffe.charsheet.model.magic.DDSpell;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.experimental.FieldDefaults;
+
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
+class SelectPreparedSpellsPanel extends JPanel {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	@Getter List<DDSpell> prepared;
+
+	public SelectPreparedSpellsPanel(List<DDSpell> prepared,
+			Collection<DDSpell> known) {
+		this.prepared = new ArrayList<>(prepared);
+	}
+}

+ 1 - 1
src/org/leumasjaffe/charsheet/view/skills/SkillLevelUpLine.java

@@ -31,7 +31,7 @@ import javax.swing.JButton;
 import java.awt.Font;
 
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
-public class SkillLevelUpLine extends JPanel {
+class SkillLevelUpLine extends JPanel {
 	/**
 	 * 
 	 */