Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. package com.neet.MapViewer.Main;
  2.  
  3. import java.io.IOException;
  4.  
  5. import com.neet.MapViewer.TileMap.TileMap;
  6. import com.neet.MapViewer.Helper.*;
  7. import javafx.application.Application;
  8. import javafx.application.Platform;
  9. import javafx.fxml.FXMLLoader;
  10. import javafx.scene.Scene;
  11. import javafx.scene.layout.BorderPane;
  12. import javafx.scene.layout.TilePane;
  13. import javafx.stage.Stage;
  14.  
  15. public class Launcher extends Application {
  16. public static Stage primaryStage;
  17. public static TileMap tileMap;
  18.  
  19.  
  20. public BorderPane rootLayout;
  21. public TilePane tilePanel;
  22.  
  23. public static void main(String[] args) {
  24. launch(args);
  25. }
  26.  
  27. @Override
  28. public void start(Stage primaryStage) {
  29. Launcher.primaryStage = primaryStage;
  30. Launcher.primaryStage.setTitle("Map Viewer");
  31.  
  32. Platform.setImplicitExit(false);
  33. initWindowFrame();
  34.  
  35. primaryStage.setOnCloseRequest(event -> { Platform.setImplicitExit(true); });
  36. }
  37.  
  38. public void initWindowFrame(){
  39. Map.loadMap("/Maps/testmap.map");
  40. tileMap = new TileMap();
  41. Img.loadImagesFiles("/Tilesets/testtileset.gif");
  42.  
  43.  
  44. try{
  45. //Initialize scene
  46. FXMLLoader loaderRootLayout = new FXMLLoader();
  47. loaderRootLayout.setLocation(Launcher.class.getResource("/com/neet/MapViewer/Main/MapViewWindow.fxml"));
  48. rootLayout = (BorderPane)loaderRootLayout.load();
  49. Scene scene = new Scene(rootLayout);
  50.  
  51. primaryStage.setResizable(false);
  52. primaryStage.setScene(scene);
  53. primaryStage.show();
  54.  
  55. //Initialize Tile Panel
  56. FXMLLoader loaderTilePanel = new FXMLLoader();
  57. loaderTilePanel.setLocation(Launcher.class.getResource("/com/neet/MapViewer/TileMap/TileMapContainer.fxml"));
  58. tilePanel = (TilePane) loaderTilePanel.load();
  59.  
  60. tilePanel.setPrefColumns(Map.getNumCols());
  61. tilePanel.setPrefRows(Map.getNumRows());
  62. tileMap.render();
  63. tilePanel.getChildren().add(tileMap.mapCanvas);
  64.  
  65. rootLayout.setCenter(tilePanel);
  66.  
  67. } catch(IOException e){
  68. e.printStackTrace();
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement