Explorar o código

Added icons to windows platform info

BearishSun %!s(int64=10) %!d(string=hai) anos
pai
achega
7c655205d8

+ 8 - 0
BansheeEditor/Include/BsPlatformInfo.h

@@ -43,6 +43,14 @@ namespace BansheeEngine
 		WinPlatformInfo();
 
 		bool is32bit;
+		HTexture icon16;
+		HTexture icon32;
+		HTexture icon48;
+		HTexture icon64;
+		HTexture icon96;
+		HTexture icon128;
+		HTexture icon192;
+		HTexture icon256;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/

+ 39 - 6
BansheeEditor/Include/BsPlatformInfoRTTI.h

@@ -21,18 +21,18 @@ namespace BansheeEngine
 			addPlainField("type", 1, &PlatformInfoRTTI::getType, &PlatformInfoRTTI::setType);
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "PlatformInfo";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_PlatformInfo;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
 			return bs_shared_ptr_new<PlatformInfo>();
 		}
@@ -43,24 +43,57 @@ namespace BansheeEngine
 	private:
 		bool& getIs32Bit(WinPlatformInfo* obj) { return obj->is32bit; }
 		void setIs32Bit(WinPlatformInfo* obj, bool& val) { obj->is32bit = val; }
+
+		HTexture& getIcon16(WinPlatformInfo* obj) { return obj->icon16; }
+		void setIcon16(WinPlatformInfo* obj, HTexture& val) { obj->icon16 = val; }
+
+		HTexture& getIcon32(WinPlatformInfo* obj) { return obj->icon32; }
+		void setIcon32(WinPlatformInfo* obj, HTexture& val) { obj->icon32 = val; }
+
+		HTexture& getIcon48(WinPlatformInfo* obj) { return obj->icon48; }
+		void setIcon48(WinPlatformInfo* obj, HTexture& val) { obj->icon48 = val; }
+
+		HTexture& getIcon64(WinPlatformInfo* obj) { return obj->icon64; }
+		void setIcon64(WinPlatformInfo* obj, HTexture& val) { obj->icon64 = val; }
+
+		HTexture& getIcon96(WinPlatformInfo* obj) { return obj->icon96; }
+		void setIcon96(WinPlatformInfo* obj, HTexture& val) { obj->icon96 = val; }
+
+		HTexture& getIcon128(WinPlatformInfo* obj) { return obj->icon128; }
+		void setIcon128(WinPlatformInfo* obj, HTexture& val) { obj->icon128 = val; }
+
+		HTexture& getIcon192(WinPlatformInfo* obj) { return obj->icon192; }
+		void setIcon192(WinPlatformInfo* obj, HTexture& val) { obj->icon192 = val; }
+
+		HTexture& getIcon256(WinPlatformInfo* obj) { return obj->icon256; }
+		void setIcon256(WinPlatformInfo* obj, HTexture& val) { obj->icon256 = val; }
+
 	public:
 		WinPlatformInfoRTTI()
 		{
 			addPlainField("is32bit", 0, &WinPlatformInfoRTTI::getIs32Bit, &WinPlatformInfoRTTI::setIs32Bit);
+			addReflectableField("icon16", 1, &WinPlatformInfoRTTI::getIcon16, &WinPlatformInfoRTTI::setIcon16);
+			addReflectableField("icon32", 2, &WinPlatformInfoRTTI::getIcon32, &WinPlatformInfoRTTI::setIcon32);
+			addReflectableField("icon48", 3, &WinPlatformInfoRTTI::getIcon48, &WinPlatformInfoRTTI::setIcon48);
+			addReflectableField("icon64", 4, &WinPlatformInfoRTTI::getIcon64, &WinPlatformInfoRTTI::setIcon64);
+			addReflectableField("icon96", 5, &WinPlatformInfoRTTI::getIcon96, &WinPlatformInfoRTTI::setIcon96);
+			addReflectableField("icon128", 6, &WinPlatformInfoRTTI::getIcon128, &WinPlatformInfoRTTI::setIcon128);
+			addReflectableField("icon192", 7, &WinPlatformInfoRTTI::getIcon192, &WinPlatformInfoRTTI::setIcon192);
+			addReflectableField("icon256", 8, &WinPlatformInfoRTTI::getIcon256, &WinPlatformInfoRTTI::setIcon256);
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "WinPlatformInfo";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_WinPlatformInfo;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
 			return bs_shared_ptr_new<WinPlatformInfo>();
 		}

