Skip to content

Commit 01e3a2d

Browse files
committed
Controls dialog startup changes
1 parent 94be4a7 commit 01e3a2d

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/main/java/wagemaker/uk/gdx/MyGdxGame.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ public void create() {
353353
// Load player position from save file if it exists
354354
gameMenu.loadPlayerPosition();
355355

356+
// Show controls dialog on first startup
357+
gameMenu.showControlsOnStartup();
358+
356359
// Initialize connection quality indicator (will be set when connecting)
357360
connectionQualityIndicator = new wagemaker.uk.ui.ConnectionQualityIndicator(null, gameMenu.getFont());
358361

src/main/java/wagemaker/uk/ui/GameMenu.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public class GameMenu implements LanguageChangeListener, FontChangeListener {
8585

8686
// Compass reference for custom target
8787
private Compass compass;
88+
89+
// First launch flag for showing controls on startup
90+
private boolean hasShownControlsOnStartup = false;
91+
private boolean shouldShowControlsOnStartup = false;
92+
private int startupFrameCounter = 0;
8893

8994

9095
public GameMenu() {
@@ -683,6 +688,9 @@ private int parseJsonObjectInt(String json, String objectKey, String propertyKey
683688
}
684689

685690
public void update() {
691+
// Check if we should show controls on startup (after a few frames)
692+
checkStartupControlsDisplay();
693+
686694
// Update save notification timer
687695
if (showSaveNotification) {
688696
saveNotificationTimer -= Gdx.graphics.getDeltaTime();
@@ -1086,6 +1094,34 @@ private void openControlsDialog() {
10861094
controlsDialog.show();
10871095
}
10881096

1097+
/**
1098+
* Marks that the controls dialog should be shown on startup.
1099+
* This is called during game initialization.
1100+
* The actual display is delayed by a few frames to allow the world to load properly.
1101+
*/
1102+
public void showControlsOnStartup() {
1103+
if (!hasShownControlsOnStartup) {
1104+
shouldShowControlsOnStartup = true;
1105+
startupFrameCounter = 0;
1106+
}
1107+
}
1108+
1109+
/**
1110+
* Checks if controls should be shown after a few frames have passed.
1111+
* This ensures the world has loaded and camera is positioned correctly.
1112+
*/
1113+
private void checkStartupControlsDisplay() {
1114+
if (shouldShowControlsOnStartup) {
1115+
startupFrameCounter++;
1116+
// Wait 3 frames before showing controls to allow world to load
1117+
if (startupFrameCounter >= 3) {
1118+
controlsDialog.show();
1119+
hasShownControlsOnStartup = true;
1120+
shouldShowControlsOnStartup = false;
1121+
}
1122+
}
1123+
}
1124+
10891125
/**
10901126
* Handles the result of the player location dialog.
10911127
*/

0 commit comments

Comments
 (0)