Refactored choosing race and class into a single class. discovered issue when only one image exists for a race or class, the last index for the randomly chosen snapshot image is set to 0 and will forever be stuck in a while loop. Need to implement some kind of safeguards.
@@ -12,8 +12,6 @@ public class FileManager {
|
||||
|
||||
public FileManager() {
|
||||
|
||||
System.out.println("FileManager object created.\n");
|
||||
|
||||
findSavedCharacters();
|
||||
|
||||
loadFonts();
|
||||
@@ -63,7 +61,7 @@ public class FileManager {
|
||||
|
||||
} catch (ClassNotFoundException c) {
|
||||
|
||||
System.out.println("Employee class not found");
|
||||
System.out.println("Saved characters not found");
|
||||
c.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,6 @@ public interface AppTheme {
|
||||
public Font paragraphFont = new Font("SanSalvi", Font.PLAIN, 20);
|
||||
public Font buttonFont = new Font("SanSalvi", Font.PLAIN, 15);
|
||||
|
||||
public String OS = System.getProperty("os.name");
|
||||
|
||||
}
|
||||
|
||||
@@ -10,24 +10,36 @@ import java.awt.event.*;
|
||||
public class GUImanager extends JFrame {
|
||||
|
||||
private static JPanel[] panels;
|
||||
private int lastPanel;
|
||||
private int currentPanel;
|
||||
private int nextPanel;
|
||||
|
||||
|
||||
private String[] raceOptions;
|
||||
private String[] raceDescriptions;
|
||||
private String[] classOptions;
|
||||
private String[] classDescriptions;
|
||||
private int raceChoice;
|
||||
private int classChoice;
|
||||
|
||||
|
||||
private int lastPanel;
|
||||
private int currentPanel;
|
||||
private int nextPanel;
|
||||
|
||||
public GUImanager (boolean returningUser) {
|
||||
super("D&D Character Builder");
|
||||
frameSetup();
|
||||
frameSetup();
|
||||
setupRaceAndClass();
|
||||
this.panels = new JPanel[]{
|
||||
new MainMenuPanel(),
|
||||
new ChooseRacePanel(createBackButton(), createContinueButton()),
|
||||
new ChooseClassPanel(createBackButton(),createContinueButton()),
|
||||
new BasicPanel(createBackButton(), createContinueButton(), raceOptions, raceDescriptions, "Step 1: Choose Your Race"), // To choose Race.
|
||||
new BasicPanel(createBackButton(), createContinueButton(), classOptions, classDescriptions, "Step 2: Choose Your Class"), // To choose Class.
|
||||
new ChooseAbilityScoresPanel(createBackButton(), createContinueButton())
|
||||
};
|
||||
|
||||
|
||||
this.lastPanel = 0;
|
||||
this.currentPanel = 1;
|
||||
this.nextPanel = 2;
|
||||
|
||||
/* if (returningUser) {
|
||||
|
||||
this.currentPanel = 0;
|
||||
@@ -36,7 +48,8 @@ public class GUImanager extends JFrame {
|
||||
|
||||
this.currentPanel = 1;
|
||||
|
||||
}*/
|
||||
}
|
||||
*/
|
||||
|
||||
add(panels[currentPanel]);
|
||||
|
||||
@@ -59,6 +72,72 @@ public class GUImanager extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
private void setupRaceAndClass() {
|
||||
|
||||
raceOptions = new String[]{
|
||||
"Dragonborn",
|
||||
"Dwarf",
|
||||
"Elf",
|
||||
"Gnome",
|
||||
"HalfElf",
|
||||
"Halfling",
|
||||
"Halforc",
|
||||
"Human",
|
||||
"Tiefling"
|
||||
};
|
||||
|
||||
raceDescriptions = new String[]{
|
||||
|
||||
"Born of dragons, as their name proclaims, the dragonborn walk proudly through a world that greets them with fearful incomprehension." + "Shaped by draconic gods or the dragons themselves, dragonborn originally hatched from dragon eggs as a unique race, combining the best attributes of dragons and humanoids." + "Some dragonborn are faithful servants to true dragons, others form the ranks of soldiers in great wars, and still others find themselves adrift, with no clear calling in life.",
|
||||
"By the numbers, dwarves are one of the best races in the Player’s Handbook. " + "" + "Their ability score increases are good, and their other racial traits make them durable and flexible enough to succeed in several classes.",
|
||||
"A staple of fantasy fiction and folklore, Elves are a simple yet effective base race with subraces which are numerous and diverse enough that elves are usable in a variety of builds and character concepts. " + "Unfortunately, because the subraces differentiate the Elf’s traits so much, it’s rare for more than one subrace to be viable in the same class unless you’re using the Customizing Your Origins optional rules presented in Tasha’s Cauldron of Everything.",
|
||||
"Gnomes have changed a lot throughout the history of Dungeons and Dragons. " + "At times they’ve been monsters. " + "At times they’ve been fey. " + "In general, DnD has always had trouble pinning down gnomes thematically in a way that distinguishes them from halflings, but I think 5th edition may have done the best job of any edition to date. " + "Gnomes have subraces which are very distinct from one another, and their traits offer some unique an interesting options.",
|
||||
"The Half-Elf is among the most powerful races in the core rules. " + "It’s a top-tier race option for several classes, and even for classes where the Half-Elf isn’t a perfect fit it’s at least workable. " + "Two flexible ability increases and two free skill proficiencies are useful on essentially any character, plus you get Darkvision and a +2 Charisma increase.",
|
||||
"Half-orcs are an easily-overlooked race. " + "Their racial traits tend to pigeon-hole them into simple martial builds, and in most official settings and works of fiction outside of D&D orcs have historically been portrayed barbaric savages, so even characters’ backstories tend to be forced into an incredibly narrow set of options. " + "Half-orcs don’t get subraces, and unlike the half-elf we haven’t seen variants of any kind, so the race offers little flexibility.",
|
||||
"Halflings are perhaps the most iconic small race in Dungeons and Dragons, dating back to its earliest editions. " + "Their mechanics have changed as much as any race, but they have consistently remained a staple option for players who enjoy playing thieves, rogues, or other stealthy characters.",
|
||||
"Human come in two flavors: the standard human and the “variant” human. " + "The standard human receives +1 increases to each ability score, making it easy to fit into any build. " + "However, it lacks any other racial traits, which makes the standard human extremely bland. " + "It also lacks the numerical appeal of a +2 ability increase, so more focused races will frequently outpace the standard human in nearly every case.",
|
||||
"Thanks to the variants presented in Sword Coast Adventurer’s Guide and the subraces presented in Mordenkainen’s Tome of Foes, the Tiefling has the longest list of subrace options of any published race, totaling an impressive 14 individual subraces and variants. " + "These options make tieflings diverse, flexible, and viable in an impressively large number of builds."
|
||||
|
||||
};
|
||||
|
||||
classOptions = new String[] {
|
||||
|
||||
"Artificer",
|
||||
"Barbarian",
|
||||
"Bard",
|
||||
"Cleric",
|
||||
"Druid",
|
||||
"Fighter",
|
||||
"Monk",
|
||||
"Paladin",
|
||||
"Ranger",
|
||||
"Rogue",
|
||||
"Sorcerer",
|
||||
"Warlock",
|
||||
"Wizard"
|
||||
|
||||
};
|
||||
|
||||
classDescriptions = new String[]{
|
||||
|
||||
"The Artificer is a class with a tool for every job and a solution to every problem. " + "They excel as a Support character, but make decent Defenders, Healers, and Strikers, too. " + "With the right infusions and spells, they can fill nearly any role in the party, making the Artificer’s versatility rival that of the Bard.",
|
||||
"Barbarians are all about getting angry and dealing damage. " + "They have a ton of hit points, resistance to damage, and Rage gives a wonderful bonus to damage. " + "Barbarians don’t get much in the way of skills, so generally they’re stuck as combat monsters, but they function equally well as a Defender and a Striker, and certain character options can even expand them into a limited Support role.",
|
||||
"The Bard is fantastically versatile. " + "With access to every skill, expertise, full casting, and a decent set of proficiencies, the Bard can fill essentially every role in the party. " + "Subclasses like College of Lore are more of the classic supportive Bard, with improved magical options and support abilities, while College of Swords and College of Valor can serve as front-line melee characters who can bring their spellcasting and support capabilities into the heat of battle.",
|
||||
"Clerics are among the most diverse and interesting classes in 5e DnD. " + "Because your choice of Divine Domain so greatly affects your capabilities, Clerics can fit a variety of roles and play styles. " + "More generally, Clerics are the best healers in the game, and have among the best support, utility, and divination options in the game. " + "However, they are by no means limited to healing and support roles. " + "Clerics have abundant offensive options, and can even be effective with weapons.",
|
||||
"Druids are a very versatile class. " + "Between their available archetypes, they’re able to serve mixes roles as scouts, strikers, blaster, support casters, and controllers. " + "Their spell list has a lot of unique options. " + "There is a strong emphasis on area control spells, and most of the Druid’s best spells require Concentration.",
|
||||
"The Fighter is a fantastic addition to any party. " + "While their skill and tool proficiencies are extremely limited, Fighters excel in combat. " + "They are durable, have great armor, and provide plenty of damage output. " + "Fighters get more Ability Score Increases than any other class, allowing them to easily explore feats without sacrificing crucial ability scores. " + "They also notably get more attacks than any other class, which can be a lot of fun.",
|
||||
"The Monk is the iconic martial-artist, popular among those who prefer to punch things rather than stabbing them or setting them on fire (though stabbing things and setting them on fire is still a possibility for the Monk). " + "Monks are excellent Defenders and Strikers, and typically fill a role in party as a Fighter-equivalent or Rogue-equivalent depending on your subclass and proficiencies.",
|
||||
"Paladins are the most durable, survivable, and self-sufficient class in the game. " + "As such, they both make excellent solo characters and are excellent additions to nearly any party regardless of existing capabilities. " + "In a party, they serve as a Defender, Face, and Striker. " + "They do have some healing and utility options, but not enough to replace a full spellcaster in most parties.",
|
||||
"The Ranger is an interesting mix of Druid-style spellcasting, Fighter-style combat capabilities, and Rogue-style skills. " + "Themed around nature and exploration, the Ranger is a welcome asset in parties exploring untamed lands above or below ground. " + "The Ranger can fill the role of either a Fighter-equivalent or a Rogue-equivalent (sometimes both), and works well as a Scout and Striker, but trades the Fighter’s durability for better skills and improved damage output.",
|
||||
"Rogues are the quintessential Face, Scout and Striker. " + "Sneak Attack allows them to do a huge pile of damage in a single attack, and their pile of skills allows them to easily handle locks, traps, guards, and many other challenges. " + "While a party can function just fine without a Rogue, it’s hard to compete with the sheer number of important skill and tool proficiencies offered by the Rogue.",
|
||||
"Sorcerers are a challenge, but at the same time they can be less complex than most spellcasting classes. " + "The Sorcerer’s spell list allows them to serve as a Blaster, Controller, Striker, and Utility Caster, and sorcerers make one of the easiest Faces in the game due to their skill list and their dependence on Charisma.",
|
||||
"The Warlock is likely the easiest of any spellcaster to play. " + "You get only a handful of spell slots at a time, and never have to juggle multiple spell slot levels. " + "Warlocks learn spells permanently, so you don’t need to worry about changing your spells on a daily basis. " + "Warlocks also get the most powerful damage cantrip in the game, giving them a solid, reliable option for damage output in between your big spells.",
|
||||
"The Wizard is the iconic arcane spellcaster, capable of doing all manner of fantastic tricks, and generally limited only by their spellbook and their spell slots. " + "A Wizard with a comprehensive spellbook can do essentially anything in the game, often as well as or better than a non-magical character who is built to do that thing. " + "A Wizard with Invisibility is as stealthy as a Rogue."
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private DefaultButton createBackButton() {
|
||||
|
||||
DefaultButton button = new DefaultButton("Back");
|
||||
@@ -99,6 +178,7 @@ public class GUImanager extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private DefaultButton createRandomCharacterButton() {
|
||||
|
||||
DefaultButton button = new DefaultButton("Create Random Character");
|
||||
@@ -121,6 +201,7 @@ public class GUImanager extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private DefaultButton createSaveButton() {
|
||||
|
||||
DefaultButton button = new DefaultButton("Save");
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import GUI.AppTheme;
|
||||
import GUI.Panels.SubPanels.*;
|
||||
import Resources.CustomAssets.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
public class BasicPanel extends JPanel implements AppTheme {
|
||||
|
||||
private DefaultButton[] optionButtons;
|
||||
private String[] options;
|
||||
private String[] descriptions;
|
||||
private InfoPanel infoPanel;
|
||||
private DefaultButton backButton;
|
||||
private DefaultButton continueButton;
|
||||
private int choiceIndex;
|
||||
private String panelTitle;
|
||||
|
||||
|
||||
|
||||
public BasicPanel(DefaultButton backButton, DefaultButton continueButton, String[] options, String[] descriptions, String panelTitle) {
|
||||
|
||||
super();
|
||||
this.backButton = backButton;
|
||||
this.continueButton = continueButton;
|
||||
this.options = options;
|
||||
this.descriptions = descriptions;
|
||||
this.panelTitle = panelTitle;
|
||||
|
||||
this.infoPanel = new InfoPanel(options, descriptions);
|
||||
choiceIndex = 0;
|
||||
|
||||
panelSetup();
|
||||
createMasterPanel();
|
||||
|
||||
}
|
||||
|
||||
private void createMasterPanel() {
|
||||
|
||||
JLabel title = new JLabel(panelTitle);
|
||||
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
title.setFont(headerFont);
|
||||
title.setForeground(darkestBrown);
|
||||
add(title, BorderLayout.NORTH);
|
||||
|
||||
JPanel racePanel = new JPanel();
|
||||
racePanel.setOpaque(false);
|
||||
racePanel.setLayout(null);
|
||||
racePanel.add(infoPanel);
|
||||
racePanel.add(createButtonPanel());
|
||||
|
||||
add(racePanel);
|
||||
add(createNavPanel(), BorderLayout.SOUTH);
|
||||
|
||||
}
|
||||
|
||||
private JPanel createButtonPanel() {
|
||||
|
||||
JPanel buttonPanel = new JPanel(new GridLayout(options.length, 1, 0, 0));
|
||||
buttonPanel.setBackground(lightBrown);
|
||||
|
||||
buttonPanel.setBounds(585, 45, 135, 355);
|
||||
|
||||
optionButtons = new DefaultButton[options.length];
|
||||
|
||||
|
||||
for (int i = 0; i < optionButtons.length; i++) {
|
||||
|
||||
optionButtons[i] = createButton(options[i], i);
|
||||
|
||||
if (i == 0) {
|
||||
|
||||
optionButtons[i].select();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
|
||||
buttonPanel.add(optionButtons[i]);
|
||||
|
||||
}
|
||||
|
||||
return buttonPanel;
|
||||
|
||||
}
|
||||
|
||||
private void panelSetup() {
|
||||
|
||||
setBackground(lightBrown);
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
|
||||
}
|
||||
|
||||
private JPanel createNavPanel() {
|
||||
|
||||
JPanel panel = new JPanel(new GridLayout(1, 2, 30, 0));
|
||||
panel.setBackground(darkestBrown);
|
||||
panel.setBorder(new EmptyBorder(15, 150, 15, 150));
|
||||
panel.add(backButton);
|
||||
panel.add(continueButton);
|
||||
|
||||
return panel;
|
||||
|
||||
}
|
||||
|
||||
private DefaultButton createButton(String raceName, int index) {
|
||||
|
||||
DefaultButton button = new DefaultButton(raceName);
|
||||
button.addActionListener(e -> updateButtons(choiceIndex, index));
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
private void updateButtons(int lastIndex, int newIndex) {
|
||||
|
||||
optionButtons[lastIndex].deSelect();
|
||||
optionButtons[newIndex].select();
|
||||
|
||||
choiceIndex = newIndex;
|
||||
infoPanel.updateInfo(choiceIndex);
|
||||
|
||||
}
|
||||
|
||||
public int getChoice() {
|
||||
|
||||
return choiceIndex;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class ChooseClassPanel extends JPanel {
|
||||
|
||||
/**
|
||||
* Create the panel.
|
||||
*/
|
||||
public ChooseClassPanel(JButton backButton, JButton contButton) {
|
||||
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));
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JLabel lblNewLabel = createLbl();
|
||||
add(lblNewLabel, BorderLayout.NORTH);
|
||||
//Creates back and continue panel
|
||||
JPanel backContPanel = createBackContinuePanel(backButton, contButton);
|
||||
add(backContPanel, BorderLayout.SOUTH);
|
||||
|
||||
JPanel innerPanel = new JPanel();
|
||||
innerPanel.setOpaque(false);
|
||||
innerPanel.setLayout(null);
|
||||
|
||||
JPanel infoPanel = createInfoPanel();
|
||||
innerPanel.add(infoPanel);
|
||||
|
||||
JPanel btnPanel = createBtnPanel();
|
||||
innerPanel.add(btnPanel);
|
||||
|
||||
add(innerPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private JPanel createBtnPanel() {
|
||||
JPanel btnPanel = new JPanel();
|
||||
btnPanel.setBackground(new Color(165, 42, 42));
|
||||
btnPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||
btnPanel.setBounds(311, 6, 409, 394);
|
||||
|
||||
JButton artificerBtn = new JButton("Artificer");
|
||||
artificerBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(artificerBtn);
|
||||
|
||||
JButton barbarianBtn = new JButton("Barbarian");
|
||||
barbarianBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(barbarianBtn);
|
||||
|
||||
JButton bardBtn = new JButton("Bard");
|
||||
bardBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(bardBtn);
|
||||
|
||||
JButton clericBtn = new JButton("Cleric");
|
||||
clericBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(clericBtn);
|
||||
|
||||
JButton druidBtn = new JButton("Druid");
|
||||
druidBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(druidBtn);
|
||||
|
||||
JButton fighterBtn = new JButton("Figther");
|
||||
fighterBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(fighterBtn);
|
||||
|
||||
JButton monkBtn = new JButton("Monk");
|
||||
monkBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(monkBtn);
|
||||
|
||||
JButton paladinBtn = new JButton("Paladin");
|
||||
paladinBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(paladinBtn);
|
||||
|
||||
JButton rangerBtn = new JButton("Ranger");
|
||||
rangerBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(rangerBtn);
|
||||
|
||||
JButton rogueBtn = new JButton("Rogue");
|
||||
rogueBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(rogueBtn);
|
||||
|
||||
JButton sorcererBtn = new JButton("Sorcerer");
|
||||
sorcererBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(sorcererBtn);
|
||||
|
||||
JButton warlockBtn = new JButton("Warlock");
|
||||
warlockBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(warlockBtn);
|
||||
|
||||
JButton wizardBtn = new JButton("Wizard");
|
||||
wizardBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnPanel.add(wizardBtn);
|
||||
|
||||
|
||||
|
||||
return btnPanel;
|
||||
}
|
||||
|
||||
private JPanel createInfoPanel() {
|
||||
JPanel infoPanel = new JPanel();
|
||||
infoPanel.setOpaque(false);
|
||||
infoPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||
infoPanel.setBounds(6, 6, 293, 394);
|
||||
infoPanel.setLayout(null);
|
||||
|
||||
JLabel infoLbl = new JLabel("Information");
|
||||
infoLbl.setFont(new Font("Bodoni 72", Font.PLAIN, 20));
|
||||
infoLbl.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
infoLbl.setBounds(92, 6, 105, 16);
|
||||
infoPanel.add(infoLbl);
|
||||
|
||||
JTextPane infoTextPane = new JTextPane();
|
||||
infoTextPane.setOpaque(false);
|
||||
infoTextPane.setBounds(6, 21, 281, 367);
|
||||
infoPanel.add(infoTextPane);
|
||||
return infoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private JPanel createBackContinuePanel(JButton backButton, JButton continueButton) {
|
||||
JPanel backContPanel = new JPanel();
|
||||
backContPanel.setBackground(new Color(205, 133, 63));
|
||||
|
||||
|
||||
JButton backBtn = new JButton("<--- Back ");
|
||||
backBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
// backContPanel.add(backBtn);
|
||||
backContPanel.add(backButton);
|
||||
|
||||
JButton continueBtn = new JButton("Continue --->");
|
||||
continueBtn.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
// backContPanel.add(continueBtn);
|
||||
backContPanel.add(continueButton);
|
||||
return backContPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private JLabel createLbl() {
|
||||
JLabel lblNewLabel = new JLabel("Step 2: Choose Class");
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 33));
|
||||
return lblNewLabel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import GUI.AppTheme;
|
||||
import GUI.Panels.SubPanels.*;
|
||||
import Resources.CustomAssets.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
public class ChooseRacePanel extends JPanel implements AppTheme {
|
||||
|
||||
private String[] raceOptions;
|
||||
private String[] raceDescriptions;
|
||||
private InfoPanel infoPanel;
|
||||
private int raceIndex;
|
||||
private JButton backButton;
|
||||
private JButton continueButton;
|
||||
|
||||
private DefaultButton[] raceOptionButtons;
|
||||
|
||||
public ChooseRacePanel(JButton backButton, DefaultButton continueButton) {
|
||||
super();
|
||||
this.backButton = backButton;
|
||||
this.continueButton = continueButton;
|
||||
raceIndex = 0;
|
||||
createRaces();
|
||||
this.infoPanel = new InfoPanel(raceOptions, raceDescriptions);
|
||||
|
||||
panelSetup();
|
||||
|
||||
createMasterPanel();
|
||||
|
||||
}
|
||||
|
||||
private void createRaces() {
|
||||
|
||||
raceOptions = new String[]{"Dragonborn", "Dwarf", "Elf", "Gnome", "HalfElf", "Halfling", "Halforc", "Human", "Tiefling"};
|
||||
|
||||
raceDescriptions = new String[]{
|
||||
|
||||
"Born of dragons, as their name proclaims, the dragonborn walk proudly through a world that greets them with fearful incomprehension. Shaped by draconic gods or the dragons themselves, dragonborn originally hatched from dragon eggs as a unique race, combining the best attributes of dragons and humanoids. Some dragonborn are faithful servants to true dragons, others form the ranks of soldiers in great wars, and still others find themselves adrift, with no clear calling in life."
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private void createMasterPanel() {
|
||||
|
||||
JLabel title = new JLabel("Step 1: Choose Race");
|
||||
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
title.setFont(headerFont);
|
||||
title.setForeground(darkestBrown);
|
||||
add(title, BorderLayout.NORTH);
|
||||
|
||||
JPanel racePanel = new JPanel();
|
||||
racePanel.setOpaque(false);
|
||||
racePanel.setLayout(null);
|
||||
racePanel.add(infoPanel);
|
||||
racePanel.add(createRaceButtonPanel());
|
||||
|
||||
add(racePanel);
|
||||
add(createNavPanel(), BorderLayout.SOUTH);
|
||||
|
||||
}
|
||||
|
||||
private JPanel createRaceButtonPanel() {
|
||||
|
||||
JPanel buttonPanel = new JPanel(new GridLayout(raceOptions.length, 1, 0, 0));
|
||||
buttonPanel.setBackground(lightBrown);
|
||||
|
||||
buttonPanel.setBounds(585, 45, 135, 355);
|
||||
|
||||
raceOptionButtons = new DefaultButton[raceOptions.length];
|
||||
|
||||
|
||||
for (int i = 0; i < raceOptionButtons.length; i++) {
|
||||
|
||||
raceOptionButtons[i] = createButton(raceOptions[i], i);
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < raceOptions.length; i++) {
|
||||
|
||||
buttonPanel.add(raceOptionButtons[i]);
|
||||
|
||||
}
|
||||
|
||||
return buttonPanel;
|
||||
|
||||
}
|
||||
|
||||
private void panelSetup() {
|
||||
|
||||
setBackground(lightBrown);
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
|
||||
}
|
||||
|
||||
private JPanel createNavPanel() {
|
||||
|
||||
JPanel panel = new JPanel(new GridLayout(1, 2, 30, 0));
|
||||
panel.setBackground(darkestBrown);
|
||||
panel.setBorder(new EmptyBorder(15, 150, 15, 150));
|
||||
panel.add(backButton);
|
||||
panel.add(continueButton);
|
||||
|
||||
return panel;
|
||||
|
||||
}
|
||||
|
||||
private DefaultButton createButton(String raceName, int index) {
|
||||
|
||||
DefaultButton button = new DefaultButton(raceName);
|
||||
button.addActionListener(e -> updateButtons(raceIndex, index));
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
private void updateButtons(int lastIndex, int newIndex) {
|
||||
|
||||
raceOptionButtons[lastIndex].deSelect();
|
||||
raceOptionButtons[newIndex].select();
|
||||
|
||||
raceIndex = newIndex;
|
||||
infoPanel.updateInfo(raceIndex);
|
||||
|
||||
}
|
||||
|
||||
public int getRaceChoice() {
|
||||
|
||||
return raceIndex;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,22 +17,16 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
private String[] holderDescriptions;
|
||||
private JLabel[][] portraits;
|
||||
private String[] categoryHolder;
|
||||
|
||||
private static String OS = null;
|
||||
private static int numInfoPanelObjects = 0;
|
||||
private int lastIndex;
|
||||
|
||||
public InfoPanel(String[] categoryHolder, String[] holderDescriptions) {
|
||||
|
||||
super();
|
||||
numInfoPanelObjects++;
|
||||
this.categoryHolder = categoryHolder;
|
||||
this.holderDescriptions = holderDescriptions;
|
||||
|
||||
if (OS == null) {
|
||||
|
||||
OS = System.getProperty("os.name");
|
||||
|
||||
}
|
||||
|
||||
panelSetup();
|
||||
|
||||
createDescriptions();
|
||||
@@ -46,9 +40,12 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
|
||||
removeAll();
|
||||
|
||||
panelSetup();
|
||||
|
||||
add(descriptions[0]);
|
||||
panelSetup();
|
||||
add(descriptions[holderIndex]);
|
||||
|
||||
System.out.println();
|
||||
|
||||
add(portraits[holderIndex][getNextPortrait(holderIndex)]);
|
||||
|
||||
repaint();
|
||||
@@ -56,17 +53,18 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private int getNextPortrait(int holderIndex) {
|
||||
|
||||
Random ran = new Random();
|
||||
int bound = portraits[holderIndex].length;
|
||||
int newIndex = ran.nextInt(bound);
|
||||
|
||||
while(newIndex == lastIndex) {
|
||||
/* while(newIndex == lastIndex) {
|
||||
|
||||
newIndex = ran.nextInt(bound);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
lastIndex = newIndex;
|
||||
|
||||
@@ -116,6 +114,18 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
|
||||
private void createPortraits() {
|
||||
|
||||
String category = "";
|
||||
|
||||
if(numInfoPanelObjects == 1) {
|
||||
|
||||
category = "Races";
|
||||
|
||||
} else if (numInfoPanelObjects == 2) {
|
||||
|
||||
category = "Classes";
|
||||
|
||||
}
|
||||
|
||||
portraits = new JLabel[categoryHolder.length][];
|
||||
|
||||
for (int i = 0; i < categoryHolder.length; i++) {
|
||||
@@ -124,15 +134,15 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
|
||||
if(OS.startsWith("Windows")) {
|
||||
|
||||
imagesDir = new File("dndBuilder\\src\\Resources\\Img\\" + categoryHolder[i] + "\\");
|
||||
imagesDir = new File("dndBuilder\\src\\Resources\\Img\\" + category + "\\" + categoryHolder[i].toLowerCase() + "\\");
|
||||
|
||||
} else if (OS.startsWith("Mac")) {
|
||||
|
||||
imagesDir = new File("dndBuilder/src/Resources/Img/" + categoryHolder[i] + "/");
|
||||
imagesDir = new File("dndBuilder/src/Resources/Img/" + category + "/" + categoryHolder[i].toLowerCase() + "/");
|
||||
|
||||
} else if (OS.startsWith("Linux")) {
|
||||
|
||||
imagesDir = new File("dndBuilder/src/Resources/Img/" + categoryHolder[i] + "/");
|
||||
imagesDir = new File("dndBuilder/src/Resources/Img/" + category + "/" + categoryHolder[i].toLowerCase() + "/");
|
||||
|
||||
} else {
|
||||
|
||||
@@ -146,7 +156,6 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
int index = 0;
|
||||
|
||||
for (File file : dir) {
|
||||
|
||||
portraits[i][index] = image(file);
|
||||
portraits[i][index].setOpaque(true);
|
||||
portraits[i][index].setBackground(lightBrown);
|
||||
@@ -156,8 +165,10 @@ public class InfoPanel extends JPanel implements AppTheme {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private JLabel image(File file) {
|
||||
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |