706
|
1 #include <assert.h>
|
|
2
|
|
3 #include "MM7.h"
|
|
4
|
|
5 #include "MapInfo.h"
|
|
6 #include "Game.h"
|
1006
|
7 #include "Player.h"
|
706
|
8 #include "GUIWindow.h"
|
|
9 #include "GUIFont.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 "TurnEngine.h"
|
924
|
38 #include "CastSpellInfo.h"
|
706
|
39 #include "Weather.h"
|
|
40 #include "stru298.h"
|
|
41 #include "StorylineTextTable.h"
|
|
42 #include "Events2D.h"
|
|
43 #include "texts.h"
|
|
44
|
|
45 #include "mm7_data.h"
|
|
46
|
|
47
|
|
48
|
|
49 //----- (0041F6C1) --------------------------------------------------------
|
1033
|
50 void RestUI_Load()
|
938
|
51 {
|
706
|
52 Player *v0; // eax@10
|
|
53
|
|
54 if ( !dword_506F14 )
|
|
55 pAudioPlayer->StopChannels(-1, -1);
|
1033
|
56 if ( pCurrentScreen != SCREEN_GAME)
|
|
57 {
|
706
|
58 pGUIWindow_CurrentMenu->Release();
|
|
59 pCurrentScreen = SCREEN_GAME;
|
1033
|
60 viewparams->bRedrawGameUI = true;
|
|
61 }
|
706
|
62 pEventTimer->Pause();
|
|
63 if ( dword_506F14 != 2 )
|
962
|
64 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0);
|
706
|
65 _506F18_num_hours_to_sleep = 0;
|
|
66 dword_506F14 = 0;
|
|
67 uRestUI_FoodRequiredToRest = 2;
|
|
68 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
962
|
69 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
|
706
|
70 if ( PartyHasDragon() )
|
|
71 {
|
|
72 v0 = pParty->pPlayers;//[0].uClass;
|
|
73 while ( v0 <= &pParty->pPlayers[3] )
|
|
74 {
|
|
75 ++v0;
|
|
76 if ( v0 > &pParty->pPlayers[3] )
|
|
77 break;
|
|
78 }
|
|
79 if(v0->classType == PLAYER_CLASS_WARLOCK)
|
|
80 ++uRestUI_FoodRequiredToRest;
|
|
81 }
|
|
82 if ( CheckHiredNPCSpeciality(Porter) )
|
|
83 --uRestUI_FoodRequiredToRest;
|
|
84 if ( CheckHiredNPCSpeciality(QuarterMaster) )
|
|
85 uRestUI_FoodRequiredToRest -= 2;
|
|
86 if ( CheckHiredNPCSpeciality(Gypsy) )
|
|
87 --uRestUI_FoodRequiredToRest;
|
|
88 if ( uRestUI_FoodRequiredToRest < 1 )
|
|
89 uRestUI_FoodRequiredToRest = 1;
|
1033
|
90 if ( !_strcmpi(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) )
|
706
|
91 uRestUI_FoodRequiredToRest = 0;
|
1033
|
92
|
706
|
93 ++pIcons_LOD->uTexturePacksCount;
|
|
94 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
95 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
1033
|
96
|
706
|
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);
|
1033
|
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, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
|
|
111 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
|
|
112 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
|
|
113 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
|
948
|
114 }
|
706
|
115
|
|
116 //----- (0041FA01) --------------------------------------------------------
|
1033
|
117 void RestUI_Draw()
|
|
118 {
|
1006
|
119 int live_characters; // esi@1
|
706
|
120 unsigned int v3; // eax@15
|
|
121 //char v4; // al@17
|
|
122 bool v5; // eax@21
|
1006
|
123 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19
|
706
|
124 //double v7; // [sp+C4h] [bp-20h]@17
|
|
125 float v8; // [sp+CCh] [bp-18h]@17
|
|
126 __int64 v9; // [sp+D0h] [bp-14h]@17
|
1006
|
127 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9
|
|
128 __int16 shadow_color; // [sp+DCh] [bp-8h]@1
|
|
129 int text_color; // [sp+E0h] [bp-4h]@1
|
706
|
130
|
1006
|
131 live_characters = 0;
|
|
132 text_color = TargetColor(10, 0, 0);
|
|
133 shadow_color = TargetColor(230, 214, 193);
|
|
134 for(int i=1; i<5; ++i)
|
|
135 if ( !pPlayers[i]->pConditions[Player::Condition_Dead] && !pPlayers[i]->pConditions[Player::Condition_Eradicated] && pPlayers[i]->sHealth > 0 )
|
|
136 ++live_characters;
|
|
137
|
|
138 if ( live_characters )
|
706
|
139 {
|
1006
|
140 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
|
|
141 am_pm_hours = pParty->uCurrentHour;
|
|
142 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
|
|
143 if ( (signed int)pParty->uCurrentHour <= 12 )
|
706
|
144 {
|
1006
|
145 if ( !am_pm_hours )
|
|
146 am_pm_hours = 12;
|
706
|
147 }
|
|
148 else
|
1006
|
149 {
|
|
150 am_pm_hours -= 12;
|
|
151 }
|
|
152 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame);
|
|
153 if ( pTexture_RestUI_CurrentHourglassFrame )
|
|
154 {
|
|
155 pTexture_RestUI_CurrentHourglassFrame->Release();
|
|
156 pIcons_LOD->SyncLoadedFilesCount();
|
|
157 }
|
|
158 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
|
|
159 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
|
|
160 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 )
|
|
161 {
|
|
162 v3 = 0;
|
|
163 _507CD4_RestUI_hourglass_anim_controller = 0;
|
|
164 }
|
|
165 v9 = v3;
|
|
166 v8 = (double)v3 / 512.0 * 120.0;
|
|
167 //v7 = v8 + 6.7553994e15;
|
|
168 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7);
|
|
169 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1;
|
|
170 //hourglass_icon_idx = v4;
|
|
171 if (hourglass_icon_idx >= 120 )
|
|
172 hourglass_icon_idx = 1;
|
|
173
|
|
174 sprintf(pTmpBuf, "hglas%03d", hourglass_icon_idx);
|
|
175 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
|
|
176 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame);
|
|
177 memset(&tmp_button, 0, sizeof(GUIButton));
|
|
178 tmp_button.uX = 24;
|
|
179 tmp_button.uY = 154;
|
|
180
|
|
181 tmp_button.uZ = 194;
|
|
182 tmp_button.uW = 190;
|
|
183
|
|
184 tmp_button.uWidth = 171;
|
|
185 tmp_button.uHeight = 37;
|
|
186
|
|
187 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
188 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, text_color, shadow_color);
|
|
189 tmp_button.pParent = 0;
|
|
190 sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
|
|
191 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, text_color, pTmpBuf, 0, 0, shadow_color);
|
|
192 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, text_color, shadow_color);
|
|
193 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, text_color, shadow_color);
|
|
194 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, text_color, shadow_color);
|
|
195 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, text_color, shadow_color);
|
|
196 memset(&tmp_button, 0, sizeof(GUIButton));
|
|
197 tmp_button.uX = 45;
|
|
198 tmp_button.uY = 199;
|
|
199
|
|
200 tmp_button.uZ = 229;
|
|
201 tmp_button.uW = 228;
|
|
202
|
|
203 tmp_button.uWidth = 185;
|
|
204 tmp_button.uHeight = 30;
|
|
205
|
|
206 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
207 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, text_color, shadow_color);
|
|
208 tmp_button.pParent = 0;
|
|
209 v5 = (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0;
|
|
210 sprintf(pTmpBuf, "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[v5]);
|
|
211 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, text_color, pTmpBuf, 0, 0, shadow_color);
|
|
212 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);
|
|
213 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, text_color, pTmpBuf, 0, 0, shadow_color);
|
|
214 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);
|
|
215 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, text_color, pTmpBuf, 0, 0, shadow_color);
|
|
216 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
|
|
217 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, text_color, pTmpBuf, 0, 0, shadow_color);
|
|
218 if ( dword_506F14 )
|
|
219 Sleep6Hours();
|
|
220 }
|
|
221 else
|
1033
|
222 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]); // "Exit Rest"
|
706
|
223 } |