Esempio n. 1
0
 private void addChunk() {
   if (!cl.addChunk(currentChunk)) {
     JOptionPane.showMessageDialog(null, "Failed to add Chunk since the ID is already in use.");
   } else {
     DefaultListModel<Integer> dlm = (DefaultListModel<Integer>) list.getModel();
     dlm.addElement(currentChunk.getId());
   }
 }
Esempio n. 2
0
 private void createNewChunk() {
   int w = (Integer) widthSpinner.getValue();
   int h = (Integer) heightSpinner.getValue();
   currentChunk = new Chunk(cl.getNextId(), w, h);
   levelDrawer.setSize(w * 16, h * 16);
   levelDrawer.setMap(currentChunk.getMap());
   levelDrawer.setSprites(currentChunk.getSprites());
   levelDrawer.repaint();
 }
Esempio n. 3
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();
   }
 }
Esempio n. 4
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;
  }
Esempio n. 5
0
 private void removeChunk(int id) {
   cl.removeChunk(id);
   DefaultListModel<Integer> dlm = (DefaultListModel<Integer>) list.getModel();
   dlm.removeElement(id);
 }