using System;
using System.Runtime.CompilerServices;
using BansheeEngine;
namespace BansheeEditor
{
///
/// Contains a list of valid platforms that can be built for.
///
public enum PlatformType // Note: Must match C++ enum PlatformType
{
Windows,
Count // Keep at end
}
///
/// Contains build data for a specific platform.
///
public abstract class PlatformInfo : ScriptObject
{
///
/// Creates a new platform info. For internal runtime use only.
///
protected PlatformInfo()
{ }
///
/// Returns the platform that this object contains data for.
///
public PlatformType Type
{
get { return Internal_GetType(mCachedPtr); }
}
///
/// Initial scene that is loaded when application is first started.
///
public Prefab MainScene
{
get { return Internal_GetMainScene(mCachedPtr); }
set
{
IntPtr scenePtr = IntPtr.Zero;
if (value != null)
scenePtr = value.GetCachedPtr();
Internal_SetMainScene(mCachedPtr, scenePtr);
}
}
///
/// Determines should the application be started in fullscreen using the user's desktop resolution.
///
public bool Fullscreen
{
get { return Internal_GetFullscreen(mCachedPtr); }
set { Internal_SetFullscreen(mCachedPtr, value); }
}
///
/// Width of a window if the game is started in windowed mode. This is only relevant if
/// is off.
///
public int WindowedWidth
{
get
{
int width, height;
Internal_GetResolution(mCachedPtr, out width, out height);
return width;
}
set { Internal_SetResolution(mCachedPtr, value, WindowedHeight); }
}
///
/// Height of a window if the game is started in windowed mode. This is only relevant if
/// is off.
///
public int WindowedHeight
{
get
{
int width, height;
Internal_GetResolution(mCachedPtr, out width, out height);
return height;
}
set { Internal_SetResolution(mCachedPtr, WindowedWidth, value); }
}
///
/// A set of semicolon separated defines to use when compiling scripts for this platform.
///
public string Defines
{
get { return Internal_GetDefines(mCachedPtr); }
set { Internal_SetDefines(mCachedPtr, value); }
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PlatformType Internal_GetType(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string Internal_GetDefines(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetDefines(IntPtr thisPtr, string value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Prefab Internal_GetMainScene(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
static extern void Internal_SetMainScene(IntPtr thisPtr, IntPtr prefabPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
static extern bool Internal_GetFullscreen(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
static extern void Internal_SetFullscreen(IntPtr thisPtr, bool fullscreen);
[MethodImpl(MethodImplOptions.InternalCall)]
static extern void Internal_GetResolution(IntPtr thisPtr, out int width, out int height);
[MethodImpl(MethodImplOptions.InternalCall)]
static extern void Internal_SetResolution(IntPtr thisPtr, int width, int height);
}
///
/// Supported icon sizes for Windows platform.
///
public enum WinIconSizes
{
Icon16 = 16,
Icon32 = 32,
Icon48 = 48,
Icon64 = 64,
Icon96 = 96,
Icon128 = 128,
Icon196 = 196,
Icon256 = 256
}
///
/// Platform data specific to Windows.
///
public class WinPlatformInfo : PlatformInfo
{
///
/// Texture that will be displayed in the taskbar when the application is running.
///
public Texture2D TaskbarIcon
{
get { return Internal_GetTaskbarIcon(mCachedPtr); }
set
{
IntPtr texturePtr = IntPtr.Zero;
if (value != null)
texturePtr = value.GetCachedPtr();
Internal_SetTaskbarIcon(mCachedPtr, texturePtr);
}
}
///
/// Text that will be displayed in the application's title bar.
///
public string TitleText
{
get { return Internal_GetTitleText(mCachedPtr); }
set { Internal_SetTitleText(mCachedPtr, value); }
}
///
/// Returns a texture of a specific icon size that will be added to the executable.
///
/// Type of icon to retrieve the texture for.
/// Texture for the specified icon size.
public Texture2D GetIcon(WinIconSizes size)
{
return Internal_GetIcon(mCachedPtr, (int)size);
}
///
/// Sets a texture of a specific icon size that will be added to the executable.
///
/// Type of icon to set the texture for.
/// Texture for the specified icon size.
public void SetIcon(WinIconSizes size, Texture2D texture)
{
IntPtr texturePtr = IntPtr.Zero;
if (texture != null)
texturePtr = texture.GetCachedPtr();
Internal_SetIcon(mCachedPtr, (int)size, texturePtr);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Texture2D Internal_GetIcon(IntPtr thisPtr, int size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetIcon(IntPtr thisPtr, int size, IntPtr texturePtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Texture2D Internal_GetTaskbarIcon(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTaskbarIcon(IntPtr thisPtr, IntPtr texturePtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string Internal_GetTitleText(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTitleText(IntPtr thisPtr, string value);
}
///
/// Handles building of the game executable and packaging of all necessary resources, making the game be ready to ran
/// as a standalone product.
///
public static class BuildManager
{
///
/// Returns a list of all available platforms that can be built for.
///
public static PlatformType[] AvailablePlatforms
{
get { return Internal_GetAvailablePlatforms(); }
}
///
/// Returns the currently active platform.
///
public static PlatformType ActivePlatform
{
get { return Internal_GetActivePlatform(); }
set { Internal_SetActivePlatform(value); }
}
///
/// Returns the data about the currently active platform.
///
public static PlatformInfo ActivePlatformInfo
{
get { return Internal_GetActivePlatformInfo(); }
}
///
/// Builds the executable and packages the game.
///
public static void Build()
{
// TODO
}
///
/// Returns a list of .NET framework managed assemblies to be included for the specified platform.
///
/// Platform type to retrieve the list of assemblies for.
/// A list of .NET framework managed assemblies that will be included with the build.
internal static string[] GetFrameworkAssemblies(PlatformType type)
{
return Internal_GetFrameworkAssemblies(type);
}
///
/// Returns the location of the executable for the provided platform.
///
/// Platform type to retrieve the executable location for.
/// Path to the executable in the editor install folder.
internal static string GetMainExecutable(PlatformType type)
{
return Internal_GetMainExecutable(type);
}
///
/// Returns a list of semicolon separated defines that will be used when compiling scripts for the specified
/// platform.
///
/// Platfrom type to retrieve the defines for.
/// Semicolor separated defines that will be passed along to the script compiler.
internal static string GetDefines(PlatformType type)
{
return Internal_GetDefines(type);
}
///
/// Returns an object containing all platform specific build data.
///
/// Platform type to retrieve the data for.
/// An object containing all platform specific build data
internal static PlatformInfo GetPlatformInfo(PlatformType type)
{
return Internal_GetPlatformInfo(type);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PlatformType[] Internal_GetAvailablePlatforms();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PlatformType Internal_GetActivePlatform();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetActivePlatform(PlatformType value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PlatformInfo Internal_GetActivePlatformInfo();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern PlatformInfo Internal_GetPlatformInfo(PlatformType type);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string[] Internal_GetFrameworkAssemblies(PlatformType type);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string Internal_GetMainExecutable(PlatformType type);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string Internal_GetDefines(PlatformType type);
}
}