1 /** 2 Resource filesystem, as the editor sees it. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.editorfilesystem; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.node; 24 import godot.editorfilesystemdirectory; 25 /** 26 Resource filesystem, as the editor sees it. 27 28 This object holds information of all resources in the filesystem, their types, etc. 29 $(B Note:) This class shouldn't be instantiated directly. Instead, access the singleton using $(D EditorInterface.getResourceFilesystem). 30 */ 31 @GodotBaseClass struct EditorFileSystem 32 { 33 package(godot) enum string _GODOT_internal_name = "EditorFileSystem"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ Node _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct GDNativeClassBinding 41 { 42 __gshared: 43 @GodotName("get_file_type") GodotMethod!(String, String) getFileType; 44 @GodotName("get_filesystem") GodotMethod!(EditorFileSystemDirectory) getFilesystem; 45 @GodotName("get_filesystem_path") GodotMethod!(EditorFileSystemDirectory, String) getFilesystemPath; 46 @GodotName("get_scanning_progress") GodotMethod!(double) getScanningProgress; 47 @GodotName("is_scanning") GodotMethod!(bool) isScanning; 48 @GodotName("scan") GodotMethod!(void) scan; 49 @GodotName("scan_sources") GodotMethod!(void) scanSources; 50 @GodotName("update_file") GodotMethod!(void, String) updateFile; 51 @GodotName("update_script_classes") GodotMethod!(void) updateScriptClasses; 52 } 53 /// 54 pragma(inline, true) bool opEquals(in EditorFileSystem other) const 55 { return _godot_object.ptr is other._godot_object.ptr; } 56 /// 57 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 58 { _godot_object.ptr = n; return null; } 59 /// 60 pragma(inline, true) bool opEquals(typeof(null) n) const 61 { return _godot_object.ptr is n; } 62 /// 63 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 64 mixin baseCasts; 65 /// Construct a new instance of EditorFileSystem. 66 /// Note: use `memnew!EditorFileSystem` instead. 67 static EditorFileSystem _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorFileSystem"); 71 if(constructor is null) return typeof(this).init; 72 return cast(EditorFileSystem)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 Returns the resource type of the file, given the full path. This returns a string such as `"Resource"` or `"GDScript"`, $(I not) a file extension such as `".gd"`. 77 */ 78 String getFileType(in String path) const 79 { 80 checkClassBinding!(typeof(this))(); 81 return ptrcall!(String)(GDNativeClassBinding.getFileType, _godot_object, path); 82 } 83 /** 84 Gets the root directory object. 85 */ 86 EditorFileSystemDirectory getFilesystem() 87 { 88 checkClassBinding!(typeof(this))(); 89 return ptrcall!(EditorFileSystemDirectory)(GDNativeClassBinding.getFilesystem, _godot_object); 90 } 91 /** 92 Returns a view into the filesystem at `path`. 93 */ 94 EditorFileSystemDirectory getFilesystemPath(in String path) 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(EditorFileSystemDirectory)(GDNativeClassBinding.getFilesystemPath, _godot_object, path); 98 } 99 /** 100 Returns the scan progress for 0 to 1 if the FS is being scanned. 101 */ 102 double getScanningProgress() const 103 { 104 checkClassBinding!(typeof(this))(); 105 return ptrcall!(double)(GDNativeClassBinding.getScanningProgress, _godot_object); 106 } 107 /** 108 Returns `true` of the filesystem is being scanned. 109 */ 110 bool isScanning() const 111 { 112 checkClassBinding!(typeof(this))(); 113 return ptrcall!(bool)(GDNativeClassBinding.isScanning, _godot_object); 114 } 115 /** 116 Scan the filesystem for changes. 117 */ 118 void scan() 119 { 120 checkClassBinding!(typeof(this))(); 121 ptrcall!(void)(GDNativeClassBinding.scan, _godot_object); 122 } 123 /** 124 Check if the source of any imported resource changed. 125 */ 126 void scanSources() 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(GDNativeClassBinding.scanSources, _godot_object); 130 } 131 /** 132 Update a file information. Call this if an external program (not Godot) modified the file. 133 */ 134 void updateFile(in String path) 135 { 136 checkClassBinding!(typeof(this))(); 137 ptrcall!(void)(GDNativeClassBinding.updateFile, _godot_object, path); 138 } 139 /** 140 Scans the script files and updates the list of custom class names. 141 */ 142 void updateScriptClasses() 143 { 144 checkClassBinding!(typeof(this))(); 145 ptrcall!(void)(GDNativeClassBinding.updateScriptClasses, _godot_object); 146 } 147 }