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

More texture refactoring GetLeather -> DrawTextureCustomHeight
author a.parshin
date Mon, 07 Mar 2016 03:48:40 +0200
parents 0c67be4ec900
children a76d408c5132
line wrap: on
line diff
--- a/GUI/UI/UIRest.cpp	Sat Mar 05 16:25:53 2016 +0200
+++ b/GUI/UI/UIRest.cpp	Mon Mar 07 03:48:40 2016 +0200
@@ -5,6 +5,7 @@
 #define _CRT_SECURE_NO_WARNINGS
 
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 
 #include "Engine/Graphics/Outdoor.h"
 #include "Engine/LOD.h"
@@ -20,6 +21,19 @@
 
 
 
+
+Image *rest_ui_btn_4 = nullptr;
+Image *rest_ui_btn_exit = nullptr;
+Image *rest_ui_btn_3 = nullptr;
+Image *rest_ui_btn_1 = nullptr;
+Image *rest_ui_btn_2 = nullptr;
+Image *rest_ui_restmain = nullptr;
+
+Image *rest_ui_sky_frame_current = nullptr;
+Image *rest_ui_hourglass_frame_current = nullptr;
+
+
+
 void GUIWindow_RestWindow::Update()
 {
     __debugbreak(); // doesnt seems to get here, check stack trace & conditions
@@ -33,7 +47,7 @@
     GUIButton2.uHeight = 37;
     GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent;
     pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
-    pRenderer->DrawTextureTransparentColorKey(uFrameX, uFrameY, *((Texture **)ptr_1C + 15));
+    pRenderer->DrawTextureTransparentColorKey(uFrameX, uFrameY, *((Texture_MM7 **)ptr_1C + 15));
     viewparams->bRedrawGameUI = 1;
     GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0); // Rest & Heal 8 hrs / Отдых и лечение 8 часов
     GUIButton2.pParent = 0;
@@ -95,21 +109,21 @@
     current_screen_type = SCREEN_REST;
 
     _507CD4_RestUI_hourglass_anim_controller = 0;
-    uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
-    uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
-    uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE);
-    uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
-    uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
-    uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
+    rest_ui_restmain = assets->GetImage_16BitAlpha("restmain");
+    rest_ui_btn_1 = assets->GetImage_16BitAlpha("restb1");
+    rest_ui_btn_2 = assets->GetImage_16BitAlpha("restb2");
+    rest_ui_btn_3 = assets->GetImage_16BitAlpha("restb3");
+    rest_ui_btn_4 = assets->GetImage_16BitAlpha("restb4");
+    rest_ui_btn_exit = assets->GetImage_16BitAlpha("restexit");
 
     OutdoorLocation::LoadActualSkyFrame();
 
     //auto wnd = new GUIWindow_Rest(0, 0, window->GetWidth(), window->GetHeight());
-    pButton_RestUI_Exit = CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
-    pButton_RestUI_Main = CreateButton(24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
-    pButton_RestUI_WaitUntilDawn = CreateButton(61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
-    pButton_RestUI_Wait1Hour = CreateButton(61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
-    pButton_RestUI_Wait5Minutes = CreateButton(61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
+    pButton_RestUI_Exit = CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", rest_ui_btn_exit, 0);
+    pButton_RestUI_Main = CreateButton(24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", rest_ui_btn_4, 0);
+    pButton_RestUI_WaitUntilDawn = CreateButton(61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", rest_ui_btn_1, 0);
+    pButton_RestUI_Wait1Hour = CreateButton(61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", rest_ui_btn_2, 0);
+    pButton_RestUI_Wait5Minutes = CreateButton(61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", rest_ui_btn_3, 0);
 }
 
 
@@ -129,7 +143,7 @@
 
   if ( live_characters )
   {
-    pRenderer->DrawTextureTransparentColorKey(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
+    pRenderer->DrawTextureAlphaNew(8/640.0f, 8/480.0f, rest_ui_restmain);
     am_pm_hours = pParty->uCurrentHour;
     dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
     if ( (signed int)pParty->uCurrentHour <= 12 )
@@ -139,11 +153,11 @@
     }
     else
       am_pm_hours -= 12;
-    pRenderer->DrawTextureTransparentColorKey(16, 26, pTexture_RestUI_CurrentSkyFrame);
-    if ( pTexture_RestUI_CurrentHourglassFrame )
+    pRenderer->DrawTextureAlphaNew(16/640.0f, 26/480.0f, rest_ui_sky_frame_current);
+    if ( rest_ui_hourglass_frame_current )
     {
-      pTexture_RestUI_CurrentHourglassFrame->Release();
-      pIcons_LOD->SyncLoadedFilesCount();
+      rest_ui_hourglass_frame_current->Release();
+      rest_ui_hourglass_frame_current = nullptr;
     }
     v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
     _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
@@ -156,9 +170,15 @@
     if (hourglass_icon_idx >= 120 )
       hourglass_icon_idx = 1;
 
-    sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx);
-    pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureTransparentColorKey(267, 159, pTexture_RestUI_CurrentHourglassFrame);
+    {
+        wchar_t name[1024];
+        sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx);
+        swprintf(name, L"hglas%03d", hourglass_icon_idx);
+        rest_ui_hourglass_frame_current = assets->GetImage_16BitColorKey(name, 0x7FF);
+
+        pRenderer->DrawTextureAlphaNew(267/640.0f, 159/480.0f, rest_ui_hourglass_frame_current);
+    }
+
     memset(&tmp_button, 0, sizeof(GUIButton));
     tmp_button.uX = 24;
     tmp_button.uY = 154;