Merge branch 'development' of https://github.com/PTE-SH/ShadowHunterGame into development

This commit is contained in:
Paul Gross 2020-05-08 16:44:12 +02:00
commit 02a15030bb
6 changed files with 141 additions and 107 deletions

View File

@ -6,6 +6,7 @@ import java.io.InputStream;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
public class EffetSonore {
@ -13,6 +14,8 @@ public class EffetSonore {
public InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav");
public InputStream fileSound2 = getClass().getResourceAsStream("/ihm/ressources/musique/BeepError.wav");
public static FloatControl volumeEffet;
public static float lvVolumeEffet;
public static void playSoundEffect(InputStream path) {
@ -29,6 +32,10 @@ public class EffetSonore {
AudioInputStream audioInput = AudioSystem.getAudioInputStream(bufferedIn);
Clip clipSound = AudioSystem.getClip();
clipSound.open(audioInput);
volumeEffet = (FloatControl) clipSound.getControl(FloatControl.Type.MASTER_GAIN);
volumeEffet.setValue(lvVolumeEffet);
clipSound.start();
} else {
@ -40,7 +47,6 @@ public class EffetSonore {
}
}
}
public static boolean isSoundOK() {
@ -51,10 +57,8 @@ public class EffetSonore {
EffetSonore.soundOK = soundOK;
}
public static void setVolumeEffets(double dValeur) {
lvVolumeEffet = (float) (dValeur);
}
}

View File

@ -42,7 +42,7 @@ public class MenuController implements Initializable{
System.out.println("Passage à l'écran de choix des joueurs");
final URL fxmlURL = getClass().getResource("/ihm/ressources/Choix_joueur.fxml");
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue);
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
AnchorPane pane = fxmlLoader.load();
Scene scene = new Scene(pane);
@ -60,7 +60,7 @@ public class MenuController implements Initializable{
System.out.println("Passage à l'écran des paramètres");
final URL fxmlURL = getClass().getResource("/ihm/ressources/parametre.fxml");
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue);
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
Pane pane = fxmlLoader.load();
@ -82,7 +82,7 @@ public class MenuController implements Initializable{
EffetSonore.playSoundEffect(fileSound1);
System.out.println("Passage à l'écran des règles");
final URL fxmlURL = getClass().getResource("/ihm/ressources/Regles.fxml");
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue);
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
AnchorPane pane = fxmlLoader.load();
Scene scene = new Scene(pane);

View File

@ -31,21 +31,24 @@ public class ParametreController implements Initializable {
private ComboBox<String> langues;
@FXML
private Slider sliderMusique;
@FXML
private Slider sliderEffets;
public static Locale LaLangue = Locale.FRANCE;
public static boolean cbMusiqueCoche = false; // verifi si la checbox musical est coche
public static boolean cbSonCoche = false;
public static boolean cbClair = false;
public static double slideValue;
public static double slideValueEffets;
public static String langueChoisi;
boolean MusiqueLancee = false; // verifi si la musique a déja été lancé une première fois
String filepathMusique = "/ihm/ressources/musique/The_Red_Fox_Tavern.wav"; // lien vers la musique : https://www.youtube.com/watch?v=LBpKUIyOHdo
String filepathMusique = "/ihm/ressources/musique/The_Red_Fox_Tavern.wav"; // lien vers la musique :
// https://www.youtube.com/watch?v=LBpKUIyOHdo
InputStream fileMusique = getClass().getResourceAsStream("/ihm/ressources/musique/The_Red_Fox_Tavern.wav");
File repertoire = new File("src//ihm//ressources");
File repertoire2;
String liste[] = repertoire.list();
@ -57,7 +60,9 @@ public class ParametreController implements Initializable {
cbEffetSonore.setSelected(cbSonCoche);
clair.setSelected(cbClair);
sliderMusique.setValue(slideValue);
sliderEffets.setValue(slideValueEffets);
System.out.println("slidevalueeffet init = "+ slideValueEffets);
langues.getItems().add("Anglais");
langues.getItems().add("Allemand");
@ -70,6 +75,13 @@ public class ParametreController implements Initializable {
public void enregistre(MouseEvent mouseEvent) throws IOException, Exception {
InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav");
if(langues.getValue()=="Anglais") {
LaLangue=Locale.ENGLISH;
}
else if(langues.getValue()=="Français") {
LaLangue=Locale.FRANCE;
}
// Pour la musique
if (fileMusique != null) {
@ -110,56 +122,48 @@ public class ParametreController implements Initializable {
System.out.println(EffetSonore.isSoundOK());
}
// Pour la couleur du theme
if (clair.isSelected()) {
//Pane root = FXMLLoader.load(getClass().getResource("../ressources/menu.fxml"));
// Pane root =
// FXMLLoader.load(getClass().getResource("../ressources/menu.fxml"));
rootPane.setStyle("-fx-background-color: white;");
rootPane.applyCss();
}
rootPane.setStyle("-fx-background-color: white;");
rootPane.applyCss();
/*if (liste != null) {
for (int i = 0; i < liste.length; i++) {
System.out.println(liste[i]);
System.out.println(i);
repertoire2 = new File("../ressources/" + liste[i]);
if (repertoire.isDirectory() == false) {
if (liste[i] == "Plateau.fxml") {
Pane root1 = FXMLLoader.load(getClass().getResource("../ressources/" + liste[i]));
root1.setStyle("../ressources/style/plateau.css");
}
Pane root1 = FXMLLoader.load(getClass().getResource("../ressources/" + liste[i]));
root1.setStyle("../ressources/style/menuLight.css");
}
}
}
}*/
/*
* if (liste != null) { for (int i = 0; i < liste.length; i++) {
*
* System.out.println(liste[i]); System.out.println(i); repertoire2 = new
* File("../ressources/" + liste[i]);
*
* if (repertoire.isDirectory() == false) { if (liste[i] == "Plateau.fxml") {
* Pane root1 = FXMLLoader.load(getClass().getResource("../ressources/" +
* liste[i])); root1.setStyle("../ressources/style/plateau.css");
*
* } Pane root1 = FXMLLoader.load(getClass().getResource("../ressources/" +
* liste[i])); root1.setStyle("../ressources/style/menuLight.css"); } }
*
* }
*
* }
*/
EffetSonore.playSoundEffect(fileSound1); // emet un bruit sur le bouton si les effets sonores sont activés
System.out.println("slidevalueeffet enregistre = "+ slideValueEffets);
// Quitter les paramètres
final URL fxmlURL = getClass().getResource("/ihm/ressources/Menu.fxml");
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue);
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
Pane pane = fxmlLoader.load();
rootPane.getChildren().setAll(pane);
}
@FXML
@ -170,23 +174,22 @@ public class ParametreController implements Initializable {
slideValue = sliderMusique.getValue();
}
}
public void slideVolumeEffet(MouseEvent mouseEvent) throws IOException {
EffetSonore.setVolumeEffets(sliderEffets.getValue());
slideValueEffets = sliderEffets.getValue();
}
/*
@FXML
public void monterVolume(MouseEvent mouseEvent) throws IOException{
Musique.volumeUp(5.f);
System.out.println("on monte le son");
}
@FXML
public void baisserVolume(MouseEvent mouseEvent) throws IOException{
Musique.volumeDown(5.f);
System.out.println("on baisse le son");
}
*
* @FXML public void monterVolume(MouseEvent mouseEvent) throws IOException{
* Musique.volumeUp(5.f); System.out.println("on monte le son"); }
*
* @FXML public void baisserVolume(MouseEvent mouseEvent) throws IOException{
* Musique.volumeDown(5.f); System.out.println("on baisse le son"); }
*/
}
}

View File

@ -26,13 +26,16 @@ public class PauseController implements Initializable {
private CheckBox cbEffet;
@FXML
private Slider sliderMusiquePause;
@FXML
private Slider sliderEffetsPause;
String filepathMusique = "src//ihm//ressources//musique//The_Red_Fox_Tavern.wav";
InputStream fileMusique = getClass().getResourceAsStream("/ihm/ressources/musique/The_Red_Fox_Tavern.wav");
boolean MusiqueLancee = ParametreController.cbMusiqueCoche;
boolean SonLance = ParametreController.cbSonCoche;
public static double slideValuePause;
public static double slideValueMusiquePause;
public static double slideValueEffetPause;
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
@ -40,6 +43,7 @@ public class PauseController implements Initializable {
cbMusique.setSelected(ParametreController.cbMusiqueCoche);
cbEffet.setSelected(ParametreController.cbSonCoche);
sliderMusiquePause.setValue(ParametreController.slideValue);
sliderEffetsPause.setValue(ParametreController.slideValueEffets);
}
@FXML
@ -83,7 +87,8 @@ public class PauseController implements Initializable {
ParametreController.cbSonCoche = cbEffet.isSelected();
ParametreController.cbMusiqueCoche = cbMusique.isSelected();
ParametreController.slideValue = slideValuePause;
ParametreController.slideValue = slideValueMusiquePause;
ParametreController.slideValueEffets = slideValueEffetPause;
EffetSonore.playSoundEffect(fileSound1); // met un bruit sur le bouton si les effets sonores sont activés
@ -122,13 +127,22 @@ public class PauseController implements Initializable {
if (Musique.musiqueEnCours == true) {
System.out.println("slide");
Musique.setVolume(sliderMusiquePause.getValue());
slideValuePause = sliderMusiquePause.getValue();
slideValueMusiquePause = sliderMusiquePause.getValue();
}else {
System.out.println("probleme");
System.out.println("probleme de slider musique");
}
}
@FXML
public void slideVolumeEffets(MouseEvent mouseEvent) throws IOException {
System.out.println("slide effet");
EffetSonore.setVolumeEffets(sliderEffetsPause.getValue());
slideValueEffetPause = sliderEffetsPause.getValue();
}
/*
@FXML
public void monterVolume(MouseEvent mouseEvent) throws IOException {

View File

@ -48,7 +48,7 @@
</HBox>
<HBox prefHeight="0.0" prefWidth="540.0">
<children>
<Slider fx:id="sliderMusiquePause" blockIncrement="1.0" majorTickUnit="1.0" max="1.0" minorTickCount="10" onMouseClicked="#slideVolumeMusique" prefHeight="14.0" prefWidth="194.0" showTickLabels="true" showTickMarks="true" value="0.1" />
<Slider fx:id="sliderMusiquePause" blockIncrement="1.0" majorTickUnit="1.0" max="1.0" minorTickCount="10" onMouseClicked="#slideVolumeMusique" prefHeight="14.0" prefWidth="194.0" value="0.1" />
</children>
</HBox>
<HBox alignment="CENTER_LEFT">
@ -64,6 +64,11 @@
<CheckBox fx:id="cbEffet" mnemonicParsing="false" />
</children>
</HBox>
<HBox prefHeight="0.0" prefWidth="540.0">
<children>
<Slider fx:id="sliderEffetsPause" blockIncrement="1.0" majorTickUnit="1.0" max="0.0" min="-20.0" minorTickCount="10" onMouseClicked="#slideVolumeEffets" prefHeight="14.0" prefWidth="194.0" />
</children>
</HBox>
<Label style="-fx-border-width: 0 0 0.5 0; -fx-border-color: #e2e2e2;" text="Jeux">
<VBox.margin>
<Insets top="50.0" />

View File

@ -15,12 +15,20 @@
<children>
<HBox alignment="TOP_CENTER" layoutX="146.0" layoutY="171.0" prefHeight="242.0" prefWidth="507.0" spacing="10.0">
<children>
<VBox prefHeight="348.0" prefWidth="195.0" spacing="40.0">
<VBox prefHeight="348.0" prefWidth="195.0" spacing="35.0">
<children>
<CheckBox fx:id="clair" mnemonicParsing="false" styleClass="checkBox" text="%mode.claire" />
<CheckBox fx:id="cmusique" mnemonicParsing="false" styleClass="checkBox" text="%musique" />
<Slider fx:id="sliderMusique" blockIncrement="1.0" majorTickUnit="1.0" max="1.0" minorTickCount="10" onMouseClicked="#slideVolumeMusique" showTickLabels="true" showTickMarks="true" value="0.1" />
<Slider fx:id="sliderMusique" blockIncrement="1.0" majorTickUnit="1.0" max="1.0" minorTickCount="10" onMouseClicked="#slideVolumeMusique" value="0.1">
<padding>
<Insets top="-20.0" />
</padding></Slider>
<CheckBox fx:id="cbEffetSonore" mnemonicParsing="false" styleClass="checkBox" text="%effet" />
<Slider fx:id="sliderEffets" blockIncrement="1.0" layoutX="10.0" layoutY="125.0" majorTickUnit="1.0" max="0.0" min="-20.0" minorTickCount="10" onMouseClicked="#slideVolumeEffet" value="-10.0">
<padding>
<Insets top="-20.0" />
</padding>
</Slider>
<VBox prefHeight="86.0" prefWidth="195.0" spacing="10.0">
<children>
<Label styleClass="titre" text="%langue">