diff --git a/dndBuilder/src/GUI/Panels/ChooseRacePanel.java b/dndBuilder/src/GUI/Panels/ChooseRacePanel.java index df3087e..ccaea40 100644 --- a/dndBuilder/src/GUI/Panels/ChooseRacePanel.java +++ b/dndBuilder/src/GUI/Panels/ChooseRacePanel.java @@ -1,6 +1,7 @@ package GUI.Panels; -import GUI.img.*; +import GUI.Panels.SubPanels.DescriptionPanel; +import GUI.Panels.SubPanels.ImagePanel; import java.awt.*; @@ -9,9 +10,11 @@ import javax.swing.border.*; public class ChooseRacePanel extends JPanel { - private String[] raceOptions = {"Dragonborn", "Dwarf", "Elf", "Gnome", "HalfElf", "Halfling", "Halforc", "Human", "Tiefling"}; + private String[] raceOptions; + private String[] raceDescriptions; private ImagePanel imgPanel; + private DescriptionPanel descPanel; // DEBUG: raceChoice to be deprecated after testing. private String raceChoice; @@ -26,7 +29,10 @@ public class ChooseRacePanel extends JPanel { super(); this.backButton = backButton; this.continueButton = continueButton; + raceOptions = new String[]{"Dragonborn", "Dwarf", "Elf", "Gnome", "HalfElf", "Halfling", "Halforc", "Human", "Tiefling"}; + createRaceDescriptions(); imgPanel = new ImagePanel(raceOptions); + descPanel = new DescriptionPanel(raceDescriptions); panelSetup(); @@ -34,6 +40,16 @@ public class ChooseRacePanel extends JPanel { } + private void createRaceDescriptions() { + + 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 JPanel createMasterPanel() { JLabel lblNewLabel = new JLabel("Step 1: Choose Race"); @@ -46,12 +62,15 @@ public class ChooseRacePanel extends JPanel { racePanel.setLayout(null); - imgPanel.setBounds(47, 67, 223, 301); - racePanel.add(imgPanel); + + infoPanel.add(imgPanel); + infoPanel.add(descPanel); + + racePanel.add(infoPanel); racePanel.add(createRaceButtonPanel()); - add(createNavPanel(), BorderLayout.SOUTH); + add(createNavPanel(), BorderLayout.SOUTH); return racePanel; @@ -104,6 +123,7 @@ public class ChooseRacePanel extends JPanel { raceChoice = raceName; raceIndex = index; imgPanel.updateImage(raceIndex); + descPanel.updateDescription(raceIndex); } diff --git a/dndBuilder/src/GUI/Panels/SubPanels/DescriptionPanel.java b/dndBuilder/src/GUI/Panels/SubPanels/DescriptionPanel.java new file mode 100644 index 0000000..473c6d5 --- /dev/null +++ b/dndBuilder/src/GUI/Panels/SubPanels/DescriptionPanel.java @@ -0,0 +1,70 @@ +package GUI.Panels.SubPanels; + +import javax.swing.*; +import javax.swing.border.BevelBorder; +import java.awt.*; + +public class DescriptionPanel extends JTextArea { + + private JTextArea[] descriptions; + private String[] holderDescriptions; + + + public DescriptionPanel(String[] holderDescriptions) { + + super(); + panelSetup(); + + this.holderDescriptions = holderDescriptions; + createDescriptionPanels(); + + updateDescription(0); + + + } + + private void panelSetup() { + + setOpaque(true); + setBackground(new Color(238, 232, 170)); + setBounds(6, 229, 281, 159); + + } + + public void updateDescription(int holderIndex) { + + removeAll(); + + add(descriptions[holderIndex]); + + repaint(); + revalidate(); + + } + + private void createDescriptionPanels() { + + descriptions = new JTextArea[holderDescriptions.length]; + + for (int i = 0; i < holderDescriptions.length; i++) { + + JTextArea tmpDesc = new JTextArea(); + tmpDesc.setText(holderDescriptions[i]); + tmpDesc.setWrapStyleWord(true); + tmpDesc.setLineWrap(true); + tmpDesc.setOpaque(false); + tmpDesc.setEditable(false); + tmpDesc.setFocusable(false); + tmpDesc.setFont(new Font("Bodoni 72", Font.PLAIN, 10)); + +/* setFont(new Font("Bodoni 72", Font.PLAIN, 10)); + setHorizontalAlignment(SwingConstants.LEFT); + setBounds(6, 21, 281, 196);*/ + + descriptions[i] = tmpDesc; + + } + + } + +} diff --git a/dndBuilder/src/GUI/img/ImagePanel.java b/dndBuilder/src/GUI/Panels/SubPanels/ImagePanel.java similarity index 79% rename from dndBuilder/src/GUI/img/ImagePanel.java rename to dndBuilder/src/GUI/Panels/SubPanels/ImagePanel.java index 0f6caaf..ba44851 100644 --- a/dndBuilder/src/GUI/img/ImagePanel.java +++ b/dndBuilder/src/GUI/Panels/SubPanels/ImagePanel.java @@ -1,7 +1,8 @@ -package GUI.img; +package GUI.Panels.SubPanels; import javax.imageio.ImageIO; import javax.swing.*; +import javax.swing.border.BevelBorder; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; @@ -10,19 +11,27 @@ import java.util.*; public class ImagePanel extends JPanel { private JLabel[][] portraits; - private String[] holder; + private String[] categoryHolder; private int lastIndex; - public ImagePanel(String[] holder) { + public ImagePanel(String[] categoryHolder) { super(); - this.holder = holder; + this.categoryHolder = categoryHolder; createPortraitsArray(); updateImage(0); // Default selection of the 0th element. } + private void panelSetup() { + + setOpaque(false); + setBounds(6, 21, 281, 196); + setLayout(null); + + } + public void updateImage(int holderIndex) { removeAll(); @@ -49,11 +58,11 @@ public class ImagePanel extends JPanel { private void createPortraitsArray() { - portraits = new JLabel[holder.length][]; + portraits = new JLabel[categoryHolder.length][]; - for (int i = 0; i < holder.length; i++) { + for (int i = 0; i < categoryHolder.length; i++) { - File imagesDir = new File("dndBuilder/src/GUI/img/" + holder[i] + "/"); + File imagesDir = new File("dndBuilder/src/GUI/img/" + categoryHolder[i] + "/"); File[] dir = imagesDir.listFiles(); portraits[i] = new JLabel[dir.length]; diff --git a/dndBuilder/src/GUI/Panels/SubPanels/InfoPanel.java b/dndBuilder/src/GUI/Panels/SubPanels/InfoPanel.java new file mode 100644 index 0000000..5692496 --- /dev/null +++ b/dndBuilder/src/GUI/Panels/SubPanels/InfoPanel.java @@ -0,0 +1,37 @@ +package GUI.Panels.SubPanels; + +import javax.swing.*; +import javax.swing.border.BevelBorder; +import java.awt.*; + +public class InfoPanel extends JPanel { + + private JTextArea[] descriptions; + private String[] holderDescriptions; + private JLabel[][] portraits; + private String[] categoryHolder; + private int lastIndex; + + public InfoPanel(String[] categoryHolder, String[] holderDescriptions) { + + super(); + panelSetup(); + + } + + private void panelSetup() { + + setOpaque(false); + setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); + setBounds(6, 6, 293, 394); + 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); + add(infoLbl); + + } + +}