diff options
author | K. S. Ernest (iFire) Lee <fire@users.noreply.github.com> | 2022-07-18 17:58:27 -0700 |
---|---|---|
committer | Lyuma <xn.lyuma@gmail.com> | 2023-01-27 02:02:02 -0800 |
commit | 39922d7167178bab9587aa00a7a108b93db6240e (patch) | |
tree | 51e404a83385757d913207cee245a1af6aba8512 /core/string | |
parent | d1e5903c67956707948b1de370b807e3aad395b7 (diff) |
Handle gltf binary
[ Ignore and Warn | Extract Textures (default) | Optimize Loading Embedded as Basisu ]
Enable compressed mip maps from Basis Universal for faster compressions.
Increase the quality of Basis to avoid corruption.
To keep compatibility use the first mip of the previous internal Godot format.
Because texture names may have invalid filename characters, adds String::validate_filename to sanitize filenames for import pipeline use.
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/ustring.cpp | 20 | ||||
-rw-r--r-- | core/string/ustring.h | 1 |
2 files changed, 20 insertions, 1 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 9e468f7075..b34d9f3271 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -4342,6 +4342,9 @@ bool String::is_valid_html_color() const { return Color::html_is_valid(*this); } +// Changes made to the set of invalid filename characters must also be reflected in the String documentation for is_valid_filename. +static const char *invalid_filename_characters = ": / \\ ? * \" | % < >"; + bool String::is_valid_filename() const { String stripped = strip_edges(); if (*this != stripped) { @@ -4352,7 +4355,22 @@ bool String::is_valid_filename() const { return false; } - return !(find(":") != -1 || find("/") != -1 || find("\\") != -1 || find("?") != -1 || find("*") != -1 || find("\"") != -1 || find("|") != -1 || find("%") != -1 || find("<") != -1 || find(">") != -1); + Vector<String> chars = String(invalid_filename_characters).split(" "); + for (const String &ch : chars) { + if (contains(ch)) { + return false; + } + } + return true; +} + +String String::validate_filename() const { + Vector<String> chars = String(invalid_filename_characters).split(" "); + String name = strip_edges(); + for (int i = 0; i < chars.size(); i++) { + name = name.replace(chars[i], "_"); + } + return name; } bool String::is_valid_ip_address() const { diff --git a/core/string/ustring.h b/core/string/ustring.h index 6338f1d3cd..1582504c57 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -433,6 +433,7 @@ public: static const String invalid_node_name_characters; String validate_node_name() const; String validate_identifier() const; + String validate_filename() const; bool is_valid_identifier() const; bool is_valid_int() const; |