فهرست منبع

Adding more detailed class information panel.

Sam Jaffe 8 سال پیش
والد
کامیت
5f86df627e

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

@@ -19,6 +19,7 @@ import javax.swing.JMenuBar;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.KeyStroke;
+import javax.swing.UIManager;
 
 import org.leumasjaffe.charsheet.model.DDCharacter;
 import org.leumasjaffe.charsheet.view.dev.DeveloperMenu;
@@ -49,6 +50,7 @@ public class D20Sheet extends JFrame {
 	private DeveloperMenu developerMenu;
 	
 	public D20Sheet() {
+		UIManager.put("CheckBox.disabledText", UIManager.get("CheckBox.foreground"));
 		// Set up local state variables
 		final JFileChooser fc = new JFileChooser("resources");
 		mapper.registerModule(new Jdk8Module());

+ 220 - 0
src/org/leumasjaffe/charsheet/view/magic/SpellInfoPanel.java

@@ -0,0 +1,220 @@
+package org.leumasjaffe.charsheet.view.magic;
+
+import javax.swing.JPanel;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.util.Set;
+
+import javax.swing.JTextArea;
+
+import org.leumasjaffe.charsheet.model.magic.DDSpell;
+import org.leumasjaffe.charsheet.model.magic.DDSpell.Component;
+
+import javax.swing.JScrollPane;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import java.awt.Font;
+import java.awt.FlowLayout;
+import javax.swing.JCheckBox;
+
+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;
+
+	public SpellInfoPanel(final DDSpell spell) {
+		GridBagLayout gridBagLayout = new GridBagLayout();
+		gridBagLayout.columnWidths = new int[]{0, 0};
+		gridBagLayout.rowHeights = new int[]{0, 0, 0};
+		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
+		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);
+		
+		JLabel lblName = new JLabel("Name:");
+		lblName.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblName = new GridBagConstraints();
+		gbc_lblName.insets = new Insets(0, 0, 5, 5);
+		gbc_lblName.anchor = GridBagConstraints.EAST;
+		gbc_lblName.gridx = 0;
+		gbc_lblName.gridy = 0;
+		panel.add(lblName, gbc_lblName);
+		
+		name = new JTextField(spell.getName());
+		name.setEditable(false);
+		GridBagConstraints gbc_name = new GridBagConstraints();
+		gbc_name.insets = new Insets(0, 0, 5, 5);
+		gbc_name.fill = GridBagConstraints.HORIZONTAL;
+		gbc_name.gridx = 1;
+		gbc_name.gridy = 0;
+		panel.add(name, gbc_name);
+		name.setColumns(10);
+		
+		JLabel lblSpellSchool = new JLabel("Spell School:");
+		lblSpellSchool.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblSpellSchool = new GridBagConstraints();
+		gbc_lblSpellSchool.anchor = GridBagConstraints.EAST;
+		gbc_lblSpellSchool.insets = new Insets(0, 0, 5, 5);
+		gbc_lblSpellSchool.gridx = 2;
+		gbc_lblSpellSchool.gridy = 0;
+		panel.add(lblSpellSchool, gbc_lblSpellSchool);
+		
+		school = new JTextField(spell.getSpellSchool());
+		school.setEditable(false);
+		school.setColumns(10);
+		GridBagConstraints gbc_school = new GridBagConstraints();
+		gbc_school.insets = new Insets(0, 0, 5, 0);
+		gbc_school.fill = GridBagConstraints.HORIZONTAL;
+		gbc_school.gridx = 3;
+		gbc_school.gridy = 0;
+		panel.add(school, gbc_school);
+		
+		JLabel lblKeywords = new JLabel("Keywords:");
+		lblKeywords.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblKeywords = new GridBagConstraints();
+		gbc_lblKeywords.anchor = GridBagConstraints.EAST;
+		gbc_lblKeywords.insets = new Insets(0, 0, 5, 5);
+		gbc_lblKeywords.gridx = 0;
+		gbc_lblKeywords.gridy = 1;
+		panel.add(lblKeywords, gbc_lblKeywords);
+		
+		keywords = new JTextField(spell.getKeywords().isEmpty() ? "<none>" : asString(spell.getKeywords()));
+		keywords.setEditable(false);
+		keywords.setColumns(10);
+		GridBagConstraints gbc_keywords = new GridBagConstraints();
+		gbc_keywords.gridwidth = 3;
+		gbc_keywords.insets = new Insets(0, 0, 5, 0);
+		gbc_keywords.fill = GridBagConstraints.HORIZONTAL;
+		gbc_keywords.gridx = 1;
+		gbc_keywords.gridy = 1;
+		panel.add(keywords, gbc_keywords);
+		
+		JLabel lblComponents = new JLabel("Components:");
+		lblComponents.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblComponents = new GridBagConstraints();
+		gbc_lblComponents.anchor = GridBagConstraints.EAST;
+		gbc_lblComponents.insets = new Insets(0, 0, 5, 5);
+		gbc_lblComponents.gridx = 0;
+		gbc_lblComponents.gridy = 2;
+		panel.add(lblComponents, gbc_lblComponents);
+		
+		JPanel panel_1 = new JPanel();
+		GridBagConstraints gbc_panel_1 = new GridBagConstraints();
+		gbc_panel_1.insets = new Insets(0, 0, 5, 0);
+		gbc_panel_1.gridwidth = 3;
+		gbc_panel_1.fill = GridBagConstraints.BOTH;
+		gbc_panel_1.gridx = 1;
+		gbc_panel_1.gridy = 2;
+		panel.add(panel_1, gbc_panel_1);
+		panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
+		
+		JCheckBox chckbxVerbal = new JCheckBox("Verbal");
+		chckbxVerbal.setEnabled(false);
+		chckbxVerbal.setSelected(spell.getComponents().contains(Component.V));
+		panel_1.add(chckbxVerbal);
+		
+		JCheckBox chckbxSomatic = new JCheckBox("Somatic");
+		chckbxSomatic.setEnabled(false);
+		chckbxSomatic.setSelected(spell.getComponents().contains(Component.S));
+		panel_1.add(chckbxSomatic);
+		
+		JCheckBox chckbxMaterial = new JCheckBox("Material");
+		chckbxMaterial.setEnabled(false);
+		chckbxMaterial.setSelected(spell.getComponents().contains(Component.M));
+		panel_1.add(chckbxMaterial);
+		
+		JCheckBox chckbxFocus = new JCheckBox("Focus");
+		chckbxFocus.setEnabled(false);
+		chckbxFocus.setSelected(spell.getComponents().contains(Component.F));
+		panel_1.add(chckbxFocus);
+		
+		JCheckBox chckbxDivineFocus = new JCheckBox("Divine Focus");
+		chckbxDivineFocus.setEnabled(false);
+		chckbxDivineFocus.setSelected(spell.getComponents().contains(Component.DF));
+		panel_1.add(chckbxDivineFocus);
+		
+		JCheckBox chckbxExperience = new JCheckBox("Experience");
+		chckbxExperience.setEnabled(false);
+		chckbxExperience.setSelected(spell.getComponents().contains(Component.XP));
+		panel_1.add(chckbxExperience);
+		
+		JLabel lblCastingTime = new JLabel("Casting Time:");
+		lblCastingTime.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblCastingTime = new GridBagConstraints();
+		gbc_lblCastingTime.anchor = GridBagConstraints.EAST;
+		gbc_lblCastingTime.insets = new Insets(0, 0, 5, 5);
+		gbc_lblCastingTime.gridx = 0;
+		gbc_lblCastingTime.gridy = 3;
+		panel.add(lblCastingTime, gbc_lblCastingTime);
+		
+		action = new JTextField(spell.getCastingTime().name());
+		action.setEditable(false);
+		action.setColumns(10);
+		GridBagConstraints gbc_action = new GridBagConstraints();
+		gbc_action.insets = new Insets(0, 0, 5, 5);
+		gbc_action.fill = GridBagConstraints.HORIZONTAL;
+		gbc_action.gridx = 1;
+		gbc_action.gridy = 3;
+		panel.add(action, gbc_action);
+		
+		JLabel lblRange = new JLabel("Range:");
+		lblRange.setFont(new Font("Tahoma", Font.BOLD, 14));
+		GridBagConstraints gbc_lblRange = new GridBagConstraints();
+		gbc_lblRange.anchor = GridBagConstraints.EAST;
+		gbc_lblRange.insets = new Insets(0, 0, 5, 5);
+		gbc_lblRange.gridx = 2;
+		gbc_lblRange.gridy = 3;
+		panel.add(lblRange, gbc_lblRange);
+		
+		range = new JTextField(spell.getRange().toString());
+		range.setEditable(false);
+		range.setColumns(10);
+		GridBagConstraints gbc_range = new GridBagConstraints();
+		gbc_range.insets = new Insets(0, 0, 5, 0);
+		gbc_range.fill = GridBagConstraints.HORIZONTAL;
+		gbc_range.gridx = 3;
+		gbc_range.gridy = 3;
+		panel.add(range, gbc_range);
+		
+		JScrollPane scrollPane = new JScrollPane();
+		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
+		gbc_scrollPane.fill = GridBagConstraints.BOTH;
+		gbc_scrollPane.gridx = 0;
+		gbc_scrollPane.gridy = 1;
+		add(scrollPane, gbc_scrollPane);
+		
+		JTextArea description = new JTextArea(spell.getDescription());
+		description.setEditable(false);
+		description.setWrapStyleWord(true);
+		description.setRows(10);
+		scrollPane.setViewportView(description);
+		description.setColumns(30);
+		description.setLineWrap(true);
+	}
+
+	private static String asString(Set<String> keys) {
+		String str = keys.toString();
+		return str.substring(1, str.length()-1);
+	}
+}

