示例#1
0
  public MapEditor(LocalSettings localSettings) throws HeadlessException {
    setTitle(TITLE);
    setSize(WIDTH, HEIGHT);

    this.localSettings = localSettings;

    mainpane = new JDesktopPane();
    mainpane.setSize(WIDTH, HEIGHT);
    mainpane.setBackground(Color.GRAY);
    setContentPane(mainpane);

    LwjglApplicationConfiguration configuration = new LwjglApplicationConfiguration();
    configuration.width = WIDTH;
    configuration.height = HEIGHT;

    levelHolder = new LevelHolder();
    final LwjglCanvas lwjglCanvas = new LwjglCanvas(levelHolder, configuration);
    canvas = lwjglCanvas;
    levelHolderFrame = new JInternalFrame("EnJine2D Map", false, false, false, true);
    levelHolderFrame.setSize(WIDTH, HEIGHT);
    levelHolderFrame.setVisible(true);

    palette = new Palette("Palette", true, false, true, true);
    palette.setVisible(true);
    palette.setLevelHolder(levelHolder);
    levelHolder.setPalette(palette);

    getContentPane().add(palette);
    getContentPane().add(levelHolderFrame);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            levelHolderFrame.getContentPane().add(lwjglCanvas.getCanvas());
            setVisible(true);
          }
        });

    loadSettings();

    levelHolderFrame.addComponentListener(this);
    palette.addComponentListener(this);

    addWindowListener(this);
  }
示例#2
0
  private void saveSettings() {
    if (localSettings != null) {
      localSettings.objectDirectory = levelHolder.getPalette().getDirectoryPath();

      localSettings.mainWidth = this.getWidth();
      localSettings.mainHeight = this.getHeight();

      localSettings.paletteX = palette.getX();
      localSettings.paletteY = palette.getY();
      localSettings.paletteWidth = palette.getWidth();
      localSettings.paletteHeight = palette.getHeight();

      localSettings.levelHolderX = levelHolderFrame.getX();
      localSettings.levelHolderY = levelHolderFrame.getY();
      localSettings.levelHolderWidth = levelHolderFrame.getWidth();
      localSettings.levelHolderHeight = levelHolderFrame.getHeight();

      localSettings.store();
    } else {
      localSettings = new LocalSettings();
    }
  }