changements pour executable x2

This commit is contained in:
Kruss 2020-05-04 14:41:30 +02:00
parent e0b60aff40
commit 745e8597ae
4 changed files with 24 additions and 12 deletions

View File

@ -5,10 +5,12 @@ import java.util.Locale;
import java.util.ResourceBundle;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import main.GestionnaireJeu;
public class Main extends Application {
@ -23,14 +25,21 @@ public class Main extends Application {
primaryStage.setTitle("Shadow Hunters");
primaryStage.setScene(new Scene(root));
primaryStage.centerOnScreen();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent arg0) {
System.exit(0);
}
});
primaryStage.setMaximized(true);
primaryStage.show();
}
public static void main(String[] args) {
System.err.close();
//System.err.close();
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
launch(args);
}
}

View File

@ -1,27 +1,28 @@
package ihm;
import java.io.File;
import java.io.BufferedInputStream;
import java.io.InputStream;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import ihm.controller.ParametreController;
public class Musique {
public static Clip clip;
public static long clipTimePosition = 0;
public static void playMusique(String path) {
public static void playMusique(InputStream path) {
try {
File musicPath = new File(path);
InputStream musicPath = path;
if (musicPath.exists()) {
if (musicPath!=null) {
InputStream bufferedIn = new BufferedInputStream(musicPath);
AudioInputStream audioInput = AudioSystem.getAudioInputStream(musicPath);
AudioInputStream audioInput = AudioSystem.getAudioInputStream(bufferedIn);
clip = AudioSystem.getClip();
clip.open(audioInput);
clip.start();

View File

@ -2,6 +2,7 @@ package ihm.controller;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Locale;
import java.util.ResourceBundle;
@ -32,8 +33,8 @@ public class ParametreController implements Initializable {
public EffetSonore soundEffects = new EffetSonore();
String filepathMusique = "src//ihm//ressources//musique//The_Red_Fox_Tavern.wav"; // lien vers la musique : https://www.youtube.com/watch?v=LBpKUIyOHdo
File fileMusique = new File("src//ihm//ressources//musique//The_Red_Fox_Tavern.wav");
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;
@ -57,12 +58,12 @@ public class ParametreController implements Initializable {
public void enregistre(MouseEvent mouseEvent) throws IOException, Exception {
//Pour la musique
if (fileMusique.exists()) {
if (fileMusique!=null) {
if (cmusique.isSelected() == true) {
coche = true;
if (Musique.clipTimePosition == 0 && MusiqueLancee == false) { // si la musique n'a jamais été lancé
Musique.playMusique(filepathMusique);
Musique.playMusique(fileMusique);
MusiqueLancee = true;
} else {
@ -78,6 +79,7 @@ public class ParametreController implements Initializable {
}
}
else System.out.println("asd");
//Pour les effets sonores
if (cbEffetSonore.isSelected() == true) {

View File

@ -38,7 +38,7 @@ public class PlateauControllerTest implements Initializable {
AnchorPane ap = getAnchorPaneJoueur(i);
Pane p;
try {
p = FXMLLoader.load(getClass().getResource("../ressources/MenuJoueur.fxml"));
p = FXMLLoader.load(getClass().getResource("/ihm/ressources/MenuJoueur.fxml"));
if(i > 1 && i < 3) {
rotateContent(p, 90);
}