diff --git a/core/src/main/java/group07/beatbattle/BeatBattle.java b/core/src/main/java/group07/beatbattle/BeatBattle.java index 597efe3..9f2eb24 100644 --- a/core/src/main/java/group07/beatbattle/BeatBattle.java +++ b/core/src/main/java/group07/beatbattle/BeatBattle.java @@ -8,6 +8,7 @@ import group07.beatbattle.audio.AudioPlayer; import group07.beatbattle.firebase.FirebaseGateway; import group07.beatbattle.controller.LobbyController; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.ecs.Engine; import group07.beatbattle.model.GameSession; import group07.beatbattle.service.MusicService; @@ -72,6 +73,8 @@ public void create() { orbitronFont = loadFont("fonts/Orbitron-Regular.ttf", 56); oswaldFont = loadFont("fonts/Oswald-Regular.ttf", 48); + Strings.reload(); + Engine engine = Engine.getInstance(); engine.addSystem(RoundSystem.getInstance()); engine.addSystem(AudioSystem.getInstance()); diff --git a/core/src/main/java/group07/beatbattle/controller/SettingsController.java b/core/src/main/java/group07/beatbattle/controller/SettingsController.java index 9f1e9be..8e4e680 100644 --- a/core/src/main/java/group07/beatbattle/controller/SettingsController.java +++ b/core/src/main/java/group07/beatbattle/controller/SettingsController.java @@ -3,7 +3,10 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; import group07.beatbattle.BeatBattle; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.model.GameMode; +import group07.beatbattle.states.StartState; +import group07.beatbattle.states.StateManager; import group07.beatbattle.view.LobbyView; public class SettingsController { @@ -59,12 +62,17 @@ public void onApply() { prefs.putString("language", language); prefs.putInteger("turns", turns); prefs.flush(); + Strings.reload(); Gdx.app.log("Settings", "Settings saved"); onBack(); } public void onBack() { Gdx.app.log("Settings", "Back pressed"); + if (sessionId == null || sessionId.isBlank()) { + StateManager.getInstance().setState(new StartState(game, new LobbyController(game))); + return; + } game.setScreen(new LobbyView( game, mode, diff --git a/core/src/main/java/group07/beatbattle/i18n/Strings.java b/core/src/main/java/group07/beatbattle/i18n/Strings.java new file mode 100644 index 0000000..33534cf --- /dev/null +++ b/core/src/main/java/group07/beatbattle/i18n/Strings.java @@ -0,0 +1,74 @@ +package group07.beatbattle.i18n; + +import com.badlogic.gdx.Gdx; + +/** + * Simple localization helper. Call {@link #reload()} once at startup and + * again after the user changes the language in Settings. + */ +public final class Strings { + + private static boolean no = false; + + private Strings() {} + + public static void reload() { + String lang = Gdx.app.getPreferences("settings").getString("language", "EN"); + no = "NO".equalsIgnoreCase(lang); + } + + // --- Start screen --- + public static String createGame() { return no ? "Lag spill" : "Create Game"; } + public static String joinGame() { return no ? "Bli med i spill" : "Join Game"; } + + // --- Join/Create screen --- + public static String readyToPlay() { return no ? "Klar til å spille" : "Ready to play"; } + public static String back() { return no ? "Tilbake" : "Back"; } + public static String enterName() { return no ? "Skriv inn spillernavn" : "Enter player name"; } + public static String enterCode() { return no ? "Skriv inn spillkode" : "Enter game code"; } + public static String gameCode() { return no ? "Spillkode" : "Game Code"; } + public static String generatingCode(){ return no ? "Genererer spillkode..." : "Generating game code..."; } + public static String failedCode() { return no ? "Kunne ikke generere spillkode" : "Failed to generate game code"; } + + // --- Lobby --- + public static String party() { return no ? "Lag" : "Party"; } + public static String loadingPlayers(){ return no ? "Laster spillere..." : "Loading players..."; } + public static String noPlayers() { return no ? "Ingen spillere ennå" : "No players yet"; } + public static String leaveLobby() { return no ? "Forlat lobbyen" : "Leave lobby"; } + public static String leaveHostMsg() { + return no + ? "Å forlate vil slette sesjonen for alle.\nVil du fortsette?" + : "Leaving will delete the session for everyone.\nDo you want to continue?"; + } + public static String leavePlayerMsg() { + return no + ? "Er du sikker på at du vil forlate sesjonen?" + : "Are you sure you want to leave the session?"; + } + public static String gameStarting() { return no ? "Spillet starter..." : "Game starting..."; } + public static String startGame() { return no ? "Start spill" : "Start Game"; } + + // --- Round --- + public static String nowPlaying() { return no ? "Spiller nå..." : "Now Playing..."; } + + // --- Leaderboard --- + public static String leaderboard() { return no ? "Ledertavle" : "Leaderboard"; } + public static String round() { return no ? "Runde" : "Round"; } + public static String playerCol() { return no ? "Spiller" : "Player"; } + public static String scoreCol() { return no ? "Poeng" : "Score"; } + public static String nextRoundIn() { return no ? "Neste runde om " : "Next round in "; } + public static String finalResultsIn(){ return no ? "Sluttresultater om " : "Final results in "; } + public static String waitingForHost(){ return no ? "Venter på vert..." : "Waiting for host..."; } + public static String leaveSession() { return no ? "Forlat sesjonen" : "Leave Session"; } + + // --- Game Over --- + public static String gameOver() { return no ? "SPILLET ER OVER" : "GAME OVER"; } + public static String finalStandings(){ return no ? "Sluttresultater" : "Final Standings"; } + public static String backToMenu() { return no ? "Tilbake til menyen" : "Back to Menu"; } + + // --- Settings --- + public static String settings() { return no ? "Innstillinger" : "Settings"; } + public static String apply() { return no ? "Bruk" : "Apply"; } + public static String numRounds() { return no ? "Antall runder" : "Number of rounds"; } + public static String language() { return no ? "Språk" : "Language"; } +} diff --git a/core/src/main/java/group07/beatbattle/ui/components/ApplyButton.java b/core/src/main/java/group07/beatbattle/ui/components/ApplyButton.java index 465bace..14b61b1 100644 --- a/core/src/main/java/group07/beatbattle/ui/components/ApplyButton.java +++ b/core/src/main/java/group07/beatbattle/ui/components/ApplyButton.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; +import group07.beatbattle.i18n.Strings; public class ApplyButton extends TextButton { @@ -34,7 +35,7 @@ private static TextButtonStyle createStyle(BitmapFont font) { } public ApplyButton(BitmapFont font) { - super("Apply", createStyle(font)); + super(Strings.apply(), createStyle(font)); pad(40f, 80f, 40f, 80f); } diff --git a/core/src/main/java/group07/beatbattle/ui/components/LanguageSelector.java b/core/src/main/java/group07/beatbattle/ui/components/LanguageSelector.java index aeafe76..7c6a53e 100644 --- a/core/src/main/java/group07/beatbattle/ui/components/LanguageSelector.java +++ b/core/src/main/java/group07/beatbattle/ui/components/LanguageSelector.java @@ -15,6 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Align; +import group07.beatbattle.i18n.Strings; public class LanguageSelector { @@ -46,7 +47,7 @@ public LanguageSelector(BitmapFont font, String initialLanguage) { labelStyle.font = font; labelStyle.fontColor = Color.LIGHT_GRAY; - Label label = new Label("Language", labelStyle); + Label label = new Label(Strings.language(), labelStyle); label.setAlignment(Align.left); TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle(); diff --git a/core/src/main/java/group07/beatbattle/ui/components/RoundSelector.java b/core/src/main/java/group07/beatbattle/ui/components/RoundSelector.java index e319353..37945b3 100644 --- a/core/src/main/java/group07/beatbattle/ui/components/RoundSelector.java +++ b/core/src/main/java/group07/beatbattle/ui/components/RoundSelector.java @@ -15,6 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Align; +import group07.beatbattle.i18n.Strings; public class RoundSelector { @@ -51,7 +52,7 @@ public RoundSelector(BitmapFont font) { labelStyle.font = font; labelStyle.fontColor = Color.LIGHT_GRAY; - Label label = new Label("Number of rounds", labelStyle); + Label label = new Label(Strings.numRounds(), labelStyle); label.setAlignment(Align.left); TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle(); diff --git a/core/src/main/java/group07/beatbattle/ui/components/StartGameButton.java b/core/src/main/java/group07/beatbattle/ui/components/StartGameButton.java index 276c56c..29dc5a5 100644 --- a/core/src/main/java/group07/beatbattle/ui/components/StartGameButton.java +++ b/core/src/main/java/group07/beatbattle/ui/components/StartGameButton.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; +import group07.beatbattle.i18n.Strings; public class StartGameButton extends TextButton { @@ -33,7 +34,7 @@ private static TextButtonStyle createStyle(BitmapFont font) { } public StartGameButton(BitmapFont font) { - super("Start Game", createStyle(font)); + super(Strings.startGame(), createStyle(font)); pad(40f, 80f, 40f, 80f); } diff --git a/core/src/main/java/group07/beatbattle/view/GameOverView.java b/core/src/main/java/group07/beatbattle/view/GameOverView.java index 499ca3f..6e5c095 100644 --- a/core/src/main/java/group07/beatbattle/view/GameOverView.java +++ b/core/src/main/java/group07/beatbattle/view/GameOverView.java @@ -18,6 +18,7 @@ import group07.beatbattle.BeatBattle; import group07.beatbattle.controller.LeaderboardController; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.model.LeaderboardEntry; import group07.beatbattle.ui.components.BackButton; @@ -55,16 +56,16 @@ public GameOverView(BeatBattle game, LeaderboardController controller) { root.top(); // Title - root.add(makeLabel("GAME OVER", game.getOrbitronFont(), Color.WHITE)) + root.add(makeLabel(Strings.gameOver(), game.getOrbitronFont(), Color.WHITE)) .padBottom(10f).row(); - root.add(makeLabel("Final Standings", game.getMontserratFont(), Color.LIGHT_GRAY)) + root.add(makeLabel(Strings.finalStandings(), game.getMontserratFont(), Color.LIGHT_GRAY)) .padBottom(50f).row(); // Header row Table header = new Table(); - header.add(makeLabel("#", game.getMontserratFont(), Color.LIGHT_GRAY)).width(80f).left(); - header.add(makeLabel("Player", game.getMontserratFont(), Color.LIGHT_GRAY)).expandX().left(); - header.add(makeLabel("Score", game.getMontserratFont(), Color.LIGHT_GRAY)).width(200f).right(); + header.add(makeLabel("#", game.getMontserratFont(), Color.LIGHT_GRAY)).width(80f).left(); + header.add(makeLabel(Strings.playerCol(), game.getMontserratFont(), Color.LIGHT_GRAY)).expandX().left(); + header.add(makeLabel(Strings.scoreCol(), game.getMontserratFont(), Color.LIGHT_GRAY)).width(200f).right(); root.add(header).fillX().padBottom(20f).row(); // Player rows (all of them for final screen) @@ -78,7 +79,7 @@ public GameOverView(BeatBattle game, LeaderboardController controller) { root.add().expandY().row(); // Back to menu button - BackButton backButton = new BackButton("Back to Menu", game.getMontserratFont()); + BackButton backButton = new BackButton(Strings.backToMenu(), game.getMontserratFont()); backButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { diff --git a/core/src/main/java/group07/beatbattle/view/GameRoundView.java b/core/src/main/java/group07/beatbattle/view/GameRoundView.java index fb0fc6a..eed505f 100644 --- a/core/src/main/java/group07/beatbattle/view/GameRoundView.java +++ b/core/src/main/java/group07/beatbattle/view/GameRoundView.java @@ -22,6 +22,7 @@ import group07.beatbattle.BeatBattle; import group07.beatbattle.controller.RoundController; import group07.beatbattle.ecs.Engine; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.model.Question; import java.util.ArrayList; @@ -111,7 +112,7 @@ public void changed(ChangeEvent event, Actor actor) { infoStyle.font = game.getMontserratFont(); infoStyle.fontColor = Color.LIGHT_GRAY; - Label songLabel = new Label("Now Playing...", infoStyle); + Label songLabel = new Label(Strings.nowPlaying(), infoStyle); songLabel.setAlignment(Align.center); songLabel.setWrap(true); root.add(songLabel).fillX().center().padTop(40f).padBottom(60f).row(); diff --git a/core/src/main/java/group07/beatbattle/view/JoinCreateView.java b/core/src/main/java/group07/beatbattle/view/JoinCreateView.java index 8ab6f85..b2c43fd 100644 --- a/core/src/main/java/group07/beatbattle/view/JoinCreateView.java +++ b/core/src/main/java/group07/beatbattle/view/JoinCreateView.java @@ -14,6 +14,7 @@ import group07.beatbattle.BeatBattle; import group07.beatbattle.controller.LobbyController; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.model.GameMode; import group07.beatbattle.model.SessionCreationResult; import group07.beatbattle.model.services.LobbyService; @@ -63,8 +64,8 @@ public JoinCreateView(BeatBattle game, GameMode mode, LobbyController controller Actor codeComponent = createCodeComponent(); statusLabel = createStatusLabel(); - readyButton = new JoinCreateButton("Ready to play", game.getMontserratFont()); - BackButton backButton = new BackButton("Back", game.getMontserratFont()); + readyButton = new JoinCreateButton(Strings.readyToPlay(), game.getMontserratFont()); + BackButton backButton = new BackButton(Strings.back(), game.getMontserratFont()); roundSelector = new RoundSelector(game.getMontserratFont()); readyButton.addListener(new ChangeListener() { @@ -108,7 +109,7 @@ public void changed(ChangeEvent event, Actor actor) { } private void loadGamePin() { - statusLabel.setText("Generating game code..."); + statusLabel.setText(Strings.generatingCode()); readyButton.setDisabled(true); lobbyService.generateAvailableGamePin(new LobbyService.GamePinCallback() { @@ -116,7 +117,7 @@ private void loadGamePin() { public void onSuccess(String gamePin) { Gdx.app.postRunnable(() -> { generatedGamePin = gamePin; - gameCodeLabel.setText("Game Code: " + gamePin); + gameCodeLabel.setText(Strings.gameCode() + ": " + gamePin); statusLabel.setText(""); readyButton.setDisabled(false); }); @@ -125,7 +126,7 @@ public void onSuccess(String gamePin) { @Override public void onFailure(Exception exception) { Gdx.app.postRunnable(() -> { - statusLabel.setText("Failed to generate game code"); + statusLabel.setText(Strings.failedCode()); readyButton.setDisabled(true); }); } @@ -154,13 +155,13 @@ private Label createTitleLabel() { titleStyle.font = game.getOrbitronFont(); titleStyle.fontColor = Color.WHITE; - String titleText = mode == GameMode.CREATE ? "Create Game" : "Join Game"; + String titleText = mode == GameMode.CREATE ? Strings.createGame() : Strings.joinGame(); return new Label(titleText, titleStyle); } private TextField createPlayerNameField() { TextField textField = new TextField("", InputFieldStyles.createDefault(game.getMontserratFont())); - textField.setMessageText("Enter player name"); + textField.setMessageText(Strings.enterName()); return textField; } @@ -183,13 +184,13 @@ private Label createGeneratedCodeLabel() { textStyle.font = game.getMontserratFont(); textStyle.fontColor = Color.WHITE; - gameCodeLabel = new Label("Game Code: ----", textStyle); + gameCodeLabel = new Label(Strings.gameCode() + ": ----", textStyle); return gameCodeLabel; } private TextField createCodeInputField() { gameCodeField = new TextField("", InputFieldStyles.createDefault(game.getMontserratFont())); - gameCodeField.setMessageText("Enter game code"); + gameCodeField.setMessageText(Strings.enterCode()); return gameCodeField; } diff --git a/core/src/main/java/group07/beatbattle/view/LeaderboardView.java b/core/src/main/java/group07/beatbattle/view/LeaderboardView.java index 5d0155e..7794d09 100644 --- a/core/src/main/java/group07/beatbattle/view/LeaderboardView.java +++ b/core/src/main/java/group07/beatbattle/view/LeaderboardView.java @@ -16,6 +16,7 @@ import group07.beatbattle.BeatBattle; import group07.beatbattle.controller.LeaderboardController; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.model.LeaderboardEntry; import group07.beatbattle.ui.components.BackButton; import group07.beatbattle.ui.components.JoinCreateButton; @@ -54,12 +55,12 @@ public LeaderboardView(BeatBattle game, LeaderboardController controller) { root.top(); // --- Title --- - Label title = new Label("Leaderboard", titleStyle()); + Label title = new Label(Strings.leaderboard(), titleStyle()); root.add(title).padBottom(20f).row(); // --- Round indicator --- Label roundLabel = new Label( - "Round " + controller.getCurrentRound() + " / " + controller.getTotalRounds(), + Strings.round() + " " + controller.getCurrentRound() + " / " + controller.getTotalRounds(), subtitleStyle() ); root.add(roundLabel).padBottom(50f).row(); @@ -67,8 +68,8 @@ public LeaderboardView(BeatBattle game, LeaderboardController controller) { // --- Header row --- Table header = new Table(); header.add(styledLabel("#", Color.LIGHT_GRAY)).width(80f).left(); - header.add(styledLabel("Player", Color.LIGHT_GRAY)).expandX().left(); - header.add(styledLabel("Score", Color.LIGHT_GRAY)).width(200f).right(); + header.add(styledLabel(Strings.playerCol(), Color.LIGHT_GRAY)).expandX().left(); + header.add(styledLabel(Strings.scoreCol(), Color.LIGHT_GRAY)).width(200f).right(); root.add(header).fillX().padBottom(20f).row(); // --- Top 3 rows --- @@ -88,12 +89,12 @@ public LeaderboardView(BeatBattle game, LeaderboardController controller) { root.add().expandY().row(); // --- Countdown label (only shown to host) --- - String countdownPrefix = controller.hasMoreRounds() ? "Next round in " : "Final results in "; - String initialText = controller.isHost() ? countdownPrefix + "3..." : "Waiting for host..."; + String countdownPrefix = controller.hasMoreRounds() ? Strings.nextRoundIn() : Strings.finalResultsIn(); + String initialText = controller.isHost() ? countdownPrefix + "3..." : Strings.waitingForHost(); countdownLabel = new Label(initialText, subtitleStyle()); root.add(countdownLabel).padBottom(30f).row(); - BackButton leaveButton = new BackButton("Leave Session", game.getMontserratFont()); + BackButton leaveButton = new BackButton(Strings.leaveSession(), game.getMontserratFont()); leaveButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { @@ -118,7 +119,7 @@ public void render(float delta) { if (!advanced && controller.isHost()) { timeLeft -= delta; int secs = Math.max(0, (int) Math.ceil(timeLeft)); - String prefix = controller.hasMoreRounds() ? "Next round in " : "Final results in "; + String prefix = controller.hasMoreRounds() ? Strings.nextRoundIn() : Strings.finalResultsIn(); countdownLabel.setText(prefix + secs + "..."); if (timeLeft <= 0) { diff --git a/core/src/main/java/group07/beatbattle/view/LobbyView.java b/core/src/main/java/group07/beatbattle/view/LobbyView.java index ed8f02f..97b18fe 100644 --- a/core/src/main/java/group07/beatbattle/view/LobbyView.java +++ b/core/src/main/java/group07/beatbattle/view/LobbyView.java @@ -21,6 +21,7 @@ import group07.beatbattle.BeatBattle; import group07.beatbattle.controller.LobbyController; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.firebase.FirebaseGateway; import group07.beatbattle.model.GameMode; import group07.beatbattle.model.Player; @@ -138,7 +139,7 @@ private void startListeningToSessionState() { public void onStateChanged(String state, int currentRound) { if ("in_round".equals(state) && !gameStarted && !leavingLobby) { gameStarted = true; - setStatusMessage("Game starting..."); + setStatusMessage(Strings.gameStarting()); game.getFirebaseGateway().getQuestions( sessionId, new FirebaseGateway.GetQuestionsCallback() { @@ -174,7 +175,7 @@ public void onFailure(Exception exception) { private Table createHeader() { Table header = new Table(); - BackButton backButton = new BackButton("Back", game.getMontserratFont()); + BackButton backButton = new BackButton(Strings.back(), game.getMontserratFont()); SettingsButton settingsButton = new SettingsButton(); backButton.addListener(new ChangeListener() { @@ -207,14 +208,12 @@ public void changed(ChangeEvent event, Actor actor) { } private void showLeaveLobbyConfirmation() { - String message = isHost - ? "Leaving will delete the session for everyone.\nDo you want to continue?" - : "Are you sure you want to leave the session?"; + String message = isHost ? Strings.leaveHostMsg() : Strings.leavePlayerMsg(); AlertDialogs.showConfirmation( stage, game.getMontserratFont(), - "Leave lobby", + Strings.leaveLobby(), message, () -> { leavingLobby = true; @@ -226,9 +225,11 @@ private void showLeaveLobbyConfirmation() { private Table createGameCodeSection() { Table table = new Table(); - String pinText = gamePin.isEmpty() ? "Game Code: ----" : "Game Code: " + gamePin; + String pinText = gamePin.isEmpty() + ? Strings.gameCode() + ": ----" + : Strings.gameCode() + ": " + gamePin; - Label label = new Label("Gamecode", infoStyle); + Label label = new Label(Strings.gameCode(), infoStyle); label.setColor(Color.LIGHT_GRAY); Label value = new Label(pinText, titleStyle); @@ -243,7 +244,7 @@ private Table createPartySection() { Table table = new Table(); table.center(); - Label partyLabel = new Label("Party", infoStyle); + Label partyLabel = new Label(Strings.party(), infoStyle); Table partyBox = createPartyBox(); table.add(partyLabel).padBottom(20).row(); @@ -263,7 +264,7 @@ private Table createPartyBox() { Table content = new Table(); playersGrid = new Table(); - statusLabel = new Label("Loading players...", infoStyle); + statusLabel = new Label(Strings.loadingPlayers(), infoStyle); statusLabel.setAlignment(Align.center); content.add(playersGrid).expand().center().row(); @@ -281,7 +282,7 @@ private void updatePlayersGrid(List players) { float cellHeight = 60f; if (players == null || players.isEmpty()) { - playersGrid.add(createPlayerLabel("No players yet")) + playersGrid.add(createPlayerLabel(Strings.noPlayers())) .width(cellWidth).height(cellHeight).pad(15); return; } diff --git a/core/src/main/java/group07/beatbattle/view/SettingsView.java b/core/src/main/java/group07/beatbattle/view/SettingsView.java index 532a25c..c810881 100644 --- a/core/src/main/java/group07/beatbattle/view/SettingsView.java +++ b/core/src/main/java/group07/beatbattle/view/SettingsView.java @@ -12,11 +12,11 @@ import group07.beatbattle.BeatBattle; import group07.beatbattle.controller.SettingsController; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.model.GameMode; import group07.beatbattle.ui.components.BackButton; import group07.beatbattle.ui.components.ApplyButton; import group07.beatbattle.ui.components.LanguageSelector; -import group07.beatbattle.ui.components.RoundSelector; public class SettingsView extends ScreenAdapter { @@ -27,7 +27,10 @@ public class SettingsView extends ScreenAdapter { private final Label.LabelStyle titleStyle; - private final GameMode mode; + /** From home screen — no session context. */ + public SettingsView(BeatBattle game) { + this(game, null, null, null, null, null, false); + } public SettingsView( BeatBattle game, @@ -39,7 +42,6 @@ public SettingsView( boolean isHost ) { this.game = game; - this.mode = mode; this.controller = new SettingsController( game, mode, @@ -69,7 +71,7 @@ public SettingsView( private Table createHeader() { Table header = new Table(); - BackButton backButton = new BackButton("Back", game.getMontserratFont()); + BackButton backButton = new BackButton(Strings.back(), game.getMontserratFont()); backButton.addListener(new ChangeListener() { @Override @@ -97,12 +99,10 @@ private Table createContent() { Table table = new Table(); table.center(); - Label title = new Label("Settings", titleStyle); + Label title = new Label(Strings.settings(), titleStyle); LanguageSelector languageSelector = new LanguageSelector(game.getMontserratFont(), controller.getLanguage()); - RoundSelector roundSelector = new RoundSelector(game.getMontserratFont()); - ApplyButton applyButton = new ApplyButton(game.getMontserratFont()); table.add(title).padBottom(60).row(); @@ -112,9 +112,6 @@ private Table createContent() { .padBottom(60) .row(); - table.add(roundSelector.getActor()) - .width(500).padBottom(60).row(); - table.add(applyButton) .width(600) .height(150); @@ -123,7 +120,6 @@ private Table createContent() { @Override public void changed(ChangeEvent event, Actor actor) { controller.onLanguageChanged(languageSelector.getSelectedLanguage()); - controller.onTurnsChanged(roundSelector.getSelectedRounds()); controller.onApply(); } }); diff --git a/core/src/main/java/group07/beatbattle/view/StartView.java b/core/src/main/java/group07/beatbattle/view/StartView.java index 4b0b033..719818a 100644 --- a/core/src/main/java/group07/beatbattle/view/StartView.java +++ b/core/src/main/java/group07/beatbattle/view/StartView.java @@ -13,7 +13,9 @@ import com.badlogic.gdx.utils.Scaling; import group07.beatbattle.BeatBattle; import group07.beatbattle.controller.LobbyController; +import group07.beatbattle.i18n.Strings; import group07.beatbattle.ui.components.JoinCreateButton; +import group07.beatbattle.ui.components.SettingsButton; public class StartView extends ScreenAdapter { @@ -39,12 +41,27 @@ public StartView(BeatBattle game, LobbyController controller) { float logoWidth = Gdx.graphics.getWidth() * LOGO_WIDTH_RATIO; float logoHeight = calculateScaledHeight(logoTexture, logoWidth); + // Settings button — top-right corner + SettingsButton settingsButton = new SettingsButton(); + settingsButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + game.setScreen(new SettingsView(game)); + } + }); + + Table topBar = new Table(); + topBar.setFillParent(true); + topBar.top().right().pad(20f); + topBar.add(settingsButton).size(80f); + stage.addActor(topBar); + Table root = new Table(); root.setFillParent(true); root.center(); - JoinCreateButton createButton = new JoinCreateButton("Create Game", game.getMontserratFont()); - JoinCreateButton joinButton = new JoinCreateButton("Join Game", game.getMontserratFont()); + JoinCreateButton createButton = new JoinCreateButton(Strings.createGame(), game.getMontserratFont()); + JoinCreateButton joinButton = new JoinCreateButton(Strings.joinGame(), game.getMontserratFont()); createButton.addListener(new ChangeListener() { @Override