diff GUI/UI/UIHouses.cpp @ 2573:0c67be4ec900

DrawTextureIndexed renamed to DrawTextureTransparentColorKey Changing more class Texture to class Image.
author a.parshin
date Sat, 05 Mar 2016 16:25:53 +0200
parents d87bfbd3bb3b
children dd36326a9994
line wrap: on
line diff
--- a/GUI/UI/UIHouses.cpp	Sat Mar 05 01:51:54 2016 +0200
+++ b/GUI/UI/UIHouses.cpp	Sat Mar 05 16:25:53 2016 +0200
@@ -5,6 +5,7 @@
 #define _CRT_SECURE_NO_WARNINGS
 
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 
 #include "UIGuilds.h"
 #include "UIPartyCreation.h"
@@ -44,6 +45,10 @@
 BuildingType in_current_building_type; // 00F8B198
 HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C
 
+
+class Image *_591428_endcap = nullptr;
+
+
 #pragma pack(push, 1)
 struct stru365_travel_info
 {
@@ -321,6 +326,18 @@
 }};
 
 
+static std::array<const char *, 19> _4F03B8_shop_background_names =
+{
+    {
+        "",         "WEPNTABL", "ARMORY",   "MAGSHELF",
+        "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF",
+        "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF",
+        "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF",
+        "MAGSHELF", "MAGSHELF", "MAGSHELF"
+    }
+};
+
+
 
 //----- (004B3A72) --------------------------------------------------------
 void InitializaDialogueOptions_Tavern(BuildingType type)
@@ -887,10 +904,10 @@
 		v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
 		pDialogueNPCCount = 0;
 		pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
-        right_panel_loop = right_panel;
+
 		PrepareHouse(uHouseID);
 		v18 = 1;
-        right_panel_loop = right_panel;
+
 		if ( uNumDialogueNPCPortraits == 1 )
 			pDialogueNPCCount = 1;
 		pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u);
@@ -1047,8 +1064,13 @@
       }
     }
     dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
-    if ( in_current_building_type < BuildingType_19 )
-      ShopTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE)];
+    if (in_current_building_type < BuildingType_19)
+    {
+        wchar_t name[1024];
+        swprintf(name, L"%S", _4F03B8_shop_background_names[(int)in_current_building_type]);
+
+        shop_ui_background = assets->GetImage_16BitColorKey(name, 0x7FF);
+    }
   }
   
   //NEW
@@ -1715,7 +1737,7 @@
         pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &window, 13, 0) + 7;
       }
       pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight);
-      pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
+      pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
       window.DrawText(pOutString, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pOutString, &window, 13, 0), 0, 0, 0);
       break;
     }
@@ -2014,7 +2036,7 @@
         pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7;
       }
       pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight);
-      pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
+      pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
       window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, FitTextInAWindow(pTmpBuf.data(), pOutString, &dialog_window, 0xCu, 0), 0, 0, 0);
       break;
     }
@@ -2025,7 +2047,7 @@
       dialog_window.uFrameZ = 452;
       pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7;
       pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight);
-      pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
+      pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
       window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0,
                                     FitTextInAWindow(pTmpBuf.data(), pFontArrus, &dialog_window, 0xCu, 0), 0, 0, 0);
       break;
@@ -2905,9 +2927,10 @@
         pRenderer->GetLeather(8, 352 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7),
            pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight
            - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7));
-        pRenderer->DrawTextureIndexed(8, 347 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7), pTexture_591428);
-        pDialogueWindow->DrawText(pFontArrus, 13, 354 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7),
-                                             0, FitTextInAWindow(pInString, pFontArrus, &house_window, 0xDu, 0), 0, 0, 0);
+
+        int h = (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7);
+        pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - h)/480.0f, _591428_endcap);
+        pDialogueWindow->DrawText(pFontArrus, 13, 354 - h, 0, FitTextInAWindow(pInString, pFontArrus, &house_window, 0xDu, 0), 0, 0, 0);
       }
     }
   }
@@ -3062,7 +3085,7 @@
       pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
     }
     pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight);
-    pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
+    pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
     house_window.DrawText(pTextFont, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pTextFont, &w, 13, 0), 0, 0, 0);
   }
 }
@@ -3319,10 +3342,10 @@
   if ( pDialogueNPCCount == 0)
     return 0;
 
-  if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL && ShopTexture )
+  if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL && shop_ui_background)
   {
-    ShopTexture->Release();
-    ShopTexture = 0;
+      shop_ui_background->Release();
+      shop_ui_background = nullptr;
   }
 
   switch(dialog_menu_id)