aboutsummaryrefslogtreecommitdiff
path: root/assets/addons/voxel-core/classes/readers/gpl.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-01-15 16:29:02 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-01-15 16:29:02 +0100
commitc9c5b5d7c2a238310ce7bde336f76d2d1b6f9f29 (patch)
treec6e935fea995752a0b307e56892e8422fb734c0e /assets/addons/voxel-core/classes/readers/gpl.gd
parent98f356e68b759bf84300290315d4ada09c41f79b (diff)
moved shapes to loading area & fixed asset paths
Diffstat (limited to 'assets/addons/voxel-core/classes/readers/gpl.gd')
-rw-r--r--assets/addons/voxel-core/classes/readers/gpl.gd48
1 files changed, 0 insertions, 48 deletions
diff --git a/assets/addons/voxel-core/classes/readers/gpl.gd b/assets/addons/voxel-core/classes/readers/gpl.gd
deleted file mode 100644
index 4a6b943..0000000
--- a/assets/addons/voxel-core/classes/readers/gpl.gd
+++ /dev/null
@@ -1,48 +0,0 @@
-class_name GPLReader
-extends Reference
-# GIMP palette file reader
-
-
-
-# Public Methods
-# Reads GPL file, and returns voxel palette
-static func read(gpl_file : File) -> Dictionary:
- var result := {
- "error": OK,
- "voxels": {},
- "palette": [],
- }
-
- if gpl_file.get_line() == "GIMP Palette":
- while not gpl_file.eof_reached():
- var line = gpl_file.get_line()
- if typeof(line) == TYPE_STRING and not line.empty() and (line[0].is_valid_integer() or line[0] == " "):
- var tokens = line.split("\t")
- var name = ""
- var color = tokens[0].split_floats(" ")
- color = Color(color[0] / 255, color[1] / 255, color[2] / 255)
- if tokens.size() > 1:
- name = tokens[1]
- var end = name.find("(")
- name = name.substr(0, end)
-
- if not result["palette"].has(color):
- var voxel := Voxel.colored(color)
- result["palette"].append(voxel)
- if not name.empty():
- Voxel.set_name(voxel, name.strip_edges())
- else:
- result["error"] = ERR_FILE_UNRECOGNIZED
-
- return result
-
-
-static func read_file(gpl_path : String) -> Dictionary:
- var result := { "error": OK }
- var file := File.new()
- var error = file.open(gpl_path, File.READ)
- if error == OK:
- result = read(file)
- if file.is_open():
- file.close()
- return result