From e48ccc235f87207b7621601c5c4b794c7c4a4fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 22 Jan 2018 14:57:10 +0100 Subject: [PATCH] Mono: Display opt-out warning in editor about WIP status This ensures that all users of the Mono flavour of Godot 3.0 are aware of its current shortcomings (no export, crashes and usability issues). The dialog is shown each time the editor is started, until the checkbox is disabled (i.e. until users will have actually read it). Fixes #15956. --- modules/mono/editor/godotsharp_editor.cpp | 86 +++++++++++++++++++++++ modules/mono/editor/godotsharp_editor.h | 8 ++- 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index 9e48da68c18..0ef3adfdd08 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -112,6 +112,21 @@ void GodotSharpEditor::_remove_create_sln_menu_option() { bottom_panel_btn->show(); } +void GodotSharpEditor::_show_about_dialog() { + + bool show_on_start = EDITOR_GET("mono/editor/show_info_on_start"); + about_dialog_checkbox->set_pressed(show_on_start); + about_dialog->popup_centered_minsize(); +} + +void GodotSharpEditor::_toggle_about_dialog_on_start(bool p_enabled) { + + bool show_on_start = EDITOR_GET("mono/editor/show_info_on_start"); + if (show_on_start != p_enabled) { + EditorSettings::get_singleton()->set_setting("mono/editor/show_info_on_start", p_enabled); + } +} + void GodotSharpEditor::_menu_option_pressed(int p_id) { switch (p_id) { @@ -119,15 +134,37 @@ void GodotSharpEditor::_menu_option_pressed(int p_id) { _create_project_solution(); } break; + case MENU_ABOUT_CSHARP: { + + _show_about_dialog(); + } break; default: ERR_FAIL(); } } +void GodotSharpEditor::_notification(int p_notification) { + + switch (p_notification) { + + case NOTIFICATION_READY: { + + bool show_info_dialog = EDITOR_GET("mono/editor/show_info_on_start"); + if (show_info_dialog) { + about_dialog->set_exclusive(true); + _show_about_dialog(); + // Once shown a first time, it can be seen again via the Mono menu - it doesn't have to be exclusive then. + about_dialog->set_exclusive(false); + } + } + } +} + void GodotSharpEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_create_project_solution"), &GodotSharpEditor::_create_project_solution); ClassDB::bind_method(D_METHOD("_remove_create_sln_menu_option"), &GodotSharpEditor::_remove_create_sln_menu_option); + ClassDB::bind_method(D_METHOD("_toggle_about_dialog_on_start"), &GodotSharpEditor::_toggle_about_dialog_on_start); ClassDB::bind_method(D_METHOD("_menu_option_pressed", "id"), &GodotSharpEditor::_menu_option_pressed); } @@ -210,6 +247,55 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) { menu_button->set_text(TTR("Mono")); menu_popup = menu_button->get_popup(); + // TODO: Remove or edit this info dialog once Mono support is no longer in alpha + { + menu_popup->add_item(TTR("About C# support"), MENU_ABOUT_CSHARP); + about_dialog = memnew(AcceptDialog); + editor->get_gui_base()->add_child(about_dialog); + about_dialog->set_title("Important: C# support is not feature-complete"); + + // We don't use set_text() as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox + // we'll add. Instead we add containers and a new autowrapped Label inside. + + // Main VBoxContainer (icon + label on top, checkbox at bottom) + VBoxContainer *about_vbc = memnew(VBoxContainer); + about_dialog->add_child(about_vbc); + + // HBoxContainer for icon + label + HBoxContainer *about_hbc = memnew(HBoxContainer); + about_vbc->add_child(about_hbc); + + TextureRect *about_icon = memnew(TextureRect); + about_hbc->add_child(about_icon); + Ref about_icon_tex = about_icon->get_icon("NodeWarning", "EditorIcons"); + about_icon->set_texture(about_icon_tex); + + Label *about_label = memnew(Label); + about_hbc->add_child(about_label); + about_label->set_custom_minimum_size(Size2(600, 150) * EDSCALE); + about_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); + about_label->set_autowrap(true); + String about_text = + String("C# support in Godot Engine is a brand new feature and a work in progress.\n") + + "It is at the alpha stage and thus not suitable for use in production.\n\n" + + "As of Godot 3.0, C# support is not feature-complete and can crash in some situations. " + + "Bugs and usability issues will be addressed gradually over 3.0.x and 3.x releases.\n" + + "The main missing feature is the ability to export games using C# assemblies - you will therefore be able to develop and run games in the editor, " + + "but not to share them as standalone binaries. This feature is of course high on the priority list and should be available in 3.0.1.\n\n" + + "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, Mono version, IDE, etc.:\n\n" + + " https://github.com/godotengine/godot/issues\n\n" + + "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!"; + about_label->set_text(about_text); + + EDITOR_DEF("mono/editor/show_info_on_start", true); + + // CheckBox in main container + about_dialog_checkbox = memnew(CheckBox); + about_vbc->add_child(about_dialog_checkbox); + about_dialog_checkbox->set_text("Show this warning when starting the editor"); + about_dialog_checkbox->connect("toggled", this, "_toggle_about_dialog_on_start"); + } + String sln_path = GodotSharpDirs::get_project_sln_path(); String csproj_path = GodotSharpDirs::get_project_csproj_path(); diff --git a/modules/mono/editor/godotsharp_editor.h b/modules/mono/editor/godotsharp_editor.h index 1b83bae1cd4..81c49aec30f 100644 --- a/modules/mono/editor/godotsharp_editor.h +++ b/modules/mono/editor/godotsharp_editor.h @@ -44,6 +44,8 @@ class GodotSharpEditor : public Node { PopupMenu *menu_popup; AcceptDialog *error_dialog; + AcceptDialog *about_dialog; + CheckBox *about_dialog_checkbox; ToolButton *bottom_panel_btn; @@ -54,17 +56,21 @@ class GodotSharpEditor : public Node { bool _create_project_solution(); void _remove_create_sln_menu_option(); + void _show_about_dialog(); + void _toggle_about_dialog_on_start(bool p_enabled); void _menu_option_pressed(int p_id); static GodotSharpEditor *singleton; protected: + void _notification(int p_notification); static void _bind_methods(); public: enum MenuOptions { - MENU_CREATE_SLN + MENU_CREATE_SLN, + MENU_ABOUT_CSHARP, }; enum ExternalEditor {