Procházet zdrojové kódy

When building only one icon is required
Build icons tested and working

BearishSun před 10 roky
rodič
revize
991d3aa857

+ 1 - 9
BansheeEditor/Include/BsPlatformInfo.h

@@ -48,15 +48,7 @@ namespace BansheeEngine
 	{
 		WinPlatformInfo();
 
-		HTexture icon16;
-		HTexture icon32;
-		HTexture icon48;
-		HTexture icon64;
-		HTexture icon96;
-		HTexture icon128;
-		HTexture icon192;
-		HTexture icon256;
-		HTexture taskbarIcon;
+		HTexture icon;
 		WString titlebarText;
 
 		/************************************************************************/

+ 3 - 35
BansheeEditor/Include/BsPlatformInfoRTTI.h

@@ -62,32 +62,8 @@ namespace BansheeEngine
 	class BS_ED_EXPORT WinPlatformInfoRTTI : public RTTIType <WinPlatformInfo, PlatformInfo, WinPlatformInfoRTTI>
 	{
 	private:
-		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; }
-
-		HTexture& getTaskbarIcon(WinPlatformInfo* obj) { return obj->taskbarIcon; }
-		void setTaskbarIcon(WinPlatformInfo* obj, HTexture& val) { obj->taskbarIcon = val; }
+		HTexture& getIcon(WinPlatformInfo* obj) { return obj->icon; }
+		void setIcon(WinPlatformInfo* obj, HTexture& val) { obj->icon = val; }
 
 		WString& getTitlebarText(WinPlatformInfo* obj) { return obj->titlebarText; }
 		void setTitlebarText(WinPlatformInfo* obj, WString& val) { obj->titlebarText = val; }
@@ -95,15 +71,7 @@ namespace BansheeEngine
 	public:
 		WinPlatformInfoRTTI()
 		{
-			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);
-			addReflectableField("taskbarIcon", 9, &WinPlatformInfoRTTI::getTaskbarIcon, &WinPlatformInfoRTTI::setTaskbarIcon);
+			addReflectableField("icon", 9, &WinPlatformInfoRTTI::getIcon, &WinPlatformInfoRTTI::setIcon);
 			addPlainField("titlebarText", 10, &WinPlatformInfoRTTI::getTitlebarText, &WinPlatformInfoRTTI::setTitlebarText);
 		}
 

binární
Game/BansheeIcon.ico


binární
Game/Game.rc


+ 9 - 0
Game/Game.vcxproj

@@ -278,6 +278,15 @@
   <ItemGroup>
     <ClCompile Include="Source\Main.cpp" />
   </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="resource.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="Game.rc" />
+  </ItemGroup>
+  <ItemGroup>
+    <Image Include="BansheeIcon.ico" />
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>

+ 11 - 4
Game/Game.vcxproj.filters

@@ -9,14 +9,21 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
     </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\Main.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="resource.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="Game.rc" />
+  </ItemGroup>
+  <ItemGroup>
+    <Image Include="BansheeIcon.ico" />
+  </ItemGroup>
 </Project>

binární
Game/resource.h


+ 7 - 37
MBansheeEditor/BuildManager.cs

@@ -166,18 +166,18 @@ namespace BansheeEditor
     public class WinPlatformInfo : PlatformInfo
     {
         /// <summary>
-        /// Texture that will be displayed in the taskbar when the application is running.
+        /// Texture that will be displayed on the application's executable.
         /// </summary>
-        public Texture2D TaskbarIcon
+        public Texture2D Icon
         {
-            get { return Internal_GetTaskbarIcon(mCachedPtr); }
+            get { return Internal_GetIcon(mCachedPtr); }
             set
             {
                 IntPtr texturePtr = IntPtr.Zero;
                 if (value != null)
                     texturePtr = value.GetCachedPtr();
 
-                Internal_SetTaskbarIcon(mCachedPtr, texturePtr);
+                Internal_SetIcon(mCachedPtr, texturePtr);
             }
         }
 
@@ -189,42 +189,12 @@ namespace BansheeEditor
             get { return Internal_GetTitleText(mCachedPtr); }
             set { Internal_SetTitleText(mCachedPtr, value); }
         }
-
-        /// <summary>
-        /// Returns a texture of a specific icon size that will be added to the executable.
-        /// </summary>
-        /// <param name="size">Type of icon to retrieve the texture for.</param>
-        /// <returns>Texture for the specified icon size.</returns>
-        public Texture2D GetIcon(WinIconSizes size)
-        {
-            return Internal_GetIcon(mCachedPtr, (int)size);
-        }
-
-        /// <summary>
-        /// Sets a texture of a specific icon size that will be added to the executable.
-        /// </summary>
-        /// <param name="size">Type of icon to set the texture for.</param>
-        /// <param name="texture">Texture for the specified icon size.</param>
-        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);
+        private static extern Texture2D Internal_GetIcon(IntPtr thisPtr);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetTaskbarIcon(IntPtr thisPtr, IntPtr texturePtr);
+        private static extern void Internal_SetIcon(IntPtr thisPtr, IntPtr texturePtr);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern string Internal_GetTitleText(IntPtr thisPtr);

