86 #define AVOID_NULLPTR_STRING(arg) (arg == nullptr?"":arg)
143 class FindAction:
public virtual Action
146 void performAction()
override {
147 if (uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText().empty() ==
true) {
148 uiEditorTabController->showInfoPopUp(
"Find",
"No find string given.");
150 if (uiEditorTabController->view->find(
151 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText(),
152 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isMatchCase(),
153 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isWholeWordOnly(),
154 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isInSelectionOnly(),
155 uiEditorTabController->firstSearch,
156 uiEditorTabController->searchIndex
158 uiEditorTabController->showInfoPopUp(
"Find",
"Text not found.");
160 uiEditorTabController->firstSearch =
false;
163 FindAction(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
169 class CountAction:
public virtual Action
172 void performAction()
override {
173 if (uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText().empty() ==
true) {
174 uiEditorTabController->showInfoPopUp(
"Count",
"No find string given.");
176 auto count = uiEditorTabController->view->count(
177 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText(),
178 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isMatchCase(),
179 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isWholeWordOnly(),
180 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isInSelectionOnly()
182 uiEditorTabController->showInfoPopUp(
"Count",
"The text occurred " + to_string(count) +
" times.");
185 CountAction(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
191 class ReplaceAction:
public virtual Action
194 void performAction()
override {
195 if (uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText().empty() ==
true) {
196 uiEditorTabController->showInfoPopUp(
"Replace",
"No find string given.");
198 if (uiEditorTabController->view->replace(
199 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText(),
200 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getReplaceText(),
201 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isMatchCase(),
202 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isWholeWordOnly(),
203 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isInSelectionOnly(),
204 uiEditorTabController->searchIndex
206 uiEditorTabController->showInfoPopUp(
"Replace",
"Text not found.");
210 ReplaceAction(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
216 class ReplaceAllAction:
public virtual Action
219 void performAction()
override {
220 if (uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText().empty() ==
true) {
221 uiEditorTabController->showInfoPopUp(
"Replace All",
"No find string given.");
223 if (uiEditorTabController->view->replaceAll(
224 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getFindText(),
225 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->getReplaceText(),
226 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isMatchCase(),
227 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isWholeWordOnly(),
228 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->isInSelectionOnly()
230 uiEditorTabController->showInfoPopUp(
"Replace All",
"Text not found.");
234 ReplaceAllAction(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
240 class CompleteAction:
public virtual Action
243 void performAction()
override {
244 uiEditorTabController->view->cancelFind();
245 uiEditorTabController->popUps->getFindReplaceDialogScreenController()->close();
247 CompleteAction(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
254 new FindAction(
this),
255 new CountAction(
this),
256 new ReplaceAction(
this),
257 new ReplaceAllAction(
this),
258 new CompleteAction(
this)
263 showInfoPopUp(
"Warning",
"This command is not supported yet");
269 if (StringTools::startsWith(payload,
"file:") ==
false) {
272 auto fileName = StringTools::substring(payload,
string(
"file:").size());
274 if (Tools::hasFileExtension(fileName, {{
"xml" }}) ==
false) {
275 showInfoPopUp(
"Warning",
"You can not drop this file here. Allowed file extensions are " + Tools::enumerateFileExtensions({{
"xml" }}));
278 auto screenIdx = Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
".")));
283 if (Tools::hasFileExtension(fileName, PrototypeReader::getModelExtensions()) ==
false) {
284 showInfoPopUp(
"Warning",
"You can not drop this file here. Allowed file extensions are " + Tools::enumerateFileExtensions(PrototypeReader::getModelExtensions()));
287 Tools::getPathName(fileName),
288 Tools::getFileName(fileName),
306 if (node->
getId() ==
"selectbox_outliner") {
309 view->
setScreenIdx(outlinerNode ==
"screens"?0:Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
"."))));
311 if (node->
getId() ==
"dropdown_outliner_add") {
313 if (addOutlinerType ==
"screen") {
318 if (node->
getId() ==
"projectedui_meshnode") {
322 if (node->
getId() ==
"projectedui_animation") {
328 if (visual ==
true) {
344 if (node->
getId() ==
"selectbox_outliner") {
346 if (outlinerNode ==
"screens") {
351 class OnAddScreenAction:
public virtual Action
354 OnAddScreenAction(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
356 void performAction()
override {
367 class OnScreensReloadAction:
public virtual Action
370 OnScreensReloadAction(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
372 void performAction()
override {
383 if (StringTools::endsWith(outlinerNode,
".0") ==
true && StringTools::startsWith(outlinerNode,
"0.") ==
false) {
384 auto screenIdx = Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
".")));
390 class OnScreenRemoveAction:
public virtual Action
393 OnScreenRemoveAction(
UIEditorTabController* uiEditorTabController,
int screenIdx): uiEditorTabController(uiEditorTabController), screenIdx(screenIdx) {
395 void performAction()
override {
413 int tooltipLeft, tooltipTop;
426 xml+=
"<selectbox-option text=\"<" + GUIParser::escape(xmlParentNode->
Value()) +
">" + (nodeId.empty() ==
false?string(
" (") + nodeId +
")":
"") +
"\" value=\"" + to_string(screenIdx) +
"." + GUIParser::escape(to_string(nodeIdx++)) +
"\" />\n";
429 xml+=
"<selectbox-parent-option text=\"<" + GUIParser::escape(xmlParentNode->
Value()) +
">" + (nodeId.empty() ==
false?string(
" (") + nodeId +
")":
"") +
"\" value=\"" + to_string(screenIdx) +
"." + GUIParser::escape(to_string(nodeIdx++)) +
"\" >\n";
433 xml+=
"</selectbox-parent-option>\n";
439 xml+=
"<selectbox-parent-option text=\"Screens\" value=\"screens\">\n";
444 xml+=
"<selectbox-option text=\"<screen>\" value=\"" + to_string(screenIdx) +
".0\" />\n";
448 if (uiScreenNode.xml.empty() ==
false) {
451 xmlDocument.
Parse(uiScreenNode.xml.c_str());
452 if (xmlDocument.
Error() ==
true) {
453 auto message =
"UIEditorTabController::setOutlinerContent(): Could not parse XML. Error='" + string(xmlDocument.
ErrorDesc()) +
"':\n\n" + uiScreenNode.xml;
454 Console::println(message);
466 xml+=
"</selectbox-parent-option>\n";
472 string(
"<dropdown-option text=\"Screen\" value=\"screen\" />\n")
477 if (outlinerNode ==
"screens") {
480 if (StringTools::endsWith(outlinerNode,
".0") ==
true) {
482 view->
setScreenIdx(outlinerNode ==
"screens"?0:Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
"."))));
490 string(
"<template id=\"details_screen\" src=\"resources/engine/gui/template_details_screen.xml\" />\n")
495 auto screenIdx = Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
".")));
499 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"details_screen"))->getActiveConditions().add(
"open");
500 if (screenIdx >= 0 &&
501 screenIdx < view->getUIScreenNodes().size() &&
504 required_dynamic_cast<GUIImageNode*>(
screenNode->
getNodeById(
"screen"))->setSource(
"resources/engine/images/gui_big.png");
508 Console::println(
"UIEditorTabController::updateScreenDetails(): An error occurred: " +
string(exception.what()));
515 string(
"<template id=\"details_screens\" src=\"resources/engine/gui/template_details_projectedui.xml\" />\n")
520 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"details_screens"))->getActiveConditions().add(
"open");
524 Console::println(
"UIEditorTabController::updateScreensDetails(): An error occurred: " +
string(exception.what()));
532 string modelMeshNodesXML;
535 "<dropdown-option text=\"<None>\" value=\"\" " + (modelMeshNodesXML.empty() ==
true?
"selected=\"true\" ":
"") +
" />\n";
536 if (model !=
nullptr) {
537 for (
const auto& nodeId: model->getNodeIds()) {
539 "<dropdown-option text=\"" +
540 GUIParser::escape(nodeId) +
542 GUIParser::escape(nodeId) +
544 (modelMeshNodesXML == nodeId?
"selected=\"true\" ":
"") +
549 required_dynamic_cast<GUIParentNode*>(
screenNode->
getInnerNodeById(
"projectedui_meshnode_scrollarea"))->replaceSubNodes(modelMeshNodesXML,
true);
551 Console::print(
"UIEditorTabController::updateScreensDetails(): An error occurred: " +
string(exception.what()));
556 string animationsXML;
557 animationsXML = animationsXML +
"<dropdown-option text=\"<No animation>\" value=\"\" selected=\"true\" />";
558 if (model !=
nullptr) {
559 for (
const auto& animationSetupId: model->getAnimationSetupIds()) {
560 auto animationSetup = model->getAnimationSetup(animationSetupId);
561 if (animationSetup ==
nullptr || animationSetup->isOverlayAnimationSetup() ==
true)
continue;
563 animationsXML +
"<dropdown-option text=\"" +
564 GUIParser::escape(animationSetup->getId()) +
566 GUIParser::escape(animationSetup->getId()) +
572 required_dynamic_cast<GUIParentNode*>(
screenNode->
getInnerNodeById(
"projectedui_animation_scrollarea"))->replaceSubNodes(animationsXML,
true);
574 Console::println(
"ModelEditorTabController::setAnimationPreviewDetails(): An error occurred: " +
string(exception.what()));
580 class OnLoadScreen:
public virtual Action
583 void performAction()
override {
585 uiEditorTabController->setScreen(
587 uiEditorTabController->popUps->getFileDialogScreenController()->getPathName() +
"/" + uiEditorTabController->popUps->getFileDialogScreenController()->getFileName()
590 uiEditorTabController->view->getPopUps()->getFileDialogScreenController()->close();
599 : uiEditorTabController(uiEditorTabController), screenIdx(screenIdx) {
608 auto screenIdx = Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
".")));
615 "Load screen from: ",
619 new OnLoadScreen(
this, screenIdx)
625 auto screenIdx = Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
".")));
634 auto screenIdx = Integer::parse(StringTools::substring(outlinerNode, 0, outlinerNode.find(
".")));
652 Console::println(
"UIEditorTabController::reloadScreens(): An error occurred: " +
string(exception.what()));
660 class OnLoadPrototype:
public virtual Action
663 void performAction()
override {
664 uiEditorTabController->setPrototype(
665 uiEditorTabController->popUps->getFileDialogScreenController()->getPathName(),
666 uiEditorTabController->popUps->getFileDialogScreenController()->getFileName(),
667 uiEditorTabController->prototypeMeshNode,
668 uiEditorTabController->prototypeMeshAnimation
670 uiEditorTabController->view->getPopUps()->getFileDialogScreenController()->close();
677 OnLoadPrototype(
UIEditorTabController* uiEditorTabController): uiEditorTabController(uiEditorTabController) {
689 "Load prototype from: ",
690 PrototypeReader::getPrototypeExtensions(),
693 new OnLoadPrototype(
this)
715 if (node->
getId() ==
"screen_open") {
718 if (node->
getId() ==
"screen_remove") {
721 if (node->
getId() ==
"screen_browseto") {
724 if (node->
getId() ==
"projectedui_prototype_open") {
727 if (node->
getId() ==
"projectedui_prototype_remove") {
730 if (node->
getId() ==
"projectedui_prototype_browseto") {
740 Console::println(
"UIEditorTabController::setScreen(): An error occurred: " +
string(exception.what()));
741 showInfoPopUp(
"Error",
"An error occurred: " +
string(exception.what()));
753 showInfoPopUp(
"Error",
string() +
"Could not load prototype");
766 class OnUISave:
public virtual Action
769 void performAction()
override {
771 if (screenIdx < 0 || screenIdx >= uiEditorTabController->view->getUIScreenNodes().size()) {
772 uiEditorTabController->popUps->getFileDialogScreenController()->close();
777 auto pathName = uiEditorTabController->popUps->getFileDialogScreenController()->getPathName();
778 auto fileName = Tools::ensureFileExtension(uiEditorTabController->popUps->getFileDialogScreenController()->getFileName(),
"xml");
779 uiEditorTabController->view->getUIScreenNodes()[screenIdx].fileName = pathName +
"/" + fileName;
783 FileSystem::getInstance()->setContentFromString(
786 uiEditorTabController->view->getUIScreenNodes()[screenIdx].xml
789 if (uiEditorTabController->view->getScreenIdx() == screenIdx) {
790 uiEditorTabController->view->getEditorView()->reloadTabOutliner(to_string(screenIdx) +
".0");
793 uiEditorTabController->showInfoPopUp(
"Warning",
string(exception.what()));
798 for (; screenIdx < uiEditorTabController->view->getUIScreenNodes().size(); screenIdx++) {
800 if (uiEditorTabController->view->getUIScreenNodes()[screenIdx].xml.empty() ==
true)
continue;
802 if (uiEditorTabController->view->getUIScreenNodes()[screenIdx].fileName.empty() ==
false)
continue;
809 auto fileName = Tools::getPathName(uiEditorTabController->view->getFileName()) +
"/Untitled.xml";
810 uiEditorTabController->popUps->getFileDialogScreenController()->show(
811 Tools::getPathName(fileName),
814 Tools::getFileName(fileName),
816 new OnUISave(uiEditorTabController, screenIdx)
820 uiEditorTabController->popUps->getFileDialogScreenController()->close();
827 OnUISave(
UIEditorTabController* uiEditorTabController,
int screenIdx): uiEditorTabController(uiEditorTabController), screenIdx(screenIdx) {
837 auto emptyFileNameIdx = -1;
838 for (
auto screenIdx = 0; screenIdx < uiScreenNodes.size(); screenIdx++) {
840 if (uiScreenNodes[screenIdx].xml.empty() ==
true)
continue;
842 if (uiScreenNodes[screenIdx].fileName.empty() ==
true) {
843 emptyFileNameIdx = screenIdx;
848 const auto& uiScreenNode = uiScreenNodes[screenIdx];
850 FileSystem::getInstance()->setContentFromString(
851 Tools::getPathName(uiScreenNode.fileName),
852 Tools::getFileName(uiScreenNode.fileName),
856 Console::println(
"UIEditorTabController::save(): An error occurred: " +
string(exception.what()));
862 if (emptyFileNameIdx != -1) {
863 const auto& uiScreenNode = uiScreenNodes[emptyFileNameIdx];
865 auto fileName = Tools::getPathName(
view->
getFileName()) +
"/Untitled.xml";
867 Tools::getPathName(fileName),
870 Tools::getFileName(fileName),
872 new OnUISave(
this, emptyFileNameIdx)
882 class OnUISaveAs:
public virtual Action
889 OnUISaveAs(
UIEditorTabController* uiEditorTabController,
int screenIdx): uiEditorTabController(uiEditorTabController), screenIdx(screenIdx) {
892 void performAction()
override {
902 uiEditorTabController->
view->
getUIScreenNodes()[screenIdx].fileName = pathName +
"/" + fileName;
906 FileSystem::getInstance()->setContentFromString(
916 uiEditorTabController->
showInfoPopUp(
"Warning",
string(exception.what()));
931 if (fileName.empty() ==
true) fileName = Tools::getPathName(uiEditorTabController->
view->
getFileName()) +
"/Untitled.xml";
933 Tools::getPathName(fileName),
936 Tools::getFileName(fileName),
938 new OnUISaveAs(uiEditorTabController, screenIdx)
952 for (
auto screenIdx = 0; screenIdx < uiScreenNodes.size(); screenIdx++) {
954 if (uiScreenNodes[screenIdx].xml.empty() ==
true)
continue;
957 auto fileName = uiScreenNodes[screenIdx].fileName;
958 if (fileName.empty() ==
true) fileName = Tools::getPathName(
view->
getFileName()) +
"/Untitled.xml";
960 Tools::getPathName(fileName),
963 Tools::getFileName(fileName),
965 new OnUISaveAs(
this, screenIdx)
#define AVOID_NULLPTR_STRING(arg)
Representation of a 3D model.
GUI node controller base class.
virtual const MutableString & getValue()=0
const string & getToolTip()
GUINodeController * getController()
GUIScreenNode * screenNode
GUI parent node base class thats supporting child nodes.
GUI screen node that represents a screen that can be rendered via GUI system.
GUINode * getInnerNodeById(const string &nodeId)
Get inner GUI node by id.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
File system singleton class.
Mutable utf8 aware string class.
bool equals(const string &s2) const
Equals.
const string & getString() const
An attribute is a name-value pair.
Always the top level node.
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given null terminated block of xml data.
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
bool Error() const
If an error occurs, Error will be set to true.
The element is a container class.
const char * Attribute(const char *name) const
Given an attribute name, Attribute() returns the value for the attribute of that name,...
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
std::exception Exception
Exception base class.