Skip to content

Commit

Permalink
Added boolean parameter to main menus and theme colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
HackusatePvP committed Jun 1, 2024
1 parent 4edf662 commit 7559e8e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 21 deletions.
36 changes: 22 additions & 14 deletions src/main/java/me/piitex/renjava/RenJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,14 @@ public void buildStage(Stage stage) {

public abstract Menu buildSplashScreen();

public abstract Menu buildTitleScreen();
/**
* This method is used to build and design the main menu screen.
* @param rightClickMenu True if the user is in the right-clicked main menu. False if they are at the title screen.
* @return A new {@link Menu} of the configured screen.
*/
public abstract Menu buildTitleScreen(boolean rightClickMenu);

public Menu buildSideMenu() {
public Menu buildSideMenu(boolean rightClickedMenu) {
Menu menu = new Menu(1920, 1080, new ImageOverlay("gui/overlay/main_menu.png"));

Font uiFont = RenJava.getInstance().getConfiguration().getUiFont().getFont();
Expand Down Expand Up @@ -473,6 +478,9 @@ private static ButtonOverlay getButtonOverlay(int page, int index) {
public Menu buildSettingsMenu() {
Menu menu = new Menu(1920, 1080, new ImageOverlay("gui/main_menu.png"));

Color themeColor = getConfiguration().getThemeColor();
Color subColor = getConfiguration().getSubColor();

// 1 hbox 3 vboxes

// Display Rollback Skip
Expand All @@ -487,23 +495,23 @@ public Menu buildSettingsMenu() {
rootLayout.setSpacing(100);

VerticalLayout displayBox = new VerticalLayout(300, 400);
TextOverlay displayText = new TextOverlay("Display", getConfiguration().getUiFont(), 0, 0);
ButtonOverlay windowButton = new ButtonOverlay("windowed-display", "Windowed", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay fullscreenButton = new ButtonOverlay("windowed-fullscreen", "Fullscreen", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
TextOverlay displayText = new TextOverlay("Display", themeColor, getConfiguration().getUiFont(), 0, 0);
ButtonOverlay windowButton = new ButtonOverlay("windowed-display", "Windowed", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay fullscreenButton = new ButtonOverlay("windowed-fullscreen", "Fullscreen", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
displayBox.addOverlays(displayText, windowButton, fullscreenButton);

VerticalLayout rollbackBox = new VerticalLayout(300, 400);
TextOverlay rollbackText = new TextOverlay("Rollback", getConfiguration().getUiFont(), 0, 0);
ButtonOverlay disabledButton = new ButtonOverlay("disabled-rollback", "Disabled", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay leftButton = new ButtonOverlay("left-rollback", "Left", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay rightButton = new ButtonOverlay("right-rollback", "Right", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
TextOverlay rollbackText = new TextOverlay("Rollback", themeColor, getConfiguration().getUiFont(), 0, 0);
ButtonOverlay disabledButton = new ButtonOverlay("disabled-rollback", "Disabled", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay leftButton = new ButtonOverlay("left-rollback", "Left", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay rightButton = new ButtonOverlay("right-rollback", "Right", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
rollbackBox.addOverlays(rollbackText, disabledButton, leftButton, rightButton);

VerticalLayout skipBox = new VerticalLayout(300, 400);
TextOverlay skipText = new TextOverlay("Skip", getConfiguration().getUiFont(), 0, 0);
ButtonOverlay unseenTextButton = new ButtonOverlay("unseen-skip", "Unseen Text", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay afterChoicesButton = new ButtonOverlay("after-skip", "After Choices", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay transitionButton = new ButtonOverlay("transitions-skip", "Transitions", Color.BLACK, getConfiguration().getUiFont().getFont(), 0,0,1,1);
TextOverlay skipText = new TextOverlay("Skip", themeColor, getConfiguration().getUiFont(), 0, 0);
ButtonOverlay unseenTextButton = new ButtonOverlay("unseen-skip", "Unseen Text", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay afterChoicesButton = new ButtonOverlay("after-skip", "After Choices", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
ButtonOverlay transitionButton = new ButtonOverlay("transitions-skip", "Transitions", subColor, getConfiguration().getUiFont().getFont(), 0,0,1,1);
skipBox.addOverlays(skipText, unseenTextButton, afterChoicesButton, transitionButton);

// Add all to root layout
Expand All @@ -515,7 +523,7 @@ public Menu buildSettingsMenu() {
VerticalLayout musicBox = new VerticalLayout(400, 600);
musicBox.setX(700);
musicBox.setY(800);
TextOverlay musicVolumeText = new TextOverlay("Music Volume", getConfiguration().getUiFont(), 0, 0);
TextOverlay musicVolumeText = new TextOverlay("Music Volume", themeColor, getConfiguration().getUiFont(), 0, 0);
SliderOverlay musicVolumeSlider = new SliderOverlay(100, 0, getSettings().getVolume(), 0,0);
musicVolumeSlider.setBlockIncrement(10);
musicVolumeSlider.setOnSliderChange(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class RenJavaConfiguration {
private final int height;
private final ImageLoader gameIcon;

private Color themeColor = Color.BLACK;
private Color subColor = Color.DARKGRAY;

private FontLoader defaultFont;
private FontLoader dialogueFont;
private FontLoader uiFont;
Expand Down Expand Up @@ -80,6 +83,22 @@ public ImageLoader getGameIcon() {
return gameIcon;
}

public Color getThemeColor() {
return themeColor;
}

public void setThemeColor(Color themeColor) {
this.themeColor = themeColor;
}

public Color getSubColor() {
return subColor;
}

public void setSubColor(Color subColor) {
this.subColor = subColor;
}

public FontLoader getDialogueFont() {
if (dialogueFont != null) {
return dialogueFont;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@ public void onButtonClick(ButtonClickEvent event) {
if (button.getId().equalsIgnoreCase("menu-load-button")) {
// NOTE: 10/20/2023 new LoadScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true);
Menu menu = renJava.buildLoadMenu(1); // Builds first page
menu.addMenu(renJava.buildSideMenu());
menu.addMenu(renJava.buildSideMenu(true));
menu.render();
renJava.setStage(renJava.getStage(), StageType.LOAD_MENU); // Update stage type
}
if (button.getId().equalsIgnoreCase("menu-preference-button")) {
//new PreferenceScreenView(new ImageLoader("gui/overlay/game_menu.png")).build(renJava.getStage(), true);
Menu settings = renJava.buildSettingsMenu();
settings.addMenu(renJava.buildSideMenu());
settings.addMenu(renJava.buildSideMenu(true));

settings.render();
renJava.setStage(renJava.getStage(), StageType.OPTIONS_MENU);
}
if (button.getId().equalsIgnoreCase("menu-about-button")) {
Menu about = renJava.buildAboutMenu();
about.addMenu(renJava.buildSideMenu());
about.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu()));

about.render();
renJava.setStage(renJava.getStage(), StageType.ABOUT_MENU);
}
if (button.getId().equalsIgnoreCase("menu-save-button")) {
//new Save(1, renJava.getPlayer().getCurrentStory().getId(), renJava.getPlayer().getCurrentScene().getId());
Menu menu = renJava.buildLoadMenu(1); // Builds first page
menu.addMenu(renJava.buildSideMenu());
menu.addMenu(renJava.buildSideMenu(renJava.getPlayer().isRightClickMenu()));
menu.render();

renJava.setStage(renJava.getStage(), StageType.SAVE_MENU);
Expand Down Expand Up @@ -108,7 +108,7 @@ public void onButtonClick(ButtonClickEvent event) {

// Re-render
Menu menu = renJava.buildLoadMenu(1); // Builds first page
menu.addMenu(renJava.buildSideMenu());
menu.addMenu(renJava.buildSideMenu(true));
menu.render();
renJava.setStage(renJava.getStage(), StageType.SAVE_MENU); // Update stage type
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/piitex/renjava/gui/GuiLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void buildMainMenu() {
stage = new Stage();
renJava.buildStage(stage); // Builds the stage parameters (Game Window)

Menu menu = renJava.buildTitleScreen();
Menu menu = renJava.buildTitleScreen(false);
MainMenuBuildEvent event = new MainMenuBuildEvent(menu);
RenJava.callEvent(event);

Expand All @@ -100,7 +100,7 @@ private void buildMainMenu() {
menu.setBackgroundImage(new ImageOverlay("gui/main_menu.png"));
}

Menu sideMenu = renJava.buildSideMenu();
Menu sideMenu = renJava.buildSideMenu(false);
SideMenuBuildEvent sideMenuBuildEvent = new SideMenuBuildEvent(sideMenu);
RenJava.callEvent(sideMenuBuildEvent);

Expand Down

0 comments on commit 7559e8e

Please sign in to comment.