Search in sources :

Example 1 with Action

use of net.drewke.tdme.gui.events.Action in project tdme by andreasdr.

the class ModelViewerScreenController method onModelSave.

/**
	 * On model save
	 */
public void onModelSave() {
    // try to use entity file name
    String fileName = view.getEntity().getEntityFileName();
    // do we have a entity name?
    if (fileName == null) {
        // nope, take file model filename
        fileName = view.getFileName();
        // and add .tmm
        if (fileName.toLowerCase().endsWith(".tmm") == false) {
            fileName += ".tmm";
        }
    }
    // we only want the file name and not path
    fileName = Tools.getFileName(fileName);
    //
    view.getPopUpsViews().getFileDialogScreenController().show(modelPath.getPath(), "Save from: ", new String[] { "tmm" }, fileName, new Action() {

        public void performAction() {
            try {
                view.saveFile(view.getPopUpsViews().getFileDialogScreenController().getPathName(), view.getPopUpsViews().getFileDialogScreenController().getFileName());
                modelPath.setPath(view.getPopUpsViews().getFileDialogScreenController().getPathName());
                view.getPopUpsViews().getFileDialogScreenController().close();
            } catch (Exception ioe) {
                showErrorPopUp("Warning", ioe.getMessage());
            }
        }
    });
}
Also used : Action(net.drewke.tdme.gui.events.Action) MutableString(net.drewke.tdme.utils.MutableString)

Example 2 with Action

use of net.drewke.tdme.gui.events.Action in project tdme by andreasdr.

the class LevelEditorEntityLibraryScreenController method onValueChanged.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.events.GUIChangeListener#onValueChanged(net.drewke.tdme.gui.nodes.GUIElementNode)
	 */
public void onValueChanged(GUIElementNode node) {
    if (node.getId().equals("entity_library_listbox") == true) {
        onEntitySelectionChanged();
    } else if (node.getId().equals("dropdown_entity_action") == true) {
        if (node.getController().getValue().equals("edit") == true) {
            onEditEntity();
        } else if (node.getController().getValue().equals("delete") == true) {
            onDeleteEntity();
        } else // model
        if (node.getController().getValue().equals("create_model") == true) {
            // model library
            final LevelEditorEntityLibrary entityLibrary = TDMELevelEditor.getInstance().getEntityLibrary();
            //
            popUps.getFileDialogScreenController().show(modelPath, "Load from: ", new String[] { "tmm", "dae", "tm" }, "", new Action() {

                public void performAction() {
                    try {
                        // add model
                        LevelEditorEntity entity = entityLibrary.addModel(LevelEditorEntityLibrary.ID_ALLOCATE, popUps.getFileDialogScreenController().getFileName(), "", popUps.getFileDialogScreenController().getPathName(), popUps.getFileDialogScreenController().getFileName(), new Vector3(0f, 0f, 0f));
                        entity.setDefaultBoundingVolumes();
                        setEntityLibrary();
                        entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(entity.getId()));
                        onEditEntity();
                    } catch (Exception exception) {
                        popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
                    }
                    modelPath = popUps.getFileDialogScreenController().getPathName();
                    popUps.getFileDialogScreenController().close();
                }
            });
        } else // trigger
        if (node.getController().getValue().equals("create_trigger") == true) {
            try {
                LevelEditorEntity model = TDMELevelEditor.getInstance().getEntityLibrary().addTrigger(LevelEditorEntityLibrary.ID_ALLOCATE, "New trigger", "", 1f, 1f, 1f);
                setEntityLibrary();
                entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(model.getId()));
                onEditEntity();
            } catch (Exception exception) {
                popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
            }
        } else // empty
        if (node.getController().getValue().equals("create_empty") == true) {
            try {
                LevelEditorEntity model = TDMELevelEditor.getInstance().getEntityLibrary().addEmpty(LevelEditorEntityLibrary.ID_ALLOCATE, "New empty", "");
                setEntityLibrary();
                entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(model.getId()));
                onEditEntity();
            } catch (Exception exception) {
                popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
            }
        } else // light
        if (node.getController().getValue().equals("create_light") == true) {
        } else // particle
        if (node.getController().getValue().equals("create_particlesystem") == true) {
            try {
                LevelEditorEntity model = TDMELevelEditor.getInstance().getEntityLibrary().addParticleSystem(LevelEditorEntityLibrary.ID_ALLOCATE, "New particle system", "");
                setEntityLibrary();
                entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(model.getId()));
                onEditEntity();
            } catch (Exception exception) {
                popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
            }
        } else {
            System.out.println("LevelEditorEntityLibraryScreenController::onValueChanged: dropdown_model_create: " + node.getController().getValue());
        }
        // reset
        node.getController().setValue(dropdownEntityActionReset);
    } else {
        System.out.println("LevelEditorEntityLibraryScreenController::onValueChanged: " + node.getId());
    }
}
Also used : LevelEditorEntityLibrary(net.drewke.tdme.tools.shared.model.LevelEditorEntityLibrary) Action(net.drewke.tdme.gui.events.Action) Vector3(net.drewke.tdme.math.Vector3) MutableString(net.drewke.tdme.utils.MutableString) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity)

Example 3 with Action

use of net.drewke.tdme.gui.events.Action in project tdme by andreasdr.

the class ParticleSystemScreenController method onActionPerformed.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.events.GUIActionListener#onActionPerformed(net.drewke.tdme.gui.events.GUIActionListener.Type, net.drewke.tdme.gui.nodes.GUIElementNode)
	 */
