mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Injected a simple toggle into the decorator for the window for the sound.
Unsure if this is the best way to do it but not a bad thing to try for now. tags : #story[1245] #story[1249]
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<ServerDescription> 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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -65,11 +65,6 @@
|
||||
</ScrollPane>
|
||||
<GridPane>
|
||||
<children>
|
||||
<JFXButton id="hostButton" fx:id="serverListHostButton" buttonType="RAISED" onMouseEntered="#playButtonHoverSound" prefHeight="45.0" prefWidth="220.0" text="HOST" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.valignment="CENTER">
|
||||
<GridPane.margin>
|
||||
<Insets right="50.0" />
|
||||
</GridPane.margin>
|
||||
</JFXButton>
|
||||
<Label text="Party Parrots At Sea" GridPane.valignment="CENTER">
|
||||
<font>
|
||||
<Font size="31.0" />
|
||||
@@ -78,6 +73,14 @@
|
||||
<Insets left="35.0" top="5.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<JFXButton id="hostButton" fx:id="serverListHostButton" buttonType="RAISED"
|
||||
onMouseEntered="#playButtonHoverSound" prefHeight="45.0" prefWidth="220.0"
|
||||
text="HOST" GridPane.columnIndex="1" GridPane.halignment="RIGHT"
|
||||
GridPane.valignment="CENTER">
|
||||
<GridPane.margin>
|
||||
<Insets right="50.0"/>
|
||||
</GridPane.margin>
|
||||
</JFXButton>
|
||||
</children>
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
|
||||
Reference in New Issue
Block a user