Skip to content

Commit c9e5008

Browse files
committed
Merge pull request #95857 from KoBeWi/novel_variant_of_0
Always store ID of PopupMenu items
2 parents cbe1d6f + 5279fec commit c9e5008

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

scene/gui/menu_button.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void MenuButton::_bind_methods() {
198198
base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), defaults.icon);
199199
base_property_helper.register_property(PropertyInfo(Variant::INT, "checkable", PROPERTY_HINT_ENUM, "No,As Checkbox,As Radio Button"), defaults.checkable_type);
200200
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "checked"), defaults.checked);
201-
base_property_helper.register_property(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0,10,1,or_greater"), defaults.id);
201+
base_property_helper.register_property(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0,10,1,or_greater", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL), defaults.id);
202202
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled);
203203
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "separator"), defaults.separator);
204204
PropertyListHelper::register_base_helper(&base_property_helper);

scene/gui/option_button.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void OptionButton::_bind_methods() {
574574
base_property_helper.set_array_length_getter(&OptionButton::get_item_count);
575575
base_property_helper.register_property(PropertyInfo(Variant::STRING, "text"), defaults.text, &OptionButton::_dummy_setter, &OptionButton::get_item_text);
576576
base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), defaults.icon, &OptionButton::_dummy_setter, &OptionButton::get_item_icon);
577-
base_property_helper.register_property(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0,10,1,or_greater"), defaults.id, &OptionButton::_dummy_setter, &OptionButton::get_item_id);
577+
base_property_helper.register_property(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0,10,1,or_greater", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL), defaults.id, &OptionButton::_dummy_setter, &OptionButton::get_item_id);
578578
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &OptionButton::_dummy_setter, &OptionButton::is_item_disabled);
579579
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "separator"), defaults.separator, &OptionButton::_dummy_setter, &OptionButton::is_item_separator);
580580
PropertyListHelper::register_base_helper(&base_property_helper);

scene/gui/popup_menu.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2823,7 +2823,7 @@ void PopupMenu::_bind_methods() {
28232823
base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), defaults.icon, &PopupMenu::set_item_icon, &PopupMenu::get_item_icon);
28242824
base_property_helper.register_property(PropertyInfo(Variant::INT, "checkable", PROPERTY_HINT_ENUM, "No,As checkbox,As radio button"), defaults.checkable_type, &PopupMenu::_set_item_checkable_type, &PopupMenu::_get_item_checkable_type);
28252825
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "checked"), defaults.checked, &PopupMenu::set_item_checked, &PopupMenu::is_item_checked);
2826-
base_property_helper.register_property(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0,10,1,or_greater"), defaults.id, &PopupMenu::set_item_id, &PopupMenu::get_item_id);
2826+
base_property_helper.register_property(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0,10,1,or_greater", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL), defaults.id, &PopupMenu::set_item_id, &PopupMenu::get_item_id);
28272827
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &PopupMenu::set_item_disabled, &PopupMenu::is_item_disabled);
28282828
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "separator"), defaults.separator, &PopupMenu::set_item_as_separator, &PopupMenu::is_item_separator);
28292829
PropertyListHelper::register_base_helper(&base_property_helper);

scene/property_list_helper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void PropertyListHelper::get_property_list(List<PropertyInfo> *p_list) const {
142142
const Property &property = E.value;
143143

144144
PropertyInfo info = property.info;
145-
if (_call_getter(&property, i) == property.default_value) {
145+
if (!(info.usage & PROPERTY_USAGE_STORE_IF_NULL) && _call_getter(&property, i) == property.default_value) {
146146
info.usage &= (~PROPERTY_USAGE_STORAGE);
147147
}
148148

0 commit comments

Comments
 (0)