2501
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6
|
|
7 #include "Engine/Engine.h"
|
|
8
|
2502
|
9 #include "..\../GUI/GUIWindow.h"
|
|
10 #include "..\../GUI/GUIFont.h"
|
2501
|
11 #include "..\../Engine/Party.h"
|
2502
|
12 #include "..\../Media/Audio/AudioPlayer.h"
|
2501
|
13 #include "..\../Engine/Graphics/Outdoor.h"
|
|
14 #include "..\../Engine/LOD.h"
|
|
15 #include "..\../Engine/Graphics/Viewport.h"
|
|
16 #include "..\../Engine/Timer.h"
|
|
17 #include "..\../Engine/texts.h"
|
|
18
|
|
19
|
|
20
|
2543
|
21 void PrepareToLoadRestUI()
|
2501
|
22 {
|
2543
|
23 if (!_506F14_resting_stage)
|
|
24 pAudioPlayer->StopChannels(-1, -1);
|
|
25 if (current_screen_type != SCREEN_GAME)
|
|
26 {
|
|
27 pGUIWindow_CurrentMenu->Release();
|
|
28 current_screen_type = SCREEN_GAME;
|
|
29 viewparams->bRedrawGameUI = true;
|
|
30 }
|
|
31 pEventTimer->Pause();
|
|
32 if (_506F14_resting_stage != 2)
|
|
33 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0);
|
|
34 _506F18_num_minutes_to_sleep = 0;
|
|
35 _506F14_resting_stage = 0;
|
|
36 uRestUI_FoodRequiredToRest = 2;
|
|
37 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
38 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
|
|
39 if (PartyHasDragon())
|
2501
|
40 {
|
2543
|
41 for (uint i = 0; i < 4; ++i)
|
|
42 {
|
|
43 if (pParty->pPlayers[i].classType == PLAYER_CLASS_WARLOCK)
|
|
44 ++uRestUI_FoodRequiredToRest;
|
|
45 }
|
2501
|
46 }
|
2543
|
47 if (CheckHiredNPCSpeciality(Porter))
|
|
48 --uRestUI_FoodRequiredToRest;
|
|
49 if (CheckHiredNPCSpeciality(QuarterMaster))
|
|
50 uRestUI_FoodRequiredToRest -= 2;
|
|
51 if (CheckHiredNPCSpeciality(Gypsy))
|
|
52 --uRestUI_FoodRequiredToRest;
|
|
53 if (uRestUI_FoodRequiredToRest < 1)
|
|
54 uRestUI_FoodRequiredToRest = 1;
|
|
55 if (!_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98))//Замок Хармондейл
|
|
56 uRestUI_FoodRequiredToRest = 0;
|
2501
|
57
|
2543
|
58 ++pIcons_LOD->uTexturePacksCount;
|
|
59 if (!pIcons_LOD->uNumPrevLoadedFiles)
|
|
60 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
61 }
|
|
62 //----- (0041F6C1) --------------------------------------------------------
|
|
63 GUIWindow *RestUI_Load()
|
|
64 {
|
2501
|
65 _507CD4_RestUI_hourglass_anim_controller = 0;
|
|
66 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
|
|
67 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
|
|
68 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE);
|
|
69 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
|
|
70 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
|
|
71 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
|
2543
|
72
|
2501
|
73 OutdoorLocation::LoadActualSkyFrame();
|
2543
|
74
|
|
75 auto wnd = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Rest, 0, 0);
|
|
76 pButton_RestUI_Exit = wnd->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
|
|
77 pButton_RestUI_Main = wnd->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
|
|
78 pButton_RestUI_WaitUntilDawn = wnd->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
|
|
79 pButton_RestUI_Wait1Hour = wnd->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
|
|
80 pButton_RestUI_Wait5Minutes = wnd->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
|
|
81
|
|
82 return wnd;
|
2501
|
83 }
|
|
84
|
|
85 //----- (0041FA01) --------------------------------------------------------
|
|
86 void RestUI_Draw()
|
|
87 {
|
|
88 int live_characters; // esi@1
|
|
89 unsigned int v3; // eax@15
|
|
90 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19
|
|
91 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9
|
|
92
|
|
93 live_characters = 0;
|
|
94 for( int i = 1; i < 5; ++i )
|
|
95 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 )
|
|
96 ++live_characters;
|
|
97
|
|
98 if ( live_characters )
|
|
99 {
|
|
100 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
|
|
101 am_pm_hours = pParty->uCurrentHour;
|
|
102 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
|
|
103 if ( (signed int)pParty->uCurrentHour <= 12 )
|
|
104 {
|
|
105 if ( !am_pm_hours )
|
|
106 am_pm_hours = 12;
|
|
107 }
|
|
108 else
|
|
109 am_pm_hours -= 12;
|
|
110 pRenderer->DrawTextureIndexed(16, 26, pTexture_RestUI_CurrentSkyFrame);
|
|
111 if ( pTexture_RestUI_CurrentHourglassFrame )
|
|
112 {
|
|
113 pTexture_RestUI_CurrentHourglassFrame->Release();
|
|
114 pIcons_LOD->SyncLoadedFilesCount();
|
|
115 }
|
|
116 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
|
|
117 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
|
|
118 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 )
|
|
119 {
|
|
120 v3 = 0;
|
|
121 _507CD4_RestUI_hourglass_anim_controller = 0;
|
|
122 }
|
|
123 hourglass_icon_idx = (int)floorf(((double)v3 / 512.0 * 120.0) + 0.5f) % 256 + 1;
|
|
124 if (hourglass_icon_idx >= 120 )
|
|
125 hourglass_icon_idx = 1;
|
|
126
|
|
127 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx);
|
|
128 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
|
|
129 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame);
|
|
130 memset(&tmp_button, 0, sizeof(GUIButton));
|
|
131 tmp_button.uX = 24;
|
|
132 tmp_button.uY = 154;
|
|
133 tmp_button.uZ = 194;
|
|
134 tmp_button.uW = 190;
|
|
135 tmp_button.uWidth = 171;
|
|
136 tmp_button.uHeight = 37;
|
|
137 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
138 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Отдых и лечение 8 часов
|
|
139 tmp_button.pParent = 0;
|
|
140
|
|
141 sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest);
|
|
142 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
|
|
143
|
|
144 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать до рассвета
|
|
145 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 1 час
|
|
146 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 5 минут
|
|
147 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Закончить отдыхать
|
|
148 memset(&tmp_button, 0, sizeof(GUIButton));
|
|
149 tmp_button.uX = 45;
|
|
150 tmp_button.uY = 199;
|
|
151
|
|
152 tmp_button.uZ = 229;
|
|
153 tmp_button.uW = 228;
|
|
154
|
|
155 tmp_button.uWidth = 185;
|
|
156 tmp_button.uHeight = 30;
|
|
157
|
|
158 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
|
|
159 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать без лечения
|
|
160 tmp_button.pParent = 0;
|
|
161 sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[(pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0]);
|
|
162 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
|
|
163 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);//День
|
|
164 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
|
|
165 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);//Месяц
|
|
166 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
|
|
167 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год
|
|
168 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
|
2543
|
169 if ( _506F14_resting_stage )
|
2501
|
170 Party::Sleep6Hours();
|
|
171 }
|
|
172 else
|
|
173 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn,
|
|
174 (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest"
|
|
175 } |