|
|
@@ -0,0 +1,183 @@
|
|
|
+package org.leumasjaffe.charsheet.view.skills;
|
|
|
+
|
|
|
+import org.leumasjaffe.charsheet.model.Ability;
|
|
|
+import org.leumasjaffe.charsheet.model.DDCharacter;
|
|
|
+import org.leumasjaffe.charsheet.model.DDCharacterClass;
|
|
|
+import org.leumasjaffe.charsheet.model.observable.IntValue;
|
|
|
+import org.leumasjaffe.charsheet.model.skill.DDSkill;
|
|
|
+import org.leumasjaffe.charsheet.util.AbilityHelper;
|
|
|
+
|
|
|
+import lombok.AccessLevel;
|
|
|
+import lombok.Getter;
|
|
|
+import lombok.Value;
|
|
|
+import lombok.experimental.FieldDefaults;
|
|
|
+
|
|
|
+import java.awt.GridBagLayout;
|
|
|
+import javax.swing.JCheckBox;
|
|
|
+import java.awt.GridBagConstraints;
|
|
|
+import javax.swing.JLabel;
|
|
|
+import java.awt.Insets;
|
|
|
+import java.util.Optional;
|
|
|
+import java.awt.Dimension;
|
|
|
+import javax.swing.JTextField;
|
|
|
+import java.awt.Color;
|
|
|
+import javax.swing.border.MatteBorder;
|
|
|
+import javax.swing.SwingConstants;
|
|
|
+import javax.swing.JPanel;
|
|
|
+
|
|
|
+@SuppressWarnings("serial")
|
|
|
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
+class WildcardSkillLevelUpLine extends SkillLevelUpLine {
|
|
|
+ @Getter DDSkill skill;
|
|
|
+
|
|
|
+ @Value
|
|
|
+ private static final class TotalPacket {
|
|
|
+ Optional<Ability.Scores> ability;
|
|
|
+ DDSkill skill;
|
|
|
+ IntValue points;
|
|
|
+ }
|
|
|
+
|
|
|
+ public WildcardSkillLevelUpLine(final DDCharacter chara, final DDCharacterClass cclass,
|
|
|
+ final DDSkill skill) {
|
|
|
+ this.skill = skill;
|
|
|
+
|
|
|
+ setBorder(new MatteBorder(0, 0, 1, 0, (Color) new Color(0, 0, 0)));
|
|
|
+ setPreferredSize(new Dimension(480, 22));
|
|
|
+ GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
+ gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
+ gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
+ gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
+ gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
+ setLayout(gridBagLayout);
|
|
|
+
|
|
|
+ JCheckBox checkBoxIsClassSkill = new JCheckBox("");
|
|
|
+ checkBoxIsClassSkill.setToolTipText("Class Skill?");
|
|
|
+ checkBoxIsClassSkill.setSelected(cclass.isClassSkill(skill.getName()));
|
|
|
+ checkBoxIsClassSkill.setEnabled(false);
|
|
|
+ GridBagConstraints gbc_checkBoxIsClassSkill = new GridBagConstraints();
|
|
|
+ gbc_checkBoxIsClassSkill.insets = new Insets(1, 0, 0, 5);
|
|
|
+ gbc_checkBoxIsClassSkill.gridx = 0;
|
|
|
+ gbc_checkBoxIsClassSkill.gridy = 0;
|
|
|
+ add(checkBoxIsClassSkill, gbc_checkBoxIsClassSkill);
|
|
|
+
|
|
|
+ JPanel panel = new JPanel();
|
|
|
+ GridBagConstraints gbc_panel = new GridBagConstraints();
|
|
|
+ panel.setMaximumSize(new Dimension(150, 14));
|
|
|
+ panel.setMinimumSize(new Dimension(150, 14));
|
|
|
+ panel.setPreferredSize(new Dimension(150, 14));
|
|
|
+ gbc_panel.insets = new Insets(1, 0, 0, 5);
|
|
|
+ gbc_panel.fill = GridBagConstraints.BOTH;
|
|
|
+ gbc_panel.gridx = 1;
|
|
|
+ gbc_panel.gridy = 0;
|
|
|
+ add(panel, gbc_panel);
|
|
|
+ GridBagLayout gbl_panel = new GridBagLayout();
|
|
|
+ gbl_panel.columnWidths = new int[]{0, 0, 0, 0};
|
|
|
+ gbl_panel.rowHeights = new int[]{0, 0};
|
|
|
+ gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
|
|
+ gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
+ panel.setLayout(gbl_panel);
|
|
|
+
|
|
|
+ JLabel lblName = new JLabel(skill.getName().replaceAll("\\(.*", "("));
|
|
|
+ GridBagConstraints gbc_lblName = new GridBagConstraints();
|
|
|
+ gbc_lblName.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblName.gridx = 0;
|
|
|
+ gbc_lblName.gridy = 0;
|
|
|
+ panel.add(lblName, gbc_lblName);
|
|
|
+
|
|
|
+ JTextField textField = new JTextField();
|
|
|
+ textField.setMinimumSize(new Dimension(10, 20));
|
|
|
+ textField.setPreferredSize(new Dimension(10, 20));
|
|
|
+ GridBagConstraints gbc_textField = new GridBagConstraints();
|
|
|
+ gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_textField.gridx = 1;
|
|
|
+ gbc_textField.gridy = 0;
|
|
|
+ panel.add(textField, gbc_textField);
|
|
|
+ textField.setColumns(10);
|
|
|
+
|
|
|
+ JLabel lblName2 = new JLabel(")");
|
|
|
+ GridBagConstraints gbc_lblName2 = new GridBagConstraints();
|
|
|
+ gbc_lblName2.gridx = 2;
|
|
|
+ gbc_lblName2.gridy = 0;
|
|
|
+ panel.add(lblName2, gbc_lblName2);
|
|
|
+
|
|
|
+ JLabel lblAbil = new JLabel(skill.getAbility());
|
|
|
+ lblAbil.setMaximumSize(new Dimension(30, 14));
|
|
|
+ lblAbil.setMinimumSize(new Dimension(30, 14));
|
|
|
+ lblAbil.setPreferredSize(new Dimension(30, 14));
|
|
|
+ GridBagConstraints gbc_lblAbil = new GridBagConstraints();
|
|
|
+ gbc_lblAbil.insets = new Insets(1, 0, 0, 5);
|
|
|
+ gbc_lblAbil.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblAbil.gridx = 2;
|
|
|
+ gbc_lblAbil.gridy = 0;
|
|
|
+ add(lblAbil, gbc_lblAbil);
|
|
|
+
|
|
|
+ String modStr = Integer.toString(getAbility(chara, skill).map(Ability.Scores::modifier).orElse(0));
|
|
|
+ JTextField total = new JTextField(modStr);
|
|
|
+ total.setToolTipText("Skill Modifier");
|
|
|
+ total.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ total.setEditable(false);
|
|
|
+ total.setMinimumSize(new Dimension(30, 20));
|
|
|
+ total.setMaximumSize(new Dimension(30, 20));
|
|
|
+ total.setPreferredSize(new Dimension(30, 20));
|
|
|
+ GridBagConstraints gbc_total = new GridBagConstraints();
|
|
|
+ gbc_total.insets = new Insets(1, 0, 0, 5);
|
|
|
+ gbc_total.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_total.gridx = 3;
|
|
|
+ gbc_total.gridy = 0;
|
|
|
+ add(total, gbc_total);
|
|
|
+ total.setColumns(10);
|
|
|
+
|
|
|
+ JLabel label = new JLabel("=");
|
|
|
+ GridBagConstraints gbc_label = new GridBagConstraints();
|
|
|
+ gbc_label.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_label.insets = new Insets(1, 0, 0, 5);
|
|
|
+ gbc_label.gridx = 4;
|
|
|
+ gbc_label.gridy = 0;
|
|
|
+ add(label, gbc_label);
|
|
|
+
|
|
|
+ JTextField modifier = new JTextField(modStr);
|
|
|
+ modifier.setToolTipText("Ability Modifier");
|
|
|
+ modifier.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ modifier.setEditable(false);
|
|
|
+ modifier.setMinimumSize(new Dimension(30, 20));
|
|
|
+ modifier.setMaximumSize(new Dimension(30, 20));
|
|
|
+ modifier.setPreferredSize(new Dimension(30, 20));
|
|
|
+ GridBagConstraints gbc_modifier = new GridBagConstraints();
|
|
|
+ gbc_modifier.insets = new Insets(1, 0, 0, 5);
|
|
|
+ gbc_modifier.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_modifier.gridx = 5;
|
|
|
+ gbc_modifier.gridy = 0;
|
|
|
+ add(modifier, gbc_modifier);
|
|
|
+ modifier.setColumns(10);
|
|
|
+
|
|
|
+ JLabel label_1 = new JLabel("+");
|
|
|
+ GridBagConstraints gbc_label_1 = new GridBagConstraints();
|
|
|
+ gbc_label_1.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_label_1.insets = new Insets(1, 0, 0, 5);
|
|
|
+ gbc_label_1.gridx = 6;
|
|
|
+ gbc_label_1.gridy = 0;
|
|
|
+ add(label_1, gbc_label_1);
|
|
|
+
|
|
|
+ JTextField ranks = new JTextField("0");
|
|
|
+ ranks.setToolTipText("Ranks");
|
|
|
+ ranks.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ ranks.setEditable(false);
|
|
|
+ ranks.setMinimumSize(new Dimension(30, 20));
|
|
|
+ ranks.setMaximumSize(new Dimension(30, 20));
|
|
|
+ ranks.setPreferredSize(new Dimension(30, 20));
|
|
|
+ GridBagConstraints gbc_ranks = new GridBagConstraints();
|
|
|
+ gbc_ranks.insets = new Insets(1, 0, 0, 0);
|
|
|
+ gbc_ranks.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_ranks.gridx = 7;
|
|
|
+ gbc_ranks.gridy = 0;
|
|
|
+ add(ranks, gbc_ranks);
|
|
|
+ ranks.setColumns(10);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Optional<Ability.Scores> getAbility(final DDCharacter chara, final DDSkill skill) {
|
|
|
+ if (skill.getAbility() == null || skill.getAbility().isEmpty()) { return Optional.empty(); }
|
|
|
+ else { return Optional.of(AbilityHelper.get(chara, skill)); }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void applyChange() { }
|
|
|
+}
|