+ 3 - 0
src/org/leumasjaffe/charsheet/view/magic/SpellLine.java

@@ -2,6 +2,7 @@ package org.leumasjaffe.charsheet.view.magic;
 
 import javax.swing.JPanel;
 
+import org.leumasjaffe.charsheet.controller.inventory.PopClickListener;
 import org.leumasjaffe.charsheet.model.magic.DDSpell;
 
 import java.awt.GridBagLayout;
@@ -84,6 +85,8 @@ public class SpellLine extends JPanel {
 		gbc_lblAction.gridx = 6;
 		gbc_lblAction.gridy = 0;
 		add(lblAction, gbc_lblAction);
+		
+		addMouseListener(new PopClickListener(new SpellMenu(spell)));
 	}
 
 }

+ 33 - 0
src/org/leumasjaffe/charsheet/view/magic/SpellMenu.java

@@ -0,0 +1,33 @@
+package org.leumasjaffe.charsheet.view.magic;
+
+import javax.swing.JPopupMenu;
+
+import org.leumasjaffe.charsheet.model.magic.DDSpell;
+
+import javax.swing.JFrame;
+import javax.swing.JMenuItem;
+
+class SpellMenu extends JPopupMenu {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	public SpellMenu(DDSpell spell) {
+		
+		JMenuItem mntmInfo = new JMenuItem("Info");
+		mntmInfo.addActionListener( e -> {
+			JFrame frame = new JFrame(spell.getName());
+			frame.add(new SpellInfoPanel(spell));
+			frame.pack();
+			frame.setVisible(true);
+		});
+		add(mntmInfo);
+		
+		JMenuItem mntmCast = new JMenuItem("Cast");
+		add(mntmCast);
+		
+	}
+
+}