BuildManager.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Contains a list of valid platforms that can be built for.
  8. /// </summary>
  9. public enum PlatformType // Note: Must match C++ enum PlatformType
  10. {
  11. Windows,
  12. Count // Keep at end
  13. }
  14. /// <summary>
  15. /// Contains build data for a specific platform.
  16. /// </summary>
  17. public abstract class PlatformInfo : ScriptObject
  18. {
  19. /// <summary>
  20. /// Creates a new platform info. For internal runtime use only.
  21. /// </summary>
  22. protected PlatformInfo()
  23. { }
  24. /// <summary>
  25. /// Returns the platform that this object contains data for.
  26. /// </summary>
  27. public PlatformType Type
  28. {
  29. get { return Internal_GetType(mCachedPtr); }
  30. }
  31. /// <summary>
  32. /// A set of semicolon separated defines to use when compiling scripts for this platform.
  33. /// </summary>
  34. public string Defines
  35. {
  36. get { return Internal_GetDefines(mCachedPtr); }
  37. set { Internal_SetDefines(mCachedPtr, value); }
  38. }
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern PlatformType Internal_GetType(IntPtr thisPtr);
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern string Internal_GetDefines(IntPtr thisPtr);
  43. [MethodImpl(MethodImplOptions.InternalCall)]
  44. private static extern void Internal_SetDefines(IntPtr thisPtr, string value);
  45. }
  46. /// <summary>
  47. /// Supported icon sizes for Windows platform.
  48. /// </summary>
  49. public enum WinIconSizes
  50. {
  51. Icon16 = 16,
  52. Icon32 = 32,
  53. Icon48 = 48,
  54. Icon64 = 64,
  55. Icon96 = 96,
  56. Icon128 = 128,
  57. Icon196 = 196,
  58. Icon256 = 256
  59. }
  60. /// <summary>
  61. /// Platform data specific to Windows.
  62. /// </summary>
  63. public class WinPlatformInfo : PlatformInfo
  64. {
  65. /// <summary>
  66. /// Determines should the executable be 32 or 64-bit.
  67. /// </summary>
  68. public bool Is32Bit
  69. {
  70. get { return Internal_GetIs32Bit(mCachedPtr); }
  71. set { Internal_SetIs32Bit(mCachedPtr, value); }
  72. }
  73. /// <summary>
  74. /// Returns a texture of a specific icon size that will be added to the executable.
  75. /// </summary>
  76. /// <param name="size">Type of icon to retrieve the texture for.</param>
  77. /// <returns>Texture for the specified icon size.</returns>
  78. public Texture2D GetIcon(WinIconSizes size)
  79. {
  80. return Internal_GetIcon(mCachedPtr, (int)size);
  81. }
  82. /// <summary>
  83. /// Sets a texture of a specific icon size that will be added to the executable.
  84. /// </summary>
  85. /// <param name="size">Type of icon to set the texture for.</param>
  86. /// <param name="texture">Texture for the specified icon size.</param>
  87. public void SetIcon(WinIconSizes size, Texture2D texture)
  88. {
  89. IntPtr texturePtr = IntPtr.Zero;
  90. if (texture != null)
  91. texturePtr = texture.GetCachedPtr();
  92. Internal_SetIcon(mCachedPtr, (int)size, texturePtr);
  93. }
  94. [MethodImpl(MethodImplOptions.InternalCall)]
  95. private static extern bool Internal_GetIs32Bit(IntPtr thisPtr);
  96. [MethodImpl(MethodImplOptions.InternalCall)]
  97. private static extern void Internal_SetIs32Bit(IntPtr thisPtr, bool value);
  98. [MethodImpl(MethodImplOptions.InternalCall)]
  99. private static extern Texture2D Internal_GetIcon(IntPtr thisPtr, int size);
  100. [MethodImpl(MethodImplOptions.InternalCall)]
  101. private static extern void Internal_SetIcon(IntPtr thisPtr, int size, IntPtr texturePtr);
  102. }
  103. /// <summary>
  104. /// Handles building of the game executable and packaging of all necessary resources, making the game be ready to ran
  105. /// as a standalone product.
  106. /// </summary>
  107. public static class BuildManager
  108. {
  109. /// <summary>
  110. /// Returns a list of all available platforms that can be built for.
  111. /// </summary>
  112. public static PlatformType[] AvailablePlatforms
  113. {
  114. get { return Internal_GetAvailablePlatforms(); }
  115. }
  116. /// <summary>
  117. /// Returns the currently active platform.
  118. /// </summary>
  119. public static PlatformType ActivePlatform
  120. {
  121. get { return Internal_GetActivePlatform(); }
  122. set { Internal_SetActivePlatform(value); }
  123. }
  124. /// <summary>
  125. /// Returns the data about the currently active platform.
  126. /// </summary>
  127. public static PlatformInfo ActivePlatformInfo
  128. {
  129. get { return Internal_GetActivePlatformInfo(); }
  130. }
  131. /// <summary>
  132. /// Builds the executable and packages the game.
  133. /// </summary>
  134. public static void Build()
  135. {
  136. // TODO
  137. }
  138. /// <summary>
  139. /// Returns a list of .NET framework managed assemblies to be included for the specified platform.
  140. /// </summary>
  141. /// <param name="type">Platform type to retrieve the list of assemblies for.</param>
  142. /// <returns>A list of .NET framework managed assemblies that will be included with the build.</returns>
  143. internal static string[] GetFrameworkAssemblies(PlatformType type)
  144. {
  145. return Internal_GetFrameworkAssemblies(type);
  146. }
  147. /// <summary>
  148. /// Returns the location of the executable for the provided platform.
  149. /// </summary>
  150. /// <param name="type">Platform type to retrieve the executable location for.</param>
  151. /// <returns>Path to the executable in the editor install folder.</returns>
  152. internal static string GetMainExecutable(PlatformType type)
  153. {
  154. return Internal_GetMainExecutable(type);
  155. }
  156. /// <summary>
  157. /// Returns a list of semicolon separated defines that will be used when compiling scripts for the specified
  158. /// platform.
  159. /// </summary>
  160. /// <param name="type">Platfrom type to retrieve the defines for.</param>
  161. /// <returns>Semicolor separated defines that will be passed along to the script compiler.</returns>
  162. internal static string GetDefines(PlatformType type)
  163. {
  164. return Internal_GetDefines(type);
  165. }
  166. /// <summary>
  167. /// Returns an object containing all platform specific build data.
  168. /// </summary>
  169. /// <param name="type">Platform type to retrieve the data for.</param>
  170. /// <returns>An object containing all platform specific build data</returns>
  171. internal static PlatformInfo GetPlatformInfo(PlatformType type)
  172. {
  173. return Internal_GetPlatformInfo(type);
  174. }
  175. [MethodImpl(MethodImplOptions.InternalCall)]
  176. private static extern PlatformType[] Internal_GetAvailablePlatforms();
  177. [MethodImpl(MethodImplOptions.InternalCall)]
  178. private static extern PlatformType Internal_GetActivePlatform();
  179. [MethodImpl(MethodImplOptions.InternalCall)]
  180. private static extern void Internal_SetActivePlatform(PlatformType value);
  181. [MethodImpl(MethodImplOptions.InternalCall)]
  182. private static extern PlatformInfo Internal_GetActivePlatformInfo();
  183. [MethodImpl(MethodImplOptions.InternalCall)]
  184. private static extern PlatformInfo Internal_GetPlatformInfo(PlatformType type);
  185. [MethodImpl(MethodImplOptions.InternalCall)]
  186. private static extern string[] Internal_GetFrameworkAssemblies(PlatformType type);
  187. [MethodImpl(MethodImplOptions.InternalCall)]
  188. private static extern string Internal_GetMainExecutable(PlatformType type);
  189. [MethodImpl(MethodImplOptions.InternalCall)]
  190. private static extern string Internal_GetDefines(PlatformType type);
  191. }
  192. }