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