1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-24 15:26:15 +00:00

-Setting script in multi node edit works, closes #4442

This commit is contained in:
Juan Linietsky
2016-06-19 10:12:35 -03:00
parent 37d1bf4d53
commit f84ffb9bed
3 changed files with 26 additions and 4 deletions

View File

@@ -35,9 +35,15 @@ bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){
if (!es)
return false;
String name = p_name;
if (name=="scripts/script") { // script/script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
name="script/script";
}
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("MultiNode Set")+" "+String(p_name));
ur->create_action(TTR("MultiNode Set")+" "+String(name));
for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) {
if (!es->has_node(E->get()))
@@ -47,10 +53,13 @@ bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){
if (!n)
continue;
ur->add_do_property(n,p_name,p_value);
ur->add_undo_property(n,p_name,n->get(p_name));
ur->add_do_property(n,name,p_value);
ur->add_undo_property(n,name,n->get(name));
}
ur->add_do_method(EditorNode::get_singleton()->get_property_editor(),"refresh");
ur->add_undo_method(EditorNode::get_singleton()->get_property_editor(),"refresh");
ur->commit_action();
return true;
@@ -62,6 +71,11 @@ bool MultiNodeEdit::_get(const StringName& p_name,Variant &r_ret) const {
if (!es)
return false;
String name=p_name;
if (name=="scripts/script") { // script/script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
name="script/script";
}
for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) {
if (!es->has_node(E->get()))
@@ -72,7 +86,7 @@ bool MultiNodeEdit::_get(const StringName& p_name,Variant &r_ret) const {
continue;
bool found;
r_ret=n->get(p_name,&found);
r_ret=n->get(name,&found);
if (found)
return true;
@@ -107,6 +121,8 @@ void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{
for(List<PropertyInfo>::Element *F=plist.front();F;F=F->next()) {
if (F->get().name=="script/script")
continue; //added later manually, since this is intercepted before being set (check Variant Object::get() )
if (!usage.has(F->get().name)) {
PLData pld;
pld.uses=0;
@@ -128,6 +144,8 @@ void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{
}
}
p_list->push_back(PropertyInfo(Variant::OBJECT,"scripts/script",PROPERTY_HINT_RESOURCE_TYPE,"Script"));
}