Feat: Adds sounds to game #327
@@ -1,6 +1,7 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui;
|
||||||
|
|
||||||
/** Main UI application for Casono. Loads the main FXML layout and sets up the stage. */
|
/** Main UI application for Casono. Loads the main FXML layout and sets up the stage. */
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.ui.sound.SoundManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
@@ -30,6 +31,9 @@ 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 {
|
||||||
|
// Pre-load sounds to avoid delays on first play
|
||||||
|
SoundManager.getInstance().preloadSounds();
|
||||||
|
|
||||||
// If the launcher passed an address argument (ip:port), expose it as
|
// If the launcher passed an address argument (ip:port), expose it as
|
||||||
// system properties so controllers can read it without embedding defaults.
|
// system properties so controllers can read it without embedding defaults.
|
||||||
var raw = getParameters().getRaw();
|
var raw = getParameters().getRaw();
|
||||||
|
|||||||
+4
@@ -5,6 +5,7 @@ import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatController;
|
|||||||
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
|
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient;
|
import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.HighscoreViewController;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.HighscoreViewController;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.ui.sound.SoundManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@@ -169,6 +170,7 @@ public class CasinomainuiController {
|
|||||||
/** Handles the login button action. Validates input and calls LobbyClient.login(). */
|
/** Handles the login button action. Validates input and calls LobbyClient.login(). */
|
||||||
@FXML
|
@FXML
|
||||||
public void handleLoginButton() {
|
public void handleLoginButton() {
|
||||||
|
SoundManager.getInstance().playButtonClick();
|
||||||
String username = usernameField == null ? null : usernameField.getText();
|
String username = usernameField == null ? null : usernameField.getText();
|
||||||
if (username == null || username.isBlank()) {
|
if (username == null || username.isBlank()) {
|
||||||
showAlert("Please enter a username.");
|
showAlert("Please enter a username.");
|
||||||
@@ -258,6 +260,7 @@ public class CasinomainuiController {
|
|||||||
/** Handles the exit button action to close the application. */
|
/** Handles the exit button action to close the application. */
|
||||||
@FXML
|
@FXML
|
||||||
public void handleexitbutton() {
|
public void handleexitbutton() {
|
||||||
|
SoundManager.getInstance().playButtonClick();
|
||||||
if (chatController != null) {
|
if (chatController != null) {
|
||||||
chatController.shutdown();
|
chatController.shutdown();
|
||||||
}
|
}
|
||||||
@@ -271,6 +274,7 @@ public class CasinomainuiController {
|
|||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
public void handleCreateLobbyButton() {
|
public void handleCreateLobbyButton() {
|
||||||
|
SoundManager.getInstance().playButtonClick();
|
||||||
if (translationManager.isFull()) {
|
if (translationManager.isFull()) {
|
||||||
LOGGER.warn("Grid is full! No more lobbies available.");
|
LOGGER.warn("Grid is full! No more lobbies available.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
@@ -6,6 +6,7 @@ import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
|
|||||||
import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient;
|
import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.CasinoGameUI;
|
import ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.CasinoGameUI;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.server.network.command.parsing.RequestParameter;
|
import ch.unibas.dmi.dbis.cs108.casono.server.network.command.parsing.RequestParameter;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.ui.sound.SoundManager;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -363,6 +364,7 @@ public class LobbyButtonGridManager {
|
|||||||
|
|
||||||
btn.setOnAction(
|
btn.setOnAction(
|
||||||
e -> {
|
e -> {
|
||||||
|
SoundManager.getInstance().playButtonClick();
|
||||||
Integer targetLobbyId = translationManager.getLobbyIdForButton(buttonId);
|
Integer targetLobbyId = translationManager.getLobbyIdForButton(buttonId);
|
||||||
|
|
||||||
if (targetLobbyId != null) {
|
if (targetLobbyId != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user