added a Dialog sequence for when the server is not up, which was previously just a log msg. Now the user gets to provide their own server.

This commit is contained in:
Rithvik Sriram 2026-01-21 22:48:07 +01:00
commit 110e5e8163
4 changed files with 208 additions and 9 deletions

View file

@ -2,6 +2,7 @@ package client;
import client.scenes.FoodpalApplicationCtrl;
import client.scenes.MainCtrl;
import client.scenes.ServerConnectionDialogCtrl;
import client.utils.server.ServerUtils;
import com.google.inject.Injector;
import javafx.application.Application;
@ -27,9 +28,14 @@ public class UI extends Application {
var serverUtils = INJECTOR.getInstance(ServerUtils.class);
if (!serverUtils.isServerAvailable()) {
var msg = "Server needs to be started before the client, but it does not seem to be available. Shutting down.";
System.err.println(msg);
return;
var connectionHandler = INJECTOR.getInstance(ServerConnectionDialogCtrl.class);
boolean serverConnected = connectionHandler.promptForURL();
if(!serverConnected){
var msg = "User Cancelled Server connection. Shutting down";
System.err.print(msg);
return;
}
}
var foodpal = FXML.load(FoodpalApplicationCtrl.class, "client", "scenes", "FoodpalApplication.fxml");