Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-603 Permit selecting abstract types for variable definitions #604

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/editor/inspector/property_type_button_property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void OrchestratorEditorPropertyVariableClassification::_notification(int p_what)
_dialog->set_popup_title("Select variable type");
_dialog->set_data_suffix("variable_type");
_dialog->set_base_type(_base_type);
_dialog->set_allow_abstract_types(true);
add_child(_dialog);

_dialog->connect("selected", callable_mp(this, &OrchestratorEditorPropertyVariableClassification::_search_selected));
Expand Down
20 changes: 14 additions & 6 deletions src/editor/select_type_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,23 @@ Vector<Ref<OrchestratorEditorSearchDialog::SearchItem>> OrchestratorSelectTypeSe
item->icon = SceneUtils::get_class_icon(clazz_name);
item->parent = parent;

if (!ClassDB::can_instantiate(clazz_name))
if (!_allow_abstract_types)
{
item->selectable = false;
item->disabled = true;
if (!ClassDB::can_instantiate(clazz_name))
{
item->selectable = false;
item->disabled = true;
}
else if (Engine::get_singleton()->get_singleton_list().has(clazz_name))
{
item->selectable = false;
item->disabled = true;
}
}
else if (Engine::get_singleton()->get_singleton_list().has(clazz_name))
else
{
item->selectable = false;
item->disabled = true;
item->selectable = true;
item->disabled = false;
}

if (ScriptServer::is_global_class(clazz_name))
Expand Down
5 changes: 5 additions & 0 deletions src/editor/select_type_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class OrchestratorSelectTypeSearchDialog : public OrchestratorEditorSearchDialog
HashSet<StringName> _exclusions; //! Set of types to be excluded
Vector<String> _variant_type_names; //! All valid variant type names
bool _is_base_type_node{ false }; //! Specifies if base type is a Node
bool _allow_abstract_types{ false }; //! Allow selecting abstract types
String _base_type; //! The base type
String _fallback_icon{ "Object" }; //! The fallback icon
String _preferred_search_result_type; //! The preferred search result type
Expand Down Expand Up @@ -101,6 +102,10 @@ class OrchestratorSelectTypeSearchDialog : public OrchestratorEditorSearchDialog
/// @param p_data_suffix the data file suffix
void set_data_suffix(const String& p_data_suffix) { _data_suffix = p_data_suffix; }

/// Sets whether abstract types should be selectable
/// @param p_allow_abstract_types true to allow selecting abstract types
void set_allow_abstract_types(bool p_allow_abstract_types) { _allow_abstract_types = p_allow_abstract_types; }

/// Sets the dialog's title
/// @param p_title the title to be used
void set_popup_title(const String& p_title) { _title = p_title; }
Expand Down
Loading