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