mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Added tests for sounds and modified the transparency for the chat history window.
#story[1245]
This commit is contained in:
@@ -26,7 +26,9 @@ public class Sounds {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMutes() {
|
|
||||||
|
|
||||||
|
static void setMutes() {
|
||||||
if (soundPlayer != null) {
|
if (soundPlayer != null) {
|
||||||
soundPlayer.setMute(soundEffectsMuted);
|
soundPlayer.setMute(soundEffectsMuted);
|
||||||
}
|
}
|
||||||
@@ -49,14 +51,14 @@ public class Sounds {
|
|||||||
toggleMuteMusic();
|
toggleMuteMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleMuteMusic() {
|
static void toggleMuteMusic() {
|
||||||
musicMuted = !musicMuted;
|
musicMuted = !musicMuted;
|
||||||
if (musicPlayer != null) {
|
if (musicPlayer != null) {
|
||||||
musicPlayer.setMute(musicMuted);
|
musicPlayer.setMute(musicMuted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleMuteEffects() {
|
static void toggleMuteEffects() {
|
||||||
soundEffectsMuted = !soundEffectsMuted;
|
soundEffectsMuted = !soundEffectsMuted;
|
||||||
if (soundPlayer != null) {
|
if (soundPlayer != null) {
|
||||||
soundPlayer.setMute(soundEffectsMuted);
|
soundPlayer.setMute(soundEffectsMuted);
|
||||||
@@ -188,5 +190,4 @@ public class Sounds {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
@@ -171,6 +173,19 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
rvAnchorPane.setOnMouseClicked((event) ->
|
rvAnchorPane.setOnMouseClicked((event) ->
|
||||||
rvAnchorPane.requestFocus()
|
rvAnchorPane.requestFocus()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Makes the chat history non transparent when clicked on
|
||||||
|
chatInput.focusedProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
|
||||||
|
Boolean newValue) {
|
||||||
|
if (newValue) {
|
||||||
|
chatHistory.increaseOpacity();
|
||||||
|
} else {
|
||||||
|
chatHistory.decreaseOpacity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadRace (
|
public void loadRace (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.jfoenix.controls.JFXTextField;
|
|||||||
import com.jfoenix.validation.RequiredFieldValidator;
|
import com.jfoenix.validation.RequiredFieldValidator;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
@@ -47,6 +48,7 @@ public class ServerCreationController implements Initializable {
|
|||||||
Sounds.playButtonClick();
|
Sounds.playButtonClick();
|
||||||
validateServerSettings();
|
validateServerSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ public class ChatHistory extends ScrollPane {
|
|||||||
this.setMaxWidth(Double.MAX_VALUE);
|
this.setMaxWidth(Double.MAX_VALUE);
|
||||||
this.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
|
this.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
|
||||||
this.setHbarPolicy(ScrollBarPolicy.NEVER);
|
this.setHbarPolicy(ScrollBarPolicy.NEVER);
|
||||||
this.lookup(".scroll-pane").setStyle("-fx-background: rgba(255, 255, 255, 0.1); -fx-background-color: rgba(255, 255, 255, 0.1);");
|
this.lookup(".scroll-pane").setStyle("-fx-background: rgba(135, 206, 235, 0.0); -fx-background-color: rgba(135, 206, 235, 0.0);");
|
||||||
|
|
||||||
this.textFlow.setStyle(
|
this.textFlow.setStyle(
|
||||||
"-fx-background: rgba(255, 255, 255, 0.1); -fx-background-color: rgba(255, 255, 255, 0.1); -fx-padding: 10px"
|
"-fx-background: rgba(135, 206, 235, 0.0); -fx-background-color: rgba(135, 206, 235, 0.0); -fx-padding: 10px"
|
||||||
);
|
);
|
||||||
//This makes the window auto scroll.
|
//This makes the window auto scroll.
|
||||||
textFlow.getChildren().addListener((ListChangeListener<Node>) c ->
|
textFlow.getChildren().addListener((ListChangeListener<Node>) c ->
|
||||||
@@ -71,6 +71,19 @@ public class ChatHistory extends ScrollPane {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void increaseOpacity() {
|
||||||
|
this.lookup(".scroll-pane").setStyle("-fx-background: rgba(255, 255, 255, 0.2); -fx-background-color: rgba(255, 255, 255, 0.2);");
|
||||||
|
|
||||||
|
this.textFlow.setStyle(
|
||||||
|
"-fx-background: rgba(255, 255, 255, 0.2); -fx-background-color: rgba(255, 255, 255, 0.2); -fx-padding: 10px"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decreaseOpacity() {
|
||||||
|
this.lookup(".scroll-pane").setStyle("-fx-background: rgba(135, 206, 235, 0.0); -fx-background-color: rgba(135, 206, 235, 0.0);");
|
||||||
|
|
||||||
|
this.textFlow.setStyle(
|
||||||
|
"-fx-background: rgba(135, 206, 235, 0.0); -fx-background-color: rgba(135, 206, 235, 0.0); -fx-padding: 10px"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package seng302.utilities;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to test the muting functionality of the sounds util
|
||||||
|
* Created by kre39 on 12/09/17.
|
||||||
|
*/
|
||||||
|
public class SoundsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMutes() throws Exception {
|
||||||
|
Sounds.setMutes();
|
||||||
|
Assert.assertFalse(Sounds.isMusicMuted());
|
||||||
|
Assert.assertFalse(Sounds.isSoundEffectsMuted());
|
||||||
|
Sounds.toggleAllSounds();
|
||||||
|
Sounds.toggleMuteEffects();
|
||||||
|
Sounds.toggleMuteMusic();
|
||||||
|
Assert.assertFalse(Sounds.isMusicMuted());
|
||||||
|
Assert.assertFalse(Sounds.isSoundEffectsMuted());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,8 +43,11 @@ public class SendChatSteps {
|
|||||||
ie.printStackTrace();
|
ie.printStackTrace();
|
||||||
}
|
}
|
||||||
mst.startGame();
|
mst.startGame();
|
||||||
Thread.sleep(200);
|
try {
|
||||||
}
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
ie.printStackTrace();
|
||||||
|
} }
|
||||||
|
|
||||||
|
|
||||||
@When("^the first client has sent the message \"([^\"]*)\"$")
|
@When("^the first client has sent the message \"([^\"]*)\"$")
|
||||||
@@ -54,6 +57,11 @@ public class SendChatSteps {
|
|||||||
|
|
||||||
@Then("^the other client should receive the message \"([^\"]*)\"$")
|
@Then("^the other client should receive the message \"([^\"]*)\"$")
|
||||||
public void the_other_client_should_receive_the_message(String arg1) throws Throwable {
|
public void the_other_client_should_receive_the_message(String arg1) throws Throwable {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
ie.printStackTrace();
|
||||||
|
}
|
||||||
Object[] packets = host.getPacketQueue().toArray();
|
Object[] packets = host.getPacketQueue().toArray();
|
||||||
Pair<Integer, String> message = StreamParser.extractChatterText((StreamPacket) packets[packets.length - 1]);
|
Pair<Integer, String> message = StreamParser.extractChatterText((StreamPacket) packets[packets.length - 1]);
|
||||||
Assert.assertEquals("[time_prefix] <name_prefix> " + arg1, message.getValue());
|
Assert.assertEquals("[time_prefix] <name_prefix> " + arg1, message.getValue());
|
||||||
|
|||||||
Reference in New Issue
Block a user