guiVersion of project, rewriting code for maximum clarity

This commit is contained in:
Joshua-Ashton01
2022-11-08 17:14:43 -07:00
parent 823683e5c4
commit b06a6021c8
29 changed files with 142 additions and 109 deletions
+147
View File
@@ -0,0 +1,147 @@
package GUI;
import javax.swing.*;
public class PanelHolder {
private JPanel mainMenuPanel;
private JPanel racePanel;
private JPanel classPanel;
private JPanel abilityScorePanel;
private JPanel descriptionPanel;
private JPanel equipmentPanel;
private JPanel finalizePanel;
private JPanel loadMenuPanel;
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();
}
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 JPanel();
}
// TODO: Need to implement.
private JPanel createClassSelectPanel() {
return new JPanel();
}
// TODO: Need to implement.
private JPanel createAbilityScoreSelectPanel() {
return new JPanel();
}
// TODO: Need to implement.
private JPanel createDescriptionPanel() {
return new JPanel();
}
// TODO: Need to implement.
private JPanel createEquipmentSelectPanel() {
return new JPanel();
}
// TODO: Need to implement.
private JPanel createFinalizePanel() {
return new JPanel();
}
// TODO: Need to implement.
private JPanel createLoadMenu() {
return new JPanel();
}
}
+69
View File
@@ -0,0 +1,69 @@
package GUI;
import javax.swing.*;
public class UImanager {
private final JFrame gui;
private final PanelHolder guiPanels;
private int currentPanel;
public UImanager (PanelHolder guiPanels) {
this.gui = new JFrame("D&D Character Builder");
this.guiPanels = guiPanels;
if (returningUser()) {
this.currentPanel = 0;
} else {
this.currentPanel = 1;
}
frameSetup();
}
// TODO: Need to implement.
private void frameSetup() {
}
// TODO: Need to implement.
private boolean returningUser() {
return false;
}
private JPanel 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.getLoadMenuPanel();
case 7 -> guiPanels.getFinalizePanel();
default -> guiPanels.getMainMenuPanel();
};
}
private void clearAndReset(JPanel nextPanel) {
gui.removeAll();
gui.add(nextPanel);
gui.repaint();
gui.revalidate();
}
}