improve menus

This commit is contained in:
2025-11-14 20:20:21 +01:00
parent edc983091b
commit db8d78043f
3 changed files with 21 additions and 14 deletions

View File

@@ -124,6 +124,11 @@ public class GameScreen implements Screen {
@Override
public void render(float delta) {
// TAB: toggle hud
if (Gdx.input.isKeyJustPressed(Input.Keys.TAB)) {
showHud = !showHud;
}
// ESC: toggle pause and mouse capture
if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
UiMode newMode = gameUi.onEsc(uiMode);
@@ -165,9 +170,6 @@ public class GameScreen implements Screen {
modelBatch.end();
// HUD
if (Gdx.input.isKeyJustPressed(Input.Keys.TAB)) {
showHud = !showHud;
}
if (showHud) {
hud.render(
RETRO_WIDTH,

View File

@@ -53,7 +53,7 @@ public class PauseMenu {
param.color = Color.WHITE;
param.mono = true;
param.hinting = FreeTypeFontGenerator.Hinting.None;
param.borderWidth = 0.2f;
param.borderWidth = 0f;
param.borderColor = Color.WHITE;
param.shadowOffsetX = 0;
param.shadowOffsetY = 0;

View File

@@ -14,6 +14,7 @@ public class SettingsMenu {
private final SpriteBatch batch;
private final BitmapFont font;
private final BitmapFont boldFont;
private final Texture pixel;
// FOV value stored here, GameScreen syncs it to the camera
@@ -39,7 +40,7 @@ public class SettingsMenu {
param.color = Color.WHITE;
param.mono = true;
param.hinting = FreeTypeFontGenerator.Hinting.None;
param.borderWidth = 0.2f;
param.borderWidth = 0f;
param.borderColor = Color.WHITE;
param.shadowOffsetX = 0;
param.shadowOffsetY = 0;
@@ -47,6 +48,10 @@ public class SettingsMenu {
param.magFilter = Texture.TextureFilter.Nearest;
font = generator.generateFont(param);
param.borderWidth = 0.2f;
boldFont = generator.generateFont(param);
generator.dispose();
// 1x1 pixel
@@ -79,7 +84,7 @@ public class SettingsMenu {
GlyphLayout layout = new GlyphLayout();
// --- central panel ---
float panelW = 200f;
float panelW = 300f;
float panelH = 220f;
float panelX = (width - panelW) / 2f;
float panelY = (height - panelH) / 2f;
@@ -94,10 +99,10 @@ public class SettingsMenu {
// --- title ---
String title = "Settings";
layout.setText(font, title);
layout.setText(boldFont, title);
float titleX = panelX + (panelW - layout.width) / 2f;
float titleY = panelY + panelH - 10f;
font.draw(batch, layout, titleX, titleY);
boldFont.draw(batch, layout, titleX, titleY);
// small separator line under title
batch.draw(pixel, panelX + 8f, titleY - 14f, panelW - 16f, 1f);
@@ -107,7 +112,7 @@ public class SettingsMenu {
float rowH = 18f;
// label
String fovLabel = "FOV";
String fovLabel = "Field of View";
layout.setText(font, fovLabel);
float labelX = panelX + 12f;
float labelY = rowY + rowH - 4f;
@@ -116,7 +121,7 @@ public class SettingsMenu {
// buttons + value area
fovDecW = 20f;
fovDecH = rowH;
fovDecX = panelX + 80f;
fovDecX = panelX + 180f;
fovDecY = rowY;
fovIncW = 20f;
@@ -142,8 +147,8 @@ public class SettingsMenu {
// --- Close button at bottom ---
String closeLabel = " Close ";
layout.setText(font, closeLabel);
closeW = layout.width + 16f;
closeH = layout.height + 8f;
closeW = layout.width + 64f;
closeH = layout.height + 12f;
closeX = panelX + (panelW - closeW) / 2f;
closeY = panelY + 16f;
@@ -158,7 +163,7 @@ public class SettingsMenu {
batch.draw(pixel, closeX + closeW - border, closeY, border, closeH);
float closeTextX = closeX + (closeW - layout.width) / 2f;
float closeTextY = closeY + closeH - (closeH - layout.height) / 2f - 2f;
float closeTextY = closeY + closeH - (closeH - layout.height) / 2f;
font.draw(batch, closeLabel, closeTextX, closeTextY);
batch.end();
@@ -178,7 +183,7 @@ public class SettingsMenu {
GlyphLayout layout = new GlyphLayout(font, text);
float tx = x + (w - layout.width) / 2f;
float ty = y + h - (h - layout.height) / 2f - 2f;
float ty = y + h - (h - layout.height) / 2f;
font.draw(batch, layout, tx, ty);
}