race and class GUIs, pending continue button implementation into GUImanager
This commit is contained in:
@@ -7,8 +7,7 @@ public class DndCharacterBuilder {
|
||||
|
||||
FileManager data = new FileManager();
|
||||
|
||||
PanelHolder guiPanels = new PanelHolder();
|
||||
GUImanager gui = new GUImanager(guiPanels, data.isReturninguser());
|
||||
GUImanager gui = new GUImanager(data.isReturninguser());
|
||||
gui.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
package GUI;
|
||||
|
||||
import GUI.Panels.ChooseClassPanel;
|
||||
import GUI.Panels.ChooseRacePanel;
|
||||
import GUI.Panels.MainMenuPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/* private void getNextPanel() {
|
||||
|
||||
|
||||
return switch (currentPanel) {
|
||||
case 1 -> guiPanels.getRacePanel();
|
||||
case 2 -> guiPanels.getClassPanel();
|
||||
case 3 -> guiPanels.getAbilityScorePanel();
|
||||
case 4 -> guiPanels.getDescriptionPanel();
|
||||
case 5 -> guiPanels.getEquipmentPanel();
|
||||
case 6 -> guiPanels.getFinalizePanel();
|
||||
case 7 -> guiPanels.getLoadMenuPanel();
|
||||
default -> guiPanels.getMainMenuPanel();
|
||||
};
|
||||
|
||||
}*/
|
||||
|
||||
public class GUImanager extends JFrame {
|
||||
|
||||
private final PanelHolder guiPanels;
|
||||
private int currentPanel;
|
||||
private static JPanel[] panels;
|
||||
|
||||
public GUImanager (PanelHolder guiPanels, boolean returningUser) {
|
||||
private int lastPanel;
|
||||
private int currentPanel;
|
||||
private int nextPanel;
|
||||
|
||||
public GUImanager (boolean returningUser) {
|
||||
super("D&D Character Builder");
|
||||
frameSetup();
|
||||
this.guiPanels = guiPanels;
|
||||
this.panels = new JPanel[]{new ChooseRacePanel(), new ChooseClassPanel()};
|
||||
|
||||
if (returningUser) {
|
||||
/* if (returningUser) {
|
||||
|
||||
this.currentPanel = 0;
|
||||
|
||||
@@ -21,9 +46,9 @@ public class GUImanager extends JFrame {
|
||||
|
||||
this.currentPanel = 1;
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
add(getNextPanel());
|
||||
add(panels[currentPanel]);
|
||||
|
||||
}
|
||||
|
||||
@@ -43,22 +68,14 @@ public class GUImanager extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
private JPanel getNextPanel() {
|
||||
/*
|
||||
|
||||
return guiPanels.getRacePanel();
|
||||
NOTES:
|
||||
I'm thinking of using CPU multi-threading to constantly check if a given creation panel's ableToContinue has become true, to update the GUI with a clickable "Continue" button.
|
||||
|
||||
/* return switch (currentPanel) {
|
||||
case 1 -> guiPanels.getRacePanel();
|
||||
case 2 -> guiPanels.getClassPanel();
|
||||
case 3 -> guiPanels.getAbilityScorePanel();
|
||||
case 4 -> guiPanels.getDescriptionPanel();
|
||||
case 5 -> guiPanels.getEquipmentPanel();
|
||||
case 6 -> guiPanels.getLoadMenuPanel();
|
||||
case 7 -> guiPanels.getFinalizePanel();
|
||||
default -> guiPanels.getMainMenuPanel();
|
||||
};*/
|
||||
Also. Continue button should be in GUI manager, otherwise the button's returned int of the next screen to display is obfuscated.
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
private void clearAndReset(JPanel nextPanel) {
|
||||
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
package GUI;
|
||||
|
||||
import Character.AbilityScores.Stats;
|
||||
import Character.Races.Race;
|
||||
import GUI.Panels.ChooseRacePanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/*
|
||||
|
||||
NOTES:
|
||||
|
||||
- Implement getters for lastPanel, currentPanel, and nextPanel.
|
||||
- Implement panel creators.
|
||||
- Implement button logic, which should set the lastPanel, currentPanel, and nextPanel indices.
|
||||
- Extract individual classes for each JPanel field to inherit JPanel and contain additional values, such as race or class.
|
||||
|
||||
*/
|
||||
|
||||
public class PanelHolder {
|
||||
|
||||
private JPanel mainMenuPanel;
|
||||
private static JPanel racePanel;
|
||||
private JPanel classPanel;
|
||||
private JPanel abilityScorePanel;
|
||||
private JPanel descriptionPanel;
|
||||
private JPanel equipmentPanel;
|
||||
private JPanel finalizePanel;
|
||||
private JPanel loadMenuPanel;
|
||||
|
||||
private int lastPanel;
|
||||
private int currentPanel;
|
||||
private int nextPanel;
|
||||
|
||||
private Race chosenRace;
|
||||
private Class chosenClass;
|
||||
private Stats chosenAbilityScores;
|
||||
|
||||
public PanelHolder() {
|
||||
|
||||
|
||||
|
||||
this.mainMenuPanel = createMainMenuPanel();
|
||||
this.racePanel = createRaceSelectPanel();
|
||||
this.classPanel = createClassSelectPanel();
|
||||
this.abilityScorePanel = createAbilityScoreSelectPanel();
|
||||
this.descriptionPanel = createDescriptionPanel();
|
||||
this.equipmentPanel = createEquipmentSelectPanel();
|
||||
this.finalizePanel = createFinalizePanel();
|
||||
this.loadMenuPanel = createLoadMenu();
|
||||
lastPanel = 0;
|
||||
currentPanel = 0;
|
||||
nextPanel = 0;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getMainMenuPanel() {
|
||||
|
||||
return mainMenuPanel;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getRacePanel() {
|
||||
|
||||
return racePanel;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getClassPanel() {
|
||||
|
||||
return classPanel;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getAbilityScorePanel() {
|
||||
|
||||
return abilityScorePanel;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getDescriptionPanel() {
|
||||
|
||||
return descriptionPanel;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getEquipmentPanel() {
|
||||
|
||||
return equipmentPanel;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getFinalizePanel() {
|
||||
|
||||
return finalizePanel;
|
||||
|
||||
}
|
||||
|
||||
public JPanel getLoadMenuPanel() {
|
||||
|
||||
return loadMenuPanel;
|
||||
|
||||
}
|
||||
|
||||
/* TODO: Need to implement.
|
||||
|
||||
LEFT-SIDE: Two large buttons, split with a horizontal line. One is to create a new DnD character, the other is to create a
|
||||
random character.
|
||||
|
||||
RIGHT-SIDE: One extra-large button to load an existing character.
|
||||
|
||||
*/
|
||||
private JPanel createMainMenuPanel() {
|
||||
|
||||
return new JPanel();
|
||||
|
||||
}
|
||||
|
||||
/* TODO: Need to implement.
|
||||
|
||||
LEFT-SIDE: Should appear with a random portrait of the default race, human. Below this
|
||||
portrait, a button for the user to upload their own portrait.
|
||||
|
||||
RIGHT-SIDE: Should appear with a scrollable list of the user's available races. A tooltip is on each race, and expands to
|
||||
describe the race, their proficiencies, languages, and ability score improvements.
|
||||
|
||||
*/
|
||||
private JPanel createRaceSelectPanel() {
|
||||
|
||||
return new ChooseRacePanel();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private JPanel createClassSelectPanel() {
|
||||
|
||||
currentPanel++;
|
||||
|
||||
return new JPanel();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private JPanel createAbilityScoreSelectPanel() {
|
||||
|
||||
currentPanel++;
|
||||
|
||||
return new JPanel();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private JPanel createDescriptionPanel() {
|
||||
|
||||
currentPanel++;
|
||||
|
||||
return new JPanel();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private JPanel createEquipmentSelectPanel() {
|
||||
|
||||
currentPanel++;
|
||||
|
||||
return new JPanel();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private JPanel createFinalizePanel() {
|
||||
|
||||
currentPanel++;
|
||||
|
||||
return new JPanel();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to implement.
|
||||
private JPanel createLoadMenu() {
|
||||
|
||||
currentPanel = 7;
|
||||
|
||||
return new JPanel();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class ChooseClassPanel extends JPanel{
|
||||
|
||||
private String classChoice;
|
||||
private boolean ableToContinue;
|
||||
|
||||
public ChooseClassPanel() {
|
||||
|
||||
super();
|
||||
createMasterPanel();
|
||||
|
||||
}
|
||||
|
||||
private void createMasterPanel() {
|
||||
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel masterPanel = new JPanel();
|
||||
|
||||
JLabel title = new JLabel("Step 2: Choose Class");
|
||||
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
masterPanel.add(title, BorderLayout.NORTH);
|
||||
|
||||
JPanel classContainer = new JPanel();
|
||||
|
||||
String[] availableClasses = {"Cleric", "Fighter", "Wizard"};
|
||||
|
||||
for (int i = 0; i < availableClasses.length; i++) {
|
||||
|
||||
classContainer.add(createButton(availableClasses[i]));
|
||||
|
||||
}
|
||||
|
||||
masterPanel.add(classContainer);
|
||||
|
||||
add(masterPanel);
|
||||
|
||||
}
|
||||
|
||||
private JButton createButton(String userChoice) {
|
||||
|
||||
JButton button = new JButton(userChoice);
|
||||
|
||||
button.addActionListener(
|
||||
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
System.out.println(userChoice);
|
||||
classChoice = userChoice;
|
||||
ableToContinue = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
public String getClassChoice() {
|
||||
|
||||
return classChoice;
|
||||
|
||||
}
|
||||
|
||||
public boolean isAbleToContinue() {
|
||||
|
||||
return ableToContinue;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,9 @@ import java.awt.event.ActionListener;
|
||||
public class ChooseRacePanel extends JPanel {
|
||||
|
||||
private String raceChoice;
|
||||
private boolean ableToContinue;
|
||||
|
||||
|
||||
/**
|
||||
* Create the panel.
|
||||
*/
|
||||
public ChooseRacePanel() {
|
||||
|
||||
super();
|
||||
@@ -38,7 +37,6 @@ public class ChooseRacePanel extends JPanel {
|
||||
|
||||
racesContainer.add(createButton(availableRaces[i]));
|
||||
|
||||
|
||||
}
|
||||
|
||||
masterPanel.add(racesContainer);
|
||||
@@ -47,16 +45,19 @@ public class ChooseRacePanel extends JPanel {
|
||||
|
||||
}
|
||||
|
||||
private JButton createButton(String raceName) {
|
||||
private JButton createButton(String userChoice) {
|
||||
|
||||
JButton button = new JButton(userChoice);
|
||||
|
||||
JButton button = new JButton(raceName);
|
||||
button.addActionListener(
|
||||
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
raceChoice = raceName;
|
||||
System.out.println(userChoice);
|
||||
raceChoice = userChoice;
|
||||
ableToContinue = true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -67,4 +68,16 @@ public class ChooseRacePanel extends JPanel {
|
||||
|
||||
}
|
||||
|
||||
public String getRaceChoice() {
|
||||
|
||||
return raceChoice;
|
||||
|
||||
}
|
||||
|
||||
public boolean isAbleToContinue() {
|
||||
|
||||
return ableToContinue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class GuiCharacterFrame extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
/* public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
GuiCharacterFrame frame = new GuiCharacterFrame();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
/* public GuiCharacterFrame() {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 550, 300);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
setContentPane(contentPane);
|
||||
|
||||
ChooseRacePanel panel = new ChooseRacePanel();
|
||||
contentPane.add(panel, BorderLayout.CENTER);
|
||||
|
||||
JButton submitBttn = new JButton("Next");
|
||||
panel.add(submitBttn, BorderLayout.SOUTH);
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class MainMenuPanel extends JPanel {
|
||||
|
||||
private int nextPanelSelected;
|
||||
|
||||
public MainMenuPanel() {
|
||||
|
||||
super();
|
||||
createMasterPanel();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to refactor/re-write, as current implementation utilizes ContinueButton.
|
||||
private void createMasterPanel() {
|
||||
|
||||
/*setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel masterPanel = new JPanel();
|
||||
|
||||
JLabel title = new JLabel("D&D Character Builder");
|
||||
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
masterPanel.add(title, BorderLayout.NORTH);
|
||||
|
||||
JPanel buttonsContainer = new JPanel(new GridLayout(1, 2, 10, 10));
|
||||
|
||||
JPanel newCharacterContainer = new JPanel(new GridLayout(2, 1, 10, 10));
|
||||
newCharacterContainer.add(new Button("Create a New Character", 1));
|
||||
newCharacterContainer.add(new Button("Generate a Random Character", -1));
|
||||
buttonsContainer.add(newCharacterContainer);
|
||||
|
||||
JPanel loadCharacterContainer = new JPanel();
|
||||
loadCharacterContainer.add(new Button("Load a Character", 7));
|
||||
buttonsContainer.add(loadCharacterContainer);
|
||||
|
||||
masterPanel.add(buttonsContainer);
|
||||
|
||||
add(masterPanel);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package GUI.Panels;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.Color;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
import java.awt.Insets;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.Scrollbar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.JScrollBar;
|
||||
|
||||
public class dndCharacterSheet extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
private JTextField textField;
|
||||
private JPanel panel;
|
||||
private JTextField textField_1;
|
||||
private JTextField textField_2;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
/* public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
dndCharacterSheet frame = new dndCharacterSheet();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public dndCharacterSheet() {
|
||||
|
||||
JLabel imageLabel = new JLabel(new ImageIcon(getClass().getResource("/dnd/img/sheet.jpg")));
|
||||
JPanel newPanel = new JPanel();
|
||||
newPanel.add(imageLabel);
|
||||
JScrollPane scrollPane = new JScrollPane(newPanel);
|
||||
|
||||
|
||||
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 850, 1200);
|
||||
setVisible(true);
|
||||
pack();
|
||||
|
||||
// contentPane = new JPanel();
|
||||
// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
// setContentPane(contentPane);
|
||||
// contentPane.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
/*ImagePanel imagePanel = new ImagePanel();
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new BorderLayout(0, 0));
|
||||
panel1.add(imagePanel, BorderLayout.CENTER);
|
||||
scrollPane.add(panel1);
|
||||
imagePanel.setLayout(null);
|
||||
|
||||
|
||||
contentPane.add(scrollPane, BorderLayout.CENTER);*/
|
||||
|
||||
// ImagePanel imagePanel = new ImagePanel();
|
||||
// contentPane.add(imagePanel, BorderLayout.CENTER);
|
||||
// imagePanel.setLayout(null);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user