+ 5 - 26
MBansheeEditor/BuildWindow.cs

@@ -7,7 +7,7 @@ namespace BansheeEditor
     /// Provides options for customizing and activating the build process which will output an executable of the game for a 
     /// specific platform, as well as any required resources.
     /// </summary>
-    [DefaultSize(500, 200)]
+    [DefaultSize(500, 300)]
     internal sealed class BuildWindow : EditorWindow
     {
         private static readonly Color PLATFORM_BG_COLOR = new Color(33.0f / 255.0f, 33.0f / 255.0f, 33.0f / 255.0f);
@@ -212,42 +212,21 @@ namespace BansheeEditor
                     WinPlatformInfo winPlatformInfo = (WinPlatformInfo) platformInfo;
 
                     GUITextField titleField = new GUITextField(new LocEdString("Title"));
-                    GUIToggle iconsFoldout = new GUIToggle(new LocEdString("Icons"), EditorStyles.Foldout);
 
                     layout.AddElement(titleField);
                     layout.AddSpace(5);
 
-                    layout.AddElement(iconsFoldout);
-                    GUILayoutY iconsLayout = layout.AddLayoutY();
-
-                    int[] iconSizes = (int[]) Enum.GetValues(typeof (WinIconSizes));
-                    GUITextureField[] iconFields = new GUITextureField[iconSizes.Length];
-                    for (int i = 0; i < iconSizes.Length; i++)
-                    {
-                        int size = iconSizes[i];
-                        iconFields[i] = new GUITextureField(new LocEdString("Icon (" + size + "x" + size + ")"));
-                        iconFields[i].Value = winPlatformInfo.GetIcon((WinIconSizes) size);
-                        iconFields[i].OnChanged += x => winPlatformInfo.SetIcon((WinIconSizes) size, x as Texture2D);
-
-                        iconsLayout.AddElement(iconFields[i]);
-                    }
-
-                    GUITextureField taskbarIconField = new GUITextureField(new LocEdString("Taskbar icon (32x32)"));
-                    iconsLayout.AddElement(taskbarIconField);
+                    GUITextureField iconField = new GUITextureField(new LocEdString("Icon"));
+                    layout.AddElement(iconField);
 
                     titleField.Value = winPlatformInfo.TitleText;
-                    taskbarIconField.Value = winPlatformInfo.TaskbarIcon;
+                    iconField.Value = winPlatformInfo.Icon;
 
                     titleField.OnChanged += x => winPlatformInfo.TitleText = x;
-                    iconsFoldout.OnToggled += x => iconsLayout.Active = x;
-                    taskbarIconField.OnChanged += x => winPlatformInfo.TaskbarIcon = x as Texture2D;
-
-                    iconsLayout.Active = false;
+                    iconField.OnChanged += x => winPlatformInfo.Icon = x as Texture2D;
                 }
                     break;
             }
-
-            // TODO - Different background for platform selection bit
         }
 
         /// <summary>

+ 2 - 4
SBansheeEditor/Include/BsScriptPlatformInfo.h

@@ -82,10 +82,8 @@ namespace BansheeEngine
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
-		static MonoObject* internal_GetIcon(ScriptWinPlatformInfo* thisPtr, int size);
-		static void internal_SetIcon(ScriptWinPlatformInfo* thisPtr, int size, ScriptTexture2D* texturePtr);
-		static MonoObject* internal_GetTaskbarIcon(ScriptWinPlatformInfo* thisPtr);
-		static void internal_SetTaskbarIcon(ScriptWinPlatformInfo* thisPtr, ScriptTexture2D* texturePtr);
+		static MonoObject* internal_GetIcon(ScriptWinPlatformInfo* thisPtr);
+		static void internal_SetIcon(ScriptWinPlatformInfo* thisPtr, ScriptTexture2D* texturePtr);
 		static MonoString* internal_GetTitleText(ScriptWinPlatformInfo* thisPtr);
 		static void internal_SetTitleText(ScriptWinPlatformInfo* thisPtr, MonoString* text);
 	};

+ 25 - 21
SBansheeEditor/Source/BsScriptBuildManager.cpp

@@ -17,6 +17,7 @@
 #include "BsResourceManifest.h"
 #include "BsBuiltinResources.h"
 #include "BsSceneObject.h"
