33 using std::make_unique;
36 using std::unique_ptr;
63 BasePropertiesSubController::BasePropertiesSubController(
EditorView* editorView,
const string& rootNode)
66 this->
view = make_unique<BasePropertiesSubView>(
this);
81 xml+=
"<selectbox-parent-option image=\"resources/engine/images/folder.png\" text=\"" + GUIParser::escape(
"Properties") +
"\" value=\"" + GUIParser::escape(
"properties") +
"\">\n";
83 xml+=
" <selectbox-option image=\"resources/engine/images/script.png\" text=\"" + GUIParser::escape(property->getName() +
": " + property->getValue()) +
"\" id=\"" + GUIParser::escape(
"properties." + property->getName()) +
"\" value=\"" + GUIParser::escape(
"properties." + property->getName()) +
"\" />\n";
85 xml+=
"</selectbox-parent-option>\n";
91 "<template id=\"details_base\" src=\"resources/engine/gui/template_details_base.xml\" />\n"
95 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"details_base"))->getActiveConditions().add(
"open");
98 if (prototype !=
nullptr) {
99 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"details_base"))->getActiveConditions().add(
"entity_hierarchy");
103 Console::println(
"PrototypeBaseSubController::setPrototypeBaseDetails(): An error occurred: " +
string(exception.what()));
110 baseProperties->
setName(required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"base_name"))->getController()->getValue().getString());
113 Console::println(
"PrototypeBaseSubController::applyPrototypeBaseDetails(): An error occurred: " +
string(exception.what()));
119 auto property = baseProperties->
getProperty(propertyName);
120 if (property ==
nullptr)
return;
123 "<template id=\"details_property\" src=\"resources/engine/gui/template_details_property.xml\" />\n"
127 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"details_property"))->getActiveConditions().add(
"open");
130 Console::println(
"PrototypeBaseSubController::setPropertyDetails(): An error occurred: " +
string(exception.what()));
139 if (StringTools::startsWith(outlinerNode,
"properties.") ==
true) {
140 auto selectedPropertyName = StringTools::substring(outlinerNode,
string(
"properties.").size(), outlinerNode.size());
150 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"property_value"))->getController()->getValue().getString()) ==
false) {
154 Console::println(
"PrototypeBaseSubController::applyPropertyDetails(): An error occurred: " +
string(exception.what()));
160 auto propertyCreated =
false;
161 auto propertyName = string() +
"New property";
166 propertyCreated =
true;
169 for (
auto i = 1; i < 10001; i++) {
170 propertyName = string() +
"New property " + to_string(i);
175 propertyCreated =
true;
182 if (propertyCreated ==
false) {
186 Console::println(
"PrototypeBaseSubController::createProperty(): An error occurred: " +
string(exception.what()));
190 if (propertyCreated ==
true) {
200 auto property = baseProperties->
getProperty(propertyName);
201 if (property ==
nullptr)
return;
203 if (selectBoxOptionParentNode ==
nullptr)
return;
205 selectBoxOptionParentNode->replaceSubNodes(
206 "<template id=\"tdme.properties.rename_input\" hint=\"Property name\" text=\"" + GUIParser::escape(property->getName()) +
"\"src=\"resources/engine/gui/template_outliner_rename.xml\" />\n",
216 if (property !=
nullptr) {
220 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"tdme.properties.rename_input"))->getController()->getValue().getString()
226 Console::println(
"PrototypeBaseSubController::renameProperty(): An error occurred: " +
string(exception.what()));
237 if (node->
getId() ==
"dropdown_outliner_add") {
239 if (addOutlinerType ==
"property") {
244 if (node->
getId() ==
"selectbox_outliner") {
246 if (StringTools::startsWith(outlinerNode,
"properties.") ==
true) {
247 auto selectedPropertyName = StringTools::substring(outlinerNode,
string(
"properties.").size(), outlinerNode.size());
252 if (prototype !=
nullptr && node->
getId() ==
"base_prototype_entityhierarchy") {
263 if (node->
getId() ==
"tdme.properties.rename_input") {
277 if (node->
getId() ==
"tdme.properties.rename_input") {
282 if (node->
getId() == applyPropertyNode) {
288 if (node->
getId() == applyBaseNode) {
299 if (node->
getId() ==
"selectbox_outliner") {
301 if (outlinerNode ==
"properties") {
305 class OnAddPropertyAction:
public virtual Action
308 void performAction()
override {
309 prototypeBaseSubController->createProperty(baseProperties);
321 if (StringTools::startsWith(outlinerNode,
"properties.") ==
true) {
325 class OnRenameAction:
public virtual Action
328 void performAction()
override {
329 auto outlinerNode = prototypeBaseSubController->editorView->getScreenController()->getOutlinerSelection();
330 if (StringTools::startsWith(outlinerNode,
"properties.") ==
true) {
331 prototypeBaseSubController->startRenameProperty(
333 StringTools::substring(outlinerNode,
string(
"properties.").size(), outlinerNode.size())
349 class OnDeleteAction:
public virtual Action
352 void performAction()
override {
353 auto outlinerNode = prototypeBaseSubController->editorView->getScreenController()->getOutlinerSelection();
354 if (StringTools::startsWith(outlinerNode,
"properties.") ==
true) {
355 auto selectedPropertyName = StringTools::substring(outlinerNode,
string(
"properties.").size(), outlinerNode.size());
357 prototypeBaseSubController->editorView->reloadTabOutliner(
"properties");
376 auto selectedPropertyName = StringTools::substring(outlinerNode,
string(
"properties.").size(), outlinerNode.size());
bool updateProperty(const string &oldName, const string &name, const string &value)
Update a property.
void setName(const string &name)
Set up name.
const BaseProperty * getProperty(const string &name) const
Retrieve property by name.
ConstUniquePtrSequenceIterator< BaseProperty > getProperties() const
bool addProperty(const string &name, const string &value)
Add a property.
const string & getDescription()
bool removeProperty(const string &name)
Removes a property.
bool renameProperty(const string &oldName, const string &name)
Rename a property.
void setDescription(const string &description)
Set up description.
Base property model class.
void setEntityHierarchy(bool entityHierarchy)
Set entity hierarchy.
GUI node controller base class.
virtual const MutableString & getValue()=0
GUINodeController * getController()
GUI parent node base class thats supporting child nodes.
GUI screen node that represents a screen that can be rendered via GUI system.
void forwardChange(GUIElementNode *node)
Forward change event.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
Mutable utf8 aware string class.
bool equals(const string &s2) const
Equals.
const string & getString() const
std::exception Exception
Exception base class.