706
|
1 #include <assert.h>
|
|
2
|
|
3 #include "MM7.h"
|
|
4
|
|
5 #include "MapInfo.h"
|
|
6 #include "Game.h"
|
|
7 #include "GUIWindow.h"
|
|
8 #include "GUIFont.h"
|
|
9 #include "GUIButton.h"
|
|
10 #include "GUIProgressBar.h"
|
|
11 #include "Party.h"
|
|
12 #include "AudioPlayer.h"
|
|
13 #include "Outdoor.h"
|
|
14 #include "IndoorCamera.h"
|
|
15 #include "Overlays.h"
|
|
16 #include "Monsters.h"
|
|
17 #include "Arcomage.h"
|
|
18 #include "LOD.h"
|
|
19 #include "Actor.h"
|
|
20 #include "Allocator.h"
|
|
21 #include "Events.h"
|
|
22 #include "Viewport.h"
|
|
23 #include "FrameTableInc.h"
|
|
24 #include "Math.h"
|
|
25 #include "SpriteObject.h"
|
|
26 #include "ObjectList.h"
|
|
27 #include "Chest.h"
|
|
28 #include "PaletteManager.h"
|
|
29 #include "DecorationList.h"
|
|
30 #include "SaveLoad.h"
|
|
31 #include "stru123.h"
|
|
32 #include "Time.h"
|
|
33 #include "IconFrameTable.h"
|
|
34 #include "Awards.h"
|
|
35 #include "Autonotes.h"
|
|
36 #include "stru160.h"
|
|
37 #include "stru279.h"
|
|
38 #include "TurnEngine.h"
|
|
39 #include "stru277.h"
|
|
40 #include "Weather.h"
|
|
41 #include "stru272.h"
|
|
42 #include "stru298.h"
|
|
43 #include "StorylineTextTable.h"
|
|
44 #include "Events2D.h"
|
|
45 #include "texts.h"
|
|
46 #include "stru351.h"
|
|
47
|
|
48 #include "mm7_data.h"
|
|
49
|
|
50
|
|
51
|
|
52 //----- (0041F6C1) --------------------------------------------------------
|
|
53 void __cdecl RestUI_Initialize()
|
|
54 {
|
|
55 Player *v0; // eax@10
|
|
56
|
|
57 if ( !dword_506F14 )
|
|
58 pAudioPlayer->StopChannels(-1, -1);
|
|
59 if ( pCurrentScreen )
|
|
60 {
|
|
61 pGUIWindow_CurrentMenu->Release();
|
|
62 pCurrentScreen = SCREEN_GAME;
|
|
63 viewparams->bRedrawGameUI = 1;
|
|
64 }
|
|
65 pEventTimer->Pause();
|
|
66 if ( dword_506F14 != 2 )
|
|
67 GUIWindow::Create(518u, 450u, 0, 0, (enum WindowType)90, (int)pBtn_Rest, 0);
|
|
68 _506F18_num_hours_to_sleep = 0;
|
|
69 dword_506F14 = 0;
|
|
70 uRestUI_FoodRequiredToRest = 2;
|
|
71 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
72 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(
|
|
73 pParty->vPosition.x,
|
|
74 pParty->vPosition.y,
|
|
75 pParty->vPosition.z);
|
|
76 if ( PartyHasDragon() )
|
|
77 {
|
|
78 v0 = pParty->pPlayers;//[0].uClass;
|
|
79 while ( v0 <= &pParty->pPlayers[3] )
|
|
80 {
|
|
81 ++v0;
|
|
82 if ( v0 > &pParty->pPlayers[3] )
|
|
83 break;
|
|
84 }
|
|
85 if(v0->classType == PLAYER_CLASS_WARLOCK)
|
|
86 ++uRestUI_FoodRequiredToRest;
|
|
87 }
|
|
88 if ( CheckHiredNPCSpeciality(Porter) )
|
|
89 --uRestUI_FoodRequiredToRest;
|
|
90 if ( CheckHiredNPCSpeciality(QuarterMaster) )
|
|
91 uRestUI_FoodRequiredToRest -= 2;
|
|
92 if ( CheckHiredNPCSpeciality(Gypsy) )
|
|
93 --uRestUI_FoodRequiredToRest;
|
|
94 if ( uRestUI_FoodRequiredToRest < 1 )
|
|
95 uRestUI_FoodRequiredToRest = 1;
|
|
96 if ( !_strcmpi(pCurrentMapName, "d29.blv") && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 98) )
|
|
97 uRestUI_FoodRequiredToRest = 0;
|
|
98 ++pIcons_LOD->uTexturePacksCount;
|
|
99 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
100 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
101 pCurrentScreen = SCREEN_REST;
|
|
102 _507CD4_RestUI_hourglass_anim_controller = 0;
|
|
103 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
|
|
104 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
|
|
105 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE);
|
|
106 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
|
|
107 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
|
|
108 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
|
|
109 LoadActualSkyFrame();
|
|
110 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)16, 0, 0);
|
|
111 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(
|
|
112 280u,
|
|
113 297u,
|
|
114 154u,
|
|
115 37u,
|
|
116 1,
|
|
117 0,
|
|
118 0xA7u,
|
|
119 0,
|
|
120 0,
|
|
121 "",
|
|
122 (Texture *)(uTextureID_RestUI_restexit != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restexit] : 0),
|
|
123 0);
|
|
124 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton(
|
|
125 24u,
|
|
126 154u,
|
|
127 225u,
|
|
128 37u,
|
|
129 1,
|
|
130 0,
|
|
131 0x61u,
|
|
132 0,
|
|
133 0x52u,
|
|
134 "",
|
|
135 (Texture *)(uTextureID_RestUI_restb4 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb4] : 0),
|
|
136 0);
|
|
137 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton(
|
|
138 61u,
|
|
139 232u,
|
|
140 154u,
|
|
141 33u,
|
|
142 1,
|
|
143 0,
|
|
144 0x6Du,
|
|
145 0,
|
|
146 0x44u,
|
|
147 "",
|
|
148 (Texture *)(uTextureID_RestUI_restb1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb1] : 0),
|
|
149 0);
|
|
150 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton(
|
|
151 61u,
|
|
152 264u,
|
|
153 154u,
|
|
154 33u,
|
|
155 1,
|
|
156 0,
|
|
157 0x60u,
|
|
158 0,
|
|
159 0x48u,
|
|
160 "",
|
|
161 (Texture *)(uTextureID_RestUI_restb2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb2] : 0),
|
|
162 0);
|
|
163 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton(
|
|
164 61u,
|
|
165 296u,
|
|
166 154u,
|
|
167 33u,
|
|
168 1,
|
|
169 0,
|
|
170 0x5Fu,
|
|
171 0,
|
|
172 0x4Du,
|
|
173 "",
|
|
174 (Texture *)(uTextureID_RestUI_restb3 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb3] : 0),
|
|
175 0);
|
|
176 }
|
|
177
|
|
178 //----- (0041FA01) --------------------------------------------------------
|
|
179 void __cdecl RestUI_Draw()
|
|
180 {
|
|
181 int v0; // esi@1
|
|
182 Player **ppPlayers; // ecx@1
|
|
183 Player *pPlayer; // eax@2
|
|
184 unsigned int v3; // eax@15
|
|
185 //char v4; // al@17
|
|
186 bool v5; // eax@21
|
|
187 GUIButton Dst; // [sp+8h] [bp-DCh]@19
|
|
188 //double v7; // [sp+C4h] [bp-20h]@17
|
|
189 float v8; // [sp+CCh] [bp-18h]@17
|
|
190 __int64 v9; // [sp+D0h] [bp-14h]@17
|
|
191 unsigned int v10; // [sp+D8h] [bp-Ch]@9
|
|
192 __int16 a9[2]; // [sp+DCh] [bp-8h]@1
|
|
193 int a5; // [sp+E0h] [bp-4h]@1
|
|
194
|
|
195 v0 = 0;
|
|
196 a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
|
|
197 *(int *)a9 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 0xD6u, 0xC1u);
|
|
198 ppPlayers = &pPlayers[1];
|
|
199 do
|
|
200 {
|
|
201 pPlayer = *ppPlayers;
|
|
202 if ( !(*ppPlayers)->pConditions[14] && !pPlayer->pConditions[16] && pPlayer->sHealth > 0 )
|
|
203 ++v0;
|
|
204 ++ppPlayers;
|
|
205 }
|
|
206 while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] );
|
|
207 if ( v0 )
|
|
208 {
|
|
209 pRenderer->DrawTextureIndexed(
|
|
210 8u,
|
|
211 8u,
|
|
212 (Texture *)(uTextureID_RestUI_restmain != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restmain] : 0));
|
|
213 v10 = pParty->uCurrentHour;
|
|
214 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
|
|
215 if ( (signed int)pParty->uCurrentHour <= 12 )
|
|
216 {
|
|
217 if ( !v10 )
|
|
218 v10 = 12;
|
|
219 }
|
|
220 else
|
|
221 {
|
|
222 v10 -= 12;
|
|
223 }
|
|
224 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame);
|
|
225 if ( pTexture_RestUI_CurrentHourglassFrame )
|
|
226 {
|
|
227 pTexture_RestUI_CurrentHourglassFrame->Release();
|
|
228 pIcons_LOD->_40F9C5();
|
|
229 }
|
|
230 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
|
|
231 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
|
|
232 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 )
|
|
233 {
|
|
234 v3 = 0;
|
|
235 _507CD4_RestUI_hourglass_anim_controller = 0;
|
|
236 }
|
|
237 v9 = v3;
|
|
238 v8 = (double)v3 / 512.0 * 120.0;
|
|
239 //v7 = v8 + 6.7553994e15;
|
|
240 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7);
|
|
241 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1;
|
|
242 //hourglass_icon_idx = v4;
|
|
243 if (hourglass_icon_idx >= 120 )
|
|
244 {
|
|
245 //v4 = 1;
|
|
246 hourglass_icon_idx = 1;
|
|
247 }
|
|
248 sprintf(pTmpBuf, "hglas%03d", hourglass_icon_idx);
|
|
249 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
|
|
250 pRenderer->DrawTextureIndexed(0x10Bu, 0x9Fu, pTexture_RestUI_CurrentHourglassFrame);
|
|
251 memset(&Dst, 0, 0xBCu);
|
|
252 Dst.uX = 24;
|
|
253 Dst.uY = 154;
|
|
254 Dst.uWidth = 171;
|
|
255 Dst.uHeight = 37;
|
|
256 Dst.uZ = 194;
|
|
257 Dst.uW = 190;
|
|
258 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
259 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, a5, *(int **)a9);
|
|
260 Dst.pParent = 0;
|
|
261 sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
|
|
262 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
263 pButton_RestUI_WaitUntilDawn->DrawLabel(
|
|
264 pGlobalTXT_LocalizationStrings[237],
|
|
265 pFontCreate,
|
|
266 a5,
|
|
267 *(int **)a9);
|
|
268 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, a5, *(int **)a9);
|
|
269 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, a5, *(int **)a9);
|
|
270 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, a5, *(int **)a9);
|
|
271 memset(&Dst, 0, 0xBCu);
|
|
272 Dst.uX = 45;
|
|
273 Dst.uY = 199;
|
|
274 Dst.uWidth = 185;
|
|
275 Dst.uHeight = 30;
|
|
276 Dst.uZ = 229;
|
|
277 Dst.uW = 228;
|
|
278 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
279 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, a5, *(int **)a9);
|
|
280 Dst.pParent = 0;
|
|
281 v5 = pParty->uCurrentHour >= 0xC && pParty->uCurrentHour < 0x18;
|
|
282 sprintf(pTmpBuf, "%d:%02d %s", v10, pParty->uCurrentMinute, aAMPMNames[v5]);
|
|
283 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
284 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);
|
|
285 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
286 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);
|
|
287 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
288 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
|
|
289 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
290 if ( dword_506F14 )
|
|
291 Sleep6Hours();
|
|
292 }
|
|
293 else
|
|
294 {
|
|
295 GUIWindow::Create(
|
|
296 pButton_RestUI_Exit->uX,
|
|
297 pButton_RestUI_Exit->uY,
|
|
298 0,
|
|
299 0,
|
|
300 (enum WindowType)96,
|
|
301 (int)pButton_RestUI_Exit,
|
|
302 (int)pGlobalTXT_LocalizationStrings[81]);
|
|
303 }
|
|
304 } |