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