Browse Source

Adding Target, Effect, Area, Duration, and (basic) Saving Throw to Spell Info Panel.

Sam Jaffe 8 years ago
parent
commit
b4aa70d921

+ 1 - 2
src/org/leumasjaffe/charsheet/model/magic/DDSpell.java

@@ -1,7 +1,6 @@
 package org.leumasjaffe.charsheet.model.magic;
 
 import java.util.EnumSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -67,7 +66,7 @@ public class DDSpell {
 	@NonNull Range range;
 	String effect; // TODO
 	Area area;
-	List<String> targets; // TODO
+	String target;
 	@NonNull String duration; // TODO
 	@NonNull String savingThrow; // TODO
 	boolean allowsSpellResistance;

+ 109 - 23
src/org/leumasjaffe/charsheet/view/magic/SpellInfoPanel.java

@@ -28,11 +28,8 @@ public class SpellInfoPanel extends JPanel {
 	 * 
 	 */
 	private static final long serialVersionUID = 1L;
-	private JTextField name;
-	private JTextField school;
-	private JTextField keywords;
-	private JTextField action;
-	private JTextField range;
+	private JTextField tgtOrEffect;
+	private JPanel panel;
 
 	public SpellInfoPanel(DDCharacterClass dclass, final DDSpell spell) {
 		GridBagLayout gridBagLayout = new GridBagLayout();
@@ -42,19 +39,19 @@ public class SpellInfoPanel extends JPanel {
 		gridBagLayout.rowWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
 		setLayout(gridBagLayout);
 		
-		JPanel panel = new JPanel();
-		GridBagConstraints gbc_panel = new GridBagConstraints();
-		gbc_panel.insets = new Insets(0, 0, 5, 0);
-		gbc_panel.fill = GridBagConstraints.BOTH;
-		gbc_panel.gridx = 0;
-		gbc_panel.gridy = 0;
-		add(panel, gbc_panel);
-		GridBagLayout gbl_panel = new GridBagLayout();
-		gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0};
-		gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
-		gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
-		gbl_panel.rowWeights = new double[]{0.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
-		panel.setLayout(gbl_panel);
+		panel = new JPanel();
+		GridBagConstraints gbc_panel_2 = new GridBagConstraints();
+		gbc_panel_2.insets = new Insets(0, 0, 5, 0);
+		gbc_panel_2.fill = GridBagConstraints.BOTH;
+		gbc_panel_2.gridx = 0;
+		gbc_panel_2.gridy = 0;
+		add(panel, gbc_panel_2);
+		GridBagLayout gbl_panel_2 = new GridBagLayout();
+		gbl_panel_2.columnWidths = new int[]{0, 0, 0, 0, 0};
+		gbl_panel_2.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
+		gbl_panel_2.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
+		gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
+		panel.setLayout(gbl_panel_2);
 		
 		JLabel lblName = new JLabel("Name:");
 		lblName.setFont(new Font("Tahoma", Font.BOLD, 14));
@@ -65,7 +62,7 @@ public class SpellInfoPanel extends JPanel {
 		gbc_lblName.gridy = 0;
 		panel.add(lblName, gbc_lblName);
 		
-		name = new JTextField(spell.getName());
+		JTextField name = new JTextField(spell.getName());
 		name.setEditable(false);
 		GridBagConstraints gbc_name = new GridBagConstraints();
 		gbc_name.insets = new Insets(0, 0, 5, 5);
@@ -84,7 +81,7 @@ public class SpellInfoPanel extends JPanel {
 		gbc_lblSpellSchool.gridy = 0;
 		panel.add(lblSpellSchool, gbc_lblSpellSchool);
 		
-		school = new JTextField(spell.getSpellSchool());
+		JTextField school = new JTextField(spell.getSpellSchool());
 		school.setEditable(false);
 		school.setColumns(10);
 		GridBagConstraints gbc_school = new GridBagConstraints();
@@ -103,7 +100,7 @@ public class SpellInfoPanel extends JPanel {
 		gbc_lblKeywords.gridy = 1;
 		panel.add(lblKeywords, gbc_lblKeywords);
 		
-		keywords = new JTextField(spell.getKeywords().isEmpty() ? "<none>" : asString(spell.getKeywords()));
+		JTextField keywords = new JTextField(asString(spell.getKeywords()));
 		keywords.setEditable(false);
 		keywords.setColumns(10);
 		GridBagConstraints gbc_keywords = new GridBagConstraints();
@@ -175,7 +172,7 @@ public class SpellInfoPanel extends JPanel {
 		gbc_lblCastingTime.gridy = 3;
 		panel.add(lblCastingTime, gbc_lblCastingTime);
 		
-		action = new JTextField(spell.getCastingTime().name());
+		JTextField action = new JTextField(spell.getCastingTime().name());
 		action.setEditable(false);
 		action.setColumns(10);
 		GridBagConstraints gbc_action = new GridBagConstraints();
@@ -194,7 +191,7 @@ public class SpellInfoPanel extends JPanel {
 		gbc_lblRange.gridy = 3;
 		panel.add(lblRange, gbc_lblRange);
 		
-		range = new JTextField(spell.getRange().getResolved(dclass.getLevel()));
+		JTextField range = new JTextField(spell.getRange().getResolved(dclass.getLevel()));
 		range.setToolTipText(spell.getRange().toString());
 		range.setEditable(false);
 		range.setColumns(10);
@@ -205,6 +202,65 @@ public class SpellInfoPanel extends JPanel {
 		gbc_range.gridy = 3;
 		panel.add(range, gbc_range);
 		
+		initTargetOrEffect(spell);
+		
+		JLabel lblArea = new JLabel("Area:");
+		lblArea.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblArea = new GridBagConstraints();
+		gbc_lblArea.anchor = GridBagConstraints.EAST;
+		gbc_lblArea.insets = new Insets(0, 0, 5, 5);
+		gbc_lblArea.gridx = 2;
+		gbc_lblArea.gridy = 4;
+		panel.add(lblArea, gbc_lblArea);
+		
+		JTextField area = new JTextField(spell.getArea() != null ? spell.getArea().toString() : "");
+		area.setEditable(false);
+		area.setColumns(10);
+		GridBagConstraints gbc_area = new GridBagConstraints();
+		gbc_area.insets = new Insets(0, 0, 5, 0);
+		gbc_area.fill = GridBagConstraints.HORIZONTAL;
+		gbc_area.gridx = 3;
+		gbc_area.gridy = 4;
+		panel.add(area, gbc_area);
+		
+		JLabel lblDuration = new JLabel("Duration:");
+		lblDuration.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblDuration = new GridBagConstraints();
+		gbc_lblDuration.anchor = GridBagConstraints.EAST;
+		gbc_lblDuration.insets = new Insets(0, 0, 5, 5);
+		gbc_lblDuration.gridx = 0;
+		gbc_lblDuration.gridy = 5;
+		panel.add(lblDuration, gbc_lblDuration);
+		
+		JTextField duration = new JTextField(spell.getDuration());
+		duration.setEditable(false);
+		duration.setColumns(10);
+		GridBagConstraints gbc_duration = new GridBagConstraints();
+		gbc_duration.insets = new Insets(0, 0, 5, 5);
+		gbc_duration.fill = GridBagConstraints.HORIZONTAL;
+		gbc_duration.gridx = 1;
+		gbc_duration.gridy = 5;
+		panel.add(duration, gbc_duration);
+		
+		JLabel lblSavingThrow = new JLabel("Saving Throw:");
+		lblSavingThrow.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblSavingThrow = new GridBagConstraints();
+		gbc_lblSavingThrow.anchor = GridBagConstraints.EAST;
+		gbc_lblSavingThrow.insets = new Insets(0, 0, 5, 5);
+		gbc_lblSavingThrow.gridx = 2;
+		gbc_lblSavingThrow.gridy = 5;
+		panel.add(lblSavingThrow, gbc_lblSavingThrow);
+		
+		JTextField saving = new JTextField(spell.getSavingThrow());
+		saving.setEditable(false);
+		saving.setColumns(10);
+		GridBagConstraints gbc_saving = new GridBagConstraints();
+		gbc_saving.insets = new Insets(0, 0, 5, 0);
+		gbc_saving.fill = GridBagConstraints.HORIZONTAL;
+		gbc_saving.gridx = 3;
+		gbc_saving.gridy = 5;
+		panel.add(saving, gbc_saving);
+		
 		JScrollPane scrollPane = new JScrollPane();
 		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
 		gbc_scrollPane.fill = GridBagConstraints.BOTH;
@@ -221,7 +277,37 @@ public class SpellInfoPanel extends JPanel {
 		description.setLineWrap(true);
 	}
 
+	private void initTargetOrEffect(final DDSpell spell) {
+		if (spell.getTarget() == null) {
+			initTargetOrEffect("Target:", spell.getTarget());
+		} else {
+			initTargetOrEffect("Effect:", spell.getEffect());
+		}
+	}
+	
+	private void initTargetOrEffect(final String header, final String value) {
+		JLabel lblTarget = new JLabel(header);
+		lblTarget.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblTarget = new GridBagConstraints();
+		gbc_lblTarget.anchor = GridBagConstraints.EAST;
+		gbc_lblTarget.insets = new Insets(0, 0, 5, 5);
+		gbc_lblTarget.gridx = 0;
+		gbc_lblTarget.gridy = 4;
+		panel.add(lblTarget, gbc_lblTarget);
+		
+		tgtOrEffect = new JTextField(value);
+		tgtOrEffect.setEditable(false);
+		tgtOrEffect.setColumns(10);
+		GridBagConstraints gbc_tgtOrEffect = new GridBagConstraints();
+		gbc_tgtOrEffect.insets = new Insets(0, 0, 5, 5);
+		gbc_tgtOrEffect.fill = GridBagConstraints.HORIZONTAL;
+		gbc_tgtOrEffect.gridx = 1;
+		gbc_tgtOrEffect.gridy = 4;
+		panel.add(tgtOrEffect, gbc_tgtOrEffect);
+	}
+
 	private static String asString(Set<String> keys) {
+		if (keys.isEmpty()) return "<none>";
 		String str = keys.toString();
 		return str.substring(1, str.length()-1);
 	}