Fix: Resolving Git Merge Conflicts #253

Merged
j.kropff merged 69 commits from chore/ui-checkstyle-fixes into main 2026-04-11 15:10:58 +02:00
3 changed files with 32 additions and 11 deletions
Showing only changes of commit 1070b5d4b9 - Show all commits
@@ -36,6 +36,12 @@ public class ClientApp {
int port = Integer.parseInt(parts[1]); int port = Integer.parseInt(parts[1]);
LOGGER.info("You've selected the client. It will connect port {} at host {}", port, host); LOGGER.info("You've selected the client. It will connect port {} at host {}", port, host);
Launcher.main(new String[] {}); // Expose the chosen host/port to the UI via system properties so controllers
// (which read System.getProperty("casono.server.host"/"casono.server.port"))
// can obtain the correct connection information.
System.setProperty("casono.server.host", host);
System.setProperty("casono.server.port", Integer.toString(port));
// Forward the original address argument to the launcher as well.
Launcher.main(new String[] { arg });
} }
} }
@@ -30,12 +30,21 @@ public class Casinomainui extends Application {
* @throws IOException If loading the FXML fails. * @throws IOException If loading the FXML fails.
*/ */
public void start(Stage stage) throws IOException { public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = // If the launcher passed an address argument (ip:port), expose it as
new FXMLLoader(getClass().getResource("/ui-structure/Casinomainui.fxml")); // system properties so controllers can read it without embedding defaults.
var raw = getParameters().getRaw();
if (raw != null && raw.size() > 0) {
String arg = raw.get(0);
String[] parts = arg.split(":", 2);
if (parts.length == 2) {
System.setProperty("casono.server.host", parts[0]);
System.setProperty("casono.server.port", parts[1]);
}
}
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/ui-structure/Casinomainui.fxml"));
Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT); Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT);
stage.setTitle("Casono"); stage.setTitle("Casono");
javafx.scene.image.Image icon = javafx.scene.image.Image icon = new javafx.scene.image.Image(
new javafx.scene.image.Image(
getClass().getResource("/images/logoinverted.png").toExternalForm()); getClass().getResource("/images/logoinverted.png").toExternalForm());
stage.getIcons().add(icon); stage.getIcons().add(icon);
stage.setScene(scene); stage.setScene(scene);
@@ -11,8 +11,12 @@ import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
/** 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.
*/
public class CasinomainuiController { public class CasinomainuiController {
private static final Logger LOGGER = LogManager.getLogger(CasinomainuiController.class); private static final Logger LOGGER = LogManager.getLogger(CasinomainuiController.class);
@@ -41,8 +45,10 @@ public class CasinomainuiController {
logoView.setImage(new Image(getClass().getResource("/images/logo.png").toExternalForm())); logoView.setImage(new Image(getClass().getResource("/images/logo.png").toExternalForm()));
translationManager = LobbyButtonTranslationManager.getInstance(); translationManager = LobbyButtonTranslationManager.getInstance();
gridManager = String host = System.getProperty("casono.server.host");
new LobbyButtonGridManager(new javafx.scene.layout.GridPane(), translationManager); int port = Integer.parseInt(System.getProperty("casono.server.port"));
ClientService clientService = new ClientService(host, port);
gridManager = new LobbyButtonGridManager(new javafx.scene.layout.GridPane(), translationManager, clientService);
casinoTable.getChildren().clear(); casinoTable.getChildren().clear();
casinoTable.getChildren().add(gridManager.getGridPane()); casinoTable.getChildren().add(gridManager.getGridPane());
gridManager.renderLobbyButtons(); gridManager.renderLobbyButtons();
@@ -62,13 +68,13 @@ public class CasinomainuiController {
return; return;
} }
int buttonId = nextButtonId++; int buttonId = nextButtonId++;
int lobbyId = gridManager.createLobby();
try { try {
int lobbyId = gridManager.createLobby();
translationManager.addLobbyButton(buttonId, lobbyId); translationManager.addLobbyButton(buttonId, lobbyId);
LOGGER.info("ButtonID: {}, LobbyID: {}", buttonId, lobbyId); LOGGER.info("ButtonID: {}, LobbyID: {}", buttonId, lobbyId);
gridManager.renderLobbyButtons(); gridManager.renderLobbyButtons();
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error while adding lobby button: {}", e.getMessage()); LOGGER.error("Failed to create or add lobby: {}", e.getMessage());
} }
} }
} }