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