summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/file_access_pack.cpp13
-rw-r--r--core/io/file_access_pack.h8
-rw-r--r--core/io/file_access_zip.cpp4
-rw-r--r--core/io/file_access_zip.h2
-rw-r--r--core/project_settings.cpp6
-rw-r--r--core/project_settings.h2
-rw-r--r--doc/classes/ProjectSettings.xml4
-rw-r--r--editor/script_editor_debugger.cpp110
-rw-r--r--scene/main/viewport.cpp6
9 files changed, 103 insertions, 52 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index a4821e0ce8..54ef753b7c 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -36,11 +36,11 @@
#define PACK_VERSION 1
-Error PackedData::add_pack(const String &p_path) {
+Error PackedData::add_pack(const String &p_path, bool p_replace_files) {
for (int i = 0; i < sources.size(); i++) {
- if (sources[i]->try_open_pack(p_path)) {
+ if (sources[i]->try_open_pack(p_path, p_replace_files)) {
return OK;
};
@@ -49,7 +49,7 @@ Error PackedData::add_pack(const String &p_path) {
return ERR_FILE_UNRECOGNIZED;
};
-void PackedData::add_path(const String &pkg_path, const String &path, uint64_t ofs, uint64_t size, const uint8_t *p_md5, PackSource *p_src) {
+void PackedData::add_path(const String &pkg_path, const String &path, uint64_t ofs, uint64_t size, const uint8_t *p_md5, PackSource *p_src, bool p_replace_files) {
PathMD5 pmd5(path.md5_buffer());
//printf("adding path %ls, %lli, %lli\n", path.c_str(), pmd5.a, pmd5.b);
@@ -64,7 +64,8 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o
pf.md5[i] = p_md5[i];
pf.src = p_src;
- files[pmd5] = pf;
+ if (!exists || p_replace_files)
+ files[pmd5] = pf;
if (!exists) {
//search for dir
@@ -133,7 +134,7 @@ PackedData::~PackedData() {
//////////////////////////////////////////////////////////////////
-bool PackedSourcePCK::try_open_pack(const String &p_path) {
+bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) {
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f)
@@ -196,7 +197,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) {
uint64_t size = f->get_64();
uint8_t md5[16];
f->get_buffer(md5, 16);
- PackedData::get_singleton()->add_path(p_path, path, ofs, size, md5, this);
+ PackedData::get_singleton()->add_path(p_path, path, ofs, size, md5, this, p_replace_files);
};
return true;
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index a21dd7d22d..8c34069f3a 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -102,13 +102,13 @@ private:
public:
void add_pack_source(PackSource *p_source);
- void add_path(const String &pkg_path, const String &path, uint64_t ofs, uint64_t size, const uint8_t *p_md5, PackSource *p_src); // for PackSource
+ void add_path(const String &pkg_path, const String &path, uint64_t ofs, uint64_t size, const uint8_t *p_md5, PackSource *p_src, bool p_replace_files); // for PackSource
void set_disabled(bool p_disabled) { disabled = p_disabled; }
_FORCE_INLINE_ bool is_disabled() const { return disabled; }
static PackedData *get_singleton() { return singleton; }
- Error add_pack(const String &p_path);
+ Error add_pack(const String &p_path, bool p_replace_files);
_FORCE_INLINE_ FileAccess *try_open_path(const String &p_path);
_FORCE_INLINE_ bool has_path(const String &p_path);
@@ -120,7 +120,7 @@ public:
class PackSource {
public:
- virtual bool try_open_pack(const String &p_path) = 0;
+ virtual bool try_open_pack(const String &p_path, bool p_replace_files) = 0;
virtual FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file) = 0;
virtual ~PackSource() {}
};
@@ -128,7 +128,7 @@ public:
class PackedSourcePCK : public PackSource {
public:
- virtual bool try_open_pack(const String &p_path);
+ virtual bool try_open_pack(const String &p_path, bool p_replace_files);
virtual FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file);
};
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index 81568b2aae..3187f3bab6 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -160,7 +160,7 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
return pkg;
}
-bool ZipArchive::try_open_pack(const String &p_path) {
+bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) {
//printf("opening zip pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
if (p_path.get_extension().nocasecmp_to("zip") != 0 && p_path.get_extension().nocasecmp_to("pcz") != 0)
@@ -210,7 +210,7 @@ bool ZipArchive::try_open_pack(const String &p_path) {
files[fname] = f;
uint8_t md5[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- PackedData::get_singleton()->add_path(p_path, fname, 1, 0, md5, this);
+ PackedData::get_singleton()->add_path(p_path, fname, 1, 0, md5, this, p_replace_files);
//printf("packed data add path %ls, %ls\n", p_name.c_str(), fname.c_str());
if ((i + 1) < gi.number_entry) {
diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h
index 217176c0af..cdd50f9eb3 100644
--- a/core/io/file_access_zip.h
+++ b/core/io/file_access_zip.h
@@ -74,7 +74,7 @@ public:
bool file_exists(String p_name) const;
- virtual bool try_open_pack(const String &p_path);
+ virtual bool try_open_pack(const String &p_path, bool p_replace_files);
FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file);
static ZipArchive *get_singleton();
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 9e3b9bd1e4..c2241ed926 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -264,12 +264,12 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-bool ProjectSettings::_load_resource_pack(const String &p_pack) {
+bool ProjectSettings::_load_resource_pack(const String &p_pack, bool p_replace_files) {
if (PackedData::get_singleton()->is_disabled())
return false;
- bool ok = PackedData::get_singleton()->add_pack(p_pack) == OK;
+ bool ok = PackedData::get_singleton()->add_pack(p_pack, p_replace_files) == OK;
if (!ok)
return false;
@@ -979,7 +979,7 @@ void ProjectSettings::_bind_methods() {
ClassDB::bind_method(D_METHOD("localize_path", "path"), &ProjectSettings::localize_path);
ClassDB::bind_method(D_METHOD("globalize_path", "path"), &ProjectSettings::globalize_path);
ClassDB::bind_method(D_METHOD("save"), &ProjectSettings::save);
- ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &ProjectSettings::_load_resource_pack);
+ ClassDB::bind_method(D_METHOD("load_resource_pack", "pack", "replace_files"), &ProjectSettings::_load_resource_pack, DEFVAL(true));
ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert);
ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ProjectSettings::property_get_revert);
diff --git a/core/project_settings.h b/core/project_settings.h
index a8deab028c..b32470361b 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -104,7 +104,7 @@ protected:
void _convert_to_last_version(int p_from_version);
- bool _load_resource_pack(const String &p_pack);
+ bool _load_resource_pack(const String &p_pack, bool p_replace_files = true);
void _add_property_info_bind(const Dictionary &p_info);
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 3da403c681..abf7c4d4e0 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -80,9 +80,11 @@
</return>
<argument index="0" name="pack" type="String">
</argument>
+ <argument index="1" name="replace_files" type="bool" default="true">
+ </argument>
<description>
Loads the contents of the .pck or .zip file specified by [code]pack[/code] into the resource filesystem ([code]res://[/code]). Returns [code]true[/code] on success.
- [b]Note:[/b] If a file from [code]pack[/code] shares the same path as a file already in the resource filesystem, any attempts to load that file will use the file from [code]pack[/code].
+ [b]Note:[/b] If a file from [code]pack[/code] shares the same path as a file already in the resource filesystem, any attempts to load that file will use the file from [code]pack[/code] unless [code]replace_files[/code] is set to [code]false[/code].
</description>
</method>
<method name="localize_path" qualifiers="const">
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 6ba507fb9c..6a9dbb103a 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -804,60 +804,102 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
} else if (p_msg == "error") {
- Array err = p_data[0];
-
- Array vals;
- vals.push_back(err[0]);
- vals.push_back(err[1]);
- vals.push_back(err[2]);
- vals.push_back(err[3]);
+ // Should have at least two elements, error array and stack items count.
+ ERR_FAIL_COND_MSG(p_data.size() < 2, "Malformed error message from script debugger.");
- bool warning = err[9];
+ // Error or warning data.
+ Array err = p_data[0];
+ ERR_FAIL_COND_MSG(err.size() < 10, "Malformed error message from script debugger.");
+
+ // Format time.
+ Array time_vals;
+ time_vals.push_back(err[0]);
+ time_vals.push_back(err[1]);
+ time_vals.push_back(err[2]);
+ time_vals.push_back(err[3]);
bool e;
- String time = String("%d:%02d:%02d:%04d").sprintf(vals, &e);
- String txt = err[8].is_zero() ? String(err[7]) : String(err[8]);
+ String time = String("%d:%02d:%02d:%04d").sprintf(time_vals, &e);
+ // Rest of the error data.
+ String method = err[4];
+ String source_file = err[5];
+ String source_line = err[6];
+ String error_cond = err[7];
+ String error_msg = err[8];
+ bool is_warning = err[9];
+ bool has_method = !method.empty();
+ bool has_error_msg = !error_msg.empty();
+ bool source_is_project_file = source_file.begins_with("res://");
+
+ // Metadata to highlight error line in scripts.
+ Array source_meta;
+ source_meta.push_back(source_file);
+ source_meta.push_back(source_line);
+
+ // Create error tree to display above error or warning details.
TreeItem *r = error_tree->get_root();
if (!r) {
r = error_tree->create_item();
}
+ // Also provide the relevant details as tooltip to quickly check without
+ // uncollapsing the tree.
+ String tooltip = is_warning ? TTR("Warning:") : TTR("Error:");
+
TreeItem *error = error_tree->create_item(r);
error->set_collapsed(true);
- error->set_icon(0, get_icon(warning ? "Warning" : "Error", "EditorIcons"));
+ error->set_icon(0, get_icon(is_warning ? "Warning" : "Error", "EditorIcons"));
error->set_text(0, time);
error->set_text_align(0, TreeItem::ALIGN_LEFT);
- error->set_text(1, txt);
-
- String source(err[5]);
- bool source_is_project_file = source.begins_with("res://");
- if (source_is_project_file)
- txt = source.get_file() + ":" + String(err[6]);
- else
- txt = source + ":" + String(err[6]);
+ String error_title;
+ // Include method name, when given, in error title.
+ if (has_method)
+ error_title += method + ": ";
+ // If we have a (custom) error message, use it as title, and add a C++ Error
+ // item with the original error condition.
+ error_title += error_msg.empty() ? error_cond : error_msg;
+ error->set_text(1, error_title);
+ tooltip += " " + error_title + "\n";
+
+ if (has_error_msg) {
+ // Add item for C++ error condition.
+ TreeItem *cpp_cond = error_tree->create_item(error);
+ cpp_cond->set_text(0, "<" + TTR("C++ Error") + ">");
+ cpp_cond->set_text(1, error_cond);
+ cpp_cond->set_text_align(0, TreeItem::ALIGN_LEFT);
+ tooltip += TTR("C++ Error:") + " " + error_cond + "\n";
+ if (source_is_project_file)
+ cpp_cond->set_metadata(0, source_meta);
+ }
- String method = err[4];
- if (method.length() > 0)
- txt += " @ " + method + "()";
+ // Source of the error.
+ String source_txt = (source_is_project_file ? source_file.get_file() : source_file) + ":" + source_line;
+ if (has_method)
+ source_txt += " @ " + method + "()";
- TreeItem *c_info = error_tree->create_item(error);
- c_info->set_text(0, "<" + TTR(source_is_project_file ? "Source" : "C Source") + ">");
- c_info->set_text(1, txt);
- c_info->set_text_align(0, TreeItem::ALIGN_LEFT);
+ TreeItem *cpp_source = error_tree->create_item(error);
+ cpp_source->set_text(0, "<" + (source_is_project_file ? TTR("Source") : TTR("C++ Source")) + ">");
+ cpp_source->set_text(1, source_txt);
+ cpp_source->set_text_align(0, TreeItem::ALIGN_LEFT);
+ tooltip += (source_is_project_file ? TTR("Source:") : TTR("C++ Source:")) + " " + source_txt + "\n";
+ // Set metadata to highlight error line in scripts.
if (source_is_project_file) {
- Array meta;
- meta.push_back(source);
- meta.push_back(err[6]);
- error->set_metadata(0, meta);
- c_info->set_metadata(0, meta);
+ error->set_metadata(0, source_meta);
+ cpp_source->set_metadata(0, source_meta);
}
- int scc = p_data[1];
+ error->set_tooltip(0, tooltip);
+ error->set_tooltip(1, tooltip);
+
+ // Format stack trace.
+ // stack_items_count is the number of elements to parse, with 3 items per frame
+ // of the stack trace (script, method, line).
+ int stack_items_count = p_data[1];
- for (int i = 0; i < scc; i += 3) {
+ for (int i = 0; i < stack_items_count; i += 3) {
String script = p_data[2 + i];
String method2 = p_data[3 + i];
int line = p_data[4 + i];
@@ -876,7 +918,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
stack_trace->set_text(1, script.get_file() + ":" + itos(line) + " @ " + method2 + "()");
}
- if (warning)
+ if (is_warning)
warning_count++;
else
error_count++;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 04278b2902..39c5759871 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1742,6 +1742,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
return; // no one gets the event if exclusive NO ONE
}
+ if (mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_DOWN || mb->get_button_index() == BUTTON_WHEEL_LEFT || mb->get_button_index() == BUTTON_WHEEL_RIGHT) {
+ //cancel scroll wheel events, only clicks should trigger focus changes.
+ set_input_as_handled();
+ return;
+ }
+
top->notification(Control::NOTIFICATION_MODAL_CLOSE);
top->_modal_stack_remove();
top->hide();