use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.
the class LevelEditorView method updateGUIElements.
/**
* Update GUI elements
* screen caption
* level size
* selected object
* object properties
* object 3d transformations
* object data
*/
private void updateGUIElements() {
levelEditorScreenController.setScreenCaption("Level Editor - " + level.getFileName());
levelEditorScreenController.setLevelSize(level.getDimension().getX(), level.getDimension().getZ(), level.getDimension().getY());
if (selectedObjects.size() == 1) {
Entity selectedObject = selectedObjects.get(0);
if (selectedObject != null && selectedObject.getId().startsWith("leveleditor.") == false) {
LevelEditorObject levelEditorObject = level.getObjectById(selectedObject.getId());
PropertyModelClass preset = levelEditorObject.getProperty("preset");
levelEditorScreenController.setObjectProperties(preset != null ? preset.getValue() : "", levelEditorObject.getProperties(), null);
levelEditorScreenController.setObject(selectedObject.getTranslation(), selectedObject.getScale(), selectedObject.getRotations().get(level.getRotationOrder().getAxisXIndex()).getAngle(), selectedObject.getRotations().get(level.getRotationOrder().getAxisYIndex()).getAngle(), selectedObject.getRotations().get(level.getRotationOrder().getAxisZIndex()).getAngle());
// determine center
Vector3 objectCenter = null;
if (levelEditorObject.getEntity().getModel() != null) {
BoundingVolume bv = levelEditorObject.getEntity().getModel().getBoundingBox().clone();
bv.fromBoundingVolumeWithTransformations(bv, levelEditorObject.getTransformations());
objectCenter = bv.getCenter();
} else {
// TODO: this is not the center, applies currently to particle systems
objectCenter = levelEditorObject.getTransformations().getTranslation();
}
//
levelEditorScreenController.setObjectData(levelEditorObject.getId(), levelEditorObject.getDescription(), levelEditorObject.getEntity().getName(), objectCenter);
} else {
levelEditorScreenController.unsetObjectData();
levelEditorScreenController.unsetObject();
levelEditorScreenController.unsetObjectProperties();
}
} else if (selectedObjects.size() > 1) {
levelEditorScreenController.unsetObjectData();
levelEditorScreenController.setObject(new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), 0f, 0f, 0f);
levelEditorScreenController.unsetObjectProperties();
} else if (selectedObjects.size() == 0) {
levelEditorScreenController.unsetObjectData();
levelEditorScreenController.unsetObject();
levelEditorScreenController.unsetObjectProperties();
}
// set up lights
for (int i = 0; i < 4; i++) {
levelEditorScreenController.setLight(i, level.getLightAt(i).getAmbient(), level.getLightAt(i).getDiffuse(), level.getLightAt(i).getSpecular(), level.getLightAt(i).getPosition(), level.getLightAt(i).getConstantAttenuation(), level.getLightAt(i).getLinearAttenuation(), level.getLightAt(i).getQuadraticAttenuation(), level.getLightAt(i).getSpotTo(), level.getLightAt(i).getSpotDirection(), level.getLightAt(i).getSpotExponent(), level.getLightAt(i).getSpotCutOff(), level.getLightAt(i).isEnabled());
}
}
use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.
the class TriggerView method updateGUIElements.
/**
* Init GUI elements
*/
public void updateGUIElements() {
if (entity != null) {
triggerScreenController.setScreenCaption("Trigger - " + entity.getName());
PropertyModelClass preset = entity.getProperty("preset");
triggerScreenController.setEntityProperties(preset != null ? preset.getValue() : null, entity.getProperties(), null);
triggerScreenController.setEntityData(entity.getName(), entity.getDescription());
// trigger
Vector3 dimension = new Vector3();
dimension.set(entity.getModel().getBoundingBox().getMax());
dimension.sub(entity.getModel().getBoundingBox().getMin());
triggerScreenController.setTrigger(dimension.getX(), dimension.getY(), dimension.getZ());
} else {
triggerScreenController.setScreenCaption("Trigger - no trigger loaded");
triggerScreenController.unsetEntityProperties();
triggerScreenController.unsetEntityData();
triggerScreenController.unsetTrigger();
}
}
use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.
the class EntityBaseView method entityPropertyRemove.
/**
* Remove a entity property from model properties
* @param entity
* @param name
* @return success
*/
public boolean entityPropertyRemove(LevelEditorEntity entity, String name) {
if (entity == null)
return false;
// try to remove property
int idx = entity.getPropertyIndex(name);
if (idx != -1 && entity.removeProperty(name) == true) {
// get property first at index that was removed
PropertyModelClass property = entity.getPropertyByIndex(idx);
if (property == null) {
// if current index does not work, take current one -1
property = entity.getPropertyByIndex(idx - 1);
}
// reload model properties
entityBaseSubScreenController.setEntityProperties(entity, null, entity.getProperties(), property == null ? null : property.getName());
//
return true;
}
//
return false;
}
use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.
the class EntityBaseView method entityPropertiesPreset.
/**
* Apply entity property preset
* @param entity
* @param preset id
*/
public void entityPropertiesPreset(LevelEditorEntity entity, String presetId) {
if (entity == null)
return;
// clear entity properties
entity.clearProperties();
// add entity properties by preset if missing
ArrayList<PropertyModelClass> entityPropertyPresetArrayList = LevelPropertyPresets.getInstance().getObjectPropertiesPresets().get(presetId);
if (entityPropertyPresetArrayList != null) {
for (PropertyModelClass entityPropertyPreset : entityPropertyPresetArrayList) {
entity.addProperty(entityPropertyPreset.getName(), entityPropertyPreset.getValue());
}
}
// update entity properties to gui
entityBaseSubScreenController.setEntityProperties(entity, presetId, entity.getProperties(), null);
}
use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.
the class LevelEditorScreenController method setObjectProperties.
/**
* Set up object properties
* @param preset id
* @param object properties
* @param selected name
*/
public void setObjectProperties(String presetId, Iterable<PropertyModelClass> objectProperties, String selectedName) {
objectPropertiesPresets.getController().setDisabled(false);
btnObjectPropertyPresetApply.getController().setDisabled(false);
objectPropertiesListBox.getController().setDisabled(false);
btnObjectPropertyAdd.getController().setDisabled(false);
btnObjectPropertyRemove.getController().setDisabled(false);
btnObjectPropertySave.getController().setDisabled(true);
objectPropertyName.getController().setDisabled(true);
objectPropertyValue.getController().setDisabled(true);
// set up preset
objectPropertiesPresets.getController().setValue(presetId != null ? value.set(presetId) : value.set("none"));
// object properties list box inner
GUIParentNode objectPropertiesListBoxInnerNode = (GUIParentNode) (objectPropertiesListBox.getScreenNode().getNodeById(objectPropertiesListBox.getId() + "_inner"));
// construct XML for sub nodes
int idx = 1;
String objectPropertiesListBoxSubNodesXML = "";
objectPropertiesListBoxSubNodesXML += "<scrollarea-vertical id=\"" + objectPropertiesListBox.getId() + "_inner_scrollarea\" width=\"100%\" height=\"100%\">\n";
for (PropertyModelClass objectProperty : objectProperties) {
objectPropertiesListBoxSubNodesXML += "<selectbox-option text=\"" + GUIParser.escapeQuotes(objectProperty.getName()) + ": " + GUIParser.escapeQuotes(objectProperty.getValue()) + "\" value=\"" + GUIParser.escapeQuotes(objectProperty.getName()) + "\" " + (selectedName != null && objectProperty.getName().equals(selectedName) ? "selected=\"true\" " : "") + "/>\n";
}
objectPropertiesListBoxSubNodesXML += "</scrollarea-vertical>\n";
// inject sub nodes
try {
objectPropertiesListBoxInnerNode.replaceSubNodes(objectPropertiesListBoxSubNodesXML, false);
} catch (Exception e) {
e.printStackTrace();
}
//
onObjectPropertiesSelectionChanged();
}
Aggregations