Skip to content

Commit 194ddfd

Browse files
committed
Merge pull request godotengine#97257 from YeldhamDev/guess_godot_is_unity_after_all
Add "Game" editor for better runtime debugging
2 parents e84fae4 + 16524a8 commit 194ddfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2375
-271
lines changed

core/config/engine.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ void Engine::set_time_scale(double p_scale) {
116116
}
117117

118118
double Engine::get_time_scale() const {
119+
return freeze_time_scale ? 0 : _time_scale;
120+
}
121+
122+
double Engine::get_unfrozen_time_scale() const {
119123
return _time_scale;
120124
}
121125

@@ -404,6 +408,10 @@ bool Engine::notify_frame_server_synced() {
404408
return server_syncs > SERVER_SYNC_FRAME_COUNT_WARNING;
405409
}
406410

411+
void Engine::set_freeze_time_scale(bool p_frozen) {
412+
freeze_time_scale = p_frozen;
413+
}
414+
407415
Engine::Engine() {
408416
singleton = this;
409417
}

core/config/engine.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class Engine {
9999
int server_syncs = 0;
100100
bool frame_server_synced = false;
101101

102+
bool freeze_time_scale = false;
103+
102104
public:
103105
static Engine *get_singleton();
104106

@@ -130,6 +132,7 @@ class Engine {
130132

131133
void set_time_scale(double p_scale);
132134
double get_time_scale() const;
135+
double get_unfrozen_time_scale() const;
133136

134137
void set_print_to_stdout(bool p_enabled);
135138
bool is_printing_to_stdout() const;
@@ -197,6 +200,8 @@ class Engine {
197200
void increment_frames_drawn();
198201
bool notify_frame_server_synced();
199202

203+
void set_freeze_time_scale(bool p_frozen);
204+
200205
Engine();
201206
virtual ~Engine();
202207
};

core/input/input.cpp

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,50 @@ Input *Input::get_singleton() {
8787

8888
void Input::set_mouse_mode(MouseMode p_mode) {
8989
ERR_FAIL_INDEX((int)p_mode, 5);
90+
91+
if (p_mode == mouse_mode) {
92+
return;
93+
}
94+
95+
// Allow to be set even if overridden, to see if the platform allows the mode.
9096
set_mouse_mode_func(p_mode);
97+
mouse_mode = get_mouse_mode_func();
98+
99+
if (mouse_mode_override_enabled) {
100+
set_mouse_mode_func(mouse_mode_override);
101+
}
91102
}
92103

93104
Input::MouseMode Input::get_mouse_mode() const {
94-
return get_mouse_mode_func();
105+
return mouse_mode;
106+
}
107+
108+
void Input::set_mouse_mode_override_enabled(bool p_enabled) {
109+
if (p_enabled == mouse_mode_override_enabled) {
110+
return;
111+
}
112+
113+
mouse_mode_override_enabled = p_enabled;
114+
115+
if (p_enabled) {
116+
set_mouse_mode_func(mouse_mode_override);
117+
mouse_mode_override = get_mouse_mode_func();
118+
} else {
119+
set_mouse_mode_func(mouse_mode);
120+
}
121+
}
122+
123+
void Input::set_mouse_mode_override(MouseMode p_mode) {
124+
ERR_FAIL_INDEX((int)p_mode, 5);
125+
126+
if (p_mode == mouse_mode_override) {
127+
return;
128+
}
129+
130+
if (mouse_mode_override_enabled) {
131+
set_mouse_mode_func(p_mode);
132+
mouse_mode_override = get_mouse_mode_func();
133+
}
95134
}
96135

97136
void Input::_bind_methods() {
@@ -252,6 +291,10 @@ Input::VelocityTrack::VelocityTrack() {
252291
bool Input::is_anything_pressed() const {
253292
_THREAD_SAFE_METHOD_
254293

294+
if (disable_input) {
295+
return false;
296+
}
297+
255298
if (!keys_pressed.is_empty() || !joy_buttons_pressed.is_empty() || !mouse_button_mask.is_empty()) {
256299
return true;
257300
}
@@ -267,21 +310,41 @@ bool Input::is_anything_pressed() const {
267310

268311
bool Input::is_key_pressed(Key p_keycode) const {
269312
_THREAD_SAFE_METHOD_
313+
314+
if (disable_input) {
315+
return false;
316+
}
317+
270318
return keys_pressed.has(p_keycode);
271319
}
272320

273321
bool Input::is_physical_key_pressed(Key p_keycode) const {
274322
_THREAD_SAFE_METHOD_
323+
324+
if (disable_input) {
325+
return false;
326+
}
327+
275328
return physical_keys_pressed.has(p_keycode);
276329
}
277330

278331
bool Input::is_key_label_pressed(Key p_keycode) const {
279332
_THREAD_SAFE_METHOD_
333+
334+
if (disable_input) {
335+
return false;
336+
}
337+
280338
return key_label_pressed.has(p_keycode);
281339
}
282340

283341
bool Input::is_mouse_button_pressed(MouseButton p_button) const {
284342
_THREAD_SAFE_METHOD_
343+
344+
if (disable_input) {
345+
return false;
346+
}
347+
285348
return mouse_button_mask.has_flag(mouse_button_to_mask(p_button));
286349
}
287350

@@ -295,11 +358,21 @@ static JoyButton _combine_device(JoyButton p_value, int p_device) {
295358

296359
bool Input::is_joy_button_pressed(int p_device, JoyButton p_button) const {
297360
_THREAD_SAFE_METHOD_
361+
362+
if (disable_input) {
363+
return false;
364+
}
365+
298366
return joy_buttons_pressed.has(_combine_device(p_button, p_device));
299367
}
300368

301369
bool Input::is_action_pressed(const StringName &p_action, bool p_exact) const {
302370
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action));
371+
372+
if (disable_input) {
373+
return false;
374+
}
375+
303376
HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
304377
if (!E) {
305378
return false;
@@ -310,6 +383,11 @@ bool Input::is_action_pressed(const StringName &p_action, bool p_exact) const {
310383

311384
bool Input::is_action_just_pressed(const StringName &p_action, bool p_exact) const {
312385
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action));
386+
387+
if (disable_input) {
388+
return false;
389+
}
390+
313391
HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
314392
if (!E) {
315393
return false;
@@ -331,6 +409,11 @@ bool Input::is_action_just_pressed(const StringName &p_action, bool p_exact) con
331409

332410
bool Input::is_action_just_released(const StringName &p_action, bool p_exact) const {
333411
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action));
412+
413+
if (disable_input) {
414+
return false;
415+
}
416+
334417
HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
335418
if (!E) {
336419
return false;
@@ -352,6 +435,11 @@ bool Input::is_action_just_released(const StringName &p_action, bool p_exact) co
352435

353436
float Input::get_action_strength(const StringName &p_action, bool p_exact) const {
354437
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), 0.0, InputMap::get_singleton()->suggest_actions(p_action));
438+
439+
if (disable_input) {
440+
return 0.0f;
441+
}
442+
355443
HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
356444
if (!E) {
357445
return 0.0f;
@@ -366,6 +454,11 @@ float Input::get_action_strength(const StringName &p_action, bool p_exact) const
366454

367455
float Input::get_action_raw_strength(const StringName &p_action, bool p_exact) const {
368456
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), 0.0, InputMap::get_singleton()->suggest_actions(p_action));
457+
458+
if (disable_input) {
459+
return 0.0f;
460+
}
461+
369462
HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
370463
if (!E) {
371464
return 0.0f;
@@ -410,6 +503,11 @@ Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_po
410503

411504
float Input::get_joy_axis(int p_device, JoyAxis p_axis) const {
412505
_THREAD_SAFE_METHOD_
506+
507+
if (disable_input) {
508+
return 0;
509+
}
510+
413511
JoyAxis c = _combine_device(p_axis, p_device);
414512
if (_joy_axis.has(c)) {
415513
return _joy_axis[c];
@@ -1664,6 +1762,14 @@ int Input::get_unused_joy_id() {
16641762
return -1;
16651763
}
16661764

1765+
void Input::set_disable_input(bool p_disable) {
1766+
disable_input = p_disable;
1767+
}
1768+
1769+
bool Input::is_input_disabled() const {
1770+
return disable_input;
1771+
}
1772+
16671773
Input::Input() {
16681774
singleton = this;
16691775

core/input/input.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ class Input : public Object {
103103
Vector2 mouse_pos;
104104
int64_t mouse_window = 0;
105105
bool legacy_just_pressed_behavior = false;
106+
bool disable_input = false;
107+
108+
MouseMode mouse_mode = MOUSE_MODE_VISIBLE;
109+
bool mouse_mode_override_enabled = false;
110+
MouseMode mouse_mode_override = MOUSE_MODE_VISIBLE;
106111

107112
struct ActionState {
108113
uint64_t pressed_physics_frame = UINT64_MAX;
@@ -279,6 +284,8 @@ class Input : public Object {
279284
public:
280285
void set_mouse_mode(MouseMode p_mode);
281286
MouseMode get_mouse_mode() const;
287+
void set_mouse_mode_override_enabled(bool p_enabled);
288+
void set_mouse_mode_override(MouseMode p_mode);
282289

283290
#ifdef TOOLS_ENABLED
284291
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
@@ -380,6 +387,9 @@ class Input : public Object {
380387

381388
void set_event_dispatch_function(EventDispatchFunc p_function);
382389

390+
void set_disable_input(bool p_disable);
391+
bool is_input_disabled() const;
392+
383393
Input();
384394
~Input();
385395
};

doc/classes/EditorFeatureProfile.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@
121121
<constant name="FEATURE_HISTORY_DOCK" value="7" enum="Feature">
122122
The History dock. If this feature is disabled, the History dock won't be visible.
123123
</constant>
124-
<constant name="FEATURE_MAX" value="8" enum="Feature">
124+
<constant name="FEATURE_GAME" value="8" enum="Feature">
125+
The Game tab, which allows embedding the game window and selecting nodes by clicking inside of it. If this feature is disabled, the Game tab won't display.
126+
</constant>
127+
<constant name="FEATURE_MAX" value="9" enum="Feature">
125128
Represents the size of the [enum Feature] enum.
126129
</constant>
127130
</constants>

editor/debugger/editor_debugger_node.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
105105
node->connect("breakpoint_selected", callable_mp(this, &EditorDebuggerNode::_error_selected).bind(id));
106106
node->connect("clear_execution", callable_mp(this, &EditorDebuggerNode::_clear_execution));
107107
node->connect("breaked", callable_mp(this, &EditorDebuggerNode::_breaked).bind(id));
108+
node->connect("remote_tree_select_requested", callable_mp(this, &EditorDebuggerNode::_remote_tree_select_requested).bind(id));
108109
node->connect("remote_tree_updated", callable_mp(this, &EditorDebuggerNode::_remote_tree_updated).bind(id));
109110
node->connect("remote_object_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_updated).bind(id));
110111
node->connect("remote_object_property_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_property_updated).bind(id));
@@ -637,6 +638,13 @@ void EditorDebuggerNode::request_remote_tree() {
637638
get_current_debugger()->request_remote_tree();
638639
}
639640

641+
void EditorDebuggerNode::_remote_tree_select_requested(ObjectID p_id, int p_debugger) {
642+
if (p_debugger != tabs->get_current_tab()) {
643+
return;
644+
}
645+
remote_scene_tree->select_node(p_id);
646+
}
647+
640648
void EditorDebuggerNode::_remote_tree_updated(int p_debugger) {
641649
if (p_debugger != tabs->get_current_tab()) {
642650
return;

editor/debugger/editor_debugger_node.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ class EditorDebuggerNode : public MarginContainer {
5151
public:
5252
enum CameraOverride {
5353
OVERRIDE_NONE,
54-
OVERRIDE_2D,
55-
OVERRIDE_3D_1, // 3D Viewport 1
56-
OVERRIDE_3D_2, // 3D Viewport 2
57-
OVERRIDE_3D_3, // 3D Viewport 3
58-
OVERRIDE_3D_4 // 3D Viewport 4
54+
OVERRIDE_INGAME,
55+
OVERRIDE_EDITORS,
5956
};
6057

6158
private:
@@ -132,6 +129,7 @@ class EditorDebuggerNode : public MarginContainer {
132129
void _debugger_stopped(int p_id);
133130
void _debugger_wants_stop(int p_id);
134131
void _debugger_changed(int p_tab);
132+
void _remote_tree_select_requested(ObjectID p_id, int p_debugger);
135133
void _remote_tree_updated(int p_debugger);
136134
void _remote_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
137135
void _remote_object_updated(ObjectID p_id, int p_debugger);

0 commit comments

Comments
 (0)