-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add popup_create_dialog()
for EditorInterface
to create custom create dialog
#100135
Add popup_create_dialog()
for EditorInterface
to create custom create dialog
#100135
Conversation
94dd750
to
91b4317
Compare
pop_create_dialog()
for EditorInterface
to create custom create dialogpop_create_dialog()
for EditorInterface
to create custom create dialog
i1f6SKNmzW.mp4You need to close the dialog and open it again.
I think exposing the dialog this way makes sense, but the additional functionality (blacklist, suffixes) is questionable. The proposal doesn't seem to have gained support. Can't say how much useful it is. |
Should preferably be called "blocklist" instead, as per the general pattern and preferred terminology |
4e5d629
to
d776185
Compare
All of these bugs are fixed |
This comment was marked as resolved.
This comment was marked as resolved.
editor/editor_interface.h
Outdated
@@ -145,6 +148,7 @@ class EditorInterface : public Object { | |||
void popup_property_selector(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter = PackedInt32Array(), const String &p_current_value = String()); | |||
void popup_method_selector(Object *p_object, const Callable &p_callback, const String &p_current_value = String()); | |||
void popup_quick_open(const Callable &p_callback, const TypedArray<StringName> &p_base_types = TypedArray<StringName>()); | |||
void popup_create_dialog(const Callable &p_callback, const StringName &p_base_type = "", const TypedArray<StringName> &p_custom_type_blacklist = TypedArray<String>(), const Dictionary &p_custom_suffix = Dictionary()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Dictionary could be typed.
(AFAIK you ran into some problems with it; it would still be nice to resolve it though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Dictionary could be typed. (AFAIK you ran into some problems with it; it would still be nice to resolve it though)
Yeah, but I'd wait for others who maintains the typed dictionary to solve the problem and then I'll make a new pr to transform all dictionaries into typed dictionaries (as long as their keys or values should be typed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the problem is that adding type technically breaks compatibility, so we should do it swiftly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm, wait for someone to fix #100137 ...
d776185
to
b5e5f3b
Compare
The replace mode that you newly exposed sounds like niche feature 🤔 It could default to |
I prefer to make it exposed, as some users will pop the dialog for literally replacing the type. |
5ca0ef2
to
0c6de3b
Compare
The crash is still not fixed #100135 (comment) |
Fixed in the latest pr that will be pushed soon ...
create_dialog->set_type_suffixes(suffix_map);
const bool is_type_valid = ClassDB::class_exists(p_base_type) || ScriptServer::is_global_class(p_base_type);
if (!is_type_valid) {
ERR_PRINT(vformat("Invalid base type '%s'. The base type has fallen back to 'Object'.", p_base_type));
}
const String safe_base_type = !p_base_type.is_empty() && is_type_valid ? p_base_type : "Object";
create_dialog->set_base_type(safe_base_type);
... |
0c6de3b
to
bf1220f
Compare
bf1220f
to
e1e86b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality-wise it's fine now.
Apparently type blocklist already existed, it was just hard-coded before.
The suffixes and dialog title are questionable, but eh.
e1e86b0
to
12e948b
Compare
pop_create_dialog()
for EditorInterface
to create custom create dialogpopup_create_dialog()
for EditorInterface
to create custom create dialog
12e948b
to
9c34ad1
Compare
Thanks! |
Supersedes #99926
Adds a new method
pop_create_dialog()
forEditorInterface
, which allows users to pop a custom create dialog.Parameters
Callable callback
: This callback requires only one argument which is ofStringName
type, where a user can define instantiating an object by callingClassDB.instantiate(...)
orScript.new(...)
.StringName base_type
: This defines the root type of the create dialog. By default it isObject
. For example, if one defines this asNode2D
, only aNode2D
and all of its derived class can be displayed.String dialog_title
: This allows you tp customize the title of the create dialog. An empty string for this will make the title fall back to "Create New ".Array[StringName] type_blocklist
: This will customize which types should be hidden from the custom create dialog. A hidden type is unable to be selected or interacted.Dictionary type_suffixes
: This will customize the suffixes of types shown in the custom create dialog. Suffixes, for global script classes, are by default the file names of the scripts. If a suffix is an empty string, there will be no suffix following the type name.