+ 32 - 0
MBansheeEditor/BuildManager.cs

@@ -37,6 +37,18 @@ namespace BansheeEditor
         private static extern void Internal_SetDefines(IntPtr thisPtr, string value);
     }
 
+    public enum WinIconSizes
+    {
+        Icon16 = 16,
+        Icon32 = 32,
+        Icon48 = 48,
+        Icon64 = 64,
+        Icon96 = 96,
+        Icon128 = 128,
+        Icon196 = 196,
+        Icon256 = 256
+    }
+
     public class WinPlatformInfo : PlatformInfo
     {
         public bool Is32Bit
@@ -45,11 +57,31 @@ namespace BansheeEditor
             set { Internal_SetIs32Bit(mCachedPtr, value); }
         }
 
+        public Texture2D GetIcon(WinIconSizes size)
+        {
+            return Internal_GetIcon(mCachedPtr, (int)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 bool Internal_GetIs32Bit(IntPtr thisPtr);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetIs32Bit(IntPtr thisPtr, bool value);
+
+        [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);
     }
 
     public static class BuildManager

+ 2 - 0
SBansheeEditor/Include/BsScriptPlatformInfo.h

@@ -76,5 +76,7 @@ namespace BansheeEngine
 		/************************************************************************/
 		static bool internal_GetIs32Bit(ScriptWinPlatformInfo* thisPtr);
 		static void internal_SetIs32Bit(ScriptWinPlatformInfo* thisPtr, bool value);
+		static MonoObject* internal_GetIcon(ScriptWinPlatformInfo* thisPtr, int size);
+		static void Internal_SetIcon(ScriptWinPlatformInfo* thisPtr, int size, ScriptTexture2D* texturePtr);
 	};
 }

+ 87 - 5
SBansheeEditor/Source/BsScriptPlatformInfo.cpp

@@ -5,6 +5,8 @@
 #include "BsMonoManager.h"
 #include "BsMonoMethod.h"
 #include "BsMonoUtil.h"
