Skip to content

Commit

Permalink
Merge 2535b8f into 44fa552
Browse files Browse the repository at this point in the history
  • Loading branch information
YeldhamDev authored Oct 21, 2024
2 parents 44fa552 + 2535b8f commit 2ee6e45
Show file tree
Hide file tree
Showing 45 changed files with 2,346 additions and 271 deletions.
8 changes: 8 additions & 0 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ void Engine::set_time_scale(double p_scale) {
}

double Engine::get_time_scale() const {
return freeze_time_scale ? 0 : _time_scale;
}

double Engine::get_unfrozen_time_scale() const {
return _time_scale;
}

Expand Down Expand Up @@ -392,6 +396,10 @@ bool Engine::notify_frame_server_synced() {
return server_syncs > SERVER_SYNC_FRAME_COUNT_WARNING;
}

void Engine::set_freeze_time_scale(bool p_frozen) {
freeze_time_scale = p_frozen;
}

Engine::Engine() {
singleton = this;
}
Expand Down
5 changes: 5 additions & 0 deletions core/config/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class Engine {
int server_syncs = 0;
bool frame_server_synced = false;

bool freeze_time_scale = false;

public:
static Engine *get_singleton();

Expand Down Expand Up @@ -127,6 +129,7 @@ class Engine {

void set_time_scale(double p_scale);
double get_time_scale() const;
double get_unfrozen_time_scale() const;

void set_print_to_stdout(bool p_enabled);
bool is_printing_to_stdout() const;
Expand Down Expand Up @@ -191,6 +194,8 @@ class Engine {
void increment_frames_drawn();
bool notify_frame_server_synced();

void set_freeze_time_scale(bool p_frozen);

Engine();
virtual ~Engine();
};
Expand Down
108 changes: 107 additions & 1 deletion core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,50 @@ Input *Input::get_singleton() {

void Input::set_mouse_mode(MouseMode p_mode) {
ERR_FAIL_INDEX((int)p_mode, 5);

if (p_mode == mouse_mode) {
return;
}

// Allow to be set even if overridden, to see if the platform allows the mode.
set_mouse_mode_func(p_mode);
mouse_mode = get_mouse_mode_func();

if (mouse_mode_override_enabled) {
set_mouse_mode_func(mouse_mode_override);
}
}

Input::MouseMode Input::get_mouse_mode() const {
return get_mouse_mode_func();
return mouse_mode;
}

void Input::set_mouse_mode_override_enabled(bool p_enabled) {
if (p_enabled == mouse_mode_override_enabled) {
return;
}

mouse_mode_override_enabled = p_enabled;

if (p_enabled) {
set_mouse_mode_func(mouse_mode_override);
mouse_mode_override = get_mouse_mode_func();
} else {
set_mouse_mode_func(mouse_mode);
}
}

void Input::set_mouse_mode_override(MouseMode p_mode) {
ERR_FAIL_INDEX((int)p_mode, 5);

if (p_mode == mouse_mode_override) {
return;
}

if (mouse_mode_override_enabled) {
set_mouse_mode_func(p_mode);
mouse_mode_override = get_mouse_mode_func();
}
}

void Input::_bind_methods() {
Expand Down Expand Up @@ -252,6 +291,10 @@ Input::VelocityTrack::VelocityTrack() {
bool Input::is_anything_pressed() const {
_THREAD_SAFE_METHOD_

if (disable_input) {
return false;
}

if (!keys_pressed.is_empty() || !joy_buttons_pressed.is_empty() || !mouse_button_mask.is_empty()) {
return true;
}
Expand All @@ -267,21 +310,41 @@ bool Input::is_anything_pressed() const {

bool Input::is_key_pressed(Key p_keycode) const {
_THREAD_SAFE_METHOD_

if (disable_input) {
return false;
}

return keys_pressed.has(p_keycode);
}

bool Input::is_physical_key_pressed(Key p_keycode) const {
_THREAD_SAFE_METHOD_

if (disable_input) {
return false;
}

return physical_keys_pressed.has(p_keycode);
}

bool Input::is_key_label_pressed(Key p_keycode) const {
_THREAD_SAFE_METHOD_

if (disable_input) {
return false;
}

return key_label_pressed.has(p_keycode);
}

bool Input::is_mouse_button_pressed(MouseButton p_button) const {
_THREAD_SAFE_METHOD_

if (disable_input) {
return false;
}

return mouse_button_mask.has_flag(mouse_button_to_mask(p_button));
}

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

bool Input::is_joy_button_pressed(int p_device, JoyButton p_button) const {
_THREAD_SAFE_METHOD_

if (disable_input) {
return false;
}

return joy_buttons_pressed.has(_combine_device(p_button, p_device));
}

bool Input::is_action_pressed(const StringName &p_action, bool p_exact) const {
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action));

if (disable_input) {
return false;
}

HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
if (!E) {
return false;
Expand All @@ -310,6 +383,11 @@ bool Input::is_action_pressed(const StringName &p_action, bool p_exact) const {

bool Input::is_action_just_pressed(const StringName &p_action, bool p_exact) const {
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action));

if (disable_input) {
return false;
}

HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
if (!E) {
return false;
Expand All @@ -331,6 +409,11 @@ bool Input::is_action_just_pressed(const StringName &p_action, bool p_exact) con

bool Input::is_action_just_released(const StringName &p_action, bool p_exact) const {
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action));

if (disable_input) {
return false;
}

HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
if (!E) {
return false;
Expand All @@ -352,6 +435,11 @@ bool Input::is_action_just_released(const StringName &p_action, bool p_exact) co

float Input::get_action_strength(const StringName &p_action, bool p_exact) const {
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), 0.0, InputMap::get_singleton()->suggest_actions(p_action));

if (disable_input) {
return 0.0f;
}

HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
if (!E) {
return 0.0f;
Expand All @@ -366,6 +454,11 @@ float Input::get_action_strength(const StringName &p_action, bool p_exact) const

float Input::get_action_raw_strength(const StringName &p_action, bool p_exact) const {
ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), 0.0, InputMap::get_singleton()->suggest_actions(p_action));

if (disable_input) {
return 0.0f;
}

HashMap<StringName, ActionState>::ConstIterator E = action_states.find(p_action);
if (!E) {
return 0.0f;
Expand Down Expand Up @@ -410,6 +503,11 @@ Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_po

float Input::get_joy_axis(int p_device, JoyAxis p_axis) const {
_THREAD_SAFE_METHOD_

if (disable_input) {
return 0;
}

JoyAxis c = _combine_device(p_axis, p_device);
if (_joy_axis.has(c)) {
return _joy_axis[c];
Expand Down Expand Up @@ -1662,6 +1760,14 @@ int Input::get_unused_joy_id() {
return -1;
}

void Input::set_disable_input(bool p_disable) {
disable_input = p_disable;
}

bool Input::is_input_disabled() const {
return disable_input;
}

Input::Input() {
singleton = this;

Expand Down
10 changes: 10 additions & 0 deletions core/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class Input : public Object {
Vector2 mouse_pos;
int64_t mouse_window = 0;
bool legacy_just_pressed_behavior = false;
bool disable_input = false;

MouseMode mouse_mode = MOUSE_MODE_VISIBLE;
bool mouse_mode_override_enabled = false;
MouseMode mouse_mode_override = MOUSE_MODE_VISIBLE;

struct ActionState {
uint64_t pressed_physics_frame = UINT64_MAX;
Expand Down Expand Up @@ -279,6 +284,8 @@ class Input : public Object {
public:
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
void set_mouse_mode_override_enabled(bool p_enabled);
void set_mouse_mode_override(MouseMode p_mode);

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

void set_event_dispatch_function(EventDispatchFunc p_function);

void set_disable_input(bool p_disable);
bool is_input_disabled() const;

Input();
~Input();
};
Expand Down
5 changes: 4 additions & 1 deletion doc/classes/EditorFeatureProfile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@
<constant name="FEATURE_HISTORY_DOCK" value="7" enum="Feature">
The History dock. If this feature is disabled, the History dock won't be visible.
</constant>
<constant name="FEATURE_MAX" value="8" enum="Feature">
<constant name="FEATURE_GAME" value="8" enum="Feature">
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.
</constant>
<constant name="FEATURE_MAX" value="9" enum="Feature">
Represents the size of the [enum Feature] enum.
</constant>
</constants>
Expand Down
8 changes: 8 additions & 0 deletions editor/debugger/editor_debugger_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
node->connect("breakpoint_selected", callable_mp(this, &EditorDebuggerNode::_error_selected).bind(id));
node->connect("clear_execution", callable_mp(this, &EditorDebuggerNode::_clear_execution));
node->connect("breaked", callable_mp(this, &EditorDebuggerNode::_breaked).bind(id));
node->connect("remote_tree_select_requested", callable_mp(this, &EditorDebuggerNode::_remote_tree_select_requested).bind(id));
node->connect("remote_tree_updated", callable_mp(this, &EditorDebuggerNode::_remote_tree_updated).bind(id));
node->connect("remote_object_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_updated).bind(id));
node->connect("remote_object_property_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_property_updated).bind(id));
Expand Down Expand Up @@ -637,6 +638,13 @@ void EditorDebuggerNode::request_remote_tree() {
get_current_debugger()->request_remote_tree();
}

void EditorDebuggerNode::_remote_tree_select_requested(ObjectID p_id, int p_debugger) {
if (p_debugger != tabs->get_current_tab()) {
return;
}
remote_scene_tree->select_node(p_id);
}

void EditorDebuggerNode::_remote_tree_updated(int p_debugger) {
if (p_debugger != tabs->get_current_tab()) {
return;
Expand Down
8 changes: 3 additions & 5 deletions editor/debugger/editor_debugger_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ class EditorDebuggerNode : public MarginContainer {
public:
enum CameraOverride {
OVERRIDE_NONE,
OVERRIDE_2D,
OVERRIDE_3D_1, // 3D Viewport 1
OVERRIDE_3D_2, // 3D Viewport 2
OVERRIDE_3D_3, // 3D Viewport 3
OVERRIDE_3D_4 // 3D Viewport 4
OVERRIDE_INGAME,
OVERRIDE_EDITORS,
};

private:
Expand Down Expand Up @@ -132,6 +129,7 @@ class EditorDebuggerNode : public MarginContainer {
void _debugger_stopped(int p_id);
void _debugger_wants_stop(int p_id);
void _debugger_changed(int p_tab);
void _remote_tree_select_requested(ObjectID p_id, int p_debugger);
void _remote_tree_updated(int p_debugger);
void _remote_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _remote_object_updated(ObjectID p_id, int p_debugger);
Expand Down
Loading

0 comments on commit 2ee6e45

Please sign in to comment.