예제 #1
0
 private void selectChunk() {
   Chunk sel = cl.getChunk(list.getSelectedValue());
   if (sel != null) {
     currentChunk = sel;
     levelDrawer.setSize(sel.getWidth() * 16, sel.getHeight() * 16);
     widthSpinner.setValue(sel.getWidth());
     heightSpinner.setValue(sel.getHeight());
     levelDrawer.setMap(currentChunk.getMap());
     levelDrawer.setSprites(currentChunk.getSprites());
     levelDrawer.repaint();
   }
 }
예제 #2
0
  /** Create the application. */
  public ChunkEditor() {
    initialize();

    cl = ChunkLibrary.getInstance();
    File clFile = new File("chunkLibrary.res");
    try {
      cl.readLibFromFile(clFile);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }

    // Get chunks and add entries to the list.
    int numOfChunks = cl.getNumOfChunks();
    int id = 0;
    DefaultListModel<Integer> dlm = new DefaultListModel<Integer>();
    while (numOfChunks > 0) {
      Chunk chunk = cl.getChunk(id);
      if (chunk != null) {
        dlm.addElement(chunk.getId());
        --numOfChunks;
      }
      ++id;
    }
    list.setModel(dlm);

    levelDrawer.init();

    createNewChunk();

    populateTileCombo();
    populateEnemyCombo();

    mousePressed = false;
    draw = true;
  }