Mercurial > mm7
annotate UI/UITransition.cpp @ 2495:7b076fe64f23
GetItemTextureFilename fix
author | Ritor1 |
---|---|
date | Wed, 17 Sep 2014 17:35:13 +0600 |
parents | 104fdbea0386 |
children | 5abd8fc8f1c6 |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2215
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
1298 | 6 #include <io.h> |
7 | |
2336 | 8 #include "..\ErrorHandling.h" |
1299 | 9 #include "..\mm7_data.h" |
2450 | 10 #include "..\MediaPlayer.h" |
1299 | 11 #include "..\MapInfo.h" |
12 #include "..\GUIWindow.h" | |
13 #include "..\GUIFont.h" | |
14 #include "..\GUIProgressBar.h" | |
15 #include "..\Party.h" | |
16 #include "..\AudioPlayer.h" | |
17 #include "..\Outdoor.h" | |
18 #include "..\LOD.h" | |
2044 | 19 #include "..\Timer.h" |
1299 | 20 #include "..\stru159.h" |
21 #include "..\Events2D.h" | |
22 #include "..\texts.h" | |
1298 | 23 #include "UIHouses.h" |
24 | |
25 | |
26 | |
27 | |
28 //----- (00444839) -------------------------------------------------------- | |
29 void TransitionUI_Load(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName) | |
30 { | |
31 const char *v15; // eax@14 | |
32 char pContainer[40]; // [sp+Ch] [bp-2Ch]@1 | |
33 | |
34 dword_59117C_teleportx = x; | |
35 dword_591178_teleporty = y; | |
36 dword_591174_teleportz = z; | |
37 dword_591170_teleport_directiony = directiony; | |
38 dword_59116C_teleport_directionx = directionx; | |
39 dword_591168_teleport_speedz = a8; | |
40 dword_591164_teleport_map_name = (char *)pLocationName; | |
41 uCurrentHouse_Animation = anim_id; | |
42 pEventTimer->Pause(); | |
43 pAudioPlayer->StopChannels(-1, -1); | |
44 | |
45 switch (pParty->alignment) | |
46 { | |
47 case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break; | |
48 case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break; | |
49 case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break; | |
1545 | 50 default: Error("Invalid alignment: %u", pParty->alignment); |
1298 | 51 } |
52 | |
1754 | 53 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)]; |
54 pTexture_outside = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[exit_pic_id], TEXTURE_16BIT_PALETTE); | |
1298 | 55 if (anim_id) |
56 { | |
1754 | 57 if ( !IndoorLocation::GetLocationIndex(pLocationName) ) |
2450 | 58 pMediaPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].video_name, 1); |
1298 | 59 } |
1754 | 60 else if ( !IndoorLocation::GetLocationIndex(pLocationName) ) |
1298 | 61 { |
1754 | 62 if ( pMapStats->GetMapInfo(pCurrentMapName) ) |
63 { | |
64 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName); // "Leave %s" | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
65 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data()); |
1754 | 66 //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId ) |
67 //PlayHouseSound(anim_id, HouseSound_Greeting); | |
68 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 ) | |
69 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0); | |
70 if ( IndoorLocation::GetLocationIndex(pLocationName) ) | |
71 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); | |
72 return; | |
73 } | |
74 strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
75 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data()); |
1754 | 76 //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId ) |
77 //PlayHouseSound(anim_id, HouseSound_Greeting); | |
78 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 ) | |
79 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0); | |
80 if ( IndoorLocation::GetLocationIndex(pLocationName) ) | |
81 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); | |
82 return; | |
1298 | 83 } |
84 v15 = pLocationName; | |
85 if ( *pLocationName == 48 ) | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1299
diff
changeset
|
86 v15 = pCurrentMapName; |
1754 | 87 if ( pMapStats->GetMapInfo(v15) ) |
1298 | 88 { |
1754 | 89 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[pMapStats->GetMapInfo(v15)].pName);//Войти в ^Pv[%s] |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
90 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data()); |
1754 | 91 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 ) |
92 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0); | |
93 if ( IndoorLocation::GetLocationIndex(pLocationName) ) | |
94 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); | |
95 return; | |
1298 | 96 } |
1754 | 97 strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[73]);//Войти |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
98 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data()); |
1754 | 99 //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId ) |
100 //PlayHouseSound(anim_id, HouseSound_Greeting); | |
1298 | 101 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 ) |
102 pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0); | |
1754 | 103 if ( IndoorLocation::GetLocationIndex(pLocationName) ) |
104 uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); | |
1298 | 105 } |
106 | |
107 //----- (00444C8F) -------------------------------------------------------- | |
108 void TravelUI_Load() | |
109 { | |
110 char pContainer[32]; // [sp+0h] [bp-28h]@1 | |
111 | |
112 pEventTimer->Pause(); | |
113 | |
114 switch (pParty->alignment) | |
115 { | |
116 case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break; | |
117 case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break; | |
118 case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break; | |
1545 | 119 default: Error("Invalid alignment: %u", pParty->alignment); |
1298 | 120 } |
121 | |
122 pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); | |
123 pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE); | |
1757 | 124 if ( pMapStats->GetMapInfo(pCurrentMapName) ) |
125 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName);// "Leave %s" | |
1298 | 126 else |
127 strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit" | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
128 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_ChangeLocation, 0, sHouseName.data()); |
1298 | 129 } |
130 | |
131 //----- (00444DCA) -------------------------------------------------------- | |
132 void TravelUI_Draw() | |
133 { | |
1757 | 134 GUIWindow travel_window; // [sp+Ch] [bp-78h]@1 |
1298 | 135 char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1 |
136 | |
1757 | 137 memcpy(&travel_window, pPrimaryWindow, sizeof(travel_window)); |
1298 | 138 pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20); |
1757 | 139 pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); |
140 pRenderer->DrawTextureTransparent(468, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]); | |
1298 | 141 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); |
1757 | 142 pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u)); |
143 pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); | |
144 if ( pMapStats->GetMapInfo(pDestinationMapName) ) | |
1298 | 145 { |
1757 | 146 travel_window.uFrameX = 493; |
147 travel_window.uFrameWidth = 126; | |
148 travel_window.uFrameZ = 366; | |
149 travel_window.DrawTitleText(pFontCreate, 0, 4, 0, pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName, 3); | |
150 travel_window.uFrameX = 483; | |
151 travel_window.uFrameWidth = 148; | |
152 travel_window.uFrameZ = 334; | |
153 if ( GetTravelTime() == 1 ) | |
154 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[663], 1, pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName);// "It will take %d day to cross to %s." | |
1298 | 155 else |
1757 | 156 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[128], GetTravelTime(), pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName);// "It will take %d days to travel to %s." |
157 | |
1298 | 158 strcat(pTmpBuf.data(), "\n \n"); |
1757 | 159 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName); |
1298 | 160 strcat(pTmpBuf.data(), pTmpBuf2.data()); |
1757 | 161 travel_window.DrawTitleText(pFontCreate, 0, (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &travel_window, 0, 0)) / 2 + 101, 0, pTmpBuf.data(), 3); |
1298 | 162 _unused_5B5924_is_travel_ui_drawn = 1; |
163 } | |
164 } | |
165 | |
166 //----- (00444A51) -------------------------------------------------------- | |
167 void TransitionUI_Draw() | |
168 { | |
169 unsigned int v4; // [sp-10h] [bp-7Ch]@12 | |
1755 | 170 GUIWindow transition_window; // [sp+Ch] [bp-60h]@1 |
1298 | 171 unsigned int v9; // [sp+60h] [bp-Ch]@1 |
1755 | 172 unsigned int map_id; // [sp+64h] [bp-8h]@1 |
1298 | 173 |
1755 | 174 memcpy(&transition_window, pPrimaryWindow, sizeof(transition_window)); |
1298 | 175 v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name); |
176 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); | |
177 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C)); | |
178 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); | |
179 uTextureID_right_panel_loop = uTextureID_right_panel; | |
180 pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel)); | |
181 pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u)); | |
182 pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); | |
1755 | 183 map_id = pMapStats->GetMapInfo(pCurrentMapName); |
2394 | 184 if ( (pMovie_Track || v9) && *dword_591164_teleport_map_name != ' ' ) |
1755 | 185 map_id = pMapStats->GetMapInfo(dword_591164_teleport_map_name); |
186 transition_window.uFrameX = 493; | |
187 transition_window.uFrameWidth = 126; | |
188 transition_window.uFrameZ = 366; | |
189 transition_window.DrawTitleText(pFontCreate, 0, 5, 0, pMapStats->pInfos[map_id].pName, 3); | |
190 transition_window.uFrameX = 483; | |
191 transition_window.uFrameWidth = 148; | |
192 transition_window.uFrameZ = 334; | |
1298 | 193 |
194 if ( uCurrentHouse_Animation ) | |
195 { | |
1755 | 196 v4 = (212 - pFontCreate->CalcTextHeight(pTransitionStrings[uCurrentHouse_Animation], &transition_window, 0, 0)) / 2 + 101; |
197 transition_window.DrawTitleText(pFontCreate, 0, v4, 0, pTransitionStrings[uCurrentHouse_Animation], 3); | |
1298 | 198 } |
1755 | 199 else if ( map_id ) |
1298 | 200 { |
1755 | 201 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[409], pMapStats->pInfos[map_id].pName);// "Do you wish to leave %s?" |
202 v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &transition_window, 0, 0)) / 2 + 101; | |
203 transition_window.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf.data(), 3); | |
1298 | 204 } |
1545 | 205 else Error("Troubles in da house"); |
1298 | 206 |
207 _unused_5B5924_is_travel_ui_drawn = true; | |
208 } |