aboutsummaryrefslogtreecommitdiff
path: root/assets/addons/voxel-core/classes/reader.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-01-14 13:04:34 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-01-14 13:04:34 +0100
commit4bfbf641dc2b8aca8de9f86a9908063f39bd6e31 (patch)
tree3d016842fc578f59cb0727ddb506c3b01cf53c62 /assets/addons/voxel-core/classes/reader.gd
parent90af765b430e3a75daa9b2b4d0343ae58ad5c33d (diff)
.
Diffstat (limited to 'assets/addons/voxel-core/classes/reader.gd')
-rw-r--r--assets/addons/voxel-core/classes/reader.gd21
1 files changed, 21 insertions, 0 deletions
diff --git a/assets/addons/voxel-core/classes/reader.gd b/assets/addons/voxel-core/classes/reader.gd
new file mode 100644
index 0000000..7c17b8a
--- /dev/null
+++ b/assets/addons/voxel-core/classes/reader.gd
@@ -0,0 +1,21 @@
+class_name Reader
+extends Reference
+# Makeshift interface class inhereted by all file readers.
+
+
+
+## Public Methods
+# Calls on appropriate file reader according to file_path's extension.
+# file_path : String : path to file to be read
+# return : Dictionary : read results, contains: { error : int, voxels : Dictionary<Vec3, int>, palette : Dictionary<int, Dictionary<String, Variant> }
+static func read_file(file_path : String) -> Dictionary:
+ var result = { "error": ERR_FILE_UNRECOGNIZED }
+ match file_path.get_extension():
+ "png", "bmp", "dds", "exr", "hdr", "jpg", "jpeg", "tga", "svg", "svgz", "webp":
+ result = ImageReader.read_file(file_path)
+ "vox": result = VoxReader.read_file(file_path)
+ "qb": continue
+ "qbt": continue
+ "vxm": continue
+ "gpl": result = GPLReader.read_file(file_path)
+ return result