Created
December 17, 2020 15:28
-
-
Save Xananax/c515f17af7c0075245554563286f2e33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func get_dir_contents(path): | |
var dir = Directory.new() | |
assert(dir.open(path) == OK,"directory `%s` is not valid"%[path]) | |
dir.list_dir_begin(true, true) | |
var files = [] | |
var file_name = dir.get_next() | |
while file_name != "": | |
if not dir.current_is_dir() and file_name.get_extension() == 'gd': | |
var c = ThingToLoad.new(dir, file_name) | |
files.push_back(c) | |
file_name = dir.get_next() | |
return files | |
class ThingToLoad: | |
var file: String = "" | |
var icon: String = "" | |
func _init(dir: Directory, _f: String): | |
var path = dir.get_current_dir() | |
file = path.plus_file(_f) | |
var _icon = path.plus_file(_f.replace('.gd','.svg')) | |
if dir.file_exists(icon): | |
icon = _icon | |
func _to_string(): | |
return "[F: %s (icon: %s)]"%[file, icon != null] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment