make the other buttons in the options menu work

This commit is contained in:
2025-12-11 19:05:35 +01:00
parent eba67d7cf8
commit 21f4acf6b1
2 changed files with 36 additions and 6 deletions

View File

@@ -235,6 +235,7 @@ public class UI {
switch(optionState) {
case OVERVIEW -> optionsTop(frameX, frameY);
case SCREENNF -> optionsFSNotify(frameX, frameY);
case CONTROLS -> optionsControls(frameX, frameY);
}
panel.keyH.spacePressed = false;
}
@@ -358,17 +359,29 @@ public class UI {
// CONTROL
textY += panel.tileSize;
graphics2d.drawString("Controls", textX, textY);
if(commandNum == 3) graphics2d.drawString(">", textX-25, textY);
if(commandNum == 3) {
graphics2d.drawString(">", textX-25, textY);
if(panel.keyH.spacePressed) {
optionState = OptionState.CONTROLS;
commandNum = 0;
}
}
// END GAME
textY += panel.tileSize;
graphics2d.drawString("Quit Game", textX, textY);
if(commandNum == 4) graphics2d.drawString(">", textX-25, textY);
if(commandNum == 4) {
graphics2d.drawString(">", textX-25, textY);
if(panel.keyH.spacePressed) System.exit(0);
}
// BACK
textY += panel.tileSize*2;
graphics2d.drawString("Back to Game", textX, textY);
if(commandNum == 5) graphics2d.drawString(">", textX-25, textY);
if(commandNum == 5) {
graphics2d.drawString(">", textX-25, textY);
if(panel.keyH.spacePressed) panel.gameState = GameState.PLAY;
}
// FULL SCREEN CHECKBOX
textX = frameX + (int)(panel.tileSize*4.5);
@@ -408,12 +421,28 @@ public class UI {
}
}
public void optionsControls(int frameX, int frameY) {
int textX;
int textY;
// TITLE
String text = "Controls";
textX = getCenteredX(text);
textY = frameY + panel.tileSize;
graphics2d.drawString(text, textX, textY);
textX = frameX + panel.tileSize;
textY +=panel.tileSize;
String[] options = {"Move", "Confirm/Attack", "Shoot/Cast", "Inventory", "Pause/Settings"};
for(String option : options) {
graphics2d.drawString(option, textX, textY);
textY += panel.tileSize;
}
}
public enum OptionState {
OVERVIEW,
SCREENNF,
MUSIC,
SFX,
CONTROLS,
}

View File

@@ -111,7 +111,8 @@ public class KeyHandler implements KeyListener {
}
// EXIT STATE
if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY;
if(code == KeyEvent.VK_ESCAPE)
if(panel.ui.optionState == UI.OptionState.OVERVIEW) panel.gameState = GameState.PLAY; else panel.ui.optionState = UI.OptionState.OVERVIEW;
}
public void handleDialogue(int code) {
// EXIT STATE