|
@@ -6,9 +6,20 @@ import javax.swing.JPanel;
|
|
|
|
|
|
|
|
import org.leumasjaffe.charsheet.model.DDCharacter;
|
|
import org.leumasjaffe.charsheet.model.DDCharacter;
|
|
|
|
|
|
|
|
|
|
+import lombok.AccessLevel;
|
|
|
|
|
+import lombok.experimental.FieldDefaults;
|
|
|
|
|
+import lombok.experimental.NonFinal;
|
|
|
|
|
+
|
|
|
|
|
+import java.awt.GridBagLayout;
|
|
|
|
|
+import java.awt.GridBagConstraints;
|
|
|
|
|
+import java.awt.Insets;
|
|
|
|
|
+import javax.swing.JButton;
|
|
|
|
|
+import javax.swing.JDialog;
|
|
|
|
|
+
|
|
|
@SuppressWarnings("serial")
|
|
@SuppressWarnings("serial")
|
|
|
|
|
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
public class LevelUpDialog extends JPanel {
|
|
public class LevelUpDialog extends JPanel {
|
|
|
- private static final int[] EXPERIENCE_CACHE;
|
|
|
|
|
|
|
+ static int[] EXPERIENCE_CACHE;
|
|
|
static {
|
|
static {
|
|
|
final int levelsToCalc = 20;
|
|
final int levelsToCalc = 20;
|
|
|
EXPERIENCE_CACHE = new int[levelsToCalc];
|
|
EXPERIENCE_CACHE = new int[levelsToCalc];
|
|
@@ -17,6 +28,11 @@ public class LevelUpDialog extends JPanel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ ChooseClassLevelUpDialog chooseClass;
|
|
|
|
|
+ JButton btnCommit;
|
|
|
|
|
+ @NonFinal JPanel updateClass;
|
|
|
|
|
+ private GridBagConstraints gbc_main;
|
|
|
|
|
+
|
|
|
public static int computeLevelsNeeded(DDCharacter chara, int bonusLevels) {
|
|
public static int computeLevelsNeeded(DDCharacter chara, int bonusLevels) {
|
|
|
final int exp = chara.getExperience().value();
|
|
final int exp = chara.getExperience().value();
|
|
|
final int currentLevel = chara.getLevel();
|
|
final int currentLevel = chara.getLevel();
|
|
@@ -25,6 +41,69 @@ public class LevelUpDialog extends JPanel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public LevelUpDialog(DDCharacter chara) {
|
|
public LevelUpDialog(DDCharacter chara) {
|
|
|
|
|
+ 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, 0.0, Double.MIN_VALUE};
|
|
|
|
|
+ setLayout(gridBagLayout);
|
|
|
|
|
+
|
|
|
|
|
+ chooseClass = new ChooseClassLevelUpDialog(chara, this::createLayer2);
|
|
|
|
|
+ gbc_main = new GridBagConstraints();
|
|
|
|
|
+ gbc_main.insets = new Insets(0, 0, 5, 0);
|
|
|
|
|
+ gbc_main.fill = GridBagConstraints.BOTH;
|
|
|
|
|
+ gbc_main.gridx = 0;
|
|
|
|
|
+ gbc_main.gridy = 0;
|
|
|
|
|
+ add(chooseClass, gbc_main);
|
|
|
|
|
+
|
|
|
|
|
+ JPanel panel_1 = new JPanel();
|
|
|
|
|
+ GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
|
|
|
|
+ gbc_panel_1.fill = GridBagConstraints.BOTH;
|
|
|
|
|
+ gbc_panel_1.gridx = 0;
|
|
|
|
|
+ gbc_panel_1.gridy = 1;
|
|
|
|
|
+ add(panel_1, gbc_panel_1);
|
|
|
|
|
+ GridBagLayout gbl_panel_1 = new GridBagLayout();
|
|
|
|
|
+ gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0, 0};
|
|
|
|
|
+ gbl_panel_1.rowHeights = new int[]{0, 0};
|
|
|
|
|
+ gbl_panel_1.columnWeights = new double[]{1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
+ gbl_panel_1.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
|
|
+ panel_1.setLayout(gbl_panel_1);
|
|
|
|
|
+
|
|
|
|
|
+ JButton btnCancel = new JButton("Cancel");
|
|
|
|
|
+ GridBagConstraints gbc_btnCancel = new GridBagConstraints();
|
|
|
|
|
+ gbc_btnCancel.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
+ gbc_btnCancel.gridx = 1;
|
|
|
|
|
+ gbc_btnCancel.gridy = 0;
|
|
|
|
|
+ panel_1.add(btnCancel, gbc_btnCancel);
|
|
|
|
|
+ btnCancel.addActionListener(e -> ((JDialog) this.getParent().getParent().getParent()).dispose());
|
|
|
|
|
+
|
|
|
|
|
+ btnCommit = new JButton("Commit");
|
|
|
|
|
+ GridBagConstraints gbc_btnCommit = new GridBagConstraints();
|
|
|
|
|
+ gbc_btnCommit.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
+ gbc_btnCommit.gridx = 2;
|
|
|
|
|
+ gbc_btnCommit.gridy = 0;
|
|
|
|
|
+ panel_1.add(btnCommit, gbc_btnCommit);
|
|
|
|
|
+ btnCommit.setEnabled(false);
|
|
|
|
|
+ btnCommit.addActionListener(e -> {
|
|
|
|
|
+ // TODO
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void dropLayer2() {
|
|
|
|
|
+ remove(updateClass);
|
|
|
|
|
+ add(chooseClass, gbc_main);
|
|
|
|
|
+ repaint();
|
|
|
|
|
+ revalidate();
|
|
|
|
|
+ ((JDialog) this.getParent().getParent().getParent()).pack();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void createLayer2(LevelUpClassInfo info) {
|
|
|
|
|
+ remove(chooseClass);
|
|
|
|
|
+ updateClass = new UpdateClassWithLevelPanel(info, this::dropLayer2, b -> btnCommit.setEnabled(b));
|
|
|
|
|
+ add(updateClass, gbc_main);
|
|
|
|
|
+ revalidate();
|
|
|
|
|
+ repaint();
|
|
|
|
|
+ ((JDialog) this.getParent().getParent().getParent()).pack();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private static int experienceForLevel(int level) {
|
|
private static int experienceForLevel(int level) {
|