diff --git a/src/de/miaurizius/jgame2d/core/UI.java b/src/de/miaurizius/jgame2d/core/UI.java index a5e3ed6..29602d1 100644 --- a/src/de/miaurizius/jgame2d/core/UI.java +++ b/src/de/miaurizius/jgame2d/core/UI.java @@ -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, } diff --git a/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java b/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java index 6cf9c46..0f522a7 100644 --- a/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java +++ b/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java @@ -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