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