+#include "BsScriptTexture2D.h"
+#include "BsScriptResourceManager.h"
 
 namespace BansheeEngine
 {
@@ -20,9 +22,9 @@ namespace BansheeEngine
 
 	void ScriptPlatformInfo::initRuntimeData()
 	{
-		metaData.scriptClass->addInternalCall("internal_GetType", &ScriptPlatformInfo::internal_GetType);
-		metaData.scriptClass->addInternalCall("internal_GetDefines", &ScriptPlatformInfo::internal_GetDefines);
-		metaData.scriptClass->addInternalCall("internal_SetDefines", &ScriptPlatformInfo::internal_SetDefines);
+		metaData.scriptClass->addInternalCall("Internal_GetType", &ScriptPlatformInfo::internal_GetType);
+		metaData.scriptClass->addInternalCall("Internal_GetDefines", &ScriptPlatformInfo::internal_GetDefines);
+		metaData.scriptClass->addInternalCall("Internal_SetDefines", &ScriptPlatformInfo::internal_SetDefines);
 	}
 
 	MonoObject* ScriptPlatformInfo::create(const SPtr<PlatformInfo>& platformInfo)
@@ -60,8 +62,10 @@ namespace BansheeEngine
 
 	void ScriptWinPlatformInfo::initRuntimeData()
 	{
-		metaData.scriptClass->addInternalCall("internal_GetIs32Bit", &ScriptWinPlatformInfo::internal_GetIs32Bit);
-		metaData.scriptClass->addInternalCall("internal_SetIs32Bit", &ScriptWinPlatformInfo::internal_SetIs32Bit);
+		metaData.scriptClass->addInternalCall("Internal_GetIs32Bit", &ScriptWinPlatformInfo::internal_GetIs32Bit);
+		metaData.scriptClass->addInternalCall("Internal_SetIs32Bit", &ScriptWinPlatformInfo::internal_SetIs32Bit);
+		metaData.scriptClass->addInternalCall("Internal_GetIcon", &ScriptWinPlatformInfo::internal_GetIcon);
+		metaData.scriptClass->addInternalCall("Internal_SetIcon", &ScriptWinPlatformInfo::Internal_SetIcon);
 	}
 
 	SPtr<WinPlatformInfo> ScriptWinPlatformInfo::getWinPlatformInfo() const
@@ -87,4 +91,82 @@ namespace BansheeEngine
 	{
 		thisPtr->getWinPlatformInfo()->is32bit = value;
 	}
+
+	MonoObject* ScriptWinPlatformInfo::internal_GetIcon(ScriptWinPlatformInfo* thisPtr, int size)
+	{
+		HTexture icon;
+		switch (size)
+		{
+		case 16:
+			icon = thisPtr->getWinPlatformInfo()->icon16;
+			break;
+		case 32:
+			icon = thisPtr->getWinPlatformInfo()->icon32;
+			break;
+		case 48:
+			icon = thisPtr->getWinPlatformInfo()->icon48;
+			break;
+		case 64:
+			icon = thisPtr->getWinPlatformInfo()->icon64;
+			break;
+		case 96:
+			icon = thisPtr->getWinPlatformInfo()->icon96;
+			break;
+		case 128:
+			icon = thisPtr->getWinPlatformInfo()->icon128;
+			break;
+		case 192:
+			icon = thisPtr->getWinPlatformInfo()->icon192;
+			break;
+		case 259:
+			icon = thisPtr->getWinPlatformInfo()->icon256;
+			break;
+		}
+
+		if (icon != nullptr)
+		{
+			ScriptTexture2D* scriptTexture;
+			ScriptResourceManager::instance().getScriptResource(icon, &scriptTexture, true);
+
+			return scriptTexture->getManagedInstance();
+		}
+
+		return nullptr;
+	}
+
+	void ScriptWinPlatformInfo::Internal_SetIcon(ScriptWinPlatformInfo* thisPtr, int size, ScriptTexture2D* texturePtr)
+	{
+		HTexture icon;
+
+		if (texturePtr != nullptr)
+			icon = texturePtr->getTextureHandle();
+
+		switch (size)
+		{
+		case 16:
+			thisPtr->getWinPlatformInfo()->icon16 = icon;
+			break;
+		case 32:
+			thisPtr->getWinPlatformInfo()->icon32 = icon;
+			break;
+		case 48:
+			thisPtr->getWinPlatformInfo()->icon48 = icon;
+			break;
+		case 64:
+			thisPtr->getWinPlatformInfo()->icon64 = icon;
+			break;
+		case 96:
+			thisPtr->getWinPlatformInfo()->icon96 = icon;
+			break;
+		case 128:
+			thisPtr->getWinPlatformInfo()->icon128 = icon;
+			break;
+		case 192:
+			thisPtr->getWinPlatformInfo()->icon192 = icon;
+			break;
+		case 259:
+			thisPtr->getWinPlatformInfo()->icon256 = icon;
+			break;
+		}
+	}
 }

+ 0 - 1
TODO.txt

@@ -77,7 +77,6 @@ Other polish:
    - Consider saving this information with the serialized object
 
 Stage 2 polish:
- - Inject an icon into an .exe (Win32 specific)
  - Prefabs
  - Game window
  - Game play/pause/step (+ save/restore objects on play/pause switch)