Session.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package eu.oschl.gui;
  2. import eu.oschl.textadventure.Game;
  3. import javafx.application.Application;
  4. import javafx.fxml.FXMLLoader;
  5. import javafx.scene.Scene;
  6. import javafx.stage.Stage;
  7. import java.io.IOException;
  8. import java.util.Objects;
  9. public class Session extends Application {
  10. private static Game game;
  11. private static ActionProcessor actionProcessor;
  12. public static Game getGame() {
  13. return game;
  14. }
  15. public static ActionProcessor getActionProcessor() {
  16. return actionProcessor;
  17. }
  18. public static void launchGui(Game game, String[] args)
  19. {
  20. Session.game = game;
  21. Session.actionProcessor = ActionProcessor.create(game);
  22. Application.launch(Session.class, args);
  23. }
  24. @Override
  25. public void start(Stage stage) throws IOException {
  26. FXMLLoader fxmlLoader = new FXMLLoader(Session.class.getResource("game.fxml"));
  27. Scene scene = new Scene(fxmlLoader.load(), 1280, 720);
  28. String cssPath = Objects.requireNonNull(Session.class.getResource("css/style.css")).toExternalForm();
  29. scene.getStylesheets().add(cssPath);
  30. stage.setTitle("Schmorn");
  31. stage.setScene(scene);
  32. stage.show();
  33. }
  34. }