ajout menu pause

This commit is contained in:
Chiara 2020-05-04 16:07:25 +02:00
parent c94e1a46af
commit 8627870e86
5 changed files with 205 additions and 0 deletions

View File

@ -0,0 +1,76 @@
package ihm.controller;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ResourceBundle;
import ihm.EffetSonore;
import ihm.Musique;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
public class PauseController implements Initializable{
@FXML private CheckBox cbMusique;
@FXML private CheckBox cbEffet;
String filepathMusique = "src//ihm//ressources//musique//The_Red_Fox_Tavern.wav";
InputStream fileInput = getClass().getResourceAsStream("src//ihm//ressources//musique//The_Red_Fox_Tavern.wav");
File fileMusique = new File("src//ihm//ressources//musique//The_Red_Fox_Tavern.wav");
public EffetSonore soundEffects = new EffetSonore();
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
// TODO Auto-generated method stub
}
@FXML
public void reprendre(MouseEvent me) {
//Pour la musique
boolean MusiqueLancee = false;
if (fileMusique.exists()) {
if (cbMusique.isSelected()) {
System.out.println("\tLancement de la musique");
if (Musique.clipTimePosition == 0 && MusiqueLancee == false) { // si la musique n'a jamais été lancé
Musique.playMusique(fileInput);
MusiqueLancee = true;
} else Musique.resumeMusique(Musique.clip); // si elle a deja été lancé mais mis en pause, reprend a partir du point d'arret
} else {
Musique.pauseMusique(Musique.clip); //met en pause la musique
System.out.println("\tMise en pause de la musique");
}
}
//Pour les effets sonores
if (cbEffet.isSelected() == true) {
System.out.println("\tEffets sonores activé");
soundEffects.setSoundOK(true);
}else {
System.out.println("\tEffets sonores désactivé");
soundEffects.setSoundOK(false);
}
soundEffects.playSoundEffect("src//ihm//ressources//musique//BEEP1.wav"); //met un bruit sur le bouton si les effets sonores sont activés
System.out.println("Retour au jeu");
Stage appStage = (Stage) ((Node) me.getSource()).getScene().getWindow();
appStage.close();
}
@FXML
public void quitter(MouseEvent me) throws IOException {
System.err.println("Fin de partie");
Stage appStage = (Stage) ((Node) me.getSource()).getScene().getWindow();
appStage.close();
}
}

View File

@ -18,6 +18,7 @@ import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
@ -293,4 +294,16 @@ public class PlateauController implements Initializable {
jIHM.deplacerPionVie(damage);*/
}
@FXML
public void mettreEnPause(MouseEvent me) throws IOException {
System.out.println("Jeu en pause ...");
final URL fxmlURL = getClass().getResource("../ressources/Pause.fxml");
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
Pane root = (Pane)fxmlLoader.load();
PopUp pu = new PopUp(root, "Pause");
pu.display();
}
}

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480.0" prefWidth="640.0" style="-fx-border-color: white; -fx-background-color: black;" stylesheets="@style/popUp.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.PauseController">
<children>
<VBox alignment="TOP_CENTER" prefHeight="480.0" prefWidth="640.0">
<children>
<Label text="Pause">
<font>
<Font size="48.0" />
</font>
</Label>
<VBox>
<children>
<Label style="-fx-border-width: 0 0 0.5 0; -fx-border-color: #e2e2e2;" text="Sons">
<font>
<Font size="18.0" />
</font>
</Label>
<HBox alignment="CENTER_LEFT">
<children>
<Label text="Musique">
<HBox.margin>
<Insets right="300.0" />
</HBox.margin>
<font>
<Font size="14.0" />
</font>
</Label>
<CheckBox fx:id="cbMusique" mnemonicParsing="false">
<HBox.margin>
<Insets bottom="5.0" />
</HBox.margin>
</CheckBox>
</children>
<VBox.margin>
<Insets bottom="5.0" />
</VBox.margin>
</HBox>
<HBox alignment="CENTER_LEFT">
<children>
<Label text="Effet sonores">
<HBox.margin>
<Insets right="273.0" />
</HBox.margin>
<font>
<Font size="14.0" />
</font>
</Label>
<CheckBox fx:id="cbEffet" mnemonicParsing="false" />
</children>
</HBox>
<Label style="-fx-border-width: 0 0 0.5 0; -fx-border-color: #e2e2e2;" text="Jeux">
<VBox.margin>
<Insets top="50.0" />
</VBox.margin>
<font>
<Font size="18.0" />
</font>
</Label>
<HBox>
<VBox.margin>
<Insets top="5.0" />
</VBox.margin>
<children>
<Button mnemonicParsing="false" onMouseClicked="#reprendre" text="Reprendre la partie">
<HBox.margin>
<Insets right="25.0" />
</HBox.margin>
<font>
<Font size="14.0" />
</font>
</Button>
<Button mnemonicParsing="false" onMouseClicked="#quitter" style="-fx-text-fill: red;" text="Quitter le jeu">
<HBox.margin>
<Insets left="25.0" />
</HBox.margin>
<font>
<Font size="14.0" />
</font>
</Button>
</children>
</HBox>
</children>
<VBox.margin>
<Insets top="50.0" />
</VBox.margin>
<padding>
<Insets left="100.0" />
</padding>
</VBox>
</children>
</VBox>
</children>
</AnchorPane>

View File

@ -355,6 +355,18 @@
</GridPane>
</children>
</GridPane>
<Button mnemonicParsing="false" onMouseClicked="#mettreEnPause" styleClass="bouton">
<graphic>
<ImageView fitHeight="44.0" fitWidth="38.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@img/pause.png" />
</image>
</ImageView>
</graphic>
<VBox.margin>
<Insets bottom="-50.0" top="-45.0" />
</VBox.margin>
</Button>
<GridPane fx:id="gridPaneVie" alignment="CENTER" hgap="5.0" vgap="5.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB