VisualScript: Fix wrongly setting default value on property hint change
PR #45096 put the backported code in the wrong case, it should be for `type` and not for `hint`. Also synced `hint` enum values with `Object.PropertyHint`. Fixes #48698.
This commit is contained in:
parent
fcfce4be67
commit
c7182512dd
1 changed files with 13 additions and 13 deletions
|
@ -227,18 +227,6 @@ protected:
|
||||||
undo_redo->create_action(TTR("Set Variable Type"));
|
undo_redo->create_action(TTR("Set Variable Type"));
|
||||||
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
|
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
|
||||||
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
|
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
|
||||||
undo_redo->add_do_method(this, "_var_changed");
|
|
||||||
undo_redo->add_undo_method(this, "_var_changed");
|
|
||||||
undo_redo->commit_action();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (String(p_name) == "hint") {
|
|
||||||
Dictionary dc = d.duplicate();
|
|
||||||
dc["hint"] = p_value;
|
|
||||||
undo_redo->create_action(TTR("Set Variable Type"));
|
|
||||||
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
|
|
||||||
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
|
|
||||||
|
|
||||||
// Setting the default value.
|
// Setting the default value.
|
||||||
Variant::Type type = (Variant::Type)(int)p_value;
|
Variant::Type type = (Variant::Type)(int)p_value;
|
||||||
|
@ -258,6 +246,18 @@ protected:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (String(p_name) == "hint") {
|
||||||
|
Dictionary dc = d.duplicate();
|
||||||
|
dc["hint"] = p_value;
|
||||||
|
undo_redo->create_action(TTR("Set Variable Type"));
|
||||||
|
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
|
||||||
|
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
|
||||||
|
undo_redo->add_do_method(this, "_var_changed");
|
||||||
|
undo_redo->add_undo_method(this, "_var_changed");
|
||||||
|
undo_redo->commit_action();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (String(p_name) == "hint_string") {
|
if (String(p_name) == "hint_string") {
|
||||||
Dictionary dc = d.duplicate();
|
Dictionary dc = d.duplicate();
|
||||||
dc["hint_string"] = p_value;
|
dc["hint_string"] = p_value;
|
||||||
|
@ -323,7 +323,7 @@ protected:
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt));
|
p_list->push_back(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt));
|
||||||
p_list->push_back(PropertyInfo(script->get_variable_info(var).type, "value", script->get_variable_info(var).hint, script->get_variable_info(var).hint_string, PROPERTY_USAGE_DEFAULT));
|
p_list->push_back(PropertyInfo(script->get_variable_info(var).type, "value", script->get_variable_info(var).hint, script->get_variable_info(var).hint_string, PROPERTY_USAGE_DEFAULT));
|
||||||
// Update this when PropertyHint changes
|
// Update this when PropertyHint changes
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText,PlaceholderText,ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,String,NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,MethodOfInstance,MethodOfScript,PropertyOfVariantType,PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig,NodePathValidTypes"));
|
p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText,PlaceholderText,ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,TypeString,NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,MethodOfInstance,MethodOfScript,PropertyOfVariantType,PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig,NodePathValidTypes,SaveFile"));
|
||||||
p_list->push_back(PropertyInfo(Variant::STRING, "hint_string"));
|
p_list->push_back(PropertyInfo(Variant::STRING, "hint_string"));
|
||||||
p_list->push_back(PropertyInfo(Variant::BOOL, "export"));
|
p_list->push_back(PropertyInfo(Variant::BOOL, "export"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue