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

View File

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

View File

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