From 5192c8df87a0f0822a8524c18856d7cc1d8c9937 Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 9 Dec 2025 14:47:43 +0100 Subject: [PATCH] continued options menu --- src/de/miaurizius/jgame2d/core/GamePanel.java | 1 + src/de/miaurizius/jgame2d/core/UI.java | 23 ++++++++++++++++--- .../jgame2d/core/handlers/KeyHandler.java | 19 +++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/de/miaurizius/jgame2d/core/GamePanel.java b/src/de/miaurizius/jgame2d/core/GamePanel.java index dcf3d19..52b63ae 100644 --- a/src/de/miaurizius/jgame2d/core/GamePanel.java +++ b/src/de/miaurizius/jgame2d/core/GamePanel.java @@ -31,6 +31,7 @@ public class GamePanel extends JPanel implements Runnable { int fScreenHeight = screenHeight; BufferedImage tempScreen; Graphics2D fg2; + public boolean fullscreen; // WORLD SETTINGS public final int maxWorldCol = 50; diff --git a/src/de/miaurizius/jgame2d/core/UI.java b/src/de/miaurizius/jgame2d/core/UI.java index 3621897..970ae55 100644 --- a/src/de/miaurizius/jgame2d/core/UI.java +++ b/src/de/miaurizius/jgame2d/core/UI.java @@ -330,11 +330,14 @@ public class UI { textY = frameY + panel.tileSize; graphics2d.drawString(title, textX, textY); - // FULLSCREEN + // FULLSCREEN ON/OFF textX = frameX + panel.tileSize; textY += panel.tileSize; graphics2d.drawString("Full Screen", textX, textY); - if(commandNum == 0) graphics2d.drawString(">", textX-25, textY); + if(commandNum == 0) { + graphics2d.drawString(">", textX-25, textY); + if(panel.keyH.spacePressed) panel.fullscreen = !panel.fullscreen; + } // MUSIC textY += panel.tileSize; @@ -343,7 +346,7 @@ public class UI { // SOUND EFFECTS textY += panel.tileSize; - graphics2d.drawString("Sound Effects (SFX)", textX, textY); + graphics2d.drawString("SFX", textX, textY); if(commandNum == 2) graphics2d.drawString(">", textX-25, textY); // CONTROL @@ -360,6 +363,20 @@ public class UI { textY += panel.tileSize*2; graphics2d.drawString("Back to Game", textX, textY); if(commandNum == 5) graphics2d.drawString(">", textX-25, textY); + + // FULL SCREEN CHECKBOX + textX = frameX + (int)(panel.tileSize*4.5); + textY = frameY + panel.tileSize*2 - panel.tileSize/2; + graphics2d.setStroke(new BasicStroke(3)); + graphics2d.drawRect(textX, textY, panel.tileSize/2, panel.tileSize/2); + + // MUSIC VOLUME + textY += panel.tileSize; + graphics2d.drawRect(textX, textY, 120, panel.tileSize/2); + + // SFX VOLUME + textY += panel.tileSize; + graphics2d.drawRect(textX, textY, 120, panel.tileSize/2); } public enum OptionState { diff --git a/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java b/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java index 5d97646..1d82c30 100644 --- a/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java +++ b/src/de/miaurizius/jgame2d/core/handlers/KeyHandler.java @@ -67,6 +67,25 @@ public class KeyHandler implements KeyListener { public void handlePause(int code) { if(code == KeyEvent.VK_SPACE) spacePressed = true; + int maxCommandNum = 0; + + switch (panel.ui.optionState) { + case OVERVIEW -> maxCommandNum = 5; + } + + switch(code) { + case KeyEvent.VK_UP: + if(panel.ui.commandNum <= 0) break; + panel.ui.commandNum--; + panel.playSE(9); + break; + case KeyEvent.VK_DOWN: + if(panel.ui.commandNum >= maxCommandNum) break; + panel.ui.commandNum++; + panel.playSE(9); + break; + } + // EXIT STATE if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY; }