use of net.drewke.tdme.utils.MutableString in project tdme by andreasdr.
the class GUIParser method parseGUINode.
/**
* Parse GUI node
* @param gui parent node
* @param xml parent node
* @param gui element
* @throws Exception
*/
private static void parseGUINode(GUIParentNode guiParentNode, Element xmlParentNode, GUIElement guiElement) throws Exception {
//
GUINodeController guiElementController = null;
boolean guiElementControllerInstalled = false;
// parse sub nodes
for (Element node : getChildrenTags(xmlParentNode)) {
if (node.getNodeName().equals("panel")) {
// TODO: validate root node
GUIPanelNode guiPanelNode = new GUIPanelNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUIParentNode.createOverflow(node.getAttribute("overflow-x")), GUIParentNode.createOverflow(node.getAttribute("overflow-y")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUIParentNode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), new GUIColor("#F0F0F0")), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), GUILayoutNode.createAlignment(node.getAttribute("alignment")));
guiParentNode.addSubNode(guiPanelNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiPanelNode);
if (guiElementController != null) {
guiPanelNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
// parse child nodes
parseGUINode(guiPanelNode, node, null);
} else if (node.getNodeName().equals("layout")) {
// TODO: validate root node
GUILayoutNode guiLayoutNode = new GUILayoutNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUIParentNode.createOverflow(node.getAttribute("overflow-x")), GUIParentNode.createOverflow(node.getAttribute("overflow-y")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUIParentNode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), GUILayoutNode.createAlignment(node.getAttribute("alignment")));
guiParentNode.addSubNode(guiLayoutNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiLayoutNode);
if (guiElementController != null) {
guiLayoutNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
// parse child nodes
parseGUINode(guiLayoutNode, node, null);
} else if (node.getNodeName().equals("space")) {
// TODO: validate root node
GUISpaceNode guiSpaceNode = new GUISpaceNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUISpaceNode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")));
guiParentNode.addSubNode(guiSpaceNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiSpaceNode);
if (guiElementController != null) {
guiSpaceNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
} else if (node.getNodeName().equals("element")) {
// TODO: validate root node
GUIElementNode guiElementNode = new GUIElementNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUIParentNode.createOverflow(node.getAttribute("overflow-x")), GUIParentNode.createOverflow(node.getAttribute("overflow-y")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUINode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), unescapeQuotes(node.getAttribute("name")), unescapeQuotes(node.getAttribute("value")), node.getAttribute("selected").trim().equalsIgnoreCase("true"), node.getAttribute("disabled").trim().equalsIgnoreCase("true"), node.getAttribute("focusable").trim().equalsIgnoreCase("true"), node.getAttribute("ignore-events").trim().equalsIgnoreCase("true"));
guiParentNode.addSubNode(guiElementNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiElementNode);
if (guiElementController != null) {
guiElementNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
// parse child nodes
parseGUINode(guiElementNode, node, null);
} else if (node.getNodeName().equals("image")) {
// TODO: validate root node
GUIImageNode guiImageNode = new GUIImageNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUINode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), unescapeQuotes(node.getAttribute("src")), GUINode.getRequestedColor(node.getAttribute("effect-color-mul"), GUIColor.EFFECT_COLOR_MUL), GUINode.getRequestedColor(node.getAttribute("effect-color-add"), GUIColor.EFFECT_COLOR_ADD));
guiParentNode.addSubNode(guiImageNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiImageNode);
if (guiElementController != null) {
guiImageNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
} else if (node.getNodeName().equals("text")) {
// TODO: validate root node
GUITextNode guiTextNode = new GUITextNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUINode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), node.getAttribute("font"), node.getAttribute("color"), new MutableString(unescapeQuotes(node.getAttribute("text"))));
guiParentNode.addSubNode(guiTextNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiTextNode);
if (guiElementController != null) {
guiTextNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
} else if (node.getNodeName().equals("input-internal")) {
// TODO: validate root node
GUIInputInternalNode guiInputInternalNode = new GUIInputInternalNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUINode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), node.getAttribute("font"), node.getAttribute("color"), node.getAttribute("color-disabled"), new MutableString(unescapeQuotes(node.getAttribute("text"))), GUIInputInternalNode.createMaxLength(node.getAttribute("maxlength")));
guiParentNode.addSubNode(guiInputInternalNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiInputInternalNode);
if (guiElementController != null) {
guiInputInternalNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
} else if (node.getNodeName().equals("vertical-scrollbar-internal")) {
// TODO: validate root node
GUIVerticalScrollbarInternalNode guiVerticalScrollbarInternalNode = new GUIVerticalScrollbarInternalNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUINode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), GUINode.getRequestedColor(node.getAttribute("color-none"), GUIColor.BLACK), GUINode.getRequestedColor(node.getAttribute("color-mouseover"), GUIColor.BLACK), GUINode.getRequestedColor(node.getAttribute("color-dragging"), GUIColor.BLACK));
guiParentNode.addSubNode(guiVerticalScrollbarInternalNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiVerticalScrollbarInternalNode);
if (guiElementController != null) {
guiVerticalScrollbarInternalNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
} else if (node.getNodeName().equals("horizontal-scrollbar-internal")) {
// TODO: validate root node
GUIHorizontalScrollbarInternalNode guiHorizontalScrollbarInternalNode = new GUIHorizontalScrollbarInternalNode(guiParentNode.getScreenNode(), guiParentNode, node.getAttribute("id"), GUINode.createFlow(node.getAttribute("flow")), GUINode.createAlignments(node.getAttribute("horizontal-align"), node.getAttribute("vertical-align")), GUINode.createRequestedConstraints(node.getAttribute("left"), node.getAttribute("top"), node.getAttribute("width"), node.getAttribute("height")), GUINode.getRequestedColor(node.getAttribute("background-color"), GUIColor.TRANSPARENT), GUINode.createBorder(node.getAttribute("border"), node.getAttribute("border-left"), node.getAttribute("border-top"), node.getAttribute("border-right"), node.getAttribute("border-bottom"), node.getAttribute("border-color"), node.getAttribute("border-color-left"), node.getAttribute("border-color-top"), node.getAttribute("border-color-right"), node.getAttribute("border-color-bottom")), GUINode.createPadding(node.getAttribute("padding"), node.getAttribute("padding-left"), node.getAttribute("padding-top"), node.getAttribute("padding-right"), node.getAttribute("padding-bottom")), GUINode.createConditions(node.getAttribute("show-on")), GUINode.createConditions(node.getAttribute("hide-on")), GUINode.getRequestedColor(node.getAttribute("color-none"), GUIColor.BLACK), GUINode.getRequestedColor(node.getAttribute("color-mouseover"), GUIColor.BLACK), GUINode.getRequestedColor(node.getAttribute("color-dragging"), GUIColor.BLACK));
guiParentNode.addSubNode(guiHorizontalScrollbarInternalNode);
// install gui element controller if not yet done
if (guiElement != null && guiElementControllerInstalled == false) {
guiElementController = guiElement.createController(guiHorizontalScrollbarInternalNode);
if (guiElementController != null) {
guiHorizontalScrollbarInternalNode.setController(guiElementController);
}
guiElementControllerInstalled = true;
}
} else {
// Try to load from GUI elements
GUIElement newGuiElement = elements.get(node.getNodeName());
if (newGuiElement == null) {
throw new GUIParserException("Unknown element '" + node.getNodeName() + "'");
}
// create final template, replace attributes
String newGuiElementTemplate = newGuiElement.getTemplate();
for (int i = 0; i < node.getAttributes().getLength(); i++) {
Node attribute = node.getAttributes().item(i);
newGuiElementTemplate = newGuiElementTemplate.replace("{$" + attribute.getNodeName() + "}", escapeQuotes(attribute.getNodeValue()));
}
HashMap<String, String> newGuiElementAttributes = newGuiElement.getAttributes(guiParentNode.getScreenNode());
for (String newGuiElementAttributeKey : newGuiElementAttributes.getKeysIterator()) {
String guiElementAttributeValue = escapeQuotes(newGuiElementAttributes.get(newGuiElementAttributeKey));
newGuiElementTemplate = newGuiElementTemplate.replace("{$" + newGuiElementAttributeKey + "}", guiElementAttributeValue);
}
newGuiElementTemplate = newGuiElementTemplate.replace("{$innerXml}", getInnerXml(node));
// create xml document and parse
DocumentBuilder newGuiElementBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document newGuiElementDocument = newGuiElementBuilder.parse(new ByteArrayInputStream(new String("<gui-element>\n" + newGuiElementTemplate + "</gui-element>\n").getBytes()));
parseGUINode(guiParentNode, newGuiElementDocument.getDocumentElement(), newGuiElement);
}
}
// if we have a GUI element controller just init it, after element has been loaded
if (guiElementController != null) {
guiElementController.init();
}
}
use of net.drewke.tdme.utils.MutableString in project tdme by andreasdr.
the class GUIScreenNode method setValues.
/**
* Set values
* @param values
*/
public void setValues(HashMap<String, MutableString> values) {
// determine screen child controller nodes
getChildControllerNodes(childControllerNodes);
// iterate nodes
for (int i = 0; i < childControllerNodes.size(); i++) {
GUINode childControllerNode = childControllerNodes.get(i);
// skip on non element nodes
if (childControllerNode instanceof GUIElementNode == false)
continue;
// cast to element node
GUIElementNode guiElementNode = ((GUIElementNode) childControllerNode);
// get controller
GUINodeController guiElementNodeController = guiElementNode.getController();
// does the controller provides a value
if (guiElementNodeController.hasValue()) {
String name = guiElementNode.getName();
MutableString newValue = values.get(name);
if (newValue == null)
continue;
guiElementNodeController.setValue(newValue);
}
}
}
use of net.drewke.tdme.utils.MutableString in project tdme by andreasdr.
the class EntityBoundingVolumeSubScreenController method init.
/**
* Init
* @param screen node
*/
public void init(GUIScreenNode screenNode) {
value = new MutableString();
// load screen node
try {
// we have fixed 8 BVs per object currently
boundingVolumeTypeDropDown = new GUIElementNode[8];
boundingVolumeNoneApply = new GUIElementNode[8];
boundingVolume = new GUIElementNode[8];
boundingvolumeSphereCenter = new GUIElementNode[8];
boundingvolumeSphereRadius = new GUIElementNode[8];
boundingvolumeCapsuleA = new GUIElementNode[8];
boundingvolumeCapsuleB = new GUIElementNode[8];
boundingvolumeCapsuleRadius = new GUIElementNode[8];
boundingvolumeBoundingBoxMin = new GUIElementNode[8];
boundingvolumeBoundingBoxMax = new GUIElementNode[8];
boundingvolumeObbCenter = new GUIElementNode[8];
boundingvolumeObbCenter = new GUIElementNode[8];
boundingvolumeObbHalfextension = new GUIElementNode[8];
boundingvolumeObbRotationX = new GUIElementNode[8];
boundingvolumeObbRotationY = new GUIElementNode[8];
boundingvolumeObbRotationZ = new GUIElementNode[8];
boundingvolumeConvexMeshFile = new GUIElementNode[8];
for (int i = 0; i < 8; i++) {
boundingVolumeTypeDropDown[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_type_" + i);
boundingVolumeNoneApply[i] = (GUIElementNode) screenNode.getNodeById("button_boundingvolume_apply_" + i);
boundingVolume[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_" + i);
boundingvolumeSphereCenter[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_sphere_center_" + i);
boundingvolumeSphereRadius[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_sphere_radius_" + i);
boundingvolumeCapsuleA[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_capsule_a_" + i);
boundingvolumeCapsuleB[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_capsule_b_" + i);
boundingvolumeCapsuleRadius[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_capsule_radius_" + i);
boundingvolumeBoundingBoxMin[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_aabb_min_" + i);
boundingvolumeBoundingBoxMax[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_aabb_max_" + i);
boundingvolumeObbCenter[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_obb_center_" + i);
boundingvolumeObbCenter[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_obb_center_" + i);
boundingvolumeObbHalfextension[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_obb_halfextension_" + i);
boundingvolumeObbRotationX[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_obb_rotation_x_" + i);
boundingvolumeObbRotationY[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_obb_rotation_y_" + i);
boundingvolumeObbRotationZ[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_obb_rotation_z_" + i);
boundingvolumeConvexMeshFile[i] = (GUIElementNode) screenNode.getNodeById("boundingvolume_convexmesh_file_" + i);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.drewke.tdme.utils.MutableString 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();
}
}
use of net.drewke.tdme.utils.MutableString in project tdme by andreasdr.
the class LevelEditorScreenController method init.
/*
* (non-Javadoc)
* @see net.drewke.tdme.tools.shared.controller.ScreenController#init()
*/
public void init() {
try {
screenNode = GUIParser.parse("resources/tools/leveleditor/gui", "screen_leveleditor.xml");
screenNode.addActionListener(this);
screenNode.addChangeListener(this);
//
screenCaption = (GUITextNode) screenNode.getNodeById("screen_caption");
gridEnabled = (GUIElementNode) screenNode.getNodeById("grid_enabled");
gridYPosition = (GUIElementNode) screenNode.getNodeById("grid_y_position");
mapWidth = (GUIElementNode) screenNode.getNodeById("map_width");
mapDepth = (GUIElementNode) screenNode.getNodeById("map_depth");
mapHeight = (GUIElementNode) screenNode.getNodeById("map_height");
mapPropertyName = (GUIElementNode) screenNode.getNodeById("map_property_name");
mapPropertyValue = (GUIElementNode) screenNode.getNodeById("map_property_value");
mapPropertySave = (GUIElementNode) screenNode.getNodeById("button_map_properties_save");
mapPropertyRemove = (GUIElementNode) screenNode.getNodeById("button_map_properties_remove");
mapPropertiesListBox = (GUIElementNode) screenNode.getNodeById("map_properties_listbox");
objectName = (GUIElementNode) screenNode.getNodeById("object_name");
objectDescription = (GUIElementNode) screenNode.getNodeById("object_description");
objectModel = (GUIElementNode) screenNode.getNodeById("object_model");
objectCenter = (GUIElementNode) screenNode.getNodeById("object_center");
btnObjectDataApply = (GUIElementNode) screenNode.getNodeById("button_objectdata_apply");
btnObjectTranslationApply = (GUIElementNode) screenNode.getNodeById("button_translation_apply");
btnObjectScaleApply = (GUIElementNode) screenNode.getNodeById("button_scale_apply");
btnObjectRotationApply = (GUIElementNode) screenNode.getNodeById("button_rotation_apply");
btnObjectColor = (GUIElementNode) screenNode.getNodeById("button_object_color");
btnObjectCenter = (GUIElementNode) screenNode.getNodeById("button_object_center");
btnObjectRemove = (GUIElementNode) screenNode.getNodeById("button_object_remove");
objectTranslationX = (GUIElementNode) screenNode.getNodeById("object_translation_x");
objectTranslationY = (GUIElementNode) screenNode.getNodeById("object_translation_y");
objectTranslationZ = (GUIElementNode) screenNode.getNodeById("object_translation_z");
objectScaleX = (GUIElementNode) screenNode.getNodeById("object_scale_x");
objectScaleY = (GUIElementNode) screenNode.getNodeById("object_scale_y");
objectScaleZ = (GUIElementNode) screenNode.getNodeById("object_scale_z");
objectRotationX = (GUIElementNode) screenNode.getNodeById("object_rotation_x");
objectRotationY = (GUIElementNode) screenNode.getNodeById("object_rotation_y");
objectRotationZ = (GUIElementNode) screenNode.getNodeById("object_rotation_z");
objectPropertyName = (GUIElementNode) screenNode.getNodeById("object_property_name");
objectPropertyValue = (GUIElementNode) screenNode.getNodeById("object_property_value");
btnObjectPropertySave = (GUIElementNode) screenNode.getNodeById("button_object_properties_save");
btnObjectPropertyRemove = (GUIElementNode) screenNode.getNodeById("button_object_properties_remove");
btnObjectPropertyAdd = (GUIElementNode) screenNode.getNodeById("button_object_properties_add");
btnObjectPropertyRemove = (GUIElementNode) screenNode.getNodeById("button_object_properties_remove");
btnObjectPropertyPresetApply = (GUIElementNode) screenNode.getNodeById("button_object_properties_presetapply");
objectPropertiesListBox = (GUIElementNode) screenNode.getNodeById("object_properties_listbox");
objectPropertiesPresets = (GUIElementNode) screenNode.getNodeById("object_properties_presets");
objectsListBox = (GUIElementNode) screenNode.getNodeById("objects_listbox");
mapWidth.getController().setDisabled(true);
mapDepth.getController().setDisabled(true);
mapHeight.getController().setDisabled(true);
objectModel.getController().setDisabled(true);
objectCenter.getController().setDisabled(true);
//
lightsPresets = new GUIElementNode[4];
lightsAmbient = new GUIElementNode[4];
lightsDiffuse = new GUIElementNode[4];
lightsSpecular = new GUIElementNode[4];
lightsPosition = new GUIElementNode[4];
lightsConstAttenuation = new GUIElementNode[4];
lightsLinAttenuation = new GUIElementNode[4];
lightsQuadAttenuation = new GUIElementNode[4];
lightsSpotTo = new GUIElementNode[4];
lightsSpotDirection = new GUIElementNode[4];
lightsSpotExponent = new GUIElementNode[4];
lightsSpotCutoff = new GUIElementNode[4];
ligthsSpotDirectionCompute = new GUIElementNode[4];
lightsEnabled = new GUIElementNode[4];
for (int i = 0; i < 4; i++) {
lightsPresets[i] = (GUIElementNode) screenNode.getNodeById("presets_light" + i);
lightsAmbient[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_ambient");
lightsDiffuse[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_diffuse");
lightsSpecular[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_specular");
lightsPosition[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_position");
lightsLinAttenuation[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_linear_attenuation");
lightsConstAttenuation[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_constant_attenuation");
lightsQuadAttenuation[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_quadratic_attenuation");
lightsSpotTo[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_spot_to");
lightsSpotDirection[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_spot_direction");
lightsSpotExponent[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_spot_exponent");
lightsSpotCutoff[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_spot_cutoff");
ligthsSpotDirectionCompute[i] = (GUIElementNode) screenNode.getNodeById("button_light" + i + "_spotdirection_compute");
lightsEnabled[i] = (GUIElementNode) screenNode.getNodeById("light" + i + "_enabled");
}
value = new MutableString();
selectedObjects = new MutableString();
selectedObjectList = new ArrayList<String>();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations