diff --git a/src/main/java/seng302/utilities/Sounds.java b/src/main/java/seng302/utilities/Sounds.java index b929205d..b0bd2209 100644 --- a/src/main/java/seng302/utilities/Sounds.java +++ b/src/main/java/seng302/utilities/Sounds.java @@ -1,6 +1,5 @@ package seng302.utilities; -import javafx.scene.media.AudioClip; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; @@ -45,6 +44,11 @@ public class Sounds { } } + public static void toggleAllSounds() { + toggleMuteEffects(); + toggleMuteMusic(); + } + public static void toggleMuteMusic() { musicMuted = !musicMuted; if (musicPlayer != null) { diff --git a/src/main/java/seng302/visualiser/controllers/ServerListController.java b/src/main/java/seng302/visualiser/controllers/ServerListController.java index d80062c1..a38e2c97 100644 --- a/src/main/java/seng302/visualiser/controllers/ServerListController.java +++ b/src/main/java/seng302/visualiser/controllers/ServerListController.java @@ -5,11 +5,8 @@ import com.jfoenix.controls.JFXDialog; import com.jfoenix.controls.JFXDialog.DialogTransition; import com.jfoenix.controls.JFXTextField; import com.jfoenix.validation.RequiredFieldValidator; -import com.jfoenix.validation.base.ValidatorBase; import java.io.IOException; -import java.net.InetAddress; import java.net.URL; -import java.net.UnknownHostException; import java.util.Arrays; import java.util.List; import java.util.ResourceBundle; @@ -61,7 +58,6 @@ public class ServerListController implements Initializable, ServerListenerDelega private Logger logger = LoggerFactory.getLogger(ServerListController.class); public void initialize(URL location, ResourceBundle resources) { - serverListVBox.minWidthProperty().bind(serverListScrollPane.widthProperty()); // Set Event Bindings diff --git a/src/main/java/seng302/visualiser/controllers/StartScreenController.java b/src/main/java/seng302/visualiser/controllers/StartScreenController.java index a47a72d7..75566eb7 100644 --- a/src/main/java/seng302/visualiser/controllers/StartScreenController.java +++ b/src/main/java/seng302/visualiser/controllers/StartScreenController.java @@ -1,6 +1,10 @@ package seng302.visualiser.controllers; import com.jfoenix.controls.JFXButton; +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -16,11 +20,6 @@ import seng302.gameServer.ServerDescription; import seng302.utilities.Sounds; import seng302.visualiser.GameClient; -import java.io.IOException; -import java.net.URL; -import java.util.List; -import java.util.ResourceBundle; - public class StartScreenController implements Initializable{ //--------FXML BEGIN--------// @@ -34,24 +33,6 @@ public class StartScreenController implements Initializable{ private Logger logger = LoggerFactory.getLogger(StartScreenController.class); private List servers; private GameClient gameClient; -// public void initialize(URL url, ResourceBundle resourceBundle) { -// Sounds.stopMusic(); -// Sounds.stopSoundEffects(); -// Sounds.playMenuMusic(); -// if (Sounds.isMusicMuted()) { -// muteMusicButton.setText("UnMute Music"); -// } else { -// muteMusicButton.setText("Mute Music"); -// } -// if (Sounds.isSoundEffectsMuted()) { -// muteSoundsButton.setText("UnMute Sounds"); -// } else { -// muteSoundsButton.setText("Mute Sounds"); -// } -// Sounds.setMutes(); -//// gameClient = new GameClient(holder); -// } - /** * @@ -99,6 +80,7 @@ public class StartScreenController implements Initializable{ setInitialDropShadow(); preloadServerListView(); + } public void toggleMusic(ActionEvent actionEvent) { diff --git a/src/main/java/seng302/visualiser/controllers/ViewManager.java b/src/main/java/seng302/visualiser/controllers/ViewManager.java index 3d366d22..6f153f24 100644 --- a/src/main/java/seng302/visualiser/controllers/ViewManager.java +++ b/src/main/java/seng302/visualiser/controllers/ViewManager.java @@ -1,16 +1,20 @@ package seng302.visualiser.controllers; +import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXDecorator; import com.jfoenix.controls.JFXDialog; +import com.jfoenix.svg.SVGGlyph; import java.io.IOException; import java.util.HashMap; import javafx.application.Platform; import javafx.collections.ObservableList; import javafx.fxml.FXMLLoader; +import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.image.Image; +import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage; @@ -69,7 +73,8 @@ public class ViewManager { decorator.getStylesheets() .add(getClass().getResource("/css/Master.css").toExternalForm()); - this.decorator = decorator; + setDecorator(decorator); + gameClient = new GameClient(decorator); stage.getIcons().add(new Image(getClass().getResourceAsStream("/PP.png"))); @@ -100,6 +105,53 @@ public class ViewManager { }); } + private void setDecorator(JFXDecorator newDecorator) { + decorator = newDecorator; + + //Injecting a volume toggle into the decorator. + //Get the button box + HBox btns = (HBox) decorator.getChildren().get(0); + + //Create new button + JFXButton btnMute = new JFXButton(); + btnMute.setText(" Toggle Sound"); + btnMute.setStyle("-fx-text-fill:#fff"); + btnMute.getStyleClass().add("jfx-decorator-button"); + btnMute.setCursor(Cursor.HAND); + + //Create Graphics + SVGGlyph spacer = new SVGGlyph(0, "SPACER", "", Color.WHITE); + SVGGlyph volumeOn = new SVGGlyph(0, "VOLUME_ON", + "M39.389,13.769 22.235,28.606 6,28.606 6,47.699 21.989,47.699 39.389,62.75 39.389,13.769 M 48.128,49.03 C 50.057,45.934 51.19,42.291 51.19,38.377 C 51.19,34.399 50.026,30.703 48.043,27.577 M 55.082,20.537 C 58.777,25.523 60.966,31.694 60.966,38.377 C 60.966,44.998 58.815,51.115 55.178,56.076 M 61.71,62.611 C 66.977,55.945 70.128,47.531 70.128,38.378 C 70.128,29.161 66.936,20.696 61.609,14.01", + Color.WHITE); + SVGGlyph volumeOff = new SVGGlyph(0, "VOLUME_ON", + "M39.389,13.769 22.235,28.606 6,28.606 6,47.699 21.989,47.699 39.389,62.75 39.389,13.769", + Color.WHITE); + volumeOn.setSize(16, 16); + volumeOff.setSize(12, 16); + spacer.setSize(40, 16); + + // Determine which graphic should go on the button + if (Sounds.isMusicMuted() && Sounds.isSoundEffectsMuted()) { + btnMute.setGraphic(volumeOff); + } else { + btnMute.setGraphic(volumeOn); + } + + // Add Buttons + btns.getChildren().add(0, spacer); + btns.getChildren().add(0, btnMute); + btnMute.setOnAction((action) -> { + Sounds.toggleAllSounds(); + if (btnMute.getGraphic().equals(volumeOff)) { + btnMute.setGraphic(volumeOn); + } else { + btnMute.setGraphic(volumeOff); + } + }); + + } + private void checkCompatibility() { if (BonjourInstallChecker.isBonjourSupported()) { BonjourInstallChecker.openInstallUrl(); @@ -189,7 +241,7 @@ public class ViewManager { decorator.applyCss(); decorator.getStylesheets() .add(getClass().getResource("/css/Master.css").toExternalForm()); - + setDecorator(decorator); Scene scene = new Scene(decorator); // set key press event to catch key stoke scene.setOnKeyPressed(gameClient::keyPressed); diff --git a/src/main/resources/css/Master.css b/src/main/resources/css/Master.css index 81b106cc..5f73543e 100644 --- a/src/main/resources/css/Master.css +++ b/src/main/resources/css/Master.css @@ -91,3 +91,11 @@ .scroll-bar { -fx-background-insets: 0; } + +.slider .thumb { + -fx-background-color: -fx-pp-theme-color; +} + +.slider .track { + -fx-background-color: -fx-pp-dark-text-color; +} \ No newline at end of file diff --git a/src/main/resources/css/dialogs/ServerCreation.css b/src/main/resources/css/dialogs/ServerCreation.css index c871335f..ddbb3e1e 100644 --- a/src/main/resources/css/dialogs/ServerCreation.css +++ b/src/main/resources/css/dialogs/ServerCreation.css @@ -45,11 +45,3 @@ .maxPlayers { -fx-font-size: 13px; } - -#maxPlayersSlider .thumb { - -fx-background-color: -fx-pp-theme-color; -} - -#maxPlayersSlider .track { - -fx-background-color: -fx-pp-dark-text-color; -} \ No newline at end of file diff --git a/src/main/resources/views/ServerListView.fxml b/src/main/resources/views/ServerListView.fxml index 16fce8ab..b75a4a54 100644 --- a/src/main/resources/views/ServerListView.fxml +++ b/src/main/resources/views/ServerListView.fxml @@ -65,11 +65,6 @@ - - - - - + + + + +