diff --git a/doc/classes/AudioStreamRandomizer.xml b/doc/classes/AudioStreamRandomizer.xml index 2b59d78f77..3053c4dbc2 100644 --- a/doc/classes/AudioStreamRandomizer.xml +++ b/doc/classes/AudioStreamRandomizer.xml @@ -80,6 +80,14 @@ The intensity of random volume variation. Volume will be increased or decreased by a random value up to [code skip-lint]random_volume_offset_db[/code]. A value of [code]0.0[/code] means no variation. A value of [code]3.0[/code] means volume will be randomized between [code]-3.0 dB[/code] and [code]+3.0 dB[/code]. + + The [AudioStream] at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. streams_count - 1[/code] range. + + + The probability weight of the [AudioStream] at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. streams_count - 1[/code] range. + The number of streams in the stream pool. diff --git a/doc/classes/Curve.xml b/doc/classes/Curve.xml index 5246e0ba67..cdf96bd0e5 100644 --- a/doc/classes/Curve.xml +++ b/doc/classes/Curve.xml @@ -175,6 +175,26 @@ The number of points describing the curve. + + The left [enum TangentMode] for the point at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The left tangent angle (in degrees) for the point at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The position of the point at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The right [enum TangentMode] for the point at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The right tangent angle (in degrees) for the point at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index 6ce9616fb6..eef28f1f21 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -177,5 +177,17 @@ The number of points describing the curve. + + The position of the control point leading to the vertex at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The position of the control point leading out of the vertex at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The position of for the vertex at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index f8386b73b2..fbaf0f7ffe 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -210,6 +210,22 @@ The number of points describing the curve. + + The position of the control point leading to the vertex at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The position of the control point leading out of the vertex at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The position of for the vertex at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + + + The tilt angle in radians for the point at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. point_count - 1[/code] range. + If [code]true[/code], the curve will bake up vectors used for orientation. This is used when [member PathFollow3D.rotation_mode] is set to [constant PathFollow3D.ROTATION_ORIENTED]. Changing it forces the cache to be recomputed. diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index d37ff25186..0e885a0142 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -258,6 +258,18 @@ The number of additional [OptionButton]s and [CheckBox]es in the dialog. + + The default value for the option at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. option_count - 1[/code] range. + + + The name of the option at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. option_count - 1[/code] range. + + + The list of values for the option at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. option_count - 1[/code] range. + If [code]true[/code], the [FileDialog] will warn the user before overwriting files in save mode. diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index df574b683a..f008e49d38 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -417,6 +417,22 @@ The number of items currently in the list. + + If [code]true[/code], the item at [code]index[/code] is disabled. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The icon of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is selectable. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The text of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + Maximum columns the list will have. If greater than zero, the content will be split among the specified columns. diff --git a/doc/classes/LabelSettings.xml b/doc/classes/LabelSettings.xml index 620a2563fb..853c38bf8c 100644 --- a/doc/classes/LabelSettings.xml +++ b/doc/classes/LabelSettings.xml @@ -163,8 +163,28 @@ The number of stacked outlines. + + The color of the outline at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. stacked_outline_count - 1[/code] range. + + + The size of the outline at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. stacked_outline_count - 1[/code] range. + The number of stacked shadows. + + The color of the shadow at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. stacked_shadow_count - 1[/code] range. + + + The offset of the shadow at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. stacked_shadow_count - 1[/code] range. + + + The size of the shadow outline at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. stacked_shadow_count - 1[/code] range. + diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index af26e2ff02..0c7be0e102 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -38,6 +38,34 @@ The number of items currently in the list. + + The checkable item type of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is checked. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is disabled. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The icon of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The ID of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is a separator. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The text of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + If [code]true[/code], when the cursor hovers above another [MenuButton] within the same parent which also has [member switch_on_hover] enabled, it will close the current [MenuButton] and open the other one. diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index 6c72fad04a..eff2106587 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -249,6 +249,26 @@ The number of items to select from. + + If [code]true[/code], the item at [code]index[/code] is disabled. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The icon of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The ID of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is a separator. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The text of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + The index of the currently selected item, or [code]-1[/code] if no item is selected. diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index fd5a5d7503..14c44d5fab 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -673,6 +673,34 @@ The number of items currently in the list. + + The checkable item type of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is checked. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is disabled. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The icon of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The ID of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + If [code]true[/code], the item at [code]index[/code] is a separator. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + + + The text of the item at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. item_count - 1[/code] range. + If [code]true[/code], [MenuBar] will use native menu when supported. [b]Note:[/b] If [PopupMenu] is linked to [StatusIndicator], [MenuBar], or another [PopupMenu] item it can use native menu regardless of this property, use [method is_native_menu] to check it. diff --git a/doc/classes/TabBar.xml b/doc/classes/TabBar.xml index 957b636f57..30db8a1403 100644 --- a/doc/classes/TabBar.xml +++ b/doc/classes/TabBar.xml @@ -282,6 +282,22 @@ The number of tabs currently in the bar. + + If [code]true[/code], the tab at [code]index[/code] is disabled. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. tab_count - 1[/code] range. + + + If [code]true[/code], the tab at [code]index[/code] is hidden. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. tab_count - 1[/code] range. + + + The title text of the tab at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. tab_count - 1[/code] range. + + + The tooltip text of the tab at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. tab_count - 1[/code] range. + [TabBar]s with the same rearrange group ID will allow dragging the tabs between them. Enable drag with [member drag_to_rearrange_enabled]. Setting this to [code]-1[/code] will disable rearranging between [TabBar]s. diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 7e6e588f58..3f9ae530db 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -232,6 +232,22 @@ The focus access mode for the internal [TabBar] node. + + If [code]true[/code], the tab at [code]index[/code] is disabled. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. get_tab_count() - 1[/code] range. + + + If [code]true[/code], the tab at [code]index[/code] is hidden. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. get_tab_count() - 1[/code] range. + + + The title text of the tab at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. get_tab_count() - 1[/code] range. + + + The tooltip text of the tab at [code]index[/code]. + [b]Note:[/b] [code]index[/code] is a value in the [code]0 .. get_tab_count() - 1[/code] range. + The horizontal alignment of the tabs. diff --git a/editor/doc/doc_tools.cpp b/editor/doc/doc_tools.cpp index 36e08c4d53..bc8ab99b77 100644 --- a/editor/doc/doc_tools.cpp +++ b/editor/doc/doc_tools.cpp @@ -43,6 +43,7 @@ #include "core/string/translation_server.h" #include "editor/export/editor_export_platform.h" #include "editor/settings/editor_settings.h" +#include "scene/property_list_helper.h" #include "scene/resources/theme.h" #include "scene/theme/theme_db.h" @@ -408,6 +409,16 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c return default_value; } +bool helpers_has_property(const String &p_class_name, const String &p_name) { + const Vector helpers = PropertyListHelper::get_helpers_for_class(p_class_name); + for (const PropertyListHelper *helper : helpers) { + if (helper->documentation_has_property(p_name)) { + return true; + } + } + return false; +} + void DocTools::generate(BitField p_flags) { // This may involve instantiating classes that are only usable from the main thread // (which is in fact the case of the core API). @@ -448,6 +459,7 @@ void DocTools::generate(BitField p_flags) { List properties; List own_properties; + Vector helpers = PropertyListHelper::get_helpers_for_class(name); // Special cases for editor/project settings, and ResourceImporter classes, // we have to rely on Object's property list to get settings and import options. @@ -492,6 +504,11 @@ void DocTools::generate(BitField p_flags) { properties_from_instance = false; ClassDB::get_property_list(name, &properties); ClassDB::get_property_list(name, &own_properties, true); + + for (const PropertyListHelper *helper : helpers) { + helper->documentation_get_property_list(&properties); + helper->documentation_get_property_list(&own_properties); + } } // Sort is still needed here to handle inherited properties, even though it is done below, do not remove. @@ -517,14 +534,22 @@ void DocTools::generate(BitField p_flags) { continue; } + bool from_helper = E.name.contains("{index}"); + DocData::PropertyDoc prop; prop.name = E.name; prop.overridden = inherited; if (inherited) { String parent = ClassDB::get_parent_class(c.name); - while (!ClassDB::has_property(parent, prop.name, true)) { - parent = ClassDB::get_parent_class(parent); + if (from_helper) { + while (!helpers_has_property(parent, prop.name)) { + parent = ClassDB::get_parent_class(parent); + } + } else { + while (!ClassDB::has_property(parent, prop.name, true)) { + parent = ClassDB::get_parent_class(parent); + } } prop.overrides = parent; } @@ -549,12 +574,22 @@ void DocTools::generate(BitField p_flags) { default_value = import_options_default[E.name]; default_value_valid = true; } else { - default_value = get_documentation_default_value(name, E.name, default_value_valid); - if (inherited) { - bool base_default_value_valid = false; - Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E.name, base_default_value_valid); - if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) { - continue; + if (from_helper) { + for (const PropertyListHelper *helper : helpers) { + if (helper->documentation_has_property(E.name)) { + default_value = helper->documentation_get_default_value(E.name); + default_value_valid = true; + break; + } + } + } else { + default_value = get_documentation_default_value(name, E.name, default_value_valid); + if (inherited) { + bool base_default_value_valid = false; + Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E.name, base_default_value_valid); + if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) { + continue; + } } } } diff --git a/editor/doc/editor_help.cpp b/editor/doc/editor_help.cpp index 96cfa35062..3364a6a685 100644 --- a/editor/doc/editor_help.cpp +++ b/editor/doc/editor_help.cpp @@ -72,6 +72,8 @@ #include "modules/mono/csharp_script.h" #endif +#include "modules/regex/regex.h" + #define CONTRIBUTE_URL "https://contributing.godotengine.org/en/latest/documentation/class_reference.html" #ifdef MODULE_MONO_ENABLED @@ -3696,6 +3698,18 @@ EditorHelpBit::HelpData EditorHelpBit::_get_property_help_data(const StringName } } + if (property.name.contains("{index}")) { + RegEx reg_index = RegEx(property.name.replace("{index}", "\\d*")); + Ref match = reg_index.search(p_property_name); + if (match.is_valid()) { + result = current; + + if (!is_native) { + break; + } + } + } + if (is_native) { doc_property_cache[p_class_name][property.name] = current; } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 4b541292a1..54491ad0e8 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1041,7 +1041,7 @@ TileMap::TileMap() { base_property_helper.register_property(PropertyInfo(Variant::BOOL, "navigation_enabled"), defaults->is_navigation_enabled(), &TileMap::set_layer_navigation_enabled, &TileMap::is_layer_navigation_enabled); #endif // NAVIGATION_2D_DISABLED base_property_helper.register_property(PropertyInfo(Variant::PACKED_INT32_ARRAY, "tile_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), Vector(), &TileMap::_set_layer_tile_data, &TileMap::_get_tile_map_data_using_compatibility_format); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); memdelete(defaults); } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 26f4e93966..ed1b2e26c4 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -2229,7 +2229,7 @@ void FileDialog::_bind_methods() { base_property_helper.register_property(PropertyInfo(Variant::STRING, "name"), defaults.name, &FileDialog::set_option_name, &FileDialog::get_option_name); base_property_helper.register_property(PropertyInfo(Variant::PACKED_STRING_ARRAY, "values"), defaults.values, &FileDialog::set_option_values, &FileDialog::get_option_values); base_property_helper.register_property(PropertyInfo(Variant::INT, "default"), defaults.default_idx, &FileDialog::set_option_default, &FileDialog::get_option_default); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); ADD_CLASS_DEPENDENCY("Button"); ADD_CLASS_DEPENDENCY("ConfirmationDialog"); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 964afb43cd..488066cc5c 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -2498,7 +2498,7 @@ void ItemList::_bind_methods() { base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, Texture2D::get_class_static()), defaults.icon, &ItemList::set_item_icon, &ItemList::get_item_icon); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "selectable"), defaults.selectable, &ItemList::set_item_selectable, &ItemList::is_item_selectable); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &ItemList::set_item_disabled, &ItemList::is_item_disabled); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } ItemList::ItemList() { diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 71ef40fb89..bd657b6fe6 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -224,7 +224,7 @@ void MenuButton::_bind_methods() { 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); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "separator"), defaults.separator); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } void MenuButton::set_disable_shortcuts(bool p_disabled) { diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 0e8682057b..bc95bbf1fa 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -649,7 +649,7 @@ void OptionButton::_bind_methods() { 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); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &OptionButton::_dummy_setter, &OptionButton::is_item_disabled); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "separator"), defaults.separator, &OptionButton::_dummy_setter, &OptionButton::is_item_separator); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); ADD_CLASS_DEPENDENCY("PopupMenu"); } diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 44e7e7229d..3ed6df2449 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -3482,7 +3482,7 @@ void PopupMenu::_bind_methods() { 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); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &PopupMenu::set_item_disabled, &PopupMenu::is_item_disabled); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "separator"), defaults.separator, &PopupMenu::set_item_as_separator, &PopupMenu::is_item_separator); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } void PopupMenu::_native_popup(const Rect2i &p_rect) { diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 258bfb1f0d..33ed5fccdf 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -2197,7 +2197,7 @@ void TabBar::_bind_methods() { base_property_helper.register_property(PropertyInfo(Variant::STRING, "tooltip"), defaults.tooltip, &TabBar::set_tab_tooltip, &TabBar::get_tab_tooltip); base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, Texture2D::get_class_static()), defaults.icon, &TabBar::set_tab_icon, &TabBar::get_tab_icon); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &TabBar::set_tab_disabled, &TabBar::is_tab_disabled); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } TabBar::TabBar() { diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index d46a3bf11f..66f52dc7b3 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -1252,7 +1252,7 @@ void TabContainer::_bind_methods() { base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, Texture2D::get_class_static()), defaults.icon, &TabContainer::set_tab_icon, &TabContainer::get_tab_icon); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &TabContainer::set_tab_disabled, &TabContainer::is_tab_disabled); base_property_helper.register_property(PropertyInfo(Variant::BOOL, "hidden"), defaults.hidden, &TabContainer::set_tab_hidden, &TabContainer::is_tab_hidden); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } TabContainer::TabContainer() { diff --git a/scene/property_list_helper.cpp b/scene/property_list_helper.cpp index 3ba5b0ef0e..1668d9c735 100644 --- a/scene/property_list_helper.cpp +++ b/scene/property_list_helper.cpp @@ -30,17 +30,27 @@ #include "property_list_helper.h" -Vector PropertyListHelper::base_helpers; // static +HashMap> PropertyListHelper::base_helpers; // static void PropertyListHelper::clear_base_helpers() { // static - for (PropertyListHelper *helper : base_helpers) { - helper->clear(); + for (KeyValue> &E : base_helpers) { + for (PropertyListHelper *helper : E.value) { + helper->clear(); + } } base_helpers.clear(); } -void PropertyListHelper::register_base_helper(PropertyListHelper *p_helper) { // static - base_helpers.push_back(p_helper); +void PropertyListHelper::register_base_helper(const StringName &p_class_name, PropertyListHelper *p_helper) { // static + base_helpers[p_class_name].push_back(p_helper); +} + +Vector PropertyListHelper::get_helpers_for_class(const StringName &p_class_name) { + if (base_helpers.has(p_class_name)) { + return base_helpers[p_class_name]; + } else { + return Vector(); + } } const PropertyListHelper::Property *PropertyListHelper::_get_property(const String &p_property, int *r_index, bool p_allow_oob) const { @@ -163,6 +173,33 @@ void PropertyListHelper::get_property_list(List *p_list) const { } } +#ifdef TOOLS_ENABLED + +void PropertyListHelper::documentation_get_property_list(List *r_list) const { + for (const KeyValue &E : property_list) { + const Property &property = E.value; + + PropertyInfo info = property.info; + info.name = vformat("%s{index}/%s", prefix, info.name); + r_list->push_back(info); + } +} +bool PropertyListHelper::documentation_has_property(const String &p_property) const { + String name = p_property.trim_prefix(vformat("%s{index}/", prefix)); + return property_list.has(name); +} + +Variant PropertyListHelper::documentation_get_default_value(const String &p_property) const { + String name = p_property.trim_prefix(vformat("%s{index}/", prefix)); + if (property_list.has(name)) { + return property_list[name].default_value; + } else { + return Variant(); + } +} + +#endif + bool PropertyListHelper::property_get_value(const String &p_property, Variant &r_ret) const { int index; const Property *property = _get_property(p_property, &index); diff --git a/scene/property_list_helper.h b/scene/property_list_helper.h index f169088482..aadc239ebd 100644 --- a/scene/property_list_helper.h +++ b/scene/property_list_helper.h @@ -41,7 +41,7 @@ class PropertyListHelper { MethodBind *getter = nullptr; }; - static Vector base_helpers; + static HashMap> base_helpers; String prefix; MethodBind *array_length_getter = nullptr; @@ -58,7 +58,9 @@ class PropertyListHelper { public: static void clear_base_helpers(); - static void register_base_helper(PropertyListHelper *p_helper); + static void register_base_helper(const StringName &p_class_name, PropertyListHelper *p_helper); + + static Vector get_helpers_for_class(const StringName &p_class_name); void set_prefix(const String &p_prefix); template @@ -94,6 +96,12 @@ public: bool property_can_revert(const String &p_property) const; bool property_get_revert(const String &p_property, Variant &r_value) const; +#ifdef TOOLS_ENABLED + void documentation_get_property_list(List *r_list) const; + bool documentation_has_property(const String &p_property) const; + Variant documentation_get_default_value(const String &p_property) const; +#endif + void enable_out_of_bounds_assign() { allow_oob_assign = true; } void clear(); diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 8bb8b2b868..aba9908659 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -662,7 +662,7 @@ void Curve::_bind_methods() { base_property_helper.register_property(PropertyInfo(Variant::INT, "left_mode", PROPERTY_HINT_ENUM, mode_hint, PROPERTY_USAGE_EDITOR), defaults.left_mode, &Curve::set_point_left_mode, &Curve::get_point_left_mode); base_property_helper.register_property(PropertyInfo(Variant::FLOAT, "right_tangent", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), defaults.right_tangent, &Curve::set_point_right_tangent, &Curve::get_point_right_tangent); base_property_helper.register_property(PropertyInfo(Variant::INT, "right_mode", PROPERTY_HINT_ENUM, mode_hint, PROPERTY_USAGE_EDITOR), defaults.right_mode, &Curve::set_point_right_mode, &Curve::get_point_right_mode); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } int Curve2D::get_point_count() const { @@ -1344,7 +1344,7 @@ void Curve2D::_bind_methods() { base_property_helper.register_property(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), defaults.position, &Curve2D::set_point_position, &Curve2D::get_point_position); base_property_helper.register_property(PropertyInfo(Variant::VECTOR2, "in", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), defaults.in, &Curve2D::set_point_in, &Curve2D::get_point_in); base_property_helper.register_property(PropertyInfo(Variant::VECTOR2, "out", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), defaults.out, &Curve2D::set_point_out, &Curve2D::get_point_out); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } Curve2D::Curve2D() { @@ -2388,7 +2388,7 @@ void Curve3D::_bind_methods() { base_property_helper.register_property(PropertyInfo(Variant::VECTOR3, "in", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), defaults.in, &Curve3D::set_point_in, &Curve3D::get_point_in); base_property_helper.register_property(PropertyInfo(Variant::VECTOR3, "out", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), defaults.out, &Curve3D::set_point_out, &Curve3D::get_point_out); base_property_helper.register_property(PropertyInfo(Variant::FLOAT, "tilt", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), defaults.tilt, &Curve3D::set_point_tilt, &Curve3D::get_point_tilt); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } Curve3D::Curve3D() { diff --git a/scene/resources/label_settings.cpp b/scene/resources/label_settings.cpp index e60cb1e9f1..78500f1c5b 100644 --- a/scene/resources/label_settings.cpp +++ b/scene/resources/label_settings.cpp @@ -119,7 +119,7 @@ void LabelSettings::_bind_methods() { stacked_outline_base_property_helper.set_array_length_getter(&LabelSettings::get_stacked_outline_count); stacked_outline_base_property_helper.register_property(PropertyInfo(Variant::INT, "size", PROPERTY_HINT_NONE, "0,127,1,or_greater,suffix:px"), stacked_outline_defaults.size, &LabelSettings::set_stacked_outline_size, &LabelSettings::get_stacked_outline_size); stacked_outline_base_property_helper.register_property(PropertyInfo(Variant::COLOR, "color"), stacked_outline_defaults.color, &LabelSettings::set_stacked_outline_color, &LabelSettings::get_stacked_outline_color); - PropertyListHelper::register_base_helper(&stacked_outline_base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &stacked_outline_base_property_helper); constexpr StackedShadowData stacked_shadow_defaults; @@ -128,7 +128,7 @@ void LabelSettings::_bind_methods() { stacked_shadow_base_property_helper.register_property(PropertyInfo(Variant::VECTOR2, "offset", PROPERTY_HINT_NONE, "suffix:px"), stacked_shadow_defaults.offset, &LabelSettings::set_stacked_shadow_offset, &LabelSettings::get_stacked_shadow_offset); stacked_shadow_base_property_helper.register_property(PropertyInfo(Variant::COLOR, "color"), stacked_shadow_defaults.color, &LabelSettings::set_stacked_shadow_color, &LabelSettings::get_stacked_shadow_color); stacked_shadow_base_property_helper.register_property(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_NONE, "0,127,1,or_greater,suffix:px"), stacked_shadow_defaults.outline_size, &LabelSettings::set_stacked_shadow_outline_size, &LabelSettings::get_stacked_shadow_outline_size); - PropertyListHelper::register_base_helper(&stacked_shadow_base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &stacked_shadow_base_property_helper); } void LabelSettings::set_line_spacing(real_t p_spacing) { diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index a9e4909fa3..6ea294b46f 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -782,7 +782,7 @@ void AudioStreamRandomizer::_bind_methods() { base_property_helper.set_array_length_getter(&AudioStreamRandomizer::get_streams_count); base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, AudioStream::get_class_static()), defaults.stream, &AudioStreamRandomizer::set_stream, &AudioStreamRandomizer::get_stream); base_property_helper.register_property(PropertyInfo(Variant::FLOAT, "weight", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), defaults.weight, &AudioStreamRandomizer::set_stream_probability_weight, &AudioStreamRandomizer::get_stream_probability_weight); - PropertyListHelper::register_base_helper(&base_property_helper); + PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper); } AudioStreamRandomizer::AudioStreamRandomizer() {