public void onActionPerformed(Type type, GUIElementNode node) {
    // delegate to model base sub screen controller
    entityBaseSubScreenController.onActionPerformed(type, node, view.getEntity());
    // delegate to display sub screen controller
    entityDisplaySubScreenController.onActionPerformed(type, node);
    // delegate to display bounding volume sub screen controller
    entityBoundingVolumeSubScreenController.onActionPerformed(type, node, view.getEntity());
    // handle own actions
    switch(type) {
        case PERFORMED:
            {
                if (node.getId().equals("button_entity_load")) {
                    onParticleSystemLoad();
                } else if (node.getId().equals("button_entity_reload")) {
                    onParticleSystemReload();
                } else if (node.getId().equals("button_entity_save")) {
                    onEntitySave();
                } else if (node.getId().equals("button_ps_type_apply")) {
                    onParticleSystemTypeApply();
                } else if (node.getId().equals("button_ops_apply") || node.getId().equals("button_pps_type_apply")) {
                    onParticleSystemTypeDataApply();
                } else if (node.getId().equals("button_emitter_apply")) {
                    onParticleSystemEmitterApply();
                } else if (node.getId().equals("button_ppe_emitter_apply") || node.getId().equals("button_bbpe_emitter_apply") || node.getId().equals("button_cpe_emitter_apply") || node.getId().equals("button_cpepv_emitter_apply") || node.getId().equals("button_spe_emitter_apply")) {
                    onParticleSystemEmitterDataApply();
                } else if (node.getId().equals("button_ops_model_file")) {
                    //
                    view.getPopUpsViews().getFileDialogScreenController().show(modelPath.getPath(), "Load from: ", new String[] { "dae", "tm" }, "", new Action() {

                        public void performAction() {
                            opsModel.getController().setValue(value.set(view.getPopUpsViews().getFileDialogScreenController().getPathName() + "/" + view.getPopUpsViews().getFileDialogScreenController().getFileName()));
                            modelPath.setPath(view.getPopUpsViews().getFileDialogScreenController().getPathName());
                            view.getPopUpsViews().getFileDialogScreenController().close();
                        }
                    });
                } else {
                    System.out.println("ModelViewerScreenController::onActionPerformed()::unknown, type='" + type + "', id = '" + node.getId() + "'" + ", name = '" + node.getName() + "'");
                }
                break;
            }
        case PERFORMING:
            {
                // System.out.println("ModelViewerScreenController::onActionPerformed()::unknown, type='" + type + "', id = '" + node.getId() + "'" + ", name = '" + node.getName() + "'");
                break;
            }
    }
}
Also used : Action(net.drewke.tdme.gui.events.Action)

Example 4 with Action

use of net.drewke.tdme.gui.events.Action in project tdme by andreasdr.

the class EntityBoundingVolumeSubScreenController method onBoundingVolumeConvexMeshFile.

/**
	 * On bounding volume convex mesh file clicked
	 * @param entity
	 * @param idx
	 */
public void onBoundingVolumeConvexMeshFile(LevelEditorEntity entity, int idx) {
    final int idxFinal = idx;
    final LevelEditorEntity entityFinal = entity;
    view.getPopUpsViews().getFileDialogScreenController().show(modelPath.getPath(), "Load from: ", new String[] { "dae", "tm" }, entity.getBoundingVolumeAt(idx).getModelMeshFile() != null ? entity.getBoundingVolumeAt(idx).getModelMeshFile() : entity.getFileName(), new Action() {

        public void performAction() {
            boundingvolumeConvexMeshFile[idxFinal].getController().setValue(value.set(view.getPopUpsViews().getFileDialogScreenController().getFileName()));
            onBoundingVolumeConvexMeshApply(entityFinal, idxFinal);
            modelPath.setPath(view.getPopUpsViews().getFileDialogScreenController().getPathName());
            view.getPopUpsViews().getFileDialogScreenController().close();
        }
    });
}
Also used : Action(net.drewke.tdme.gui.events.Action) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity)

Example 5 with Action

use of net.drewke.tdme.gui.events.Action in project tdme by andreasdr.

the class ParticleSystemScreenController method onEntitySave.

/**
	 * On model save
	 */
public void onEntitySave() {
    // try to use entity file name
    String fileName = view.getEntity().getEntityFileName();
    // do we have a entity name?
    if (fileName == null) {
        fileName = "untitle.tps";
    }
    // we only want the file name and not path
    fileName = Tools.getFileName(fileName);
    //
    view.getPopUpsViews().getFileDialogScreenController().show(particleSystemPath.getPath(), "Save from: ", new String[] { "tps" }, fileName, new Action() {

        public void performAction() {
            try {
                view.saveFile(view.getPopUpsViews().getFileDialogScreenController().getPathName(), view.getPopUpsViews().getFileDialogScreenController().getFileName());
                particleSystemPath.setPath(view.getPopUpsViews().getFileDialogScreenController().getPathName());
                view.getPopUpsViews().getFileDialogScreenController().close();
            } catch (Exception ioe) {
                ioe.printStackTrace();
                showErrorPopUp("Warning", ioe.getMessage());
            }
        }
    });
}
Also used : Action(net.drewke.tdme.gui.events.Action) MutableString(net.drewke.tdme.utils.MutableString)

Aggregations

Action (net.drewke.tdme.gui.events.Action)5 MutableString (net.drewke.tdme.utils.MutableString)3 LevelEditorEntity (net.drewke.tdme.tools.shared.model.LevelEditorEntity)2 Vector3 (net.drewke.tdme.math.Vector3)1 LevelEditorEntityLibrary (net.drewke.tdme.tools.shared.model.LevelEditorEntityLibrary)1