Skip to content

Commit 95a0cad

Browse files
committed
Merge pull request #104482 from YeldhamDev/game_view_featprof_3d
Hide 3D mode in Game view if the feature is disabled
2 parents 96b5fe8 + 123b5ba commit 95a0cad

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

editor/plugins/game_view_plugin.cpp

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ void GameViewDebugger::_session_stopped() {
108108
emit_signal(SNAME("session_stopped"));
109109
}
110110

111-
void GameViewDebugger::set_is_feature_enabled(bool p_enabled) {
112-
is_feature_enabled = p_enabled;
113-
}
114-
115111
void GameViewDebugger::set_suspend(bool p_enabled) {
116112
Array message;
117113
message.append(p_enabled);
@@ -213,11 +209,20 @@ void GameViewDebugger::setup_session(int p_session_id) {
213209
session->connect("stopped", callable_mp(this, &GameViewDebugger::_session_stopped));
214210
}
215211

212+
void GameViewDebugger::_feature_profile_changed() {
213+
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
214+
is_feature_enabled = profile.is_null() || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME);
215+
}
216+
216217
void GameViewDebugger::_bind_methods() {
217218
ADD_SIGNAL(MethodInfo("session_started"));
218219
ADD_SIGNAL(MethodInfo("session_stopped"));
219220
}
220221

222+
GameViewDebugger::GameViewDebugger() {
223+
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &GameViewDebugger::_feature_profile_changed));
224+
}
225+
221226
///////
222227

223228
void GameView::_sessions_changed() {
@@ -248,6 +253,7 @@ void GameView::_instance_starting(int p_idx, List<String> &r_arguments) {
248253
if (!is_feature_enabled) {
249254
return;
250255
}
256+
251257
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) {
252258
// Set the Floating Window default title. Always considered in DEBUG mode, same as in Window::set_title.
253259
String appname = GLOBAL_GET("application/config/name");
@@ -429,6 +435,10 @@ void GameView::_node_type_pressed(int p_option) {
429435

430436
void GameView::_select_mode_pressed(int p_option) {
431437
RuntimeNodeSelect::SelectMode mode = (RuntimeNodeSelect::SelectMode)p_option;
438+
if (!select_mode_button[mode]->is_visible()) {
439+
return;
440+
}
441+
432442
for (int i = 0; i < RuntimeNodeSelect::SELECT_MODE_MAX; i++) {
433443
select_mode_button[i]->set_pressed_no_signal(i == mode);
434444
}
@@ -723,10 +733,6 @@ void GameView::_notification(int p_what) {
723733
}
724734
}
725735

726-
void GameView::set_is_feature_enabled(bool p_enabled) {
727-
is_feature_enabled = p_enabled;
728-
}
729-
730736
void GameView::set_window_layout(Ref<ConfigFile> p_layout) {
731737
floating_window_rect = p_layout->get_value("GameView", "floating_window_rect", Rect2i());
732738
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) {
884890
_update_embed_window_size();
885891
}
886892

893+
void GameView::_feature_profile_changed() {
894+
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
895+
bool is_profile_null = profile.is_null();
896+
897+
is_feature_enabled = is_profile_null || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME);
898+
899+
bool is_3d_enabled = is_profile_null || !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D);
900+
if (!is_3d_enabled && node_type_button[RuntimeNodeSelect::NODE_TYPE_3D]->is_pressed()) {
901+
_node_type_pressed(RuntimeNodeSelect::NODE_TYPE_NONE);
902+
}
903+
node_type_button[RuntimeNodeSelect::NODE_TYPE_3D]->set_visible(is_3d_enabled);
904+
}
905+
887906
GameView::GameView(Ref<GameViewDebugger> p_debugger, WindowWrapper *p_wrapper) {
888907
singleton = this;
889908

@@ -1090,6 +1109,8 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, WindowWrapper *p_wrapper) {
10901109
p_wrapper->connect("window_size_changed", callable_mp(this, &GameView::_update_floating_window_settings));
10911110

10921111
EditorDebuggerNode::get_singleton()->connect("breaked", callable_mp(this, &GameView::_debugger_breaked));
1112+
1113+
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &GameView::_feature_profile_changed));
10931114
}
10941115

10951116
///////
@@ -1136,24 +1157,6 @@ void GameViewPlugin::_notification(int p_what) {
11361157
}
11371158
}
11381159

1139-
void GameViewPlugin::_feature_profile_changed() {
1140-
bool is_feature_enabled = true;
1141-
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
1142-
if (profile.is_valid()) {
1143-
is_feature_enabled = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_GAME);
1144-
}
1145-
1146-
if (debugger.is_valid()) {
1147-
debugger->set_is_feature_enabled(is_feature_enabled);
1148-
}
1149-
1150-
#ifndef ANDROID_ENABLED
1151-
if (game_view) {
1152-
game_view->set_is_feature_enabled(is_feature_enabled);
1153-
}
1154-
#endif // ANDROID_ENABLED
1155-
}
1156-
11571160
void GameViewPlugin::_save_last_editor(const String &p_editor) {
11581161
if (p_editor != get_plugin_name()) {
11591162
last_editor = p_editor;
@@ -1196,6 +1199,4 @@ GameViewPlugin::GameViewPlugin() {
11961199
window_wrapper->hide();
11971200
window_wrapper->connect("window_visibility_changed", callable_mp(this, &GameViewPlugin::_focus_another_editor).unbind(1));
11981201
#endif // ANDROID_ENABLED
1199-
1200-
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &GameViewPlugin::_feature_profile_changed));
12011202
}

editor/plugins/game_view_plugin.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ class GameViewDebugger : public EditorDebuggerPlugin {
5858
void _session_started(Ref<EditorDebuggerSession> p_session);
5959
void _session_stopped();
6060

61+
void _feature_profile_changed();
62+
6163
protected:
6264
static void _bind_methods();
6365

6466
public:
65-
void set_is_feature_enabled(bool p_enabled);
66-
6767
void set_suspend(bool p_enabled);
6868
void next_frame();
6969

@@ -81,6 +81,8 @@ class GameViewDebugger : public EditorDebuggerPlugin {
8181
void reset_camera_3d_position();
8282

8383
virtual void setup_session(int p_session_id) override;
84+
85+
GameViewDebugger();
8486
};
8587

8688
class GameView : public VBoxContainer {
@@ -198,12 +200,12 @@ class GameView : public VBoxContainer {
198200

199201
void _debugger_breaked(bool p_breaked, bool p_can_debug);
200202

203+
void _feature_profile_changed();
204+
201205
protected:
202206
void _notification(int p_what);
203207

204208
public:
205-
void set_is_feature_enabled(bool p_enabled);
206-
207209
void set_state(const Dictionary &p_state);
208210
Dictionary get_state() const;
209211

@@ -225,7 +227,6 @@ class GameViewPlugin : public EditorPlugin {
225227

226228
String last_editor;
227229

228-
void _feature_profile_changed();
229230
#ifndef ANDROID_ENABLED
230231
void _window_visibility_changed(bool p_visible);
231232
#endif // ANDROID_ENABLED

0 commit comments

Comments
 (0)