Random as - not sure what's in this submit

This commit is contained in:
bryce
2024-12-02 12:19:14 +13:00
parent 49a34e77ab
commit e4189b454b
15 changed files with 50 additions and 94 deletions

View File

@@ -2,6 +2,7 @@ package com.example.bricklog.view;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
@@ -9,17 +10,22 @@ import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import static javafx.scene.paint.Color.WHITE; import javafx.scene.paint.Color;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import java.util.Objects;
public class SettingsWindow extends BorderPane { public class SettingsWindow extends BorderPane {
private final StackPane contentPane; private final StackPane contentPane;
private final VBox generalSettings; private final VBox generalSettings;
private final VBox serverSettings; private final VBox serverSettings;
private final Label connectionStatus; private final Label connectionStatus;
private final Scene currentScene; // Reference to the main scene for applying styles dynamically
public SettingsWindow(Scene scene) {
this.currentScene = scene; // Pass the main scene
public SettingsWindow() {
// Menu on the left side for navigation // Menu on the left side for navigation
VBox menu = new VBox(); VBox menu = new VBox();
menu.setSpacing(10); menu.setSpacing(10);
@@ -48,6 +54,7 @@ public class SettingsWindow extends BorderPane {
generalSettings.setAlignment(Pos.TOP_LEFT); generalSettings.setAlignment(Pos.TOP_LEFT);
Label themeLabel = new Label("Theme:"); Label themeLabel = new Label("Theme:");
CheckBox darkTheme = new CheckBox("Dark Theme"); CheckBox darkTheme = new CheckBox("Dark Theme");
darkTheme.setOnAction(event -> toggleTheme(darkTheme.isSelected()));
Label layoutLabel = new Label("Layout:"); Label layoutLabel = new Label("Layout:");
CheckBox compactLayout = new CheckBox("Compact Layout"); CheckBox compactLayout = new CheckBox("Compact Layout");
@@ -62,7 +69,7 @@ public class SettingsWindow extends BorderPane {
// Connection Status Label // Connection Status Label
connectionStatus = new Label("Server Status: Not Connected"); connectionStatus = new Label("Server Status: Not Connected");
connectionStatus.setFont(new Font("Arial", 14)); connectionStatus.setFont(new Font("Arial", 14));
connectionStatus.setTextFill(WHITE); connectionStatus.setTextFill(Color.WHITE);
connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;"); connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;");
connectionStatus.setAlignment(Pos.CENTER); connectionStatus.setAlignment(Pos.CENTER);
connectionStatus.setMaxWidth(Double.MAX_VALUE); connectionStatus.setMaxWidth(Double.MAX_VALUE);
@@ -77,7 +84,6 @@ public class SettingsWindow extends BorderPane {
serverSettings.getChildren().addAll(connectionStatus, ipLabel, ipField, connectButton); serverSettings.getChildren().addAll(connectionStatus, ipLabel, ipField, connectButton);
// Add panels to contentPane and show the default panel // Add panels to contentPane and show the default panel
contentPane.getChildren().addAll(generalSettings, serverSettings); contentPane.getChildren().addAll(generalSettings, serverSettings);
showGeneralSettings(); // Default to showing the general settings showGeneralSettings(); // Default to showing the general settings
@@ -97,6 +103,13 @@ public class SettingsWindow extends BorderPane {
generalSettings.setVisible(false); generalSettings.setVisible(false);
} }
// Method to toggle themes
private void toggleTheme(boolean isDarkTheme) {
String theme = isDarkTheme ? "/css/dark-theme.css" : "/css/light-theme.css";
currentScene.getStylesheets().clear(); // Clear existing stylesheets
currentScene.getStylesheets().add(Objects.requireNonNull(getClass().getResource(theme)).toExternalForm());
}
// Method to connect to the server // Method to connect to the server
private void connectToServer(String ipAddress) { private void connectToServer(String ipAddress) {
if (!isValidIPAddress(ipAddress)) { if (!isValidIPAddress(ipAddress)) {
@@ -123,30 +136,8 @@ public class SettingsWindow extends BorderPane {
); );
} }
// DEMO PURPOSES ONLY [Commented out when in production]
// Simulated connection logic for demonstration purposes // Simulated connection logic for demonstration purposes
private boolean simulateServerConnection(String ipAddress) { private boolean simulateServerConnection(String ipAddress) {
if (ipAddress == null || ipAddress.isEmpty()) {
return false; // IP address is invalid
}
// Simulate connection by checking for a specific IP pattern (e.g., localhost)
return ipAddress.equals("127.0.0.1") || ipAddress.startsWith("192.168."); return ipAddress.equals("127.0.0.1") || ipAddress.startsWith("192.168.");
} }
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//PRODUCTION _ UNCOMmENT When Needed for true Server Connectivity
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
private boolean simulateServerConnection(String ipAddress) {
int port = 12345; // Replace with your server's port
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress(ipAddress, port), 3000); // 3-second timeout
return true; // Connection successful
} catch (IOException e) {
return false; // Connection failed
}
}
====================================================================================================== */
} }

View File

@@ -1,19 +0,0 @@
.root {
-fx-background-color: #161616;
background-color: #161616; /* Compatibility fix */
}
.label.title {
-fx-text-fill: #B22222;
-fx-effect: dropshadow(gaussian, white, 2, 0, 0, 0);
}
.table-view {
-fx-font-size: 14px;
font-size: 14px;/* Compatibility fix */
-fx-text-fill: #E0FFFF;
}
.caption {
-fx-text-fill: #C0C0C0;
}

View File

@@ -1,22 +0,0 @@
.toggle-button {
-fx-background-color: #444;
-fx-text-fill: white;
-fx-padding: 5 10;
-fx-border-radius: 5;
-fx-background-radius: 5;
}
.toggle-button:selected {
-fx-background-color: #666;
}
.grid-pane {
-fx-background-color: #f0f0f0;
-fx-padding: 10;
-fx-hgap: 15;
-fx-vgap: 15;
}
.list-view {
-fx-background-color: #f9f9f9;
}

View File

@@ -1,4 +1,7 @@
com\example\bricklog\model\Build.class
com\example\bricklog\BrickLogClientApplication.class com\example\bricklog\BrickLogClientApplication.class
com\example\bricklog\view\MainLayout.class com\example\bricklog\view\MainLayout.class
com\example\bricklog\view\MocPage.class
com\example\bricklog\view\SettingsWindow.class com\example\bricklog\view\SettingsWindow.class
com\example\bricklog\view\KitsetPage.class
com\example\bricklog\view\GalleryLayout.class com\example\bricklog\view\GalleryLayout.class

View File

@@ -2,4 +2,7 @@ C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\controller\SettingsController.java C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\controller\SettingsController.java
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\MainLayout.java C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\MainLayout.java
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\SettingsWindow.java C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\SettingsWindow.java
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\KitsetPage.java
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\GalleryLayout.java C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\GalleryLayout.java
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\MocPage.java
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\model\Build.java