gui panels are being constructed properly, need to refactor code
This commit is contained in:
@@ -5,11 +5,10 @@ public class DndCharacterBuilder {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
//FileManager data = new FileManager();
|
FileManager data = new FileManager();
|
||||||
|
|
||||||
PanelHolder guiPanels = new PanelHolder();
|
PanelHolder guiPanels = new PanelHolder();
|
||||||
// UImanager gui = new UImanager(guiPanels, data.isReturninguser());
|
UImanager gui = new UImanager(guiPanels, data.isReturninguser());
|
||||||
UImanager gui = new UImanager(guiPanels);
|
|
||||||
gui.setVisible(true);
|
gui.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class FileManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
FileInputStream fileIn = new FileInputStream("/tmp/" + savedCharacters[index].getPath() + ".dnd");
|
FileInputStream fileIn = new FileInputStream("/dndBuilder/" + savedCharacters[index].getPath() + ".dnd");
|
||||||
ObjectInputStream in = new ObjectInputStream(fileIn);
|
ObjectInputStream in = new ObjectInputStream(fileIn);
|
||||||
sheet = (CharacterSheet) in.readObject();
|
sheet = (CharacterSheet) in.readObject();
|
||||||
in.close();
|
in.close();
|
||||||
@@ -61,7 +61,7 @@ public class FileManager {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
FileOutputStream fileOut =
|
FileOutputStream fileOut =
|
||||||
new FileOutputStream("/bin/" + completedCharacter.getName().hashCode() + ".dnd");
|
new FileOutputStream("/dndBuilder/" + completedCharacter.getName().hashCode() + ".dnd");
|
||||||
ObjectOutputStream out = new ObjectOutputStream(fileOut);
|
ObjectOutputStream out = new ObjectOutputStream(fileOut);
|
||||||
out.writeObject(completedCharacter);
|
out.writeObject(completedCharacter);
|
||||||
out.close();
|
out.close();
|
||||||
|
|||||||
@@ -18,44 +18,40 @@ NOTES:
|
|||||||
|
|
||||||
public class PanelHolder {
|
public class PanelHolder {
|
||||||
|
|
||||||
/*
|
|
||||||
private JPanel mainMenuPanel;
|
private JPanel mainMenuPanel;
|
||||||
*/
|
|
||||||
private JPanel racePanel;
|
private JPanel racePanel;
|
||||||
/* private JPanel classPanel;
|
private JPanel classPanel;
|
||||||
private JPanel abilityScorePanel;
|
private JPanel abilityScorePanel;
|
||||||
private JPanel descriptionPanel;
|
private JPanel descriptionPanel;
|
||||||
private JPanel equipmentPanel;
|
private JPanel equipmentPanel;
|
||||||
private JPanel finalizePanel;
|
private JPanel finalizePanel;
|
||||||
private JPanel loadMenuPanel;*/
|
private JPanel loadMenuPanel;
|
||||||
|
|
||||||
// private int lastPanel;
|
private int lastPanel;
|
||||||
private int currentPanel;
|
private int currentPanel;
|
||||||
// private int nextPanel;
|
private int nextPanel;
|
||||||
|
|
||||||
public PanelHolder() {
|
public PanelHolder() {
|
||||||
|
|
||||||
/*
|
|
||||||
this.mainMenuPanel = createMainMenuPanel();
|
this.mainMenuPanel = createMainMenuPanel();
|
||||||
*/
|
|
||||||
this.racePanel = createRaceSelectPanel();
|
this.racePanel = createRaceSelectPanel();
|
||||||
/* this.classPanel = createClassSelectPanel();
|
this.classPanel = createClassSelectPanel();
|
||||||
this.abilityScorePanel = createAbilityScoreSelectPanel();
|
this.abilityScorePanel = createAbilityScoreSelectPanel();
|
||||||
this.descriptionPanel = createDescriptionPanel();
|
this.descriptionPanel = createDescriptionPanel();
|
||||||
this.equipmentPanel = createEquipmentSelectPanel();
|
this.equipmentPanel = createEquipmentSelectPanel();
|
||||||
this.finalizePanel = createFinalizePanel();
|
this.finalizePanel = createFinalizePanel();
|
||||||
this.loadMenuPanel = createLoadMenu();*/
|
this.loadMenuPanel = createLoadMenu();
|
||||||
// lastPanel = 0;
|
lastPanel = 0;
|
||||||
currentPanel = 0;
|
currentPanel = 0;
|
||||||
// nextPanel = 0;
|
nextPanel = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public JPanel getMainMenuPanel() {
|
public JPanel getMainMenuPanel() {
|
||||||
|
|
||||||
return mainMenuPanel;
|
return mainMenuPanel;
|
||||||
|
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public JPanel getRacePanel() {
|
public JPanel getRacePanel() {
|
||||||
|
|
||||||
@@ -63,7 +59,7 @@ public class PanelHolder {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public JPanel getClassPanel() {
|
public JPanel getClassPanel() {
|
||||||
|
|
||||||
return classPanel;
|
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
|
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.
|
random character.
|
||||||
|
|
||||||
RIGHT-SIDE: One extra-large button to load an existing character.
|
RIGHT-SIDE: One extra-large button to load an existing character.
|
||||||
|
|
||||||
*//*
|
*/
|
||||||
private JPanel createMainMenuPanel() {
|
private JPanel createMainMenuPanel() {
|
||||||
|
|
||||||
return new JPanel();
|
return new JPanel();
|
||||||
|
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/* TODO: Need to implement.
|
/* TODO: Need to implement.
|
||||||
|
|
||||||
@@ -134,58 +130,12 @@ public class PanelHolder {
|
|||||||
title.setHorizontalAlignment(SwingConstants.CENTER);
|
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
display.add(title, BorderLayout.NORTH);
|
display.add(title, BorderLayout.NORTH);
|
||||||
|
|
||||||
JPanel textPanel = new JPanel();
|
return display;
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Need to implement.
|
// TODO: Need to implement.
|
||||||
/* private JPanel createClassSelectPanel() {
|
private JPanel createClassSelectPanel() {
|
||||||
|
|
||||||
currentPanel++;
|
currentPanel++;
|
||||||
|
|
||||||
@@ -237,5 +187,4 @@ public class PanelHolder {
|
|||||||
return new JPanel();
|
return new JPanel();
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
@@ -8,13 +8,12 @@ public class UImanager extends JFrame {
|
|||||||
private final PanelHolder guiPanels;
|
private final PanelHolder guiPanels;
|
||||||
private int currentPanel;
|
private int currentPanel;
|
||||||
|
|
||||||
//public UImanager (PanelHolder guiPanels, boolean returningUser) {
|
public UImanager (PanelHolder guiPanels, boolean returningUser) {
|
||||||
public UImanager (PanelHolder guiPanels) {
|
|
||||||
super("D&D Character Builder");
|
super("D&D Character Builder");
|
||||||
frameSetup();
|
frameSetup();
|
||||||
this.guiPanels = guiPanels;
|
this.guiPanels = guiPanels;
|
||||||
|
|
||||||
/* if (returningUser) {
|
if (returningUser) {
|
||||||
|
|
||||||
this.currentPanel = 0;
|
this.currentPanel = 0;
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ public class UImanager extends JFrame {
|
|||||||
|
|
||||||
this.currentPanel = 1;
|
this.currentPanel = 1;
|
||||||
|
|
||||||
}*/
|
}
|
||||||
|
|
||||||
clearAndReset(getNextPanel());
|
clearAndReset(getNextPanel());
|
||||||
|
|
||||||
@@ -46,9 +45,7 @@ public class UImanager extends JFrame {
|
|||||||
|
|
||||||
private JPanel getNextPanel() {
|
private JPanel getNextPanel() {
|
||||||
|
|
||||||
return guiPanels.getRacePanel();
|
return switch (currentPanel) {
|
||||||
|
|
||||||
/* return switch (currentPanel) {
|
|
||||||
case 1 -> guiPanels.getRacePanel();
|
case 1 -> guiPanels.getRacePanel();
|
||||||
case 2 -> guiPanels.getClassPanel();
|
case 2 -> guiPanels.getClassPanel();
|
||||||
case 3 -> guiPanels.getAbilityScorePanel();
|
case 3 -> guiPanels.getAbilityScorePanel();
|
||||||
@@ -57,7 +54,7 @@ public class UImanager extends JFrame {
|
|||||||
case 6 -> guiPanels.getLoadMenuPanel();
|
case 6 -> guiPanels.getLoadMenuPanel();
|
||||||
case 7 -> guiPanels.getFinalizePanel();
|
case 7 -> guiPanels.getFinalizePanel();
|
||||||
default -> guiPanels.getMainMenuPanel();
|
default -> guiPanels.getMainMenuPanel();
|
||||||
};*/
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user