use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class FileDialogScreenController method setupFileDialogListBox.
/**
* Set up file dialog list box
*/
private void setupFileDialogListBox() {
// set up caption
{
String directory = cwd;
if (directory.length() > 50)
directory = "..." + directory.substring(directory.length() - 50 + 3);
caption.getText().set(captionText).append(directory);
}
// list files
String[] fileList = new String[0];
try {
String directory = cwd;
fileList = FileSystem.getInstance().list(directory, new FilenameFilter() {
public boolean accept(File directory, String file) {
if (new File(directory, file).isDirectory() == true)
return true;
for (String extension : extensions) {
if (file.toLowerCase().endsWith("." + extension))
return true;
}
return false;
}
});
} catch (IOException ioe) {
ioe.printStackTrace();
}
// files inner
GUIParentNode filesInnerNode = (GUIParentNode) (files.getScreenNode().getNodeById(files.getId() + "_inner"));
// construct XML for sub nodes
int idx = 1;
String filesInnerNodeSubNodesXML = "";
filesInnerNodeSubNodesXML += "<scrollarea width=\"100%\" height=\"100%\">\n";
filesInnerNodeSubNodesXML += "<selectbox-option text=\"..\" value=\"..\" />\n";
for (String file : fileList) {
filesInnerNodeSubNodesXML += "<selectbox-option text=\"" + GUIParser.escapeQuotes(file) + "\" value=\"" + GUIParser.escapeQuotes(file) + "\" />\n";
}
filesInnerNodeSubNodesXML += "</scrollarea>\n";
// inject sub nodes
try {
filesInnerNode.replaceSubNodes(filesInnerNodeSubNodesXML, true);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class ParticleSystemScreenController method setParticleSystemTypes.
/**
* Set up particle system types
* @param particle system types
*/
public void setParticleSystemTypes(Collection<String> particleSystemTypesCollection) {
// particle system types inner node
GUIParentNode particleSystemTypesInnerNode = (GUIParentNode) (particleSystemTypes.getScreenNode().getNodeById(particleSystemTypes.getId() + "_inner"));
// construct XML for sub nodes
int idx = 0;
String particleSystemTypesInnerNodeSubNodesXML = "";
particleSystemTypesInnerNodeSubNodesXML += "<scrollarea-vertical id=\"" + particleSystemTypes.getId() + "_inner_scrollarea\" width=\"100%\" height=\"100\">\n";
for (String particleSystem : particleSystemTypesCollection) {
particleSystemTypesInnerNodeSubNodesXML += "<dropdown-option text=\"" + GUIParser.escapeQuotes(particleSystem) + "\" value=\"" + GUIParser.escapeQuotes(particleSystem) + "\" " + (idx == 0 ? "selected=\"true\" " : "") + " />\n";
idx++;
}
particleSystemTypesInnerNodeSubNodesXML += "</scrollarea-vertical>";
// inject sub nodes
try {
particleSystemTypesInnerNode.replaceSubNodes(particleSystemTypesInnerNodeSubNodesXML, true);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class EntityBaseSubScreenController method setEntityProperties.
/**
* Set up entity properties
* @param model
* @param preset id
* @param entity properties
* @param selected name
*/
public void setEntityProperties(LevelEditorEntity model, String presetId, Iterable<PropertyModelClass> entityProperties, String selectedName) {
//
entityPropertiesPresets.getController().setDisabled(false);
entityPropertyPresetApply.getController().setDisabled(false);
entityPropertiesList.getController().setDisabled(false);
entityPropertyAdd.getController().setDisabled(false);
entityPropertyRemove.getController().setDisabled(false);
entityPropertySave.getController().setDisabled(true);
entityPropertyName.getController().setDisabled(true);
entityPropertyValue.getController().setDisabled(true);
// set up preset
entityPropertiesPresets.getController().setValue(presetId != null ? value.set(presetId) : value.set("none"));
// model properties list box inner
GUIParentNode entityPropertiesListBoxInnerNode = (GUIParentNode) (entityPropertiesList.getScreenNode().getNodeById(entityPropertiesList.getId() + "_inner"));
// construct XML for sub nodes
int idx = 1;
String entityPropertiesListBoxSubNodesXML = "";
entityPropertiesListBoxSubNodesXML += "<scrollarea-vertical id=\"" + entityPropertiesList.getId() + "_inner_scrollarea\" width=\"100%\" height=\"100%\">\n";
for (PropertyModelClass entityProperty : entityProperties) {
entityPropertiesListBoxSubNodesXML += "<selectbox-option text=\"" + GUIParser.escapeQuotes(entityProperty.getName()) + ": " + GUIParser.escapeQuotes(entityProperty.getValue()) + "\" value=\"" + GUIParser.escapeQuotes(entityProperty.getName()) + "\" " + (selectedName != null && entityProperty.getName().equals(selectedName) ? "selected=\"true\" " : "") + "/>\n";
}
entityPropertiesListBoxSubNodesXML += "</scrollarea-vertical>\n";
// inject sub nodes
try {
entityPropertiesListBoxInnerNode.replaceSubNodes(entityPropertiesListBoxSubNodesXML, false);
} catch (Exception e) {
e.printStackTrace();
}
//
onEntityPropertiesSelectionChanged(model);
}
use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class EntityBoundingVolumeSubScreenController method setupBoundingVolumeTypes.
/**
* Set up bounding volume types
* @param idx
* @param bounding volume types
*/
public void setupBoundingVolumeTypes(int idx, String[] boundingVolumeTypes) {
// bounding volume types drop downs inner
GUIParentNode boundingVolumeTypeDropDownInnerNode = (GUIParentNode) (boundingVolumeTypeDropDown[idx].getScreenNode().getNodeById(boundingVolumeTypeDropDown[idx].getId() + "_inner"));
// construct XML for sub nodes
int bvIdx = 0;
String boundingVolumeTypeDropDownSubNodesXML = "";
boundingVolumeTypeDropDownSubNodesXML += "<scrollarea-vertical width=\"100%\" height=\"80\">";
for (String bvType : boundingVolumeTypes) {
boundingVolumeTypeDropDownSubNodesXML += "<dropdown-option text=\"" + GUIParser.escapeQuotes(bvType) + "\" value=\"" + +(bvIdx++) + "\" />\n";
}
boundingVolumeTypeDropDownSubNodesXML += "</scrollarea-vertical>";
// inject sub nodes
try {
boundingVolumeTypeDropDownInnerNode.replaceSubNodes(boundingVolumeTypeDropDownSubNodesXML, true);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.drewke.tdme.gui.nodes.GUIParentNode in project tdme by andreasdr.
the class GUITest method init.
/*
* (non-Javadoc)
* @see com.jogamp.opengl.GLEventListener#init(com.jogamp.opengl.GLAutoDrawable)
*/
public void init(GLAutoDrawable drawable) {
// init engine
engine.init(drawable);
// register gui to mouse, keyboard events
glWindow.addMouseListener(engine.getGUI());
glWindow.addKeyListener(engine.getGUI());
//
try {
engine.getGUI().addScreen("test", GUIParser.parse("resources/tests/gui", "test.xml"));
engine.getGUI().getScreen("test").setScreenSize(640, 480);
engine.getGUI().getScreen("test").addActionListener(new GUIActionListener() {
public void onActionPerformed(GUIActionListener.Type type, GUIElementNode node) {
// check if button 1 is pressed
if (type == Type.PERFORMED && node.getName().equals("button")) {
// action performed
System.out.println(node.getId() + ".actionPerformed()");
// test get values
HashMap<String, MutableString> values = new HashMap<String, MutableString>();
node.getScreenNode().getValues(values);
System.out.println(values);
// test set values
values.clear();
values.put("select", new MutableString("8"));
values.put("input", new MutableString("Enter some more text here!"));
values.put("checkbox1", new MutableString("1"));
values.put("checkbox2", new MutableString("1"));
values.put("checkbox3", new MutableString("1"));
values.put("dropdown", new MutableString("11"));
values.put("radio", new MutableString("3"));
values.put("selectmultiple", new MutableString("|1|2|3|15|16|17|"));
node.getScreenNode().setValues(values);
// test GUI tab controller select tab method
((GUITabController) node.getScreenNode().getNodeById("tab1").getController()).selectTab();
} else // check if button 2 is pressed
if (type == Type.PERFORMED && node.getName().equals("button2")) {
try {
{
GUIParentNode parentNode = (GUIParentNode) (node.getScreenNode().getNodeById("sadd_inner"));
parentNode.replaceSubNodes("<dropdown-option text=\"Option 1\" value=\"1\" />" + "<dropdown-option text=\"Option 2\" value=\"2\" />" + "<dropdown-option text=\"Option 3\" value=\"3\" />" + "<dropdown-option text=\"Option 4\" value=\"4\" />" + "<dropdown-option text=\"Option 5\" value=\"5\" />" + "<dropdown-option text=\"Option 6\" value=\"6\" />" + "<dropdown-option text=\"Option 7\" value=\"7\" />" + "<dropdown-option text=\"Option 8\" value=\"8\" selected=\"true\" />" + "<dropdown-option text=\"Option 9\" value=\"9\" />" + "<dropdown-option text=\"Option 10\" value=\"10\" />", true);
}
{
//
GUIParentNode parentNode = (GUIParentNode) (node.getScreenNode().getNodeById("sasb_inner"));
parentNode.replaceSubNodes("<selectbox-option text=\"Option 1\" value=\"1\" />" + "<selectbox-option text=\"Option 2\" value=\"2\" />" + "<selectbox-option text=\"Option 3\" value=\"3\" />" + "<selectbox-option text=\"Option 4\" value=\"4\" selected=\"true\" />" + "<selectbox-option text=\"Option 5\" value=\"5\" />" + "<selectbox-option text=\"Option 6\" value=\"6\" />" + "<selectbox-option text=\"Option 7\" value=\"7\" />" + "<selectbox-option text=\"Option 8\" value=\"8\" />" + "<selectbox-option text=\"Option 9\" value=\"9\" />" + "<selectbox-option text=\"Option 10\" value=\"10\" />", true);
}
} catch (Exception e) {
e.printStackTrace();
}
// test GUI tab controller select tab method
((GUITabController) node.getScreenNode().getNodeById("tab2").getController()).selectTab();
}
}
});
engine.getGUI().getScreen("test").addChangeListener(new GUIChangeListener() {
public void onValueChanged(GUIElementNode node) {
System.out.println(node.getName() + ":onValueChanged: " + node.getController().getValue());
}
});
// layout
engine.getGUI().getScreen("test").layout();
// add fade in effect
GUIColorEffect effectFadeIn = new GUIColorEffect();
effectFadeIn.getColorMulStart().set(0f, 0f, 0f, 1f);
effectFadeIn.getColorMulEnd().set(1f, 1f, 1f, 1f);
effectFadeIn.setTimeTotal(1f);
effectFadeIn.start();
engine.getGUI().getScreen("test").addEffect("fadein", effectFadeIn);
// add scroll in effect
GUIPositionEffect effectScrollIn = new GUIPositionEffect();
effectScrollIn.setPositionXStart(-800f);
effectScrollIn.setPositionXEnd(0f);
effectScrollIn.setTimeTotal(1f);
effectScrollIn.start();
engine.getGUI().getScreen("test").addEffect("scrollin", effectScrollIn);
// add to render queue
engine.getGUI().addRenderScreen("test");
} catch (Exception exception) {
exception.printStackTrace();
}
}
Aggregations