diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/CasinomainuiController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/CasinomainuiController.java index 8f50083..5c235cf 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/CasinomainuiController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/CasinomainuiController.java @@ -1,82 +1,56 @@ package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui; -/** - * Controller for the Casono main UI lobby. - * Handles UI initialization and user actions. - */ - -/** - * Controller for the Casono main UI lobby. - * Handles UI initialization and user actions. - */ import javafx.application.Platform; import javafx.fxml.FXML; import javafx.scene.control.Label; -import javafx.scene.layout.AnchorPane; import javafx.scene.control.Button; +import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.shape.Rectangle; -import javafx.application.Platform; -import javafx.fxml.FXML; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.input.MouseEvent; -import javafx.scene.layout.HBox; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; +import javafx.scene.shape.Rectangle; /** * Controller for the Casono main UI lobby. * Handles UI initialization and user actions. - *
- * Standardkonstruktor für den Controller. */ public class CasinomainuiController { - /** - * Default constructor for the controller. - */ - public CasinomainuiController() { - // Default constructor - } - - /** Root pane of the UI. */ @FXML private AnchorPane rootPane; - /** Title label for the main UI. */ @FXML private Label titleLabel; - /** Subtitle label for the main UI. */ @FXML private Label subtitleLabel; - /** Logo image view. */ @FXML - private javafx.scene.image.ImageView logoView; - /** Green box shape element. */ + private ImageView logoView; @FXML - private javafx.scene.shape.Rectangle greenBox; - /** Exit button for closing the application. */ + private Rectangle greenBox; @FXML private Button exitbutton; - /** Casino table VBox for grid rendering. */ @FXML - private javafx.scene.layout.VBox casinoTable; + private VBox casinoTable; private LobbyButtonTranslationManager translationManager; private LobbyButtonGridManager gridManager; private int nextButtonId = 1; + public CasinomainuiController() { + // Default constructor + } + /** * Initializes the UI components and sets default values. */ + @FXML public void initialize() { titleLabel.setText("Casono"); subtitleLabel.setText("Texas Hold'em Poker"); - logoView.setImage(new javafx.scene.image.Image(getClass().getResource("/images/logo.png").toExternalForm())); + logoView.setImage(new Image(getClass().getResource("/images/logo.png").toExternalForm())); translationManager = new LobbyButtonTranslationManager(); gridManager = new LobbyButtonGridManager(new javafx.scene.layout.GridPane(), translationManager); + casinoTable.getChildren().clear(); casinoTable.getChildren().add(gridManager.getGridPane()); gridManager.renderLobbyButtons(); } @@ -108,5 +82,4 @@ public class CasinomainuiController { System.out.println("Fehler beim Hinzufügen: " + e.getMessage()); } } - } diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/LobbyButtonTranslationManager.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/LobbyButtonTranslationManager.java index 60b0f94..e3dd72e 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/LobbyButtonTranslationManager.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/LobbyButtonTranslationManager.java @@ -2,82 +2,34 @@ package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui; import java.util.HashMap; import java.util.Map; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import org.json.JSONObject; /** - * Handles JSON translation between ButtonID and LobbyID. - *
- * Verwaltet das Mapping zwischen Button-IDs und Lobby-IDs, speichert und lädt die Zuordnung aus einer JSON-Datei.
+ * Verwaltet das Mapping zwischen Button-IDs und Lobby-IDs rein im Speicher.
+ * Keine Dateioperationen, nur Laufzeitdatenstruktur.
*/
public class LobbyButtonTranslationManager {
- /**
- * Removes all lobbies from the mapping and saves the file.
- */
- public void clearAllLobbies() {
- buttonIdToLobbyId.clear();
- saveTranslation();
- }
- /** Pfad zur JSON-Translationsdatei. */
- private final String translationFilePath = "src/main/resources/ui-structure/lobby_button_translation.json";
- /** Zuordnung ButtonID → LobbyID. */
+ /** Maximale Anzahl an Buttons/Lobbys */
+ private static final int MAX_BUTTONS = 8;
+ /** Zuordnung ButtonID → LobbyID */
private final Map