Merge pull request #55324 from akien-mga/3.x-cherrypicks

This commit is contained in:
Rémi Verschelde 2021-11-25 23:49:09 +01:00 committed by GitHub
commit 81d1d5a30f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 69 additions and 17 deletions

View file

@ -289,6 +289,13 @@ opts.Update(env_base)
env_base["platform"] = selected_platform # Must always be re-set after calling opts.Update().
Help(opts.GenerateHelpText(env_base))
# Detect and print a warning listing unknown SCons variables to ease troubleshooting.
unknown = opts.UnknownVariables()
if unknown:
print("WARNING: Unknown SCons variables were passed and will be ignored:")
for item in unknown.items():
print(" " + item[0] + "=" + item[1])
# add default include paths
env_base.Prepend(CPPPATH=["#"])

View file

@ -55,6 +55,7 @@ Input::MouseMode Input::get_mouse_mode() const {
void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_key_pressed", "scancode"), &Input::is_key_pressed);
ClassDB::bind_method(D_METHOD("is_physical_key_pressed", "scancode"), &Input::is_physical_key_pressed);
ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed);
ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed);
ClassDB::bind_method(D_METHOD("is_action_pressed", "action", "exact"), &Input::is_action_pressed, DEFVAL(false));

View file

@ -79,6 +79,7 @@ public:
static Input *get_singleton();
virtual bool is_key_pressed(int p_scancode) const = 0;
virtual bool is_physical_key_pressed(int p_scancode) const = 0;
virtual bool is_mouse_button_pressed(int p_button) const = 0;
virtual bool is_joy_button_pressed(int p_device, int p_button) const = 0;
virtual bool is_action_pressed(const StringName &p_action, bool p_exact = false) const = 0;

View file

