summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/core_bind.cpp61
-rw-r--r--core/core_bind.h19
-rw-r--r--doc/classes/Directory.xml30
-rw-r--r--doc/classes/VisualShaderNodeTextureUniform.xml4
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp2
-rw-r--r--scene/resources/material.cpp2
-rw-r--r--scene/resources/visual_shader_nodes.cpp18
-rw-r--r--scene/resources/visual_shader_nodes.h2
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp2
-rw-r--r--servers/rendering/shader_language.cpp10
-rw-r--r--servers/rendering/shader_language.h4
11 files changed, 115 insertions, 39 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 161008fd35..fe026ed38f 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -1470,12 +1470,8 @@ bool Directory::is_open() const {
return d && dir_open;
}
-Error Directory::list_dir_begin(bool p_show_navigational, bool p_show_hidden) {
+Error Directory::list_dir_begin() {
ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
-
- _list_skip_navigational = !p_show_navigational;
- _list_skip_hidden = !p_show_hidden;
-
return d->list_dir_begin();
}
@@ -1483,7 +1479,7 @@ String Directory::get_next() {
ERR_FAIL_COND_V_MSG(!is_open(), "", "Directory must be opened before use.");
String next = d->get_next();
- while (!next.is_empty() && ((_list_skip_navigational && (next == "." || next == "..")) || (_list_skip_hidden && d->current_is_hidden()))) {
+ while (!next.is_empty() && ((!include_navigational && (next == "." || next == "..")) || (!include_hidden && d->current_is_hidden()))) {
next = d->get_next();
}
return next;
@@ -1499,6 +1495,47 @@ void Directory::list_dir_end() {
d->list_dir_end();
}
+PackedStringArray Directory::get_files() {
+ return _get_contents(false);
+}
+
+PackedStringArray Directory::get_directories() {
+ return _get_contents(true);
+}
+
+PackedStringArray Directory::_get_contents(bool p_directories) {
+ PackedStringArray ret;
+ ERR_FAIL_COND_V_MSG(!is_open(), ret, "Directory must be opened before use.");
+
+ list_dir_begin();
+ String s = get_next();
+ while (!s.is_empty()) {
+ if (current_is_dir() == p_directories) {
+ ret.append(s);
+ }
+ s = get_next();
+ }
+
+ ret.sort();
+ return ret;
+}
+
+void Directory::set_include_navigational(bool p_enable) {
+ include_navigational = p_enable;
+}
+
+bool Directory::get_include_navigational() const {
+ return include_navigational;
+}
+
+void Directory::set_include_hidden(bool p_enable) {
+ include_hidden = p_enable;
+}
+
+bool Directory::get_include_hidden() const {
+ return include_hidden;
+}
+
int Directory::get_drive_count() {
ERR_FAIL_COND_V_MSG(!is_open(), 0, "Directory must be opened before use.");
return d->get_drive_count();
@@ -1614,10 +1651,12 @@ Error Directory::remove(String p_name) {
void Directory::_bind_methods() {
ClassDB::bind_method(D_METHOD("open", "path"), &Directory::open);
- ClassDB::bind_method(D_METHOD("list_dir_begin", "show_navigational", "show_hidden"), &Directory::list_dir_begin, DEFVAL(false), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("list_dir_begin"), &Directory::list_dir_begin, DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_next"), &Directory::get_next);
ClassDB::bind_method(D_METHOD("current_is_dir"), &Directory::current_is_dir);
ClassDB::bind_method(D_METHOD("list_dir_end"), &Directory::list_dir_end);
+ ClassDB::bind_method(D_METHOD("get_files"), &Directory::get_files);
+ ClassDB::bind_method(D_METHOD("get_directories"), &Directory::get_directories);
ClassDB::bind_method(D_METHOD("get_drive_count"), &Directory::get_drive_count);
ClassDB::bind_method(D_METHOD("get_drive", "idx"), &Directory::get_drive);
ClassDB::bind_method(D_METHOD("get_current_drive"), &Directory::get_current_drive);
@@ -1632,6 +1671,14 @@ void Directory::_bind_methods() {
ClassDB::bind_method(D_METHOD("copy", "from", "to"), &Directory::copy);
ClassDB::bind_method(D_METHOD("rename", "from", "to"), &Directory::rename);
ClassDB::bind_method(D_METHOD("remove", "path"), &Directory::remove);
+
+ ClassDB::bind_method(D_METHOD("set_include_navigational"), &Directory::set_include_navigational);
+ ClassDB::bind_method(D_METHOD("get_include_navigational"), &Directory::get_include_navigational);
+ ClassDB::bind_method(D_METHOD("set_include_hidden"), &Directory::set_include_hidden);
+ ClassDB::bind_method(D_METHOD("get_include_hidden"), &Directory::get_include_hidden);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "include_navigational"), "set_include_navigational", "get_include_navigational");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "include_hidden"), "set_include_hidden", "get_include_hidden");
}
Directory::Directory() {
diff --git a/core/core_bind.h b/core/core_bind.h
index 920f2b539b..6da4403880 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -444,7 +444,10 @@ public:
class Directory : public RefCounted {
GDCLASS(Directory, RefCounted);
DirAccess *d;
+
bool dir_open = false;
+ bool include_navigational = false;
+ bool include_hidden = false;
protected:
static void _bind_methods();
@@ -454,12 +457,20 @@ public:
bool is_open() const;
- Error list_dir_begin(bool p_show_navigational = false, bool p_show_hidden = false); // This starts dir listing.
+ Error list_dir_begin();
String get_next();
bool current_is_dir() const;
-
void list_dir_end();
+ PackedStringArray get_files();
+ PackedStringArray get_directories();
+ PackedStringArray _get_contents(bool p_directories);
+
+ void set_include_navigational(bool p_enable);
+ bool get_include_navigational() const;
+ void set_include_hidden(bool p_enable);
+ bool get_include_hidden() const;
+
int get_drive_count();
String get_drive(int p_drive);
int get_current_drive();
@@ -481,10 +492,6 @@ public:
Directory();
virtual ~Directory();
-
-private:
- bool _list_skip_navigational = false;
- bool _list_skip_hidden = false;
};
class Marshalls : public Object {
diff --git a/doc/classes/Directory.xml b/doc/classes/Directory.xml
index cd4b8fde1e..dbf5e31da4 100644
--- a/doc/classes/Directory.xml
+++ b/doc/classes/Directory.xml
@@ -108,6 +108,13 @@
Returns the currently opened directory's drive index. See [method get_drive] to convert returned index to the name of the drive.
</description>
</method>
+ <method name="get_directories">
+ <return type="PackedStringArray" />
+ <description>
+ Returns a [PackedStringArray] containing filenames of the directory contents, excluding files. The array is sorted alphabetically.
+ Affected by [member include_hidden] and [member include_navigational].
+ </description>
+ </method>
<method name="get_drive">
<return type="String" />
<argument index="0" name="idx" type="int" />
@@ -121,6 +128,13 @@
On Windows, returns the number of drives (partitions) mounted on the current filesystem. On other platforms, the method returns 0.
</description>
</method>
+ <method name="get_files">
+ <return type="PackedStringArray" />
+ <description>
+ Returns a [PackedStringArray] containing filenames of the directory contents, excluding directories. The array is sorted alphabetically.
+ Affected by [member include_hidden].
+ </description>
+ </method>
<method name="get_next">
<return type="String" />
<description>
@@ -136,12 +150,10 @@
</method>
<method name="list_dir_begin">
<return type="int" enum="Error" />
- <argument index="0" name="show_navigational" type="bool" default="false" />
- <argument index="1" name="show_hidden" type="bool" default="false" />
<description>
Initializes the stream used to list all files and directories using the [method get_next] function, closing the currently opened stream if needed. Once the stream has been processed, it should typically be closed with [method list_dir_end].
- If [code]show_navigational[/code] is [code]true[/code], [code].[/code] and [code]..[/code] are included too.
- If [code]show_hidden[/code] is [code]true[/code], hidden files are included too.
+ Affected by [member include_hidden] and [member include_navigational].
+ [b]Note:[/b] The order of files and directories returned by this method is not deterministic, and can vary between operating systems. If you want a list of all files or folders sorted alphabetically, use [method get_files] or [method get_directories].
</description>
</method>
<method name="list_dir_end">
@@ -192,4 +204,14 @@
</description>
</method>
</methods>
+ <members>
+ <member name="include_hidden" type="bool" setter="set_include_hidden" getter="get_include_hidden" default="false">
+ If [code]true[/code], hidden files are included when the navigating directory.
+ Affects [method list_dir_begin], [method get_directories] and [method get_files].
+ </member>
+ <member name="include_navigational" type="bool" setter="set_include_navigational" getter="get_include_navigational" default="false">
+ If [code]true[/code], [code].[/code] and [code]..[/code] are included when navigating the directory.
+ Affects [method list_dir_begin] and [method get_directories].
+ </member>
+ </members>
</class>
diff --git a/doc/classes/VisualShaderNodeTextureUniform.xml b/doc/classes/VisualShaderNodeTextureUniform.xml
index 26c72d2714..c2e66ccb96 100644
--- a/doc/classes/VisualShaderNodeTextureUniform.xml
+++ b/doc/classes/VisualShaderNodeTextureUniform.xml
@@ -26,8 +26,8 @@
<constant name="TYPE_NORMAL_MAP" value="2" enum="TextureType">
Adds [code]hint_normal[/code] as hint to the uniform declaration, which internally converts the texture for proper usage as normal map.
</constant>
- <constant name="TYPE_ANISO" value="3" enum="TextureType">
- Adds [code]hint_aniso[/code] as hint to the uniform declaration to use for a flowmap.
+ <constant name="TYPE_ANISOTROPY" value="3" enum="TextureType">
+ Adds [code]hint_anisotropy[/code] as hint to the uniform declaration to use for a flowmap.
</constant>
<constant name="TYPE_MAX" value="4" enum="TextureType">
Represents the size of the [enum TextureType] enum.
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 7cd90ea1de..9ae081c0d1 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -1415,7 +1415,7 @@ void RasterizerCanvasGLES3::_legacy_canvas_render_item(Item *p_ci, RenderItemSta
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: {
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
} break;
- case ShaderLanguage::ShaderNode::Uniform::HINT_ANISO: {
+ case ShaderLanguage::ShaderNode::Uniform::HINT_ANISOTROPY: {
glBindTexture(GL_TEXTURE_2D, storage->resources.aniso_tex);
} break;
case ShaderLanguage::ShaderNode::Uniform::HINT_NORMAL: {
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 98bda4ad1b..87aee0aae4 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -695,7 +695,7 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_ANISOTROPY]) {
code += "uniform float anisotropy_ratio : hint_range(0,256);\n";
- code += "uniform sampler2D texture_flowmap : hint_aniso," + texfilter_str + ";\n";
+ code += "uniform sampler2D texture_flowmap : hint_anisotropy," + texfilter_str + ";\n";
}
if (features[FEATURE_AMBIENT_OCCLUSION]) {
code += "uniform sampler2D texture_ambient_occlusion : hint_white, " + texfilter_str + ";\n";
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 51e7ec8092..9e60a1243f 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -4877,8 +4877,8 @@ String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, Visu
case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
- case TYPE_ANISO:
- code += " : hint_aniso;\n";
+ case TYPE_ANISOTROPY:
+ code += " : hint_anisotropy;\n";
break;
default:
code += ";\n";
@@ -4967,7 +4967,7 @@ void VisualShaderNodeTextureUniform::_bind_methods() {
BIND_ENUM_CONSTANT(TYPE_DATA);
BIND_ENUM_CONSTANT(TYPE_COLOR);
BIND_ENUM_CONSTANT(TYPE_NORMAL_MAP);
- BIND_ENUM_CONSTANT(TYPE_ANISO);
+ BIND_ENUM_CONSTANT(TYPE_ANISOTROPY);
BIND_ENUM_CONSTANT(TYPE_MAX);
BIND_ENUM_CONSTANT(COLOR_DEFAULT_WHITE);
@@ -5154,8 +5154,8 @@ String VisualShaderNodeTexture2DArrayUniform::generate_global(Shader::Mode p_mod
case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
- case TYPE_ANISO:
- code += " : hint_aniso;\n";
+ case TYPE_ANISOTROPY:
+ code += " : hint_anisotropy;\n";
break;
default:
code += ";\n";
@@ -5227,8 +5227,8 @@ String VisualShaderNodeTexture3DUniform::generate_global(Shader::Mode p_mode, Vi
case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
- case TYPE_ANISO:
- code += " : hint_aniso;\n";
+ case TYPE_ANISOTROPY:
+ code += " : hint_anisotropy;\n";
break;
default:
code += ";\n";
@@ -5300,8 +5300,8 @@ String VisualShaderNodeCubemapUniform::generate_global(Shader::Mode p_mode, Visu
case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
- case TYPE_ANISO:
- code += " : hint_aniso;\n";
+ case TYPE_ANISOTROPY:
+ code += " : hint_anisotropy;\n";
break;
default:
code += ";\n";
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 2f3400404c..a9ad762b32 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -1943,7 +1943,7 @@ public:
TYPE_DATA,
TYPE_COLOR,
TYPE_NORMAL_MAP,
- TYPE_ANISO,
+ TYPE_ANISOTROPY,
TYPE_MAX,
};
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index 79728169ae..321d86ffda 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -2821,7 +2821,7 @@ void RendererStorageRD::MaterialData::update_textures(const Map<StringName, Vari
case ShaderLanguage::ShaderNode::Uniform::HINT_NONE: {
rd_texture = singleton->texture_rd_get_default(DEFAULT_RD_TEXTURE_NORMAL);
} break;
- case ShaderLanguage::ShaderNode::Uniform::HINT_ANISO: {
+ case ShaderLanguage::ShaderNode::Uniform::HINT_ANISOTROPY: {
rd_texture = singleton->texture_rd_get_default(DEFAULT_RD_TEXTURE_ANISO);
} break;
default: {
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index a6cdcfefeb..0c0ee67962 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -204,7 +204,7 @@ const char *ShaderLanguage::token_names[TK_MAX] = {
"HINT_WHITE_TEXTURE",
"HINT_BLACK_TEXTURE",
"HINT_NORMAL_TEXTURE",
- "HINT_ANISO_TEXTURE",
+ "HINT_ANISOTROPY_TEXTURE",
"HINT_ALBEDO_TEXTURE",
"HINT_BLACK_ALBEDO_TEXTURE",
"HINT_COLOR",
@@ -318,7 +318,7 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = {
{ TK_HINT_ROUGHNESS_B, "hint_roughness_b" },
{ TK_HINT_ROUGHNESS_A, "hint_roughness_a" },
{ TK_HINT_ROUGHNESS_GRAY, "hint_roughness_gray" },
- { TK_HINT_ANISO_TEXTURE, "hint_aniso" },
+ { TK_HINT_ANISOTROPY_TEXTURE, "hint_anisotropy" },
{ TK_HINT_ALBEDO_TEXTURE, "hint_albedo" },
{ TK_HINT_BLACK_ALBEDO_TEXTURE, "hint_black_albedo" },
{ TK_HINT_COLOR, "hint_color" },
@@ -7946,8 +7946,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_A;
} else if (tk.type == TK_HINT_ROUGHNESS_GRAY) {
uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_GRAY;
- } else if (tk.type == TK_HINT_ANISO_TEXTURE) {
- uniform2.hint = ShaderNode::Uniform::HINT_ANISO;
+ } else if (tk.type == TK_HINT_ANISOTROPY_TEXTURE) {
+ uniform2.hint = ShaderNode::Uniform::HINT_ANISOTROPY;
} else if (tk.type == TK_HINT_ALBEDO_TEXTURE) {
uniform2.hint = ShaderNode::Uniform::HINT_ALBEDO;
} else if (tk.type == TK_HINT_BLACK_ALBEDO_TEXTURE) {
@@ -9539,7 +9539,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
options.push_back("filter_nearest_mipmap");
options.push_back("filter_nearest_mipmap_aniso");
options.push_back("hint_albedo");
- options.push_back("hint_aniso");
+ options.push_back("hint_anisotropy");
options.push_back("hint_black");
options.push_back("hint_black_albedo");
options.push_back("hint_normal");
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index 9a76c44e55..6681af2594 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -169,7 +169,7 @@ public:
TK_HINT_ROUGHNESS_B,
TK_HINT_ROUGHNESS_A,
TK_HINT_ROUGHNESS_GRAY,
- TK_HINT_ANISO_TEXTURE,
+ TK_HINT_ANISOTROPY_TEXTURE,
TK_HINT_ALBEDO_TEXTURE,
TK_HINT_BLACK_ALBEDO_TEXTURE,
TK_HINT_COLOR,
@@ -682,7 +682,7 @@ public:
HINT_ROUGHNESS_GRAY,
HINT_BLACK,
HINT_WHITE,
- HINT_ANISO,
+ HINT_ANISOTROPY,
HINT_MAX
};