gui panels are being constructed properly, need to refactor code

This commit is contained in:
Josh Ashton
2022-11-09 11:41:48 -07:00
parent 048b7a342f
commit bd64de79e5
4 changed files with 25 additions and 80 deletions
+2 -3
View File
@@ -5,11 +5,10 @@ public class DndCharacterBuilder {
public static void main(String[] args) {
//FileManager data = new FileManager();
FileManager data = new FileManager();
PanelHolder guiPanels = new PanelHolder();
// UImanager gui = new UImanager(guiPanels, data.isReturninguser());
UImanager gui = new UImanager(guiPanels);
UImanager gui = new UImanager(guiPanels, data.isReturninguser());
gui.setVisible(true);
}
@@ -35,7 +35,7 @@ public class FileManager {
try {
FileInputStream fileIn = new FileInputStream("/tmp/" + savedCharacters[index].getPath() + ".dnd");
FileInputStream fileIn = new FileInputStream("/dndBuilder/" + savedCharacters[index].getPath() + ".dnd");
ObjectInputStream in = new ObjectInputStream(fileIn);
sheet = (CharacterSheet) in.readObject();
in.close();
@@ -61,7 +61,7 @@ public class FileManager {
try {
FileOutputStream fileOut =
new FileOutputStream("/bin/" + completedCharacter.getName().hashCode() + ".dnd");
new FileOutputStream("/dndBuilder/" + completedCharacter.getName().hashCode() + ".dnd");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(completedCharacter);
out.close();
+16 -67
View File
@@ -18,44 +18,40 @@ NOTES:
public class PanelHolder {
/*
private JPanel mainMenuPanel;
*/
private JPanel racePanel;
/* private JPanel classPanel;
private JPanel classPanel;
private JPanel abilityScorePanel;
private JPanel descriptionPanel;
private JPanel equipmentPanel;
private JPanel finalizePanel;
private JPanel loadMenuPanel;*/
private JPanel loadMenuPanel;
// private int lastPanel;
private int lastPanel;
private int currentPanel;
// private int nextPanel;
private int nextPanel;
public PanelHolder() {
/*
this.mainMenuPanel = createMainMenuPanel();
*/
this.racePanel = createRaceSelectPanel();
/* this.classPanel = createClassSelectPanel();
this.classPanel = createClassSelectPanel();
this.abilityScorePanel = createAbilityScoreSelectPanel();
this.descriptionPanel = createDescriptionPanel();
this.equipmentPanel = createEquipmentSelectPanel();
this.finalizePanel = createFinalizePanel();
this.loadMenuPanel = createLoadMenu();*/
// lastPanel = 0;
this.loadMenuPanel = createLoadMenu();
lastPanel = 0;
currentPanel = 0;
// nextPanel = 0;
nextPanel = 0;
}
/* public JPanel getMainMenuPanel() {
public JPanel getMainMenuPanel() {
return mainMenuPanel;
}*/
}
public JPanel getRacePanel() {
@@ -63,7 +59,7 @@ public class PanelHolder {
}
/* public JPanel getClassPanel() {
public JPanel getClassPanel() {
return classPanel;
@@ -99,19 +95,19 @@ public class PanelHolder {
}
*//* TODO: Need to implement.
/* 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.
@@ -134,58 +130,12 @@ public class PanelHolder {
title.setHorizontalAlignment(SwingConstants.CENTER);
display.add(title, BorderLayout.NORTH);
JPanel textPanel = new JPanel();
textPanel.setLayout(null);
JLabel characterName = new JLabel("Character Name: ");
characterName.setBounds(113, 31, 108, 16);
textPanel.add(characterName);
JTextField nameTextBox = new JTextField();
nameTextBox.setBounds(233, 26, 211, 26);
textPanel.add(nameTextBox);
nameTextBox.setColumns(10);
JLabel raceLbl = new JLabel("Choose Race: ");
raceLbl.setBounds(113, 70, 98, 16);
textPanel.add(raceLbl);
JComboBox raceComboBox = new JComboBox();
raceComboBox.setBounds(196, 54, 221, 50);
textPanel.add(raceComboBox);
JLabel genderLbl = new JLabel("Gender: ");
genderLbl.setBounds(113, 108, 61, 16);
textPanel.add(genderLbl);
JComboBox genderComboBox = new JComboBox();
genderComboBox.setBounds(162, 92, 211, 50);
textPanel.add(genderComboBox);
JLabel classLbl = new JLabel("Class: ");
classLbl.setBounds(113, 154, 61, 16);
textPanel.add(classLbl);
JComboBox classComboBox = new JComboBox();
classComboBox.setBounds(162, 138, 200, 50);
textPanel.add(classComboBox);
JLabel AlignmentLbl = new JLabel("Alignment: ");
AlignmentLbl.setBounds(113, 200, 80, 16);
textPanel.add(AlignmentLbl);
JComboBox comboBox = new JComboBox();
comboBox.setBounds(190, 184, 200, 50);
textPanel.add(comboBox);
display.add(textPanel, BorderLayout.CENTER);
return new JPanel();
return display;
}
// TODO: Need to implement.
/* private JPanel createClassSelectPanel() {
private JPanel createClassSelectPanel() {
currentPanel++;
@@ -237,5 +187,4 @@ public class PanelHolder {
return new JPanel();
}
*/
}
+5 -8
View File
@@ -8,13 +8,12 @@ public class UImanager extends JFrame {
private final PanelHolder guiPanels;
private int currentPanel;
//public UImanager (PanelHolder guiPanels, boolean returningUser) {
public UImanager (PanelHolder guiPanels) {
public UImanager (PanelHolder guiPanels, boolean returningUser) {
super("D&D Character Builder");
frameSetup();
this.guiPanels = guiPanels;
/* if (returningUser) {
if (returningUser) {
this.currentPanel = 0;
@@ -22,7 +21,7 @@ public class UImanager extends JFrame {
this.currentPanel = 1;
}*/
}
clearAndReset(getNextPanel());
@@ -46,9 +45,7 @@ public class UImanager extends JFrame {
private JPanel getNextPanel() {
return guiPanels.getRacePanel();
/* return switch (currentPanel) {
return switch (currentPanel) {
case 1 -> guiPanels.getRacePanel();
case 2 -> guiPanels.getClassPanel();
case 3 -> guiPanels.getAbilityScorePanel();
@@ -57,7 +54,7 @@ public class UImanager extends JFrame {
case 6 -> guiPanels.getLoadMenuPanel();
case 7 -> guiPanels.getFinalizePanel();
default -> guiPanels.getMainMenuPanel();
};*/
};
}