diff --git a/editor/plugins/game_view_plugin.cpp b/editor/plugins/game_view_plugin.cpp index b4b84a1a98..0bdd98321d 100644 --- a/editor/plugins/game_view_plugin.cpp +++ b/editor/plugins/game_view_plugin.cpp @@ -108,10 +108,6 @@ void GameViewDebugger::_session_stopped() { emit_signal(SNAME("session_stopped")); } -void GameViewDebugger::set_is_feature_enabled(bool p_enabled) { - is_feature_enabled = p_enabled; -} - void GameViewDebugger::set_suspend(bool p_enabled) { Array message; message.append(p_enabled); @@ -213,11 +209,20 @@ void GameViewDebugger::setup_session(int p_session_id) { session->connect("stopped", callable_mp(this, &GameViewDebugger::_session_stopped)); } +void GameViewDebugger::_feature_profile_changed() { + Ref profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); + is_feature_enabled = profile.is_null() || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME); +} + void GameViewDebugger::_bind_methods() { ADD_SIGNAL(MethodInfo("session_started")); ADD_SIGNAL(MethodInfo("session_stopped")); } +GameViewDebugger::GameViewDebugger() { + EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &GameViewDebugger::_feature_profile_changed)); +} + /////// void GameView::_sessions_changed() { @@ -248,6 +253,7 @@ void GameView::_instance_starting(int p_idx, List &r_arguments) { if (!is_feature_enabled) { return; } + if (p_idx == 0 && embed_on_play && make_floating_on_play && window_wrapper->is_window_available() && !window_wrapper->get_window_enabled() && _get_embed_available() == EMBED_AVAILABLE) { // Set the Floating Window default title. Always considered in DEBUG mode, same as in Window::set_title. String appname = GLOBAL_GET("application/config/name"); @@ -429,6 +435,10 @@ void GameView::_node_type_pressed(int p_option) { void GameView::_select_mode_pressed(int p_option) { RuntimeNodeSelect::SelectMode mode = (RuntimeNodeSelect::SelectMode)p_option; + if (!select_mode_button[mode]->is_visible()) { + return; + } + for (int i = 0; i < RuntimeNodeSelect::SELECT_MODE_MAX; i++) { select_mode_button[i]->set_pressed_no_signal(i == mode); } @@ -723,10 +733,6 @@ void GameView::_notification(int p_what) { } } -void GameView::set_is_feature_enabled(bool p_enabled) { - is_feature_enabled = p_enabled; -} - void GameView::set_window_layout(Ref p_layout) { floating_window_rect = p_layout->get_value("GameView", "floating_window_rect", Rect2i()); floating_window_screen = p_layout->get_value("GameView", "floating_window_screen", -1); @@ -884,6 +890,19 @@ void GameView::_debugger_breaked(bool p_breaked, bool p_can_debug) { _update_embed_window_size(); } +void GameView::_feature_profile_changed() { + Ref profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); + bool is_profile_null = profile.is_null(); + + is_feature_enabled = is_profile_null || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME); + + bool is_3d_enabled = is_profile_null || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D); + if (!is_3d_enabled && node_type_button[RuntimeNodeSelect::NODE_TYPE_3D]->is_pressed()) { + _node_type_pressed(RuntimeNodeSelect::NODE_TYPE_NONE); + } + node_type_button[RuntimeNodeSelect::NODE_TYPE_3D]->set_visible(is_3d_enabled); +} + GameView::GameView(Ref p_debugger, WindowWrapper *p_wrapper) { singleton = this; @@ -1090,6 +1109,8 @@ GameView::GameView(Ref p_debugger, WindowWrapper *p_wrapper) { p_wrapper->connect("window_size_changed", callable_mp(this, &GameView::_update_floating_window_settings)); EditorDebuggerNode::get_singleton()->connect("breaked", callable_mp(this, &GameView::_debugger_breaked)); + + EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &GameView::_feature_profile_changed)); } /////// @@ -1136,24 +1157,6 @@ void GameViewPlugin::_notification(int p_what) { } } -void GameViewPlugin::_feature_profile_changed() { - bool is_feature_enabled = true; - Ref profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); - if (profile.is_valid()) { - is_feature_enabled = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME); - } - - if (debugger.is_valid()) { - debugger->set_is_feature_enabled(is_feature_enabled); - } - -#ifndef ANDROID_ENABLED - if (game_view) { - game_view->set_is_feature_enabled(is_feature_enabled); - } -#endif // ANDROID_ENABLED -} - void GameViewPlugin::_save_last_editor(const String &p_editor) { if (p_editor != get_plugin_name()) { last_editor = p_editor; @@ -1196,6 +1199,4 @@ GameViewPlugin::GameViewPlugin() { window_wrapper->hide(); window_wrapper->connect("window_visibility_changed", callable_mp(this, &GameViewPlugin::_focus_another_editor).unbind(1)); #endif // ANDROID_ENABLED - - EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &GameViewPlugin::_feature_profile_changed)); } diff --git a/editor/plugins/game_view_plugin.h b/editor/plugins/game_view_plugin.h index 41782b78e6..a4748f3546 100644 --- a/editor/plugins/game_view_plugin.h +++ b/editor/plugins/game_view_plugin.h @@ -58,12 +58,12 @@ private: void _session_started(Ref p_session); void _session_stopped(); + void _feature_profile_changed(); + protected: static void _bind_methods(); public: - void set_is_feature_enabled(bool p_enabled); - void set_suspend(bool p_enabled); void next_frame(); @@ -81,6 +81,8 @@ public: void reset_camera_3d_position(); virtual void setup_session(int p_session_id) override; + + GameViewDebugger(); }; class GameView : public VBoxContainer { @@ -198,12 +200,12 @@ class GameView : public VBoxContainer { void _debugger_breaked(bool p_breaked, bool p_can_debug); + void _feature_profile_changed(); + protected: void _notification(int p_what); public: - void set_is_feature_enabled(bool p_enabled); - void set_state(const Dictionary &p_state); Dictionary get_state() const; @@ -225,7 +227,6 @@ class GameViewPlugin : public EditorPlugin { String last_editor; - void _feature_profile_changed(); #ifndef ANDROID_ENABLED void _window_visibility_changed(bool p_visible); #endif // ANDROID_ENABLED