ProjectLibrary.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System;
  2. using System.IO;
  3. using System.Runtime.CompilerServices;
  4. using BansheeEngine;
  5. namespace BansheeEditor
  6. {
  7. public sealed class ProjectLibrary : ScriptObject
  8. {
  9. public static DirectoryEntry Root { get { return Internal_GetRoot(); } }
  10. public static void Create(Resource resource, string path)
  11. {
  12. if (Path.IsPathRooted(path))
  13. throw new ArgumentException("Provided path must be relative.", "path");
  14. Internal_Create(resource, path);
  15. }
  16. public static void Save(Resource resource)
  17. {
  18. Internal_Save(resource);
  19. }
  20. public static T Load<T>(string path) where T : Resource
  21. {
  22. if (Path.IsPathRooted(path))
  23. throw new ArgumentException("Provided path must be relative.", "path");
  24. return (T) Internal_Load(path);
  25. }
  26. public static void Reimport(string path, ImportOptions options = null, bool force = false)
  27. {
  28. Internal_Reimport(path, options, force);
  29. }
  30. public static bool Exists(string path)
  31. {
  32. return GetEntry(path) != null;
  33. }
  34. public static LibraryEntry GetEntry(string path)
  35. {
  36. return Internal_GetEntry(path);
  37. }
  38. public static string GetPath(Resource resource)
  39. {
  40. return Internal_GetPath(resource);
  41. }
  42. public static void Delete(string path)
  43. {
  44. Internal_Delete(path);
  45. }
  46. public static void CreateFolder(string path)
  47. {
  48. Internal_CreateFolder(path);
  49. }
  50. public static void Rename(string path, string name)
  51. {
  52. Internal_Rename(path, name);
  53. }
  54. public static void Move(string oldPath, string newPath, bool overwrite = false)
  55. {
  56. Internal_Move(oldPath, newPath, overwrite);
  57. }
  58. public static void Copy(string source, string destination, bool overwrite = false)
  59. {
  60. Internal_Copy(source, destination, overwrite);
  61. }
  62. [MethodImpl(MethodImplOptions.InternalCall)]
  63. private static extern void Internal_Create(Resource resource, string path);
  64. [MethodImpl(MethodImplOptions.InternalCall)]
  65. private static extern Resource Internal_Load(string path);
  66. [MethodImpl(MethodImplOptions.InternalCall)]
  67. private static extern void Internal_Save(Resource resource);
  68. [MethodImpl(MethodImplOptions.InternalCall)]
  69. private static extern DirectoryEntry Internal_GetRoot();
  70. [MethodImpl(MethodImplOptions.InternalCall)]
  71. private static extern void Internal_Reimport(string path, ImportOptions options, bool force);
  72. [MethodImpl(MethodImplOptions.InternalCall)]
  73. private static extern LibraryEntry Internal_GetEntry(string path);
  74. [MethodImpl(MethodImplOptions.InternalCall)]
  75. private static extern string Internal_GetPath(Resource resource);
  76. [MethodImpl(MethodImplOptions.InternalCall)]
  77. private static extern void Internal_Delete(string path);
  78. [MethodImpl(MethodImplOptions.InternalCall)]
  79. private static extern void Internal_CreateFolder(string path);
  80. [MethodImpl(MethodImplOptions.InternalCall)]
  81. private static extern void Internal_Rename(string path, string name);
  82. [MethodImpl(MethodImplOptions.InternalCall)]
  83. private static extern void Internal_Move(string oldPath, string newPath, bool overwrite);
  84. [MethodImpl(MethodImplOptions.InternalCall)]
  85. private static extern void Internal_Copy(string source, string destination, bool overwrite);
  86. }
  87. public enum LibraryEntryType
  88. {
  89. File, Directory
  90. }
  91. public enum ResourceType
  92. {
  93. Texture, SpriteTexture, Mesh, Font, GUISkin
  94. }
  95. public class LibraryEntry : ScriptObject
  96. {
  97. public String Path
  98. {
  99. get
  100. {
  101. // TODO
  102. return "";
  103. }
  104. }
  105. public String Name
  106. {
  107. get
  108. {
  109. // TODO
  110. return "";
  111. }
  112. }
  113. public LibraryEntryType Type
  114. {
  115. get
  116. {
  117. // TODO
  118. return LibraryEntryType.File;
  119. }
  120. }
  121. public DirectoryEntry Parent
  122. {
  123. get
  124. {
  125. // TODO
  126. return null;
  127. }
  128. }
  129. }
  130. public class DirectoryEntry : LibraryEntry
  131. {
  132. public LibraryEntry[] Children
  133. {
  134. get
  135. {
  136. // TODO
  137. return null;
  138. }
  139. }
  140. }
  141. public class FileEntry : LibraryEntry
  142. {
  143. public ImportOptions Options
  144. {
  145. get
  146. {
  147. // TODO
  148. return null;
  149. }
  150. }
  151. public string UUID
  152. {
  153. get
  154. {
  155. // TODO
  156. return "";
  157. }
  158. }
  159. public Texture2D Icon
  160. {
  161. get
  162. {
  163. // TODO
  164. return null;
  165. }
  166. }
  167. public ResourceType ResType
  168. {
  169. get
  170. {
  171. // TODO
  172. return ResourceType.Texture;
  173. }
  174. }
  175. }
  176. }