Skip to content

Commit abf8e1e

Browse files
committed
Merge pull request godotengine#101405 from Hilderin/fix-game-view-cannot-be-editor-feature-disabled
Fix Game View cannot be editor feature disabled
2 parents 0332cee + 683cef1 commit abf8e1e

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

editor/plugins/game_view_plugin.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "core/debugger/debugger_marshalls.h"
3535
#include "editor/debugger/editor_debugger_node.h"
3636
#include "editor/editor_command_palette.h"
37+
#include "editor/editor_feature_profile.h"
3738
#include "editor/editor_interface.h"
3839
#include "editor/editor_main_screen.h"
3940
#include "editor/editor_node.h"
@@ -49,6 +50,10 @@
4950
#include "scene/gui/separator.h"
5051

5152
void GameViewDebugger::_session_started(Ref<EditorDebuggerSession> p_session) {
53+
if (!is_feature_enabled) {
54+
return;
55+
}
56+
5257
Array setup_data;
5358
Dictionary settings;
5459
settings["editors/panning/2d_editor_panning_scheme"] = EDITOR_GET("editors/panning/2d_editor_panning_scheme");
@@ -73,9 +78,17 @@ void GameViewDebugger::_session_started(Ref<EditorDebuggerSession> p_session) {
7378
}
7479

7580
void GameViewDebugger::_session_stopped() {
81+
if (!is_feature_enabled) {
82+
return;
83+
}
84+
7685
emit_signal(SNAME("session_stopped"));
7786
}
7887

88+
void GameViewDebugger::set_is_feature_enabled(bool p_enabled) {
89+
is_feature_enabled = p_enabled;
90+
}
91+
7992
void GameViewDebugger::set_suspend(bool p_enabled) {
8093
Array message;
8194
message.append(p_enabled);
@@ -198,6 +211,9 @@ void GameView::_instance_starting_static(int p_idx, List<String> &r_arguments) {
198211
}
199212

200213
void GameView::_instance_starting(int p_idx, List<String> &r_arguments) {
214+
if (!is_feature_enabled) {
215+
return;
216+
}
201217
if (p_idx == 0 && embed_on_play && make_floating_on_play && !window_wrapper->get_window_enabled() && EditorNode::get_singleton()->is_multi_window_enabled()) {
202218
window_wrapper->restore_window_from_saved_position(floating_window_rect, floating_window_screen, floating_window_screen_rect);
203219
}
@@ -206,6 +222,10 @@ void GameView::_instance_starting(int p_idx, List<String> &r_arguments) {
206222
}
207223

208224
void GameView::_play_pressed() {
225+
if (!is_feature_enabled) {
226+
return;
227+
}
228+
209229
OS::ProcessID current_process_id = EditorRunBar::get_singleton()->get_current_process();
210230
if (current_process_id == 0) {
211231
return;
@@ -231,6 +251,10 @@ void GameView::_play_pressed() {
231251
}
232252

233253
void GameView::_stop_pressed() {
254+
if (!is_feature_enabled) {
255+
return;
256+
}
257+
234258
EditorNode::get_singleton()->set_unfocused_low_processor_usage_mode_enabled(true);
235259
embedded_process->reset();
236260
_update_ui();
@@ -476,6 +500,10 @@ void GameView::_notification(int p_what) {
476500
}
477501
}
478502

503+
void GameView::set_is_feature_enabled(bool p_enabled) {
504+
is_feature_enabled = p_enabled;
505+
}
506+
479507
void GameView::set_state(const Dictionary &p_state) {
480508
if (p_state.has("hide_selection")) {
481509
hide_selection->set_pressed(p_state["hide_selection"]);
@@ -801,6 +829,22 @@ void GameViewPlugin::_notification(int p_what) {
801829
}
802830
}
803831

832+
void GameViewPlugin::_feature_profile_changed() {
833+
bool is_feature_enabled = true;
834+
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
835+
if (profile.is_valid()) {
836+
is_feature_enabled = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME);
837+
}
838+
839+
if (debugger.is_valid()) {
840+
debugger->set_is_feature_enabled(is_feature_enabled);
841+
}
842+
843+
if (game_view) {
844+
game_view->set_is_feature_enabled(is_feature_enabled);
845+
}
846+
}
847+
804848
void GameViewPlugin::_window_visibility_changed(bool p_visible) {
805849
_focus_another_editor();
806850
}
@@ -834,6 +878,8 @@ GameViewPlugin::GameViewPlugin() {
834878
window_wrapper->set_v_size_flags(Control::SIZE_EXPAND_FILL);
835879
window_wrapper->hide();
836880
window_wrapper->connect("window_visibility_changed", callable_mp(this, &GameViewPlugin::_window_visibility_changed));
881+
882+
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &GameViewPlugin::_feature_profile_changed));
837883
}
838884

839885
GameViewPlugin::~GameViewPlugin() {

editor/plugins/game_view_plugin.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class GameViewDebugger : public EditorDebuggerPlugin {
4747
private:
4848
Vector<Ref<EditorDebuggerSession>> sessions;
4949

50+
bool is_feature_enabled = true;
5051
int node_type = RuntimeNodeSelect::NODE_TYPE_NONE;
5152
bool selection_visible = true;
5253
int select_mode = RuntimeNodeSelect::SELECT_MODE_SINGLE;
@@ -59,6 +60,8 @@ class GameViewDebugger : public EditorDebuggerPlugin {
5960
static void _bind_methods();
6061

6162
public:
63+
void set_is_feature_enabled(bool p_enabled);
64+
6265
void set_suspend(bool p_enabled);
6366
void next_frame();
6467

@@ -95,6 +98,7 @@ class GameView : public VBoxContainer {
9598
Ref<GameViewDebugger> debugger;
9699
WindowWrapper *window_wrapper = nullptr;
97100

101+
bool is_feature_enabled = true;
98102
int active_sessions = 0;
99103
int screen_index_before_start = -1;
100104

@@ -163,6 +167,8 @@ class GameView : public VBoxContainer {
163167
void _notification(int p_what);
164168

165169
public:
170+
void set_is_feature_enabled(bool p_enabled);
171+
166172
void set_state(const Dictionary &p_state);
167173
Dictionary get_state() const;
168174

@@ -182,6 +188,7 @@ class GameViewPlugin : public EditorPlugin {
182188

183189
String last_editor;
184190

191+
void _feature_profile_changed();
185192
void _window_visibility_changed(bool p_visible);
186193
void _save_last_editor(const String &p_editor);
187194
void _focus_another_editor();

0 commit comments

Comments
 (0)