+#include "BsDebug.h"
 
 namespace BansheeEngine
 {
@@ -175,36 +176,38 @@ namespace BansheeEngine
 			struct IconData
 			{
 				UINT32 size;
-				HTexture texture;
 				PixelDataPtr pixels;
 			};
 
 			IconData textures[] =
 			{ 
-				{ 16, winPlatformInfo->icon16 },
-				{ 32, winPlatformInfo->icon32 },
-				{ 48, winPlatformInfo->icon48 },
-				{ 64, winPlatformInfo->icon64 },
-				{ 96, winPlatformInfo->icon96 },
-				{ 128, winPlatformInfo->icon128 },
-				{ 192, winPlatformInfo->icon192 }, 
-				{ 256, winPlatformInfo->icon256 } 
+				{ 16 },
+				{ 32 },
+				{ 48 },
+				{ 64 },
+				{ 96 },
+				{ 128 },
+				{ 192 }, 
+				{ 256 } 
 			};
 
-			for (auto& entry : textures)
+			HTexture icon = winPlatformInfo->icon;
+			if (icon.isLoaded())
 			{
-				if (!entry.texture.isLoaded())
-					continue;
+				auto& texProps = icon->getProperties();
 
-				auto& texProps = entry.texture->getProperties();
+				PixelDataPtr pixels = texProps.allocateSubresourceBuffer(0);
+				icon->readSubresource(gCoreAccessor(), 0, pixels);
+				gCoreAccessor().submitToCoreThread(true);
 
-				entry.pixels = texProps.allocateSubresourceBuffer(0);
-				entry.texture->readSubresource(gCoreAccessor(), 0, entry.pixels);
+				for (auto& entry : textures)
+				{
+					entry.pixels = PixelData::create(entry.size, entry.size, 1, PF_R8G8B8A8);
+					PixelUtil::scale(*pixels, *entry.pixels);
 
-				icons[entry.size] = entry.pixels;
+					icons[entry.size] = entry.pixels;
+				}
 			}
-
-			gCoreAccessor().submitToCoreThread(true);
 		}
 			break;
 		}
@@ -356,9 +359,10 @@ namespace BansheeEngine
 		case PlatformType::Windows:
 		{
 			SPtr<WinPlatformInfo> winPlatformInfo = std::static_pointer_cast<WinPlatformInfo>(platformInfo);
-
-			if (winPlatformInfo->taskbarIcon != nullptr)
-				gResources().save(winPlatformInfo->taskbarIcon, destIconFile, false);
+			
+			HTexture icon = winPlatformInfo->icon;
+			if (icon != nullptr)
+				gResources().save(icon, destIconFile, true);
 		}
 		};
 

+ 4 - 84
SBansheeEditor/Source/BsScriptPlatformInfo.cpp

@@ -130,8 +130,6 @@ namespace BansheeEngine
 	{
 		metaData.scriptClass->addInternalCall("Internal_GetIcon", &ScriptWinPlatformInfo::internal_GetIcon);
 		metaData.scriptClass->addInternalCall("Internal_SetIcon", &ScriptWinPlatformInfo::internal_SetIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetTaskbarIcon", &ScriptWinPlatformInfo::internal_GetTaskbarIcon);
-		metaData.scriptClass->addInternalCall("Internal_SetTaskbarIcon", &ScriptWinPlatformInfo::internal_SetTaskbarIcon);
 		metaData.scriptClass->addInternalCall("Internal_GetTitleText", &ScriptWinPlatformInfo::internal_GetTitleText);
 		metaData.scriptClass->addInternalCall("Internal_SetTitleText", &ScriptWinPlatformInfo::internal_SetTitleText);
 	}
@@ -150,87 +148,9 @@ namespace BansheeEngine
 		return managedInstance;
 	}
 
-	MonoObject* ScriptWinPlatformInfo::internal_GetIcon(ScriptWinPlatformInfo* thisPtr, int size)
+	MonoObject* ScriptWinPlatformInfo::internal_GetIcon(ScriptWinPlatformInfo* thisPtr)
 	{
-		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 256:
-			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->getHandle();
-
-		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 256:
-			thisPtr->getWinPlatformInfo()->icon256 = icon;
-			break;
-		}
-	}
-
-	MonoObject* ScriptWinPlatformInfo::internal_GetTaskbarIcon(ScriptWinPlatformInfo* thisPtr)
-	{
-		HTexture icon = thisPtr->getWinPlatformInfo()->taskbarIcon;
+		HTexture icon = thisPtr->getWinPlatformInfo()->icon;
 
 		if (icon != nullptr)
 		{
@@ -243,14 +163,14 @@ namespace BansheeEngine
 		return nullptr;
 	}
 
-	void ScriptWinPlatformInfo::internal_SetTaskbarIcon(ScriptWinPlatformInfo* thisPtr, ScriptTexture2D* texturePtr)
+	void ScriptWinPlatformInfo::internal_SetIcon(ScriptWinPlatformInfo* thisPtr, ScriptTexture2D* texturePtr)
 	{
 		HTexture icon;
 
 		if (texturePtr != nullptr)
 			icon = texturePtr->getHandle();
 
-		thisPtr->getWinPlatformInfo()->taskbarIcon = icon;
+		thisPtr->getWinPlatformInfo()->icon = icon;
 	}
 
 	MonoString* ScriptWinPlatformInfo::internal_GetTitleText(ScriptWinPlatformInfo* thisPtr)