@ -97,6 +97,7 @@ Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_off
}
Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, bool &err) const {
ERR_FAIL_COND_V(p_ofs + 4 > (uint32_t)data.size(), Variant());
uint32_t type = decode_uint32(p_buf + p_ofs);
if (type == TYPE_ARRAY || type == TYPE_DICT) {
@ -119,6 +120,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b
}
uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
ERR_FAIL_COND_V(p_ofs + 4 > (uint32_t)data.size(), 0);
PoolVector<uint8_t>::Read rd = data.read();
ERR_FAIL_COND_V(!rd.ptr(), 0);
const uint8_t *r = &rd[p_ofs];
@ -128,6 +130,7 @@ uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
};
int PackedDataContainer::_size(uint32_t p_ofs) const {
ERR_FAIL_COND_V(p_ofs + 4 > (uint32_t)data.size(), 0);
PoolVector<uint8_t>::Read rd = data.read();
ERR_FAIL_COND_V(!rd.ptr(), 0);
const uint8_t *r = &rd[p_ofs];
@ -146,6 +149,7 @@ int PackedDataContainer::_size(uint32_t p_ofs) const {
};
Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, bool &err) const {
ERR_FAIL_COND_V(p_ofs + 4 > (uint32_t)data.size(), Variant());
PoolVector<uint8_t>::Read rd = data.read();
if (!rd.ptr()) {
err = true;

View file

@ -340,12 +340,12 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) {
* If a project file is found, load it or fail.
* If nothing was found, error out.
*/
Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, bool p_upwards, bool p_ignore_override) {
// If looking for files in a network client, use it directly
if (FileAccessNetworkClient::get_singleton()) {
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) {
if (err == OK && !p_ignore_override) {
// Optional, we don't mind if it fails
_load_settings_text("res://override.cfg");
}
@ -359,7 +359,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
ERR_FAIL_COND_V_MSG(!ok, ERR_CANT_OPEN, "Cannot open resource pack '" + p_main_pack + "'.");
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) {
if (err == OK && !p_ignore_override) {
// Load override from location of the main pack
// Optional, we don't mind if it fails
_load_settings_text(p_main_pack.get_base_dir().plus_file("override.cfg"));
@ -409,7 +409,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
// If we opened our package, try and load our project.
if (found) {
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) {
if (err == OK && !p_ignore_override) {
// Load override from location of the executable.
// Optional, we don't mind if it fails.
_load_settings_text(exec_path.get_base_dir().plus_file("override.cfg"));
@ -430,7 +430,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
}
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) {
if (err == OK && !p_ignore_override) {
// Optional, we don't mind if it fails.
_load_settings_text("res://override.cfg");
}
@ -451,7 +451,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
while (true) {
err = _load_settings_text_or_binary(current_dir.plus_file("project.godot"), current_dir.plus_file("project.binary"));
if (err == OK) {
if (err == OK && !p_ignore_override) {
// Optional, we don't mind if it fails.
_load_settings_text(current_dir.plus_file("override.cfg"));
candidate = current_dir;
@ -486,8 +486,8 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
return OK;
}
Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
Error err = _setup(p_path, p_main_pack, p_upwards);
Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards, bool p_ignore_override) {
Error err = _setup(p_path, p_main_pack, p_upwards, p_ignore_override);
if (err == OK) {
String custom_settings = GLOBAL_DEF("application/config/project_settings_override", "");
if (custom_settings != "") {

View file

@ -115,7 +115,7 @@ protected:
void _add_property_info_bind(const Dictionary &p_info);
Error _setup(const String &p_path, const String &p_main_pack, bool p_upwards = false);
Error _setup(const String &p_path, const String &p_main_pack, bool p_upwards = false, bool p_ignore_override = false);
static void _bind_methods();
@ -148,7 +148,7 @@ public:
void set_order(const String &p_name, int p_order);
void set_builtin_order(const String &p_name);
Error setup(const String &p_path, const String &p_main_pack, bool p_upwards = false);
Error setup(const String &p_path, const String &p_main_pack, bool p_upwards = false, bool p_ignore_override = false);
Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
Error save();

View file

@ -264,6 +264,13 @@
Returns [code]true[/code] if you are pressing the mouse button specified with [enum ButtonList].
</description>
</method>
<method name="is_physical_key_pressed" qualifiers="const">
<return type="bool" />
<argument index="0" name="scancode" type="int" />
<description>
Returns [code]true[/code] if you are pressing the key in the physical location on the 101/102-key US QWERTY keyboard. You can pass a [enum KeyList] constant.
</description>
</method>
<method name="joy_connection_changed">
<return type="void" />
<argument index="0" name="device" type="int" />

View file

@ -202,6 +202,14 @@
<description>
Returns an array listing the groups that the node is a member of.
[b]Note:[/b] For performance reasons, the order of node groups is [i]not[/i] guaranteed. The order of node groups should not be relied upon as it can vary across project runs.
[b]Note:[/b] The engine uses some group names internally (all starting with an underscore). To avoid conflicts with internal groups, do not add custom groups whose name starts with an underscore. To exclude internal groups while looping over [method get_groups], use the following snippet:
[codeblock]
# Stores the node's non-internal groups only (as an array of Strings).
var non_internal_groups = []
for group in get_groups():
if not group.begins_with("_"):
non_internal_groups.push_back(group)
[/codeblock]
</description>
</method>
<method name="get_index" qualifiers="const">
@ -513,6 +521,7 @@
<argument index="1" name="keep_data" type="bool" default="false" />
<description>
Replaces a node in a scene by the given one. Subscriptions that pass through this node will be lost.
Note that the replaced node is not automatically freed, so you either need to keep it in a variable for later use or free it using [method Object.free].
</description>
</method>
<method name="request_ready">

View file

@ -201,6 +201,7 @@
<argument index="0" name="property" type="NodePath" />
<description>
Gets the object's property indexed by the given [NodePath]. The node path should be relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Examples: [code]"position:x"[/code] or [code]"material:next_pass:blend_mode"[/code].
[b]Note:[/b] Even though the method takes [NodePath] argument, it doesn't support actual paths to [Node]s in the scene tree, only colon-separated sub-property paths. For the purpose of nodes, use [method Node.get_node_and_resource] instead.
</description>
</method>
<method name="get_instance_id" qualifiers="const">

View file

@ -6790,10 +6790,12 @@ EditorNode::EditorNode() {
file_export_lib->connect("file_selected", this, "_dialog_action");
file_export_lib_merge = memnew(CheckBox);
file_export_lib_merge->set_text(TTR("Merge With Existing"));
file_export_lib_merge->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
file_export_lib_merge->set_pressed(true);
file_export_lib->get_vbox()->add_child(file_export_lib_merge);
file_export_lib_apply_xforms = memnew(CheckBox);
file_export_lib_apply_xforms->set_text(TTR("Apply MeshInstance Transforms"));
file_export_lib_apply_xforms->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
file_export_lib_apply_xforms->set_pressed(false);
file_export_lib->get_vbox()->add_child(file_export_lib_apply_xforms);
gui_base->add_child(file_export_lib);

View file

@ -71,6 +71,9 @@ void ThemeEditorPreview::_preview_visibility_changed() {
void ThemeEditorPreview::_picker_button_cbk() {
picker_overlay->set_visible(picker_button->is_pressed());
if (picker_button->is_pressed()) {
_reset_picker_overlay();
}
}
Control *ThemeEditorPreview::_find_hovered_control(Control *p_parent, Vector2 p_mouse_position) {

View file

@ -1174,11 +1174,13 @@ ProjectExportDialog::ProjectExportDialog() {
export_debug = memnew(CheckBox);
export_debug->set_text(TTR("Export With Debug"));
export_debug->set_pressed(true);
export_debug->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
export_project->get_vbox()->add_child(export_debug);
export_pck_zip_debug = memnew(CheckBox);
export_pck_zip_debug->set_text(TTR("Export With Debug"));
export_pck_zip_debug->set_pressed(true);
export_pck_zip_debug->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
export_pck_zip->get_vbox()->add_child(export_pck_zip_debug);
set_hide_on_ok(false);

View file

@ -76,6 +76,11 @@ bool InputDefault::is_key_pressed(int p_scancode) const {
return keys_pressed.has(p_scancode);
}
bool InputDefault::is_physical_key_pressed(int p_scancode) const {
_THREAD_SAFE_METHOD_
return physical_keys_pressed.has(p_scancode);
}
bool InputDefault::is_mouse_button_pressed(int p_button) const {
_THREAD_SAFE_METHOD_
return (mouse_button_mask & (1 << (p_button - 1))) != 0;
@ -316,6 +321,13 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
keys_pressed.erase(k->get_scancode());
}
}
if (k.is_valid() && !k->is_echo() && k->get_physical_scancode() != 0) {
if (k->is_pressed()) {
physical_keys_pressed.insert(k->get_physical_scancode());
} else {
physical_keys_pressed.erase(k->get_physical_scancode());
}
}
Ref<InputEventMouseButton> mb = p_event;
@ -716,6 +728,7 @@ void InputDefault::release_pressed_events() {
flush_buffered_events(); // this is needed to release actions strengths
keys_pressed.clear();
physical_keys_pressed.clear();
joy_buttons_pressed.clear();
_joy_axis.clear();

View file

@ -39,6 +39,7 @@ class InputDefault : public Input {
int mouse_button_mask;
Set<int> physical_keys_pressed;
Set<int> keys_pressed;
Set<int> joy_buttons_pressed;
Map<int, float> _joy_axis;
@ -220,6 +221,7 @@ protected:
public:
virtual bool is_key_pressed(int p_scancode) const;
virtual bool is_physical_key_pressed(int p_scancode) const;
virtual bool is_mouse_button_pressed(int p_button) const;
virtual bool is_joy_button_pressed(int p_device, int p_button) const;
virtual bool is_action_pressed(const StringName &p_action, bool p_exact = false) const;

View file

@ -887,7 +887,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
FileAccess::make_default<FileAccessNetwork>(FileAccess::ACCESS_RESOURCES);
}
if (globals->setup(project_path, main_pack, upwards) == OK) {
if (globals->setup(project_path, main_pack, upwards, editor) == OK) {
#ifdef TOOLS_ENABLED
found_project = true;
#endif

View file

@ -272,9 +272,9 @@
- 1.0: Linear
- Between -1.0 and 0.0 (exclusive): Ease out-in
- 0.0: Constant
- Between 0.0 to 1.0 (exclusive): Ease in
- Between 0.0 to 1.0 (exclusive): Ease out
- 1.0: Linear
- Greater than 1.0 (exclusive): Ease out
- Greater than 1.0 (exclusive): Ease in
[/codeblock]
[url=https://raw.githubusercontent.com/godotengine/godot-docs/3.4/img/ease_cheatsheet.png]ease() curve values cheatsheet[/url]
See also [method smoothstep]. If you need to perform more advanced transitions, use [Tween] or [AnimationPlayer].

View file

@ -183,7 +183,7 @@
// #define THROW_RUNTIME_ERROR(str)
// throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
#define THROW_RUNTIME_ERROR(str) \
printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort();
printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
// -- GODOT end --
#else
// -- GODOT start --

View file

@ -126,7 +126,7 @@ namespace embree
// #define throw_RTCError(error,str) \
// throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
#define throw_RTCError(error,str) \
printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort();
printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
// -- GODOT end --
#else
// -- GODOT begin --

View file

@ -259,7 +259,7 @@ index 8a6d9fa0a9..697e07bb86 100644
+ // throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
#define THROW_RUNTIME_ERROR(str) \
- throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
+ printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort();
+ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
+ // -- GODOT end --
#else
+ // -- GODOT start --
@ -583,7 +583,7 @@ index 4e4b24e9c2..373e49a689 100644
+ // throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
#define throw_RTCError(error,str) \
- throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
+ printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort();
+ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
+ // -- GODOT end --
#else
+ // -- GODOT begin --