diff GUI/UI/UITransition.cpp @ 2574:dd36326a9994

More texture refactoring GetLeather -> DrawTextureCustomHeight
author a.parshin
date Mon, 07 Mar 2016 03:48:40 +0200
parents 0c67be4ec900
children
line wrap: on
line diff
--- a/GUI/UI/UITransition.cpp	Sat Mar 05 16:25:53 2016 +0200
+++ b/GUI/UI/UITransition.cpp	Mon Mar 07 03:48:40 2016 +0200
@@ -19,6 +19,7 @@
 #include "GUI/GUIFont.h"
 #include "GUI/GUIProgressBar.h"
 #include "GUI/UI/UIHouses.h"
+#include "GUI/UI/UIGame.h"
 
 #include "Media/Audio/AudioPlayer.h"
 #include "Media/MediaPlayer.h"
@@ -26,13 +27,25 @@
 
 
 
+Image *transition_ui_icon = nullptr;
+
+
 void GUIWindow_Travel::Release()
 {
 // -----------------------------------------
 // 0041C26A void GUIWindow::Release --- part
-    pTexture_outside->Release();
-    pTexture_Dialogue_Background->Release();
-    pIcons_LOD->SyncLoadedFilesCount();
+    if (transition_ui_icon)
+    {
+        transition_ui_icon->Release();
+        transition_ui_icon = nullptr;
+    }
+
+    if (game_ui_dialogue_background)
+    {
+        game_ui_dialogue_background->Release();
+        game_ui_dialogue_background = nullptr;
+    }
+
     current_screen_type = prev_screen_type;
 
     GUIWindow::Release();
@@ -43,9 +56,18 @@
 // -----------------------------------------
 // 0041C26A void GUIWindow::Release --- part
     //pVideoPlayer->Unload();
-    pTexture_outside->Release();
-    pTexture_Dialogue_Background->Release();
-    pIcons_LOD->SyncLoadedFilesCount();
+    if (transition_ui_icon)
+    {
+        transition_ui_icon->Release();
+        transition_ui_icon = nullptr;
+    }
+
+    if (game_ui_dialogue_background)
+    {
+        game_ui_dialogue_background->Release();
+        game_ui_dialogue_background = nullptr;
+    }
+
     current_screen_type = prev_screen_type;
 
     GUIWindow::Release();
@@ -79,9 +101,9 @@
     case PartyAlignment_Evil:    sprintfex(pContainer, "evt%02d-c", const_2()); break;
     default: Error("Invalid alignment: %u", pParty->alignment);
   }
+  game_ui_dialogue_background = assets->GetImage_16Bit(pContainer);
 
-  pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
-  pTexture_outside = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[exit_pic_id], TEXTURE_16BIT_PALETTE);
+  transition_ui_icon = assets->GetImage_16Bit(pHouse_ExitPictures[exit_pic_id]);
   if (anim_id)
   {
     if ( !IndoorLocation::GetLocationIndex(pLocationName) )
@@ -140,8 +162,8 @@
 // 0041C432 GUIWindow c-tor -- part
   prev_screen_type = current_screen_type;
   current_screen_type = SCREEN_INPUT_BLV;
-  pBtn_ExitCancel = CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionWindowCloseBtn, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); // Cancel / Отмена
-  pBtn_YES = CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
+  pBtn_ExitCancel = CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionWindowCloseBtn, 0, 'N', pGlobalTXT_LocalizationStrings[34], ui_buttdesc2, 0); // Cancel / Отмена
+  pBtn_YES = CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', hint, ui_buttyes2, 0);
   CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, hint, 0);
   CreateButton(8, 8, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, hint, 0);
 }
@@ -165,9 +187,9 @@
     case PartyAlignment_Evil:    sprintfex(pContainer, "evt%02d-c", const_2()); break;
     default: Error("Invalid alignment: %u", pParty->alignment);
   }
+  game_ui_dialogue_background = assets->GetImage_16Bit(pContainer);
 
-  pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
-  pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE);
+  transition_ui_icon = assets->GetImage_16Bit("outside");
   if ( pMapStats->GetMapInfo(pCurrentMapName) )
     sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName);// "Leave %s"
   else
@@ -187,7 +209,7 @@
       0,
       'N',
       pGlobalTXT_LocalizationStrings[156],
-      pIcons_LOD->GetTexture(uTextureID_BUTTDESC2),
+      ui_buttdesc2,
       0
   );// Stay in this area / Остаться в этой области
   pBtn_YES = CreateButton(
@@ -196,7 +218,7 @@
       0,
       'Y',
       hint,
-      pIcons_LOD->GetTexture(uTextureID_BUTTYES2),
+      ui_buttyes2,
       0
   );
   CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63, 73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', hint, 0, 0, 0);
@@ -215,11 +237,11 @@
 
   memcpy(&travel_window, pPrimaryWindow, sizeof(travel_window));
   pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20);
-  pRenderer->DrawTextureTransparentColorKey(477, 0, pTexture_Dialogue_Background);
+  pRenderer->DrawTextureNew(477/640.0f, 0, game_ui_dialogue_background);
   pRenderer->DrawTextureAlphaNew(468/640.0f, 0, game_ui_right_panel_frame);
-  pRenderer->DrawTextureTransparentColorKey(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
-  pRenderer->DrawTextureTransparentColorKey(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
-  pRenderer->DrawTextureTransparentColorKey(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
+  pRenderer->DrawTextureNew(pNPCPortraits_x[0][0]/640.0f, pNPCPortraits_y[0][0]/480.0f, transition_ui_icon);
+  pRenderer->DrawTextureAlphaNew(556/640.0f, 451/480.0f, dialogue_ui_x_x_u);
+  pRenderer->DrawTextureAlphaNew(476/640.0f, 451/480.0f, dialogue_ui_x_ok_u);
   if ( pMapStats->GetMapInfo(pDestinationMapName) )
   {
     travel_window.uFrameX = 493;
@@ -256,13 +278,13 @@
 
   memcpy(&transition_window, pPrimaryWindow, sizeof(transition_window));
   v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name);
-  pRenderer->DrawTextureTransparentColorKey(0x1DDu, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureTransparentColorKey(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C));
-  pRenderer->DrawTextureTransparentColorKey(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
+  pRenderer->DrawTextureNew(477/640.0f, 0, game_ui_dialogue_background);
+  pRenderer->DrawTextureAlphaNew((pNPCPortraits_x[0][0] - 4)/640.0f, (pNPCPortraits_y[0][0] - 4)/480.0f, game_ui_evtnpc);
+  pRenderer->DrawTextureNew(pNPCPortraits_x[0][0]/640.0f, pNPCPortraits_y[0][0]/480.0f, transition_ui_icon);
 
   pRenderer->DrawTextureAlphaNew(468/640.0f, 0, game_ui_right_panel_frame);
-  pRenderer->DrawTextureTransparentColorKey(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
-  pRenderer->DrawTextureTransparentColorKey(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
+  pRenderer->DrawTextureAlphaNew(556/640.0f, 451/480.0f, dialogue_ui_x_x_u);
+  pRenderer->DrawTextureAlphaNew(476/640.0f, 451/480.0f, dialogue_ui_x_ok_u);
   map_id = pMapStats->GetMapInfo(pCurrentMapName);
   if ( (pMovie_Track || v9) && *dword_591164_teleport_map_name != ' ' )
     map_id = pMapStats->GetMapInfo(dword_591164_teleport_map_name);