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