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

Allow user to disable script editor and use external editor instead #73760

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nongvantinh
Copy link
Contributor

@nongvantinh nongvantinh commented Feb 22, 2023

Fixes: #73702

@nongvantinh nongvantinh requested a review from a team as a code owner February 22, 2023 13:08
@akien-mga akien-mga added this to the 4.x milestone Feb 22, 2023
@akien-mga
Copy link
Member

The main question is what is the use case for disabling the script editor. There seems to be conflicted use cases:

  • Disabling all scripting functionality (e.g. for teachers who want to teach students with only nodes/inspector/animations/premade custom nodes but no scripting initially). That's what the current implementation was intended for.
  • Hiding the script editor because users want to use an external editor, and thus remove the internal editor from the interface. This is what this PR seems to allow, but breaks the above requirement.

@nongvantinh nongvantinh changed the title Disables the Script Editor, the editor no longer allows the user to interact with the script Allow user to disable script editor and use external editor instead Feb 26, 2023
@nongvantinh nongvantinh requested a review from a team as a code owner February 26, 2023 08:56
@KoBeWi
Copy link
Member

KoBeWi commented Jun 29, 2023

Disabling Scripting does not disable Script Editor. Probably not intended (and inconsistent with how other nested features work).

@@ -49,6 +49,7 @@ class EditorFeatureProfile : public RefCounted {
enum Feature {
FEATURE_3D,
FEATURE_SCRIPT,
FEATURE_EDITOR_SCRIPT,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to also use BIND_ENUM_CONSTANT.

Ref<EditorFeatureProfile> profile = feature_profile_manager->get_current_profile();
if (profile->is_feature_disabled(EditorFeatureProfile::FEATURE_EDITOR_SCRIPT) &&
!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT)) {
if (main_plugin->get_name() == "Script" && current_res && !current_res->is_built_in() && (bool(EDITOR_GET("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is 4 nested conditions here, maybe it could be simplified.
The first if (with == main_plugin) could be changed to early continue.

@@ -49,6 +49,7 @@ class EditorFeatureProfile : public RefCounted {
enum Feature {
FEATURE_3D,
FEATURE_SCRIPT,
FEATURE_EDITOR_SCRIPT,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding FEATURE_EDITOR_SCRIPT here breaks compat, it should be added at the end of the enum.

@nongvantinh
Copy link
Contributor Author

While reviewing the PR and making revisions based on your suggestions, I noticed several underlying issues with this PR. Should I relocate FEATURE_EDITOR_SCRIPT to the bottom, it would require adjustments in many other places, as the current implementation does not account for the possibility of a main feature having multiple sub-main features.

I will need more time to reconsider how to solve the problem in an elegant manner. Given my full-time job, it will take a little longer to complete, at the very least, not before the release of 4.1. My current idea is to solve the issue by utilizing an array or other suitable mechanisms. That's all I can think of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabling Script Editor also disable the ability to create "New Scripts" from inspector
4 participants