Refactoring.

This commit is contained in:
Josh Ashton
2022-11-17 19:12:49 -07:00
parent dd6a0c4ce4
commit b951b04e66
40 changed files with 1529 additions and 1550 deletions
@@ -46,12 +46,10 @@ public class CharacterStats {
} }
/** /**
*
* Allows for access to a particular stat. * Allows for access to a particular stat.
* *
* @param index * @param index
* @return a specific stat * @return a specific stat
*
*/ */
public Stats getStats(int index) { public Stats getStats(int index) {
+3 -4
View File
@@ -1,15 +1,13 @@
package Character; package Character;
import java.util.Arrays;
public class Background { public class Background {
int backgroundIndex;
private String name; private String name;
private boolean[] proficientStatus; private boolean[] proficientStatus;
private String[] skills; private String[] skills;
private String feature; private String feature;
private String skillProficiencies; private String skillProficiencies;
int backgroundIndex;
/** /**
* @param name * @param name
@@ -124,12 +122,14 @@ public class Background {
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* @return the skillProficiencies * @return the skillProficiencies
*/ */
public String getskillProficiences() { public String getskillProficiences() {
return skillProficiencies; return skillProficiencies;
} }
/** /**
* @return the feature * @return the feature
*/ */
@@ -151,5 +151,4 @@ public class Background {
} }
} }
+9 -2
View File
@@ -1,8 +1,7 @@
package Character; package Character;
import Character.AbilityScores.CharacterStats; import Character.AbilityScores.CharacterStats;
import Character.Classes.ClassTemplate; import Character.Races.Race;
import Character.Races.*;
import java.io.Serializable; import java.io.Serializable;
@@ -41,6 +40,7 @@ public class CharacterSheet implements Serializable {
this.race = race; this.race = race;
this.stats = stats; this.stats = stats;
} }
/** /**
* Default constructor * Default constructor
*/ */
@@ -54,42 +54,49 @@ public class CharacterSheet implements Serializable {
this.hair = "null"; this.hair = "null";
} }
/** /**
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* @return the age * @return the age
*/ */
public int getAge() { public int getAge() {
return age; return age;
} }
/** /**
* @return the heightFeet * @return the heightFeet
*/ */
public int getHeightFeet() { public int getHeightFeet() {
return heightFeet; return heightFeet;
} }
/** /**
* @return the heightInch * @return the heightInch
*/ */
public int getHeightInch() { public int getHeightInch() {
return heightInch; return heightInch;
} }
/** /**
* @return the weigth * @return the weigth
*/ */
public int getWeight() { public int getWeight() {
return weight; return weight;
} }
/** /**
* @return the eye * @return the eye
*/ */
public String getEye() { public String getEye() {
return eye; return eye;
} }
/** /**
* @return the hair * @return the hair
*/ */
@@ -1,6 +1,6 @@
package Character.Classes; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public interface ClassTemplate { public interface ClassTemplate {
+1 -2
View File
@@ -1,6 +1,6 @@
package Character.Classes; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public class Cleric implements ClassTemplate { public class Cleric implements ClassTemplate {
@@ -14,7 +14,6 @@ public class Cleric implements ClassTemplate {
public Cleric(Stats[] stats, int level) { public Cleric(Stats[] stats, int level) {
} }
// TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc? // TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc?
@@ -1,6 +1,6 @@
package Character.Classes; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public class Fighter implements ClassTemplate { public class Fighter implements ClassTemplate {
@@ -14,7 +14,6 @@ public class Fighter implements ClassTemplate {
public Fighter(Stats[] stats, int level) { public Fighter(Stats[] stats, int level) {
} }
// TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc? // TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc?
+2 -2
View File
@@ -1,6 +1,7 @@
package Character.Classes; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public class Wizard implements ClassTemplate { public class Wizard implements ClassTemplate {
private int HP; private int HP;
@@ -13,7 +14,6 @@ public class Wizard implements ClassTemplate {
public Wizard(Stats[] stats, int level) { public Wizard(Stats[] stats, int level) {
} }
// TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc? // TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc?
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class Dragonborn implements Race { public class Dragonborn implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 80; private final int maxAge = 80;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+1 -1
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class Dwarf implements Race { public class Dwarf implements Race {
private String[] traits;
private final int speed = 25; private final int speed = 25;
private final int maxAge = 350; private final int maxAge = 350;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+1 -1
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class Elf implements Race { public class Elf implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 750; private final int maxAge = 750;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+1 -1
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class Gnome implements Race { public class Gnome implements Race {
private String[] traits;
private final int speed = 25; private final int speed = 25;
private final int maxAge = 500; private final int maxAge = 500;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+1 -1
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class HalfElf implements Race { public class HalfElf implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 180; private final int maxAge = 180;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+1 -1
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class HalfOrc implements Race { public class HalfOrc implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 75; private final int maxAge = 75;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+1 -1
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class Halfling implements Race { public class Halfling implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 750; private final int maxAge = 750;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+1 -1
View File
@@ -2,9 +2,9 @@ package Character.Races;
public class Human implements Race { public class Human implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 80; private final int maxAge = 80;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
-1
View File
@@ -44,5 +44,4 @@ public interface Race {
// } // }
} }
+1 -1
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class Tiefling implements Race { public class Tiefling implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 85; private final int maxAge = 85;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
+3 -13
View File
@@ -1,33 +1,27 @@
package Character; package Character;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
/** /**
*
* Object stores information about a character's skills arrays. Firstly, the name of each skill, and secondly the value of each skill. When constructed, a private method is called * Object stores information about a character's skills arrays. Firstly, the name of each skill, and secondly the value of each skill. When constructed, a private method is called
* which adds any proficiency bonus to each skill and then adds the ability score modifier to each skill. * which adds any proficiency bonus to each skill and then adds the ability score modifier to each skill.
*
*/ */
public class Skills { public class Skills {
// TODO: Need to verify skills are in correct order.
private String[] allSkillsText = {"Acrobatics", "Animal Handling", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"};
// TODO: Prof bonus comes from the class, changes upon certain level thresholds. // TODO: Prof bonus comes from the class, changes upon certain level thresholds.
private final int profBonus = 5; private final int profBonus = 5;
// TODO: Need to verify skills are in correct order.
private String[] allSkillsText = {"Acrobatics", "Animal Handling", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"};
private Stats[] stats; private Stats[] stats;
private int[] skills; private int[] skills;
/** /**
*
* Default constructor for the Skills class. Should be constructed AFTER the user has generated their stats and chosen the skills they are proficient in. * Default constructor for the Skills class. Should be constructed AFTER the user has generated their stats and chosen the skills they are proficient in.
* *
* @param skills * @param skills
* @param stats * @param stats
*
*/ */
public Skills(int[] skills, Stats[] stats) { public Skills(int[] skills, Stats[] stats) {
@@ -40,9 +34,7 @@ public class Skills {
} }
/** /**
*
* Adds proficiency bonus to each element of the skills array, and then adds the corresponding AS modifier to each skill. * Adds proficiency bonus to each element of the skills array, and then adds the corresponding AS modifier to each skill.
*
*/ */
private void setSkills() { private void setSkills() {
@@ -64,11 +56,9 @@ public class Skills {
} }
/** /**
*
* Returns the value of each skill's score. * Returns the value of each skill's score.
* *
* @return int[] skills * @return int[] skills
*
*/ */
public int[] getSkills() { public int[] getSkills() {
+8 -17
View File
@@ -4,16 +4,12 @@
*/ */
package DieRoller; package DieRoller;
import javax.swing.*;
import java.util.Arrays; import java.util.Arrays;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class DiceRoller public class DiceRoller {
{
public static void main(String[] args) public static void main(String[] args) {
{
JTextField diceNum = new JTextField(); JTextField diceNum = new JTextField();
JTextField diceMod = new JTextField(); JTextField diceMod = new JTextField();
@@ -39,29 +35,24 @@ public class DiceRoller
JOptionPane.showMessageDialog(null, rollString, "Dice Rolls", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, rollString, "Dice Rolls", JOptionPane.INFORMATION_MESSAGE);
} }
public static int[] rollDice(int numberOfDice, int sizeOfDice) public static int[] rollDice(int numberOfDice, int sizeOfDice) {
{
int[] diceRolls = new int[numberOfDice]; int[] diceRolls = new int[numberOfDice];
for (int rolledDice = 0; rolledDice < diceRolls.length; rolledDice++) for (int rolledDice = 0; rolledDice < diceRolls.length; rolledDice++) {
{
diceRolls[rolledDice] = (int) (Math.random() * sizeOfDice) + 1; diceRolls[rolledDice] = (int) (Math.random() * sizeOfDice) + 1;
} }
return diceRolls; return diceRolls;
} }
public static int rollTotal(int[] diceRolls, int modifier) public static int rollTotal(int[] diceRolls, int modifier) {
{
int rollTotal = 0; int rollTotal = 0;
for (int index = 0; index < diceRolls.length; index++) for (int index = 0; index < diceRolls.length; index++) {
{
rollTotal += diceRolls[index]; rollTotal += diceRolls[index];
} }
rollTotal += modifier; rollTotal += modifier;
return rollTotal; return rollTotal;
} }
public static String modifierString(int modifier) public static String modifierString(int modifier) {
{
String modifierString = ""; String modifierString = "";
if (modifier < 0) if (modifier < 0)
modifierString += modifier; modifierString += modifier;
+2 -2
View File
@@ -1,5 +1,5 @@
import GUI.*; import FileManagement.FileManager;
import FileManagement.*; import GUI.GUImanager;
public class DndCharacterBuilder { public class DndCharacterBuilder {
@@ -5,7 +5,6 @@ public class ExportPDF {
public ExportPDF() { public ExportPDF() {
} }
} }
@@ -1,10 +1,9 @@
package FileManagement; package FileManagement;
import Character.CharacterSheet;
import java.awt.*; import java.awt.*;
import java.io.*; import java.io.*;
import java.util.Arrays;
import Character.*;
public class FileManager { public class FileManager {
+43 -17
View File
@@ -1,6 +1,9 @@
package GUI; package GUI;
import GUI.Panels.*; import GUI.Panels.BasicPanel;
import GUI.Panels.ChooseAbilityScoresPanel;
import GUI.Panels.DescriptionPanel;
import GUI.Panels.MainMenuPanel;
import Resources.CustomAssets.BasicNavPanel; import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton; import Resources.CustomAssets.DefaultButton;
@@ -32,28 +35,23 @@ public class GUImanager extends JFrame {
private int[] selectedStats; private int[] selectedStats;
public GUImanager(boolean returningUser) { public GUImanager(boolean returningUser) {
super("D&D Character Builder"); super("D&D Character Builder");
frameSetup(); frameSetup();
setupPanelInfo(); setupPanelInfo();
this.panels = new JPanel[]{ this.panels = new JPanel[]{
new MainMenuPanel(), new MainMenuPanel(createNewCharacterButton(), createRandomCharacterButton(), createLoadButton()),
new BasicPanel(createNavPanel(), raceOptions, raceDescriptions, "Step 1: Choose Your Race"), // To choose Race. new BasicPanel(createNavPanel(), raceOptions, raceDescriptions, "Step 1: Choose Your Race"), // To choose Race.
new BasicPanel(createNavPanel(), classOptions, classDescriptions, "Step 2: Choose Your Class"), // To choose Class. new BasicPanel(createNavPanel(), classOptions, classDescriptions, "Step 2: Choose Your Class"), // To choose Class.
new ChooseAbilityScoresPanel(createNavPanel(27), statOptions, statDescriptions, selectedStats, "Step 3: Choose Your Ability Scores"), new ChooseAbilityScoresPanel(createNavPanel(1), statOptions, statDescriptions, selectedStats, "Step 3: Choose Your Ability Scores"),
new DescriptionPanel(createNavPanel(), characteristics, alignmentOptions, alignmentDescriptions, backgroundOptions, backgroundDescriptions, "Step 4: Describe your character") new DescriptionPanel(createNavPanel(), characteristics, alignmentOptions, alignmentDescriptions, backgroundOptions, backgroundDescriptions, "Step 4: Describe your character")
}; };
/*
this.currentPanel = 4; this.currentPanel = 0;
this.lastPanel = currentPanel - 1; this.lastPanel = currentPanel - 1;
this.nextPanel = currentPanel + 1; this.nextPanel = currentPanel + 1;*/
/* this.lastPanel = 0; if (returningUser) {
this.currentPanel = 1;
this.nextPanel = 2;*/
/* if (returningUser) {
this.currentPanel = 0; this.currentPanel = 0;
@@ -62,7 +60,6 @@ public class GUImanager extends JFrame {
this.currentPanel = 1; this.currentPanel = 1;
} }
*/
add(panels[currentPanel]); add(panels[currentPanel]);
@@ -312,6 +309,15 @@ public class GUImanager extends JFrame {
} }
private DefaultButton createNewCharacterButton() {
DefaultButton button = createContinueButton();
button.setText("Create New Character");
return button;
}
// TODO: Need to implement. // TODO: Need to implement.
private DefaultButton createRandomCharacterButton() { private DefaultButton createRandomCharacterButton() {
@@ -323,7 +329,7 @@ public class GUImanager extends JFrame {
createRandomCharacter(); createRandomCharacter();
lastPanel = currentPanel; lastPanel = currentPanel;
currentPanel = 6; currentPanel = 3;
nextPanel = currentPanel + 1; nextPanel = currentPanel + 1;
clearAndReset(); clearAndReset();
@@ -335,7 +341,7 @@ public class GUImanager extends JFrame {
} }
// TODO: Need to implement. // TODO: Need to implement with exact indices and file manager logic.
private DefaultButton createSaveButton() { private DefaultButton createSaveButton() {
DefaultButton button = new DefaultButton("Save"); DefaultButton button = new DefaultButton("Save");
@@ -356,10 +362,30 @@ public class GUImanager extends JFrame {
} }
// TODO: Need to implement. private DefaultButton createLoadButton() {
DefaultButton button = new DefaultButton("Load");
button.addActionListener(
e -> {
lastPanel = currentPanel;
currentPanel = 3;
nextPanel = currentPanel + 1;
clearAndReset();
}
);
return button;
}
// TODO: Need to implement random character creation.
private void createRandomCharacter() { private void createRandomCharacter() {
System.out.println("Request to create random character. Need to implement.");
} }
+3 -3
View File
@@ -1,11 +1,11 @@
package GUI.Panels; package GUI.Panels;
import GUI.AppTheme; import GUI.AppTheme;
import Resources.CustomAssets.*; import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.ImageInfoPanel;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
public class BasicPanel extends JPanel implements AppTheme { public class BasicPanel extends JPanel implements AppTheme {
@@ -1,9 +1,9 @@
package GUI.Panels; package GUI.Panels;
import GUI.AppTheme; import GUI.AppTheme;
import Resources.CustomAssets.InfoPanel;
import Resources.CustomAssets.BasicNavPanel; import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton; import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.InfoPanel;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
@@ -116,17 +116,14 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]); JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]);
scoreLabel.setFont(paragraphFont); scoreLabel.setFont(paragraphFont);
scoreLabel.setHorizontalAlignment(SwingConstants.CENTER); scoreLabel.setHorizontalAlignment(SwingConstants.CENTER);
scoreLabel.setBounds(56, 50, 30, 30);
statLabels[statIndex] = scoreLabel; statLabels[statIndex] = scoreLabel;
DefaultButton increaseButton = new DefaultButton("+"); DefaultButton increaseButton = new DefaultButton("+");
increaseButton.setBounds(90, 50, 50, 50);
increaseButton.addActionListener(e -> increase(statIndex)); increaseButton.addActionListener(e -> increase(statIndex));
DefaultButton decreaseButton = new DefaultButton("-"); DefaultButton decreaseButton = new DefaultButton("-");
decreaseButton.setBounds(21, 50, 50, 50);
decreaseButton.addActionListener(e -> decrease(statIndex)); decreaseButton.addActionListener(e -> decrease(statIndex));
subPanel.add(decreaseButton); subPanel.add(decreaseButton);
+44 -49
View File
@@ -3,7 +3,6 @@ package GUI.Panels;
import GUI.AppTheme; import GUI.AppTheme;
import Resources.CustomAssets.BasicNavPanel; import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton; import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.InfoPanel;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@@ -87,7 +86,6 @@ public class DescriptionPanel extends JPanel implements AppTheme {
} }
private void createPanel(String panelTitle, BasicNavPanel nav) { private void createPanel(String panelTitle, BasicNavPanel nav) {
add(createPanelTitle(panelTitle), BorderLayout.NORTH); add(createPanelTitle(panelTitle), BorderLayout.NORTH);
@@ -165,80 +163,59 @@ public class DescriptionPanel extends JPanel implements AppTheme {
JPanel panel = new JPanel(new GridLayout(1, 3)); JPanel panel = new JPanel(new GridLayout(1, 3));
panel.setOpaque(false); panel.setOpaque(false);
panel.add(createAlignmentPanel()); panel.add(createSubPanel("Alignment"));
panel.add(createBackgroundPanel()); panel.add(createSubPanel("Background"));
panel.add(createTextBoxPanel()); panel.add(createTextBoxPanel());
return panel; return panel;
} }
private JPanel createAlignmentPanel() { private JPanel createSubPanel(String labelName) {
JPanel alignmentPanel = new JPanel(new BorderLayout(0, 0)); JPanel panel = new JPanel(new BorderLayout(0, 0));
alignmentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); panel.setBorder(new EmptyBorder(5, 5, 5, 5));
alignmentPanel.setOpaque(false); panel.setOpaque(false);
JLabel backgroundLabel = new JLabel("Alignment"); JLabel label = new JLabel(labelName);
backgroundLabel.setForeground(darkestBrown); label.setForeground(darkestBrown);
backgroundLabel.setFont(subHeaderFont); label.setFont(subHeaderFont);
backgroundLabel.setHorizontalAlignment(SwingConstants.CENTER); label.setHorizontalAlignment(SwingConstants.CENTER);
JPanel innerPanel = new JPanel(new GridLayout(9, 1)); JPanel innerPanel;
if(labelName.equals("Alignment")) {
innerPanel = new JPanel(new GridLayout(9, 1));
innerPanel.setOpaque(false); innerPanel.setOpaque(false);
for (int i = 0; i < alignmentOptions.length; i++) { createButtons(alignmentOptions, alignmentButtons, labelName);
for (int i = 0; i < alignmentButtons.length; i++) {
alignmentButtons[i] = createButton(alignmentOptions[i], false, i);
innerPanel.add(alignmentButtons[i]); innerPanel.add(alignmentButtons[i]);
if(i == 0) {
alignmentButtons[i].select();
} }
} } else {
alignmentPanel.add(backgroundLabel, BorderLayout.NORTH); innerPanel = new JPanel(new GridLayout(9, 2));
alignmentPanel.add(innerPanel);
return alignmentPanel;
}
private JPanel createBackgroundPanel() {
JPanel backgroundPanel = new JPanel(new BorderLayout(0, 0));
backgroundPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
backgroundPanel.setOpaque(false);
JLabel backgroundLabel = new JLabel("Background");
backgroundLabel.setForeground(darkestBrown);
backgroundLabel.setFont(subHeaderFont);
backgroundLabel.setHorizontalAlignment(SwingConstants.CENTER);
backgroundPanel.add(backgroundLabel, BorderLayout.NORTH);
JPanel innerPanel = new JPanel(new GridLayout(9, 2));
innerPanel.setOpaque(false); innerPanel.setOpaque(false);
for (int i = 0; i < backgroundOptions.length; i++) { createButtons(backgroundOptions, backgroundButtons, labelName);
for (int i = 0; i < backgroundButtons.length; i++) {
backgroundButtons[i] = createButton(backgroundOptions[i], false, i);
innerPanel.add(backgroundButtons[i]); innerPanel.add(backgroundButtons[i]);
if(i == 0) {
backgroundButtons[i].select();
} }
} }
backgroundPanel.add(innerPanel); panel.add(label);
panel.add(innerPanel);
return backgroundPanel; return panel;
} }
@@ -288,6 +265,24 @@ public class DescriptionPanel extends JPanel implements AppTheme {
} }
private void createButtons(String[] options, DefaultButton[] buttons, String type) {
boolean tmp = type.equals("Alignment");
for (int i = 0; i < options.length; i++) {
buttons[i] = createButton(options[i], tmp, i);
if(i == 0) {
buttons[i].select();
}
}
}
private DefaultButton createButton(String name, boolean isAlignmentElseBackground, int index) { private DefaultButton createButton(String name, boolean isAlignmentElseBackground, int index) {
DefaultButton button = new DefaultButton(name); DefaultButton button = new DefaultButton(name);
+52 -66
View File
@@ -1,83 +1,69 @@
package GUI.Panels; package GUI.Panels;
import javax.swing.JPanel; import GUI.AppTheme;
import java.awt.BorderLayout; import Resources.CustomAssets.DefaultButton;
import javax.swing.JLabel;
import javax.swing.SwingConstants; import javax.swing.*;
import java.awt.Font;
import java.awt.Color;
import javax.swing.border.BevelBorder; import javax.swing.border.BevelBorder;
import javax.swing.JButton; import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainMenuPanel extends JPanel { public class MainMenuPanel extends JPanel implements AppTheme {
/** private DefaultButton newCharacter;
* Create the panel. private DefaultButton randomCharacter;
*/ private DefaultButton loadCharacter;
public MainMenuPanel() {
setBackground(new Color(222, 184, 135)); public MainMenuPanel(DefaultButton newCharacter, DefaultButton randomCharacter, DefaultButton loadCharacter) {
setBorder(new BevelBorder(BevelBorder.RAISED, new Color(160, 82, 45), new Color(165, 42, 42), new Color(0, 0, 0), null));
super();
panelSetup();
this.newCharacter = newCharacter;
this.randomCharacter = randomCharacter;
this.loadCharacter = loadCharacter;
add(createLabel(), BorderLayout.NORTH);
add(createControlPanel(), BorderLayout.CENTER);
}
private void panelSetup() {
setBackground(lightBrown);
setLayout(new BorderLayout(0, 0)); setLayout(new BorderLayout(0, 0));
JLabel mainMenuLbl = mainMenuLbl();
add(mainMenuLbl, BorderLayout.NORTH);
JPanel controlPanel = createControlPanel();
add(controlPanel, BorderLayout.CENTER);
} }
/** private JLabel createLabel() {
* @return
*/ JLabel label = new JLabel("D&D Character Builder");
label.setFont(headerFont);
label.setForeground(darkestBrown);
label.setOpaque(false);
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBorder(new EmptyBorder(5, 5, 5, 5));
return label;
}
private JPanel createControlPanel() { private JPanel createControlPanel() {
JPanel controlPanel = new JPanel(); JPanel panel = new JPanel(new GridLayout(1, 2, 50, 0));
controlPanel.setOpaque(false); panel.setOpaque(false);
controlPanel.setLayout(null); panel.setBorder(new EmptyBorder(25, 25, 25, 25));
JButton newCharBtn = new JButton("New \nCharacter"); JPanel subPanel = new JPanel(new GridLayout(2, 1, 0, 50));
newCharBtn.addActionListener(new ActionListener() { subPanel.setOpaque(false);
public void actionPerformed(ActionEvent e) {
}
});
newCharBtn.setOpaque(true);
newCharBtn.setBackground(new Color(160, 82, 45));
newCharBtn.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 23));
newCharBtn.setBounds(118, 90, 200, 50);
controlPanel.add(newCharBtn);
JButton randCharacterBtn = new JButton("Random Character"); subPanel.add(newCharacter);
randCharacterBtn.addActionListener(new ActionListener() { subPanel.add(randomCharacter);
public void actionPerformed(ActionEvent e) {
}
});
randCharacterBtn.setOpaque(true);
randCharacterBtn.setBackground(new Color(160, 82, 45));
randCharacterBtn.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 23));
randCharacterBtn.setBounds(118, 156, 200, 50);
controlPanel.add(randCharacterBtn);
JButton loadCharacter = new JButton("Load Character"); panel.add(subPanel);
loadCharacter.addActionListener(new ActionListener() { panel.add(loadCharacter);
public void actionPerformed(ActionEvent e) {
} return panel;
});
loadCharacter.setOpaque(true);
loadCharacter.setBackground(new Color(160, 82, 45));
loadCharacter.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 23));
loadCharacter.setBounds(376, 98, 233, 97);
controlPanel.add(loadCharacter);
return controlPanel;
} }
/**
* @return
*/
private JLabel mainMenuLbl() {
JLabel mainMenuLbl = new JLabel("Main Menu");
mainMenuLbl.setFont(new Font("Bodoni 72 Smallcaps", Font.PLAIN, 33));
mainMenuLbl.setHorizontalAlignment(SwingConstants.CENTER);
return mainMenuLbl;
}
} }
+4 -12
View File
@@ -2,21 +2,12 @@ package GUI.Panels;
import GUI.AppTheme; import GUI.AppTheme;
import java.awt.BorderLayout; import javax.swing.*;
import java.awt.Color; import javax.swing.border.BevelBorder;
import java.awt.Font; import java.awt.*;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.JTextField;
import javax.swing.JTextArea;
public class step4 extends JPanel implements AppTheme { public class step4 extends JPanel implements AppTheme {
private JTextField nameTxtField; private JTextField nameTxtField;
private JTextField ageTextField; private JTextField ageTextField;
@@ -34,6 +25,7 @@ public class step4 extends JPanel implements AppTheme {
} }
private void createEntirePanel() { private void createEntirePanel() {
setBackground(new Color(222, 184, 135)); setBackground(new Color(222, 184, 135));
setBorder(new BevelBorder(BevelBorder.RAISED, new Color(160, 82, 45), new Color(165, 42, 42), new Color(0, 0, 0), null)); setBorder(new BevelBorder(BevelBorder.RAISED, new Color(160, 82, 45), new Color(165, 42, 42), new Color(0, 0, 0), null));
@@ -52,13 +52,22 @@ public class DefaultButton extends JButton implements AppTheme {
addMouseListener( addMouseListener(
new MouseListener() { new MouseListener() {
@Override @Override
public void mouseClicked(MouseEvent e) {} public void mouseClicked(MouseEvent e) {
}
@Override @Override
public void mousePressed(MouseEvent e) {} public void mousePressed(MouseEvent e) {
}
@Override @Override
public void mouseReleased(MouseEvent e) {} public void mouseReleased(MouseEvent e) {
}
@Override @Override
public void mouseEntered(MouseEvent e) { applyFocusedButtonStyle(); } public void mouseEntered(MouseEvent e) {
applyFocusedButtonStyle();
}
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
@@ -83,5 +92,4 @@ public class DefaultButton extends JButton implements AppTheme {
} }
} }
@@ -2,14 +2,9 @@ package Resources.CustomAssets;
import GUI.AppTheme; import GUI.AppTheme;
import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Objects;
import java.util.Random;
public class InfoPanel extends JPanel implements AppTheme { public class InfoPanel extends JPanel implements AppTheme {
@@ -1,6 +1,6 @@
package Resources.CustomAssets; package Resources.CustomAssets;
import javax.swing.border.*; import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
public class RoundedBorder implements Border { public class RoundedBorder implements Border {