Mercurial > mm7
annotate GUI/UI/UIRest.cpp @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | dd36326a9994 |
children |
rev | line source |
---|---|
2501 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
2541 | 6 |
7 #include "Engine/Engine.h" | |
2574 | 8 #include "Engine/AssetsManager.h" |
2541 | 9 |
2545 | 10 #include "Engine/Graphics/Outdoor.h" |
11 #include "Engine/LOD.h" | |
12 #include "Engine/Graphics/Viewport.h" | |
13 #include "Engine/Timer.h" | |
14 #include "Engine/texts.h" | |
15 #include "Engine/Party.h" | |
16 | |
17 #include "GUI/UI/UIRest.h" | |
18 #include "GUI/GUIFont.h" | |
19 | |
20 #include "Media/Audio/AudioPlayer.h" | |
21 | |
22 | |
2501 | 23 |
2574 | 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; | |
34 | |
35 | |
36 | |
2545 | 37 void GUIWindow_RestWindow::Update() |
38 { | |
39 __debugbreak(); // doesnt seems to get here, check stack trace & conditions | |
40 GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133 | |
41 memset(&GUIButton2, 0, sizeof(GUIButton2)); | |
42 GUIButton2.uZ = 197; | |
43 GUIButton2.uW = 197; | |
44 GUIButton2.uX = 27; | |
45 GUIButton2.uY = 161; | |
46 GUIButton2.uWidth = 171; | |
47 GUIButton2.uHeight = 37; | |
48 GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
49 pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0); | |
2575 | 50 pRenderer->DrawTextureAlphaNew(uFrameX/640.0f, uFrameY/480.0f, *((Image **)ptr_1C + 15)); |
2545 | 51 viewparams->bRedrawGameUI = 1; |
52 GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0); // Rest & Heal 8 hrs / Отдых и лечение 8 часов | |
53 GUIButton2.pParent = 0; | |
54 Release(); | |
55 } | |
2501 | 56 |
57 | |
2543 | 58 void PrepareToLoadRestUI() |
2501 | 59 { |
2543 | 60 if (!_506F14_resting_stage) |
61 pAudioPlayer->StopChannels(-1, -1); | |
62 if (current_screen_type != SCREEN_GAME) | |
63 { | |
64 pGUIWindow_CurrentMenu->Release(); | |
65 current_screen_type = SCREEN_GAME; | |
66 viewparams->bRedrawGameUI = true; | |
67 } | |
68 pEventTimer->Pause(); | |
69 if (_506F14_resting_stage != 2) | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
70 new OnButtonClick2(518, 450, 0, 0, (int)pBtn_Rest, 0); |
2543 | 71 _506F18_num_minutes_to_sleep = 0; |
72 _506F14_resting_stage = 0; | |
73 uRestUI_FoodRequiredToRest = 2; | |
74 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
75 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
76 if (PartyHasDragon()) | |
2501 | 77 { |
2543 | 78 for (uint i = 0; i < 4; ++i) |
79 { | |
80 if (pParty->pPlayers[i].classType == PLAYER_CLASS_WARLOCK) | |
81 ++uRestUI_FoodRequiredToRest; | |
82 } | |
2501 | 83 } |
2543 | 84 if (CheckHiredNPCSpeciality(Porter)) |
85 --uRestUI_FoodRequiredToRest; | |
86 if (CheckHiredNPCSpeciality(QuarterMaster)) | |
87 uRestUI_FoodRequiredToRest -= 2; | |
88 if (CheckHiredNPCSpeciality(Gypsy)) | |
89 --uRestUI_FoodRequiredToRest; | |
90 if (uRestUI_FoodRequiredToRest < 1) | |
91 uRestUI_FoodRequiredToRest = 1; | |
2549 | 92 if (!_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, PARTY_QUEST_HARMONDALE_REBUILT)) // d29 = Harmondale / Замок Хармондейл |
2543 | 93 uRestUI_FoodRequiredToRest = 0; |
2501 | 94 |
2543 | 95 ++pIcons_LOD->uTexturePacksCount; |
96 if (!pIcons_LOD->uNumPrevLoadedFiles) | |
97 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | |
98 } | |
2549 | 99 |
100 | |
101 | |
102 | |
2543 | 103 //----- (0041F6C1) -------------------------------------------------------- |
2549 | 104 GUIWindow_Rest::GUIWindow_Rest() : |
105 GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr) | |
2543 | 106 { |
2549 | 107 |
108 PrepareToLoadRestUI(); | |
109 current_screen_type = SCREEN_REST; | |
2543 | 110 |
2549 | 111 _507CD4_RestUI_hourglass_anim_controller = 0; |
2574 | 112 rest_ui_restmain = assets->GetImage_16BitAlpha("restmain"); |
113 rest_ui_btn_1 = assets->GetImage_16BitAlpha("restb1"); | |
114 rest_ui_btn_2 = assets->GetImage_16BitAlpha("restb2"); | |
115 rest_ui_btn_3 = assets->GetImage_16BitAlpha("restb3"); | |
116 rest_ui_btn_4 = assets->GetImage_16BitAlpha("restb4"); | |
117 rest_ui_btn_exit = assets->GetImage_16BitAlpha("restexit"); | |
2543 | 118 |
2549 | 119 OutdoorLocation::LoadActualSkyFrame(); |
2543 | 120 |
2549 | 121 //auto wnd = new GUIWindow_Rest(0, 0, window->GetWidth(), window->GetHeight()); |
2574 | 122 pButton_RestUI_Exit = CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", rest_ui_btn_exit, 0); |
123 pButton_RestUI_Main = CreateButton(24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", rest_ui_btn_4, 0); | |
124 pButton_RestUI_WaitUntilDawn = CreateButton(61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", rest_ui_btn_1, 0); | |
125 pButton_RestUI_Wait1Hour = CreateButton(61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", rest_ui_btn_2, 0); | |
126 pButton_RestUI_Wait5Minutes = CreateButton(61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", rest_ui_btn_3, 0); | |
2501 | 127 } |
128 | |
2545 | 129 |
130 | |
2501 | 131 //----- (0041FA01) -------------------------------------------------------- |
2545 | 132 void GUIWindow_Rest::Update() |
2501 | 133 { |
134 int live_characters; // esi@1 | |
135 unsigned int v3; // eax@15 | |
136 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19 | |
137 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9 | |
138 | |
139 live_characters = 0; | |
140 for( int i = 1; i < 5; ++i ) | |
141 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 ) | |
142 ++live_characters; | |
143 | |
144 if ( live_characters ) | |
145 { | |
2574 | 146 pRenderer->DrawTextureAlphaNew(8/640.0f, 8/480.0f, rest_ui_restmain); |
2501 | 147 am_pm_hours = pParty->uCurrentHour; |
148 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; | |
149 if ( (signed int)pParty->uCurrentHour <= 12 ) | |
150 { | |
151 if ( !am_pm_hours ) | |
152 am_pm_hours = 12; | |
153 } | |
154 else | |
155 am_pm_hours -= 12; | |
2574 | 156 pRenderer->DrawTextureAlphaNew(16/640.0f, 26/480.0f, rest_ui_sky_frame_current); |
157 if ( rest_ui_hourglass_frame_current ) | |
2501 | 158 { |
2574 | 159 rest_ui_hourglass_frame_current->Release(); |
160 rest_ui_hourglass_frame_current = nullptr; | |
2501 | 161 } |
162 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; | |
163 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; | |
164 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) | |
165 { | |
166 v3 = 0; | |
167 _507CD4_RestUI_hourglass_anim_controller = 0; | |
168 } | |
169 hourglass_icon_idx = (int)floorf(((double)v3 / 512.0 * 120.0) + 0.5f) % 256 + 1; | |
170 if (hourglass_icon_idx >= 120 ) | |
171 hourglass_icon_idx = 1; | |
172 | |
2574 | 173 { |
174 wchar_t name[1024]; | |
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 | |
2501 | 182 memset(&tmp_button, 0, sizeof(GUIButton)); |
183 tmp_button.uX = 24; | |
184 tmp_button.uY = 154; | |
185 tmp_button.uZ = 194; | |
186 tmp_button.uW = 190; | |
187 tmp_button.uWidth = 171; | |
188 tmp_button.uHeight = 37; | |
189 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
190 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Отдых и лечение 8 часов | |
191 tmp_button.pParent = 0; | |
192 | |
193 sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest); | |
194 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
195 | |
196 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать до рассвета | |
197 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 1 час | |
198 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 5 минут | |
199 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Закончить отдыхать | |
200 memset(&tmp_button, 0, sizeof(GUIButton)); | |
201 tmp_button.uX = 45; | |
202 tmp_button.uY = 199; | |
203 | |
204 tmp_button.uZ = 229; | |
205 tmp_button.uW = 228; | |
206 | |
207 tmp_button.uWidth = 185; | |
208 tmp_button.uHeight = 30; | |
209 | |
210 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
211 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать без лечения | |
212 tmp_button.pParent = 0; | |
213 sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[(pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0]); | |
214 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
215 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);//День | |
216 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
217 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);//Месяц | |
218 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
219 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год | |
220 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
2543 | 221 if ( _506F14_resting_stage ) |
2501 | 222 Party::Sleep6Hours(); |
223 } | |
224 else | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
225 new OnCancel(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest" |
2501 | 226 } |