1 /** 2 Resource saving interface. 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.resourcesaver; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.resource; 23 /** 24 Resource saving interface. 25 26 Resource saving interface, used for saving resources to disk. 27 */ 28 @GodotBaseClass struct ResourceSaverSingleton 29 { 30 enum string _GODOT_internal_name = "_ResourceSaver"; 31 public: 32 @nogc nothrow: 33 union { godot_object _godot_object; GodotObject _GODOT_base; } 34 alias _GODOT_base this; 35 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 36 package(godot) __gshared bool _classBindingInitialized = false; 37 package(godot) static struct _classBinding 38 { 39 __gshared: 40 godot_object _singleton; 41 immutable char* _singletonName = "ResourceSaver"; 42 @GodotName("save") GodotMethod!(GodotError, String, Resource, long) save; 43 @GodotName("get_recognized_extensions") GodotMethod!(PoolStringArray, Resource) getRecognizedExtensions; 44 } 45 bool opEquals(in ResourceSaverSingleton other) const { return _godot_object.ptr is other._godot_object.ptr; } 46 ResourceSaverSingleton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 47 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 48 mixin baseCasts; 49 static ResourceSaverSingleton _new() 50 { 51 static godot_class_constructor constructor; 52 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("_ResourceSaver"); 53 if(constructor is null) return typeof(this).init; 54 return cast(ResourceSaverSingleton)(constructor()); 55 } 56 @disable new(size_t s); 57 /// 58 enum SaverFlags : int 59 { 60 /** 61 62 */ 63 flagRelativePaths = 1, 64 /** 65 66 */ 67 flagBundleResources = 2, 68 /** 69 70 */ 71 flagChangePath = 4, 72 /** 73 74 */ 75 flagOmitEditorProperties = 8, 76 /** 77 78 */ 79 flagSaveBigEndian = 16, 80 /** 81 82 */ 83 flagCompress = 32, 84 /** 85 86 */ 87 flagReplaceSubresourcePaths = 64, 88 } 89 /// 90 enum Constants : int 91 { 92 flagRelativePaths = 1, 93 flagBundleResources = 2, 94 flagChangePath = 4, 95 flagOmitEditorProperties = 8, 96 flagSaveBigEndian = 16, 97 flagCompress = 32, 98 flagReplaceSubresourcePaths = 64, 99 } 100 /** 101 Saves a resource to disk. 102 */ 103 GodotError save(StringArg0)(in StringArg0 path, Resource resource, in long flags = 0) 104 { 105 checkClassBinding!(typeof(this))(); 106 return ptrcall!(GodotError)(_classBinding.save, _godot_object, path, resource, flags); 107 } 108 /** 109 Returns the list of extensions available for saving a resource of a given type. 110 */ 111 PoolStringArray getRecognizedExtensions(Resource type) 112 { 113 checkClassBinding!(typeof(this))(); 114 return ptrcall!(PoolStringArray)(_classBinding.getRecognizedExtensions, _godot_object, type); 115 } 116 } 117 /// Returns: the ResourceSaverSingleton 118 @property @nogc nothrow pragma(inline, true) 119 ResourceSaverSingleton ResourceSaver() 120 { 121 checkClassBinding!ResourceSaverSingleton(); 122 return ResourceSaverSingleton(ResourceSaverSingleton._classBinding._singleton); 123 }