2501
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
|
6 #include <io.h>
|
|
7
|
2541
|
8 #include "Engine/Engine.h"
|
2545
|
9 #include "Engine/Party.h"
|
|
10 #include "Engine/Graphics/Outdoor.h"
|
|
11 #include "Engine/LOD.h"
|
|
12 #include "Engine/Timer.h"
|
|
13 #include "Engine/stru159.h"
|
|
14 #include "Engine/Events2D.h"
|
|
15 #include "Engine/texts.h"
|
|
16 #include "Engine/MapInfo.h"
|
2541
|
17
|
2545
|
18 #include "GUI/UI/UITransition.h"
|
|
19 #include "GUI/GUIFont.h"
|
|
20 #include "GUI/GUIProgressBar.h"
|
|
21 #include "GUI/UI/UIHouses.h"
|
|
22
|
|
23 #include "Media/Audio/AudioPlayer.h"
|
|
24 #include "Media/MediaPlayer.h"
|
2501
|
25
|
|
26
|
|
27
|
|
28
|
2545
|
29 void GUIWindow_Travel::Release()
|
|
30 {
|
2549
|
31 // -----------------------------------------
|
|
32 // 0041C26A void GUIWindow::Release --- part
|
2545
|
33 pTexture_outside->Release();
|
|
34 pTexture_Dialogue_Background->Release();
|
|
35 pIcons_LOD->SyncLoadedFilesCount();
|
|
36 current_screen_type = prev_screen_type;
|
|
37
|
|
38 GUIWindow::Release();
|
|
39 }
|
|
40
|
|
41 void GUIWindow_Transition::Release()
|
|
42 {
|
2549
|
43 // -----------------------------------------
|
|
44 // 0041C26A void GUIWindow::Release --- part
|
2545
|
45 //pVideoPlayer->Unload();
|
|
46 pTexture_outside->Release();
|
|
47 pTexture_Dialogue_Background->Release();
|
|
48 pIcons_LOD->SyncLoadedFilesCount();
|
|
49 current_screen_type = prev_screen_type;
|
|
50
|
|
51 GUIWindow::Release();
|
|
52 }
|
|
53
|
|
54
|
2501
|
55 //----- (00444839) --------------------------------------------------------
|
2545
|
56 GUIWindow_Transition::GUIWindow_Transition(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName) :
|
|
57 GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr)
|
2501
|
58 {
|
2545
|
59 // ----------------------------------
|
|
60 // 00444839 TransitionUI_Load -- part
|
2501
|
61 const char *v15; // eax@14
|
|
62 char pContainer[40]; // [sp+Ch] [bp-2Ch]@1
|
|
63
|
|
64 dword_59117C_teleportx = x;
|
|
65 dword_591178_teleporty = y;
|
|
66 dword_591174_teleportz = z;
|
|
67 dword_591170_teleport_directiony = directiony;
|
|
68 dword_59116C_teleport_directionx = directionx;
|
|
69 dword_591168_teleport_speedz = a8;
|
|
70 dword_591164_teleport_map_name = (char *)pLocationName;
|
|
71 uCurrentHouse_Animation = anim_id;
|
|
72 pEventTimer->Pause();
|
|
73 pAudioPlayer->StopChannels(-1, -1);
|
|
74
|
|
75 switch (pParty->alignment)
|
|
76 {
|
|
77 case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break;
|
|
78 case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break;
|
|
79 case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break;
|
|
80 default: Error("Invalid alignment: %u", pParty->alignment);
|
|
81 }
|
|
82
|
|
83 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
|
|
84 pTexture_outside = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[exit_pic_id], TEXTURE_16BIT_PALETTE);
|
|
85 if (anim_id)
|
|
86 {
|
|
87 if ( !IndoorLocation::GetLocationIndex(pLocationName) )
|
|
88 pMediaPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].video_name, 1);
|
2545
|
89
|
|
90 v15 = pLocationName;
|
|
91 if (*pLocationName == 48)
|
|
92 v15 = pCurrentMapName;
|
|
93 if (pMapStats->GetMapInfo(v15))
|
|
94 {
|
|
95 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[pMapStats->GetMapInfo(v15)].pName);//Войти в ^Pv[%s]
|
|
96 if (uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30)
|
|
97 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
|
|
98 if (IndoorLocation::GetLocationIndex(pLocationName))
|
|
99 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName);
|
|
100 }
|
|
101 else
|
|
102 {
|
|
103 strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[73]);//Войти
|
|
104 //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
|
|
105 //PlayHouseSound(anim_id, HouseSound_Greeting);
|
|
106 if (uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30)
|
|
107 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
|
|
108 if (IndoorLocation::GetLocationIndex(pLocationName))
|
|
109 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName);
|
|
110 }
|
2501
|
111 }
|
|
112 else if ( !IndoorLocation::GetLocationIndex(pLocationName) )
|
|
113 {
|
|
114 if ( pMapStats->GetMapInfo(pCurrentMapName) )
|
|
115 {
|
|
116 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName); // "Leave %s"
|
|
117 //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
|
|
118 //PlayHouseSound(anim_id, HouseSound_Greeting);
|
|
119 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
|
|
120 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
|
|
121 if ( IndoorLocation::GetLocationIndex(pLocationName) )
|
|
122 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName);
|
|
123 }
|
2545
|
124 else
|
|
125 {
|
|
126 strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);
|
|
127 //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
|
|
128 //PlayHouseSound(anim_id, HouseSound_Greeting);
|
|
129 if (uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30)
|
|
130 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
|
|
131 if (IndoorLocation::GetLocationIndex(pLocationName))
|
|
132 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName);
|
|
133 }
|
2501
|
134 }
|
2545
|
135
|
|
136 auto hint = this->Hint = sHouseName.data();
|
|
137
|
|
138 //
|
|
139 // --------------------------------
|
|
140 // 0041C432 GUIWindow c-tor -- part
|
|
141 prev_screen_type = current_screen_type;
|
|
142 current_screen_type = SCREEN_INPUT_BLV;
|
|
143 pBtn_ExitCancel = CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionWindowCloseBtn, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); // Cancel / Отмена
|
|
144 pBtn_YES = CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
|
|
145 CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, hint, 0);
|
|
146 CreateButton(8, 8, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, hint, 0);
|
2501
|
147 }
|
|
148
|
2545
|
149
|
2546
|
150
|
2501
|
151 //----- (00444C8F) --------------------------------------------------------
|
2545
|
152 GUIWindow_Travel::GUIWindow_Travel() :
|
|
153 GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr)
|
2501
|
154 {
|
2545
|
155 // ------------------------------
|
|
156 // 00444C8F TravelUI_Load -- part
|
2501
|
157 char pContainer[32]; // [sp+0h] [bp-28h]@1
|
|
158
|
|
159 pEventTimer->Pause();
|
|
160
|
|
161 switch (pParty->alignment)
|
|
162 {
|
|
163 case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break;
|
|
164 case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break;
|
|
165 case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break;
|
|
166 default: Error("Invalid alignment: %u", pParty->alignment);
|
|
167 }
|
|
168
|
|
169 pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
|
|
170 pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE);
|
|
171 if ( pMapStats->GetMapInfo(pCurrentMapName) )
|
|
172 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName);// "Leave %s"
|
|
173 else
|
|
174 strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit"
|
2545
|
175
|
|
176
|
|
177
|
|
178 auto hint = this->Hint = sHouseName.data();
|
|
179
|
|
180 // --------------------------------
|
|
181 // 0041C432 GUIWindow c-tor -- part
|
|
182 prev_screen_type = current_screen_type;
|
|
183 current_screen_type = SCREEN_CHANGE_LOCATION;
|
|
184 pBtn_ExitCancel = CreateButton(
|
|
185 566, 445, 75, 33, 1, 0,
|
|
186 UIMSG_CHANGE_LOCATION_ClickCencelBtn,
|
|
187 0,
|
|
188 'N',
|
|
189 pGlobalTXT_LocalizationStrings[156],
|
|
190 pIcons_LOD->GetTexture(uTextureID_BUTTDESC2),
|
|
191 0
|
|
192 );// Stay in this area / Остаться в этой области
|
|
193 pBtn_YES = CreateButton(
|
|
194 486, 445, 75, 33, 1, 0,
|
|
195 UIMSG_OnTravelByFoot,
|
|
196 0,
|
|
197 'Y',
|
|
198 hint,
|
|
199 pIcons_LOD->GetTexture(uTextureID_BUTTYES2),
|
|
200 0
|
|
201 );
|
|
202 CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63, 73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', hint, 0, 0, 0);
|
|
203 CreateButton(8, 8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1, 0, hint, 0);
|
2501
|
204 }
|
|
205
|
2545
|
206
|
|
207
|
2501
|
208 //----- (00444DCA) --------------------------------------------------------
|
2545
|
209 void GUIWindow_Travel::Update()
|
2501
|
210 {
|
2546
|
211 // -----------------------------------
|
|
212 // 004156F0 GUI_UpdateWindows --- part
|
2501
|
213 GUIWindow travel_window; // [sp+Ch] [bp-78h]@1
|
|
214 char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1
|
|
215
|
|
216 memcpy(&travel_window, pPrimaryWindow, sizeof(travel_window));
|
|
217 pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20);
|
|
218 pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background);
|
2524
|
219 pRenderer->DrawTextureIndexedAlpha(468, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
|
2501
|
220 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
|
|
221 pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
|
|
222 pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
|
|
223 if ( pMapStats->GetMapInfo(pDestinationMapName) )
|
|
224 {
|
|
225 travel_window.uFrameX = 493;
|
|
226 travel_window.uFrameWidth = 126;
|
|
227 travel_window.uFrameZ = 366;
|
|
228 travel_window.DrawTitleText(pFontCreate, 0, 4, 0, pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName, 3);
|
|
229 travel_window.uFrameX = 483;
|
|
230 travel_window.uFrameWidth = 148;
|
|
231 travel_window.uFrameZ = 334;
|
|
232 if ( GetTravelTime() == 1 )
|
|
233 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[663], 1, pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName);// "It will take %d day to cross to %s."
|
|
234 else
|
|
235 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[128], GetTravelTime(), pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName);// "It will take %d days to travel to %s."
|
|
236
|
|
237 strcat(pTmpBuf.data(), "\n \n");
|
|
238 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName);
|
|
239 strcat(pTmpBuf.data(), pTmpBuf2.data());
|
|
240 travel_window.DrawTitleText(pFontCreate, 0, (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &travel_window, 0, 0)) / 2 + 101, 0, pTmpBuf.data(), 3);
|
|
241 _unused_5B5924_is_travel_ui_drawn = 1;
|
|
242 }
|
|
243 }
|
|
244
|
2545
|
245
|
|
246
|
2501
|
247 //----- (00444A51) --------------------------------------------------------
|
2545
|
248 void GUIWindow_Transition::Update()
|
2501
|
249 {
|
2546
|
250 // -----------------------------------
|
|
251 // 004156F0 GUI_UpdateWindows --- part
|
2501
|
252 unsigned int v4; // [sp-10h] [bp-7Ch]@12
|
|
253 GUIWindow transition_window; // [sp+Ch] [bp-60h]@1
|
|
254 unsigned int v9; // [sp+60h] [bp-Ch]@1
|
|
255 unsigned int map_id; // [sp+64h] [bp-8h]@1
|
|
256
|
|
257 memcpy(&transition_window, pPrimaryWindow, sizeof(transition_window));
|
|
258 v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name);
|
|
259 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
|
|
260 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C));
|
|
261 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
|
|
262 uTextureID_right_panel_loop = uTextureID_right_panel;
|
2524
|
263 pRenderer->DrawTextureIndexedAlpha(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
|
2501
|
264 pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
|
|
265 pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
|
|
266 map_id = pMapStats->GetMapInfo(pCurrentMapName);
|
|
267 if ( (pMovie_Track || v9) && *dword_591164_teleport_map_name != ' ' )
|
|
268 map_id = pMapStats->GetMapInfo(dword_591164_teleport_map_name);
|
|
269 transition_window.uFrameX = 493;
|
|
270 transition_window.uFrameWidth = 126;
|
|
271 transition_window.uFrameZ = 366;
|
|
272 transition_window.DrawTitleText(pFontCreate, 0, 5, 0, pMapStats->pInfos[map_id].pName, 3);
|
|
273 transition_window.uFrameX = 483;
|
|
274 transition_window.uFrameWidth = 148;
|
|
275 transition_window.uFrameZ = 334;
|
|
276
|
|
277 if ( uCurrentHouse_Animation )
|
|
278 {
|
|
279 v4 = (212 - pFontCreate->CalcTextHeight(pTransitionStrings[uCurrentHouse_Animation], &transition_window, 0, 0)) / 2 + 101;
|
|
280 transition_window.DrawTitleText(pFontCreate, 0, v4, 0, pTransitionStrings[uCurrentHouse_Animation], 3);
|
|
281 }
|
|
282 else if ( map_id )
|
|
283 {
|
|
284 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[409], pMapStats->pInfos[map_id].pName);// "Do you wish to leave %s?"
|
|
285 v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &transition_window, 0, 0)) / 2 + 101;
|
|
286 transition_window.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf.data(), 3);
|
|
287 }
|
|
288 else Error("Troubles in da house");
|
|
289
|
|
290 _unused_5B5924_is_travel_ui_drawn = true;
|
|
291 }
|