comparison 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
comparison
equal deleted inserted replaced
2573:0c67be4ec900 2574:dd36326a9994
3 #include <crtdbg.h> 3 #include <crtdbg.h>
4 4
5 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include "Engine/Engine.h" 7 #include "Engine/Engine.h"
8 #include "Engine/AssetsManager.h"
8 9
9 #include "Engine/Graphics/Outdoor.h" 10 #include "Engine/Graphics/Outdoor.h"
10 #include "Engine/LOD.h" 11 #include "Engine/LOD.h"
11 #include "Engine/Graphics/Viewport.h" 12 #include "Engine/Graphics/Viewport.h"
12 #include "Engine/Timer.h" 13 #include "Engine/Timer.h"
15 16
16 #include "GUI/UI/UIRest.h" 17 #include "GUI/UI/UIRest.h"
17 #include "GUI/GUIFont.h" 18 #include "GUI/GUIFont.h"
18 19
19 #include "Media/Audio/AudioPlayer.h" 20 #include "Media/Audio/AudioPlayer.h"
21
22
23
24
25 Image *rest_ui_btn_4 = nullptr;
26 Image *rest_ui_btn_exit = nullptr;
27 Image *rest_ui_btn_3 = nullptr;
28 Image *rest_ui_btn_1 = nullptr;
29 Image *rest_ui_btn_2 = nullptr;
30 Image *rest_ui_restmain = nullptr;
31
32 Image *rest_ui_sky_frame_current = nullptr;
33 Image *rest_ui_hourglass_frame_current = nullptr;
20 34
21 35
22 36
23 void GUIWindow_RestWindow::Update() 37 void GUIWindow_RestWindow::Update()
24 { 38 {
31 GUIButton2.uY = 161; 45 GUIButton2.uY = 161;
32 GUIButton2.uWidth = 171; 46 GUIButton2.uWidth = 171;
33 GUIButton2.uHeight = 37; 47 GUIButton2.uHeight = 37;
34 GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent; 48 GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent;
35 pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0); 49 pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
36 pRenderer->DrawTextureTransparentColorKey(uFrameX, uFrameY, *((Texture **)ptr_1C + 15)); 50 pRenderer->DrawTextureTransparentColorKey(uFrameX, uFrameY, *((Texture_MM7 **)ptr_1C + 15));
37 viewparams->bRedrawGameUI = 1; 51 viewparams->bRedrawGameUI = 1;
38 GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0); // Rest & Heal 8 hrs / Отдых и лечение 8 часов 52 GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0); // Rest & Heal 8 hrs / Отдых и лечение 8 часов
39 GUIButton2.pParent = 0; 53 GUIButton2.pParent = 0;
40 Release(); 54 Release();
41 } 55 }
93 107
94 PrepareToLoadRestUI(); 108 PrepareToLoadRestUI();
95 current_screen_type = SCREEN_REST; 109 current_screen_type = SCREEN_REST;
96 110
97 _507CD4_RestUI_hourglass_anim_controller = 0; 111 _507CD4_RestUI_hourglass_anim_controller = 0;
98 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); 112 rest_ui_restmain = assets->GetImage_16BitAlpha("restmain");
99 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); 113 rest_ui_btn_1 = assets->GetImage_16BitAlpha("restb1");
100 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); 114 rest_ui_btn_2 = assets->GetImage_16BitAlpha("restb2");
101 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); 115 rest_ui_btn_3 = assets->GetImage_16BitAlpha("restb3");
102 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); 116 rest_ui_btn_4 = assets->GetImage_16BitAlpha("restb4");
103 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); 117 rest_ui_btn_exit = assets->GetImage_16BitAlpha("restexit");
104 118
105 OutdoorLocation::LoadActualSkyFrame(); 119 OutdoorLocation::LoadActualSkyFrame();
106 120
107 //auto wnd = new GUIWindow_Rest(0, 0, window->GetWidth(), window->GetHeight()); 121 //auto wnd = new GUIWindow_Rest(0, 0, window->GetWidth(), window->GetHeight());
108 pButton_RestUI_Exit = CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); 122 pButton_RestUI_Exit = CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", rest_ui_btn_exit, 0);
109 pButton_RestUI_Main = CreateButton(24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); 123 pButton_RestUI_Main = CreateButton(24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", rest_ui_btn_4, 0);
110 pButton_RestUI_WaitUntilDawn = CreateButton(61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0); 124 pButton_RestUI_WaitUntilDawn = CreateButton(61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", rest_ui_btn_1, 0);
111 pButton_RestUI_Wait1Hour = CreateButton(61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0); 125 pButton_RestUI_Wait1Hour = CreateButton(61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", rest_ui_btn_2, 0);
112 pButton_RestUI_Wait5Minutes = CreateButton(61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0); 126 pButton_RestUI_Wait5Minutes = CreateButton(61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", rest_ui_btn_3, 0);
113 } 127 }
114 128
115 129
116 130
117 //----- (0041FA01) -------------------------------------------------------- 131 //----- (0041FA01) --------------------------------------------------------
127 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 ) 141 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 )
128 ++live_characters; 142 ++live_characters;
129 143
130 if ( live_characters ) 144 if ( live_characters )
131 { 145 {
132 pRenderer->DrawTextureTransparentColorKey(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); 146 pRenderer->DrawTextureAlphaNew(8/640.0f, 8/480.0f, rest_ui_restmain);
133 am_pm_hours = pParty->uCurrentHour; 147 am_pm_hours = pParty->uCurrentHour;
134 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; 148 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
135 if ( (signed int)pParty->uCurrentHour <= 12 ) 149 if ( (signed int)pParty->uCurrentHour <= 12 )
136 { 150 {
137 if ( !am_pm_hours ) 151 if ( !am_pm_hours )
138 am_pm_hours = 12; 152 am_pm_hours = 12;
139 } 153 }
140 else 154 else
141 am_pm_hours -= 12; 155 am_pm_hours -= 12;
142 pRenderer->DrawTextureTransparentColorKey(16, 26, pTexture_RestUI_CurrentSkyFrame); 156 pRenderer->DrawTextureAlphaNew(16/640.0f, 26/480.0f, rest_ui_sky_frame_current);
143 if ( pTexture_RestUI_CurrentHourglassFrame ) 157 if ( rest_ui_hourglass_frame_current )
144 { 158 {
145 pTexture_RestUI_CurrentHourglassFrame->Release(); 159 rest_ui_hourglass_frame_current->Release();
146 pIcons_LOD->SyncLoadedFilesCount(); 160 rest_ui_hourglass_frame_current = nullptr;
147 } 161 }
148 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; 162 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
149 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; 163 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
150 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) 164 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 )
151 { 165 {
154 } 168 }
155 hourglass_icon_idx = (int)floorf(((double)v3 / 512.0 * 120.0) + 0.5f) % 256 + 1; 169 hourglass_icon_idx = (int)floorf(((double)v3 / 512.0 * 120.0) + 0.5f) % 256 + 1;
156 if (hourglass_icon_idx >= 120 ) 170 if (hourglass_icon_idx >= 120 )
157 hourglass_icon_idx = 1; 171 hourglass_icon_idx = 1;
158 172
159 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx); 173 {
160 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); 174 wchar_t name[1024];
161 pRenderer->DrawTextureTransparentColorKey(267, 159, pTexture_RestUI_CurrentHourglassFrame); 175 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx);
176 swprintf(name, L"hglas%03d", hourglass_icon_idx);
177 rest_ui_hourglass_frame_current = assets->GetImage_16BitColorKey(name, 0x7FF);
178
179 pRenderer->DrawTextureAlphaNew(267/640.0f, 159/480.0f, rest_ui_hourglass_frame_current);
180 }
181
162 memset(&tmp_button, 0, sizeof(GUIButton)); 182 memset(&tmp_button, 0, sizeof(GUIButton));
163 tmp_button.uX = 24; 183 tmp_button.uX = 24;
164 tmp_button.uY = 154; 184 tmp_button.uY = 154;
165 tmp_button.uZ = 194; 185 tmp_button.uZ = 194;
166 tmp_button.uW = 190; 186 tmp_button.uW = 190;