World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
UITransition.cpp
См. документацию.
1 #define _CRTDBG_MAP_ALLOC
2 #include <stdlib.h>
3 
4 #define _CRT_SECURE_NO_WARNINGS
5 #include "Engine/Engine.h"
6 #include "Engine/Events2D.h"
7 #include "Engine/LOD.h"
8 #include "Engine/Localization.h"
9 #include "Engine/MapInfo.h"
10 #include "Engine/Party.h"
11 #include "Engine/Time.h"
12 #include "Engine/stru159.h"
13 
15 
16 #include "GUI/GUIButton.h"
17 #include "GUI/UI/UITransition.h"
18 #include "GUI/GUIFont.h"
19 #include "GUI/GUIProgressBar.h"
20 #include "GUI/UI/UIGame.h"
21 #include "GUI/UI/UIHouses.h"
22 
24 #include "Media/MediaPlayer.h"
25 
26 #include "Platform/Api.h"
27 
29 
31 
33  // -----------------------------------------
34  // 0041C26A void GUIWindow::Release --- part
35  if (transition_ui_icon) {
37  transition_ui_icon = nullptr;
38  }
39 
43  }
44 
46 
48 }
49 
51  // -----------------------------------------
52  // 0041C26A void GUIWindow::Release --- part
53  // pVideoPlayer->Unload();
54  if (transition_ui_icon) {
56  transition_ui_icon = nullptr;
57  }
58 
62  }
63 
65 
67 }
68 
69 //----- (00444839) --------------------------------------------------------
71  int x, int y, int z, int directiony,
72  int directionx, int a8,
73  const char *pLocationName)
78  Party_Teleport_Cam_Yaw = directiony;
79  Party_Teleport_Cam_Pitch = directionx;
81  Party_Teleport_Map_Name = (char *)pLocationName;
82  uCurrentHouse_Animation = anim_id;
83  pEventTimer->Pause();
84  pAudioPlayer->StopChannels(-1, -1);
85 
86  String filename;
87  switch (pParty->alignment) {
89  filename = "evt02-b";
90  break;
92  filename = "evt02";
93  break;
95  filename = "evt02-c";
96  break;
97  default:
98  Error("Invalid alignment: %u", pParty->alignment);
99  }
101 
104  if (anim_id) {
105  if (!IndoorLocation::GetLocationIndex(pLocationName))
107  pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].video_name,
108  1);
109 
110  String v15 = pLocationName;
111  if (*pLocationName == 48) {
112  v15 = pCurrentMapName;
113  }
114  if (pMapStats->GetMapInfo(v15)) {
116  411, pMapStats->pInfos[pMapStats->GetMapInfo(v15)]
117  .pName.c_str()); // Enter %s Войти в ^Pv[%s]
118 
120  pParty->uFlags & 0x30)
121  pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
122  if (IndoorLocation::GetLocationIndex(pLocationName))
124  IndoorLocation::GetLocationIndex(pLocationName);
125  } else {
127  73); // Enter Войти
128  // if (
129  // pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId
130  // )
131  // PlayHouseSound(anim_id, HouseSound_Greeting);
133  pParty->uFlags & 0x30)
134  pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
135  if (IndoorLocation::GetLocationIndex(pLocationName))
137  IndoorLocation::GetLocationIndex(pLocationName);
138  }
139  } else if (!IndoorLocation::GetLocationIndex(pLocationName)) {
142  410,
144  .pName.c_str()); // "Leave %s"
145  // if (
146  // pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId
147  // ) PlayHouseSound(anim_id, HouseSound_Greeting);
149  pParty->uFlags & 0x30)
150  pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
151  if (IndoorLocation::GetLocationIndex(pLocationName))
153  IndoorLocation::GetLocationIndex(pLocationName);
154  } else {
156  // if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId
157  // ) PlayHouseSound(anim_id, HouseSound_Greeting);
159  pParty->uFlags & 0x30)
160  pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
161  if (IndoorLocation::GetLocationIndex(pLocationName))
163  IndoorLocation::GetLocationIndex(pLocationName);
164  }
165  }
166 
167  String hint = this->sHint = transition_button_label;
168 
172  0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionWindowCloseBtn, 0,
173  'N', localization->GetString(34), {{ui_buttdesc2}}); // Cancel / Отмена
174  pBtn_YES =
175  CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0,
176  UIMSG_TransitionUI_Confirm, 0, 'Y', hint, {{ui_buttyes2}});
177  CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1,
178  0, UIMSG_TransitionUI_Confirm, 1, 0x20u, hint);
179  CreateButton(8, 8, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0,
180  hint);
181 }
182 
185  String pContainer; // [sp+0h] [bp-28h]@1
186 
187  pEventTimer->Pause();
188 
189  switch (pParty->alignment) {
191  pContainer = "evt02-b";
192  break;
194  pContainer = "evt02";
195  break;
197  pContainer = "evt02-c";
198  break;
199  default:
200  Error("Invalid alignment: %u", pParty->alignment);
201  }
203 
208  .pName.c_str()); // "Leave %s"
209  else
211 
212  String hint = this->sHint = transition_button_label;
213 
217  566, 445, 75, 33, 1, 0, UIMSG_CHANGE_LOCATION_ClickCencelBtn, 0, 'N',
218  localization->GetString(156),
219  {{ui_buttdesc2}}); // Stay in this area / Остаться в этой области
220  pBtn_YES = CreateButton(486, 445, 75, 33, 1, 0, UIMSG_OnTravelByFoot, 0,
221  'Y', hint, {{ui_buttyes2}});
222  CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63, 73, 1, 0,
223  UIMSG_OnTravelByFoot, 1, ' ', hint);
224  CreateButton(8, 8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1, 0, hint);
225 }
226 
228  char pDestinationMapName[32];
229 
231  pDestinationMapName, 20);
232  render->DrawTextureNew(477 / 640.0f, 0, game_ui_dialogue_background);
233  render->DrawTextureAlphaNew(468 / 640.0f, 0, game_ui_right_panel_frame);
234  render->DrawTextureNew(pNPCPortraits_x[0][0] / 640.0f,
235  pNPCPortraits_y[0][0] / 480.0f, transition_ui_icon);
236  render->DrawTextureAlphaNew(556 / 640.0f, 451 / 480.0f, dialogue_ui_x_x_u);
237  render->DrawTextureAlphaNew(476 / 640.0f, 451 / 480.0f, dialogue_ui_x_ok_u);
238  if (pMapStats->GetMapInfo(pDestinationMapName)) {
239  GUIWindow travel_window = *pPrimaryWindow;
240  travel_window.uFrameX = 493;
241  travel_window.uFrameWidth = 126;
242  travel_window.uFrameZ = 366;
243  travel_window.DrawTitleText(
244  pFontCreate, 0, 4, 0,
245  pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName,
246  3);
247  travel_window.uFrameX = 483;
248  travel_window.uFrameWidth = 148;
249  travel_window.uFrameZ = 334;
250 
251  String str;
252  if (GetTravelTime() == 1) {
253  str = localization->FormatString(
254  663, 1,
255  pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)]
256  .pName.c_str()); // It will take %d day to cross to %s.
257  } else {
258  str = localization->FormatString(
259  128, GetTravelTime(),
260  pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)]
261  .pName.c_str()); // It will take %d days to travel to %s.
262  }
263  str += "\n \n";
264  str += localization->FormatString(
265  126,
267 
268  travel_window.DrawTitleText(
269  pFontCreate, 0,
270  (212 -
271  pFontCreate->CalcTextHeight(str, travel_window.uFrameWidth, 0)) /
272  2 +
273  101,
274  0, str, 3);
276  }
277 }
278 
280  unsigned int v9 =
282  render->DrawTextureNew(477 / 640.0f, 0, game_ui_dialogue_background);
283  render->DrawTextureAlphaNew((pNPCPortraits_x[0][0] - 4) / 640.0f,
284  (pNPCPortraits_y[0][0] - 4) / 480.0f,
286  render->DrawTextureNew(pNPCPortraits_x[0][0] / 640.0f,
287  pNPCPortraits_y[0][0] / 480.0f, transition_ui_icon);
288 
289  render->DrawTextureAlphaNew(468 / 640.0f, 0, game_ui_right_panel_frame);
290  render->DrawTextureAlphaNew(556 / 640.0f, 451 / 480.0f, dialogue_ui_x_x_u);
291  render->DrawTextureAlphaNew(476 / 640.0f, 451 / 480.0f, dialogue_ui_x_ok_u);
292  unsigned int map_id = pMapStats->GetMapInfo(pCurrentMapName);
293  if ((pMovie_Track || v9) && *Party_Teleport_Map_Name != ' ') {
295  }
296 
297  GUIWindow transition_window = *pPrimaryWindow;
298  transition_window.uFrameX = 493;
299  transition_window.uFrameWidth = 126;
300  transition_window.uFrameZ = 366;
301  transition_window.DrawTitleText(pFontCreate, 0, 5, 0,
302  pMapStats->pInfos[map_id].pName, 3);
303  transition_window.uFrameX = 483;
304  transition_window.uFrameWidth = 148;
305  transition_window.uFrameZ = 334;
306 
308  unsigned int v4 =
309  (212 - pFontCreate->CalcTextHeight(
311  transition_window.uFrameWidth, 0)) /
312  2 +
313  101;
314  transition_window.DrawTitleText(
316  3);
317  } else if (map_id) {
319  409, pMapStats->pInfos[map_id].pName.c_str()); // Do you wish to leave %s?
320  unsigned int v4 = (212 - pFontCreate->CalcTextHeight(
321  str, transition_window.uFrameWidth, 0)) /
322  2 +
323  101;
324  transition_window.DrawTitleText(pFontCreate, 0, v4, 0, str, 3);
325  } else {
326  Error("Troubles in da house");
327  }
328 
330 }
UIGame.h
PartyAlignment::PartyAlignment_Good
@ PartyAlignment_Good
transition_button_label
String transition_button_label
Definition: UITransition.cpp:30
Party::vPosition
Vec3_int_ vPosition
Definition: Party.h:250
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
PartyAlignment::PartyAlignment_Neutral
@ PartyAlignment_Neutral
MapStats::pInfos
MapInfo pInfos[77]
Definition: MapInfo.h:79
LOD.h
Image::GetHeight
unsigned int GetHeight()
Definition: Image.cpp:230
GUIWindow
Definition: GUIWindow.h:433
AssetsManager::GetImage_Solid
Texture * GetImage_Solid(const String &name)
Definition: AssetsManager.cpp:51
Party_Teleport_Y_Pos
int Party_Teleport_Y_Pos
Definition: mm7_data.cpp:623
GUIWindow_Transition::Update
virtual void Update()
Definition: UITransition.cpp:279
WINDOW_ChangeLocation
@ WINDOW_ChangeLocation
Definition: GUIWindow.h:302
z
GLdouble GLdouble z
Definition: SDL_opengl_glext.h:407
GUIWindow::CreateButton
GUIButton * CreateButton(int x, int y, int width, int height, int a6, int a7, UIMessageType msg, unsigned int msg_param, uint8_t hotkey, const String &label, const std::vector< Image * > &textures=std::vector< Image * >())
Definition: GUIWindow.cpp:717
GUIWindow_Travel::Release
virtual void Release()
Definition: UITransition.cpp:32
MapStats::GetMapInfo
MAP_TYPE GetMapInfo(const String &Str2)
Definition: MapInfo.cpp:225
PartyAlignment::PartyAlignment_Evil
@ PartyAlignment_Evil
pTransitionStrings
std::array< char *, 465 > pTransitionStrings
Definition: mm7_data.cpp:309
pHouse_ExitPictures
std::array< const char *, 11 > pHouse_ExitPictures
Definition: mm7_data.cpp:298
localization
Localization * localization
Definition: Localization.cpp:11
pAnimatedRooms
std::array< const stru159, 196 > pAnimatedRooms
Definition: UIHouses.cpp:132
dialogue_ui_x_x_u
Image * dialogue_ui_x_x_u
Definition: GUIWindow.cpp:92
pMediaPlayer
MPlayer * pMediaPlayer
Definition: MediaPlayer.cpp:43
UIMSG_TransitionWindowCloseBtn
@ UIMSG_TransitionWindowCloseBtn
Definition: GUIWindow.h:199
pNPCPortraits_y
std::array< std::array< int, 6 >, 6 > pNPCPortraits_y
Definition: mm7_data.cpp:290
pNPCPortraits_x
std::array< std::array< int, 6 >, 6 > pNPCPortraits_x
Definition: mm7_data.cpp:282
GUIWindow::DrawTitleText
void DrawTitleText(GUIFont *font, int horizontal_margin, int vertical_margin, unsigned __int16 uDefaultColor, const char *pInString, int line_spacing)
Definition: GUIWindow.cpp:665
GUIWindow::Release
virtual void Release()
Definition: GUIWindow.cpp:292
GUIFont.h
pMovie_Track
PMovie pMovie_Track
Definition: MediaPlayer.cpp:44
pPlayers
NZIArray< struct Player *, 5 > pPlayers
Definition: Player.cpp:46
pFontCreate
GUIFont * pFontCreate
Definition: GUIFont.cpp:22
GUIWindow::uFrameWidth
unsigned int uFrameWidth
Definition: GUIWindow.h:470
GUIWindow::uFrameZ
unsigned int uFrameZ
Definition: GUIWindow.h:472
Engine.h
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
p2DEvents
_2devent p2DEvents[525]
Definition: Events.cpp:57
SPEECH_47
@ SPEECH_47
Definition: Player.h:93
pMapStats
struct MapStats * pMapStats
Definition: mm7_data.cpp:20
IndoorLocation::GetLocationIndex
static unsigned int GetLocationIndex(const char *Str1)
Definition: Indoor.cpp:839
UIHouses.h
MPlayer::OpenHouseMovie
void OpenHouseMovie(const std::string &pMovieName, bool bLoop)
Definition: MediaPlayer.cpp:633
Localization.h
y
EGLSurface EGLint EGLint y
Definition: SDL_egl.h:1596
Image::GetWidth
unsigned int GetWidth()
Definition: Image.cpp:217
GUIButton.h
pBtn_ExitCancel
GUIButton * pBtn_ExitCancel
Definition: GUIButton.cpp:28
pBtn_YES
GUIButton * pBtn_YES
Definition: GUIButton.cpp:29
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
Party_Teleport_Cam_Pitch
int Party_Teleport_Cam_Pitch
Definition: mm7_data.cpp:626
WINDOW_Transition
@ WINDOW_Transition
Definition: GUIWindow.h:310
prev_screen_type
enum CURRENT_SCREEN prev_screen_type
Definition: GUIWindow.cpp:84
x
EGLSurface EGLint x
Definition: SDL_egl.h:1596
transition_ui_icon
Image * transition_ui_icon
Definition: UITransition.cpp:28
Party_Teleport_Map_Name
char * Party_Teleport_Map_Name
Definition: mm7_data.cpp:608
Party_Teleport_X_Pos
int Party_Teleport_X_Pos
Definition: mm7_data.cpp:622
GUIWindow_Travel::Update
virtual void Update()
Definition: UITransition.cpp:227
game_ui_right_panel_frame
Image * game_ui_right_panel_frame
Definition: GUIWindow.cpp:90
UIMSG_CHANGE_LOCATION_ClickCencelBtn
@ UIMSG_CHANGE_LOCATION_ClickCencelBtn
Definition: GUIWindow.h:76
game_ui_evtnpc
Image * game_ui_evtnpc
Definition: UIGame.cpp:102
AudioPlayer::StopChannels
void StopChannels(int uStartChannel, int uEndChannel)
Definition: AudioPlayer.cpp:331
GUIFont::CalcTextHeight
unsigned int CalcTextHeight(const String &str, unsigned int width, int x_offset, bool return_on_carriage=false)
Definition: GUIFont.cpp:246
MediaPlayer.h
Party_Teleport_Cam_Yaw
int Party_Teleport_Cam_Yaw
Definition: mm7_data.cpp:625
Party.h
UIMSG_OnTravelByFoot
@ UIMSG_OnTravelByFoot
Definition: GUIWindow.h:75
uCurrentHouse_Animation
int uCurrentHouse_Animation
Definition: mm7_data.cpp:607
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
Party::uFlags
unsigned int uFlags
Definition: Party.h:313
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
MapInfo::pName
String pName
Definition: MapInfo.h:38
Timer::Pause
void Pause()
Definition: Time.cpp:19
Events2D.h
pCurrentMapName
String pCurrentMapName
Definition: mm7_data.cpp:712
CURRENT_SCREEN::SCREEN_INPUT_BLV
@ SCREEN_INPUT_BLV
Outdoor.h
LEVEL_Indoor
@ LEVEL_Indoor
Definition: Indoor.h:286
AudioPlayer.h
CURRENT_SCREEN::SCREEN_CHANGE_LOCATION
@ SCREEN_CHANGE_LOCATION
MapInfo.h
GetTravelTime
int GetTravelTime()
Definition: Party.cpp:1171
Party_Teleport_Z_Speed
int Party_Teleport_Z_Speed
Definition: mm7_data.cpp:627
UIMSG_TransitionUI_Confirm
@ UIMSG_TransitionUI_Confirm
Definition: GUIWindow.h:198
assets
AssetsManager * assets
Definition: AssetsManager.cpp:12
GUIWindow_Transition::GUIWindow_Transition
GUIWindow_Transition(uint32_t anim_id, uint32_t exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName)
Definition: UITransition.cpp:70
uint
unsigned int uint
Definition: MM7.h:4
ui_buttyes2
Image * ui_buttyes2
Definition: GUIWindow.cpp:95
UITransition.h
uActiveCharacter
unsigned int uActiveCharacter
Definition: mm7_data.cpp:555
Localization::FormatString
String FormatString(unsigned int index,...) const
Definition: Localization.cpp:17
GUIWindow_Transition::Release
virtual void Release()
Definition: UITransition.cpp:50
OutdoorLocation::GetTravelDestination
bool GetTravelDestination(signed int sPartyX, signed int sPartyZ, char *pOut, signed int a5)
Definition: Outdoor.cpp:330
game_ui_dialogue_background
Image * game_ui_dialogue_background
Definition: UIGame.cpp:93
uCurrentlyLoadedLevelType
LEVEL_TYPE uCurrentlyLoadedLevelType
Definition: Indoor.cpp:52
pPrimaryWindow
GUIWindow * pPrimaryWindow
Definition: GUIWindow.cpp:48
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
GUIWindow::sHint
String sHint
Definition: GUIWindow.h:488
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
GUIWindow_Travel::GUIWindow_Travel
GUIWindow_Travel()
Definition: UITransition.cpp:183
pOutdoor
OutdoorLocation * pOutdoor
Definition: Outdoor.cpp:48
GUIProgressBar.h
Party_Teleport_Z_Pos
int Party_Teleport_Z_Pos
Definition: mm7_data.cpp:624
String
std::string String
Definition: Strings.h:10
_unused_5B5924_is_travel_ui_drawn
int _unused_5B5924_is_travel_ui_drawn
Definition: mm7_data.cpp:621
stru159.h
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
Image::Release
bool Release()
Definition: Image.cpp:335
Api.h
dialogue_ui_x_ok_u
Image * dialogue_ui_x_ok_u
Definition: GUIWindow.cpp:91
Party::alignment
PartyAlignment alignment
Definition: Party.h:308
Time.h
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52