예제 #1
0
 void openEffect() {
   FileDialog dialog = new FileDialog(editor, "Open Effect", FileDialog.LOAD);
   if (lastDir != null) dialog.setDirectory(lastDir);
   dialog.setVisible(true);
   final String file = dialog.getFile();
   final String dir = dialog.getDirectory();
   if (dir == null || file == null || file.trim().length() == 0) return;
   lastDir = dir;
   ParticleEffect effect = new ParticleEffect();
   try {
     effect.loadEmitters(Gdx.files.absolute(new File(dir, file).getAbsolutePath()));
     editor.effect = effect;
     emitterTableModel.getDataVector().removeAllElements();
     editor.particleData.clear();
   } catch (Exception ex) {
     System.out.println("Error loading effect: " + new File(dir, file).getAbsolutePath());
     ex.printStackTrace();
     JOptionPane.showMessageDialog(editor, "Error opening effect.");
     return;
   }
   for (ParticleEmitter emitter : effect.getEmitters()) {
     emitter.setPosition(
         editor.worldCamera.viewportWidth / 2, editor.worldCamera.viewportHeight / 2);
     emitterTableModel.addRow(new Object[] {emitter.getName(), true});
   }
   editIndex = 0;
   emitterTable.getSelectionModel().setSelectionInterval(editIndex, editIndex);
   editor.reloadRows();
 }
예제 #2
0
 void emitterSelected() {
   int row = emitterTable.getSelectedRow();
   if (row == -1) {
     row = editIndex;
     emitterTable.getSelectionModel().setSelectionInterval(row, row);
   }
   if (row == editIndex) return;
   editIndex = row;
   editor.reloadRows();
 }
예제 #3
0
 void deleteEmitter() {
   if (editor.effect.getEmitters().size == 1) return;
   int row = emitterTable.getSelectedRow();
   if (row == -1) return;
   if (row <= editIndex) {
     int oldEditIndex = editIndex;
     editIndex = Math.max(0, editIndex - 1);
     if (oldEditIndex == row) editor.reloadRows();
   }
   editor.effect.getEmitters().removeIndex(row);
   emitterTableModel.removeRow(row);
   emitterTable.getSelectionModel().setSelectionInterval(editIndex, editIndex);
 }
예제 #4
0
  private void addEmitter(String name, boolean select, final ParticleEmitter emitter) {
    Array<ParticleEmitter> emitters = editor.effect.getEmitters();
    if (emitters.size == 0)
      emitter.setPosition(
          editor.worldCamera.viewportWidth / 2, editor.worldCamera.viewportHeight / 2);
    else {
      ParticleEmitter p = emitters.get(0);
      emitter.setPosition(p.getX(), p.getY());
    }
    emitters.add(emitter);

    emitterTableModel.addRow(new Object[] {name, true});
    if (select) {
      editor.reloadRows();
      int row = emitterTableModel.getRowCount() - 1;
      emitterTable.getSelectionModel().setSelectionInterval(row, row);
    }
  }
예제 #5
0
 void emitterChecked(int index, boolean checked) {
   editor.setEnabled(editor.effect.getEmitters().get(index), checked);
   editor.effect.start();
 }