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);
|
948
|
105
|
706
|
106 LoadActualSkyFrame();
|
948
|
107
|
|
108 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0);
|
|
109 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
|
|
110 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 0x52u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
|
|
111 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 0x44u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
|
|
112 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 0x48u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
|
|
113 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 0x4Du, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
|
|
114 }
|
706
|
115
|
|
116 //----- (0041FA01) --------------------------------------------------------
|
|
117 void __cdecl RestUI_Draw()
|
|
118 {
|
|
119 int v0; // esi@1
|
|
120 Player **ppPlayers; // ecx@1
|
|
121 Player *pPlayer; // eax@2
|
|
122 unsigned int v3; // eax@15
|
|
123 //char v4; // al@17
|
|
124 bool v5; // eax@21
|
|
125 GUIButton Dst; // [sp+8h] [bp-DCh]@19
|
|
126 //double v7; // [sp+C4h] [bp-20h]@17
|
|
127 float v8; // [sp+CCh] [bp-18h]@17
|
|
128 __int64 v9; // [sp+D0h] [bp-14h]@17
|
|
129 unsigned int v10; // [sp+D8h] [bp-Ch]@9
|
|
130 __int16 a9[2]; // [sp+DCh] [bp-8h]@1
|
|
131 int a5; // [sp+E0h] [bp-4h]@1
|
|
132
|
|
133 v0 = 0;
|
949
|
134 a5 = TargetColor(0xAu, 0, 0);
|
|
135 *(int *)a9 = TargetColor(0xE6u, 0xD6u, 0xC1u);
|
706
|
136 ppPlayers = &pPlayers[1];
|
|
137 do
|
|
138 {
|
|
139 pPlayer = *ppPlayers;
|
|
140 if ( !(*ppPlayers)->pConditions[14] && !pPlayer->pConditions[16] && pPlayer->sHealth > 0 )
|
|
141 ++v0;
|
|
142 ++ppPlayers;
|
|
143 }
|
|
144 while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] );
|
|
145 if ( v0 )
|
|
146 {
|
948
|
147 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
|
706
|
148 v10 = pParty->uCurrentHour;
|
|
149 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
|
|
150 if ( (signed int)pParty->uCurrentHour <= 12 )
|
|
151 {
|
|
152 if ( !v10 )
|
|
153 v10 = 12;
|
|
154 }
|
|
155 else
|
|
156 {
|
|
157 v10 -= 12;
|
|
158 }
|
|
159 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame);
|
|
160 if ( pTexture_RestUI_CurrentHourglassFrame )
|
|
161 {
|
|
162 pTexture_RestUI_CurrentHourglassFrame->Release();
|
|
163 pIcons_LOD->_40F9C5();
|
|
164 }
|
|
165 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
|
|
166 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
|
|
167 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 )
|
|
168 {
|
|
169 v3 = 0;
|
|
170 _507CD4_RestUI_hourglass_anim_controller = 0;
|
|
171 }
|
|
172 v9 = v3;
|
|
173 v8 = (double)v3 / 512.0 * 120.0;
|
|
174 //v7 = v8 + 6.7553994e15;
|
|
175 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7);
|
|
176 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1;
|
|
177 //hourglass_icon_idx = v4;
|
|
178 if (hourglass_icon_idx >= 120 )
|
|
179 {
|
|
180 //v4 = 1;
|
|
181 hourglass_icon_idx = 1;
|
|
182 }
|
|
183 sprintf(pTmpBuf, "hglas%03d", hourglass_icon_idx);
|
|
184 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
|
|
185 pRenderer->DrawTextureIndexed(0x10Bu, 0x9Fu, pTexture_RestUI_CurrentHourglassFrame);
|
|
186 memset(&Dst, 0, 0xBCu);
|
|
187 Dst.uX = 24;
|
|
188 Dst.uY = 154;
|
|
189 Dst.uWidth = 171;
|
|
190 Dst.uHeight = 37;
|
|
191 Dst.uZ = 194;
|
|
192 Dst.uW = 190;
|
|
193 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
194 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, a5, *(int **)a9);
|
|
195 Dst.pParent = 0;
|
|
196 sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
|
|
197 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
198 pButton_RestUI_WaitUntilDawn->DrawLabel(
|
|
199 pGlobalTXT_LocalizationStrings[237],
|
|
200 pFontCreate,
|
|
201 a5,
|
|
202 *(int **)a9);
|
|
203 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, a5, *(int **)a9);
|
|
204 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, a5, *(int **)a9);
|
|
205 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, a5, *(int **)a9);
|
|
206 memset(&Dst, 0, 0xBCu);
|
|
207 Dst.uX = 45;
|
|
208 Dst.uY = 199;
|
|
209 Dst.uWidth = 185;
|
|
210 Dst.uHeight = 30;
|
|
211 Dst.uZ = 229;
|
|
212 Dst.uW = 228;
|
|
213 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
214 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, a5, *(int **)a9);
|
|
215 Dst.pParent = 0;
|
|
216 v5 = pParty->uCurrentHour >= 0xC && pParty->uCurrentHour < 0x18;
|
|
217 sprintf(pTmpBuf, "%d:%02d %s", v10, pParty->uCurrentMinute, aAMPMNames[v5]);
|
|
218 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
219 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);
|
|
220 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
221 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);
|
|
222 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
223 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
|
|
224 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
|
|
225 if ( dword_506F14 )
|
|
226 Sleep6Hours();
|
|
227 }
|
|
228 else
|
|
229 {
|
|
230 GUIWindow::Create(
|
|
231 pButton_RestUI_Exit->uX,
|
|
232 pButton_RestUI_Exit->uY,
|
|
233 0,
|
|
234 0,
|
|
235 (enum WindowType)96,
|
|
236 (int)pButton_RestUI_Exit,
|
|
237 (int)pGlobalTXT_LocalizationStrings[81]);
|
|
238 }
|
|
239 } |