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