Mercurial > mm7
annotate UI/UITransition.cpp @ 1618:f5b13e6be493
Player::UseItem_DrinkPotion_etc some minor edits(brace indentation, a few warnings), commented out 2 sections which never get used
author | Grumpy7 |
---|---|
date | Sat, 14 Sep 2013 07:21:56 +0200 |
parents | c4ab816fcc5e |
children | 79621dd04649 bae4ffd25a03 |
rev | line source |
---|---|
1298 | 1 #ifdef _MSC_VER |
2 #define _CRT_SECURE_NO_WARNINGS | |
3 #endif | |
4 | |
5 #include <io.h> | |
6 | |
1299 | 7 #include "..\mm7_data.h" |
8 #include "..\VideoPlayer.h" | |
9 #include "..\MapInfo.h" | |
10 #include "..\GUIWindow.h" | |
11 #include "..\GUIFont.h" | |
12 #include "..\GUIProgressBar.h" | |
13 #include "..\Party.h" | |
14 #include "..\AudioPlayer.h" | |
15 #include "..\Outdoor.h" | |
16 #include "..\LOD.h" | |
17 #include "..\Time.h" | |
18 #include "..\stru159.h" | |
19 #include "..\Events2D.h" | |
20 #include "..\texts.h" | |
1298 | 21 #include "UIHouses.h" |
22 | |
23 | |
24 | |
25 | |
26 | |
27 //----- (00444839) -------------------------------------------------------- | |
28 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) | |
29 { | |
30 //unsigned int v9; // ebx@1 | |
31 //int v10; // edi@1 | |
32 //signed int v11; // eax@1 | |
33 unsigned int v12; // eax@6 | |
34 const char *v13; // ST0C_4@6 | |
35 unsigned int v14; // eax@8 | |
36 const char *v15; // eax@14 | |
37 unsigned int v16; // eax@16 | |
38 //unsigned int result; // eax@26 | |
39 const char *v18; // [sp-8h] [bp-40h]@9 | |
40 //const char *v19; // [sp-4h] [bp-3Ch]@2 | |
41 char *v20; // [sp-4h] [bp-3Ch]@9 | |
42 const char *v21; // [sp-4h] [bp-3Ch]@11 | |
43 char pContainer[40]; // [sp+Ch] [bp-2Ch]@1 | |
44 unsigned int v23; // [sp+34h] [bp-4h]@1 | |
45 | |
46 //v9 = a1; | |
47 //v10 = a2; | |
48 v23 = IndoorLocation::GetLocationIndex(pLocationName); | |
49 dword_59117C_teleportx = x; | |
50 dword_591178_teleporty = y; | |
51 dword_591174_teleportz = z; | |
52 dword_591170_teleport_directiony = directiony; | |
53 dword_59116C_teleport_directionx = directionx; | |
54 dword_591168_teleport_speedz = a8; | |
55 dword_591164_teleport_map_name = (char *)pLocationName; | |
56 uCurrentHouse_Animation = anim_id; | |
57 pEventTimer->Pause(); | |
58 pAudioPlayer->StopChannels(-1, -1); | |
59 | |
60 switch (pParty->alignment) | |
61 { | |
62 case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break; | |
63 case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break; | |
64 case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break; | |
1545 | 65 default: Error("Invalid alignment: %u", pParty->alignment); |
1298 | 66 } |
67 | |
68 v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); | |
69 v13 = pHouse_ExitPictures[exit_pic_id]; | |
70 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12]; | |
71 pTexture_outside = pIcons_LOD->LoadTexturePtr(v13, TEXTURE_16BIT_PALETTE); | |
72 if (anim_id) | |
73 { | |
74 if ( !v23 ) | |
75 //pVideoPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_0, 1u); | |
76 pVideoPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].video_name, 1); | |
77 } | |
78 else if ( !v23 ) | |
79 { | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1299
diff
changeset
|
80 v14 = pMapStats->GetMapInfo(pCurrentMapName); |
1298 | 81 if ( v14 ) |
82 { | |
83 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v14].pName); // "Leave %s" | |
84 goto LABEL_20; | |
85 } | |
86 v21 = pGlobalTXT_LocalizationStrings[79]; | |
87 goto LABEL_19; | |
88 } | |
89 v15 = pLocationName; | |
90 if ( *pLocationName == 48 ) | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1299
diff
changeset
|
91 v15 = pCurrentMapName; |
1298 | 92 v16 = pMapStats->GetMapInfo(v15); |
93 if ( v16 ) | |
94 { | |
95 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[v16].pName); | |
96 goto LABEL_20; | |
97 } | |
98 v21 = pGlobalTXT_LocalizationStrings[73]; | |
99 LABEL_19: | |
100 strcpy(sHouseName.data(), v21); | |
101 LABEL_20: | |
102 pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data()); | |
103 //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) ) | |
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 ( v23 ) | |
109 uCurrentHouse_Animation = v23; | |
110 } | |
111 | |
112 | |
113 | |
114 | |
115 //----- (00444C8F) -------------------------------------------------------- | |
116 void TravelUI_Load() | |
117 { | |
118 //signed int v0; // eax@1 | |
119 unsigned int v1; // eax@6 | |
120 GUIWindow *result; // eax@9 | |
121 //const char *v3; // [sp-4h] [bp-2Ch]@2 | |
122 char pContainer[32]; // [sp+0h] [bp-28h]@1 | |
123 | |
124 pEventTimer->Pause(); | |
125 | |
126 switch (pParty->alignment) | |
127 { | |
128 case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break; | |
129 case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break; | |
130 case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break; | |
1545 | 131 default: Error("Invalid alignment: %u", pParty->alignment); |
1298 | 132 } |
133 | |
134 pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); | |
135 pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1299
diff
changeset
|
136 v1 = pMapStats->GetMapInfo(pCurrentMapName); |
1298 | 137 if ( v1 ) |
138 sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" | |
139 else | |
140 strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit" | |
141 pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, sHouseName.data()); | |
142 } | |
143 | |
144 | |
145 | |
146 //----- (00444DCA) -------------------------------------------------------- | |
147 void TravelUI_Draw() | |
148 { | |
149 unsigned int v0; // edi@1 | |
150 MapInfo *v1; // edi@2 | |
151 signed int v3; // eax@2 | |
152 int v4; // eax@5 | |
153 const char *v5; // [sp-Ch] [bp-90h]@3 | |
154 signed int v6; // [sp-8h] [bp-8Ch]@3 | |
155 GUIWindow v7; // [sp+Ch] [bp-78h]@1 | |
156 char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1 | |
157 unsigned int v9; // [sp+80h] [bp-4h]@1 | |
158 | |
159 memcpy(&v7, pPrimaryWindow, sizeof(v7)); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1299
diff
changeset
|
160 v9 = pMapStats->GetMapInfo(pCurrentMapName); |
1298 | 161 pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20); |
162 v0 = pMapStats->GetMapInfo(pDestinationMapName); | |
163 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); | |
164 pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]); | |
165 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); | |
166 pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, pIcons_LOD->GetTexture(uTextureID_x_x_u)); | |
167 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C3u, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); | |
168 if ( v0 ) | |
169 { | |
170 v1 = &pMapStats->pInfos[v0]; | |
171 v7.uFrameX = 493; | |
172 v7.uFrameWidth = 126; | |
173 v7.uFrameZ = 366; | |
174 v7.DrawTitleText(pFontCreate, 0, 4u, 0, v1->pName, 3); | |
175 v7.uFrameX = 483; | |
176 v7.uFrameWidth = 148; | |
177 v7.uFrameZ = 334; | |
178 v3 = GetTravelTime(); | |
179 if ( v3 == 1 ) | |
180 { | |
181 v6 = 1; | |
182 v5 = pGlobalTXT_LocalizationStrings[663]; // "It will take %d day to cross to %s." | |
183 } | |
184 else | |
185 { | |
186 v6 = v3; | |
187 v5 = pGlobalTXT_LocalizationStrings[128]; // "It will take %d days to travel to %s." | |
188 } | |
189 sprintfex(pTmpBuf.data(), v5, v6, v1->pName); | |
190 strcat(pTmpBuf.data(), "\n \n"); | |
191 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName); | |
192 strcat(pTmpBuf.data(), pTmpBuf2.data()); | |
193 v4 = pFontCreate->CalcTextHeight(pTmpBuf.data(), &v7, 0, 0); | |
194 v7.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf.data(), 3); | |
195 _unused_5B5924_is_travel_ui_drawn = 1; | |
196 } | |
197 } | |
198 | |
199 | |
200 | |
201 //----- (00444A51) -------------------------------------------------------- | |
202 void TransitionUI_Draw() | |
203 { | |
204 MapInfo *pMapInfo; // esi@5 | |
205 char *v1; // eax@6 | |
206 std::string v3; // [sp-18h] [bp-84h]@11 | |
207 unsigned int v4; // [sp-10h] [bp-7Ch]@12 | |
208 int v5; // [sp-Ch] [bp-78h]@12 | |
209 const char *v6; // [sp-8h] [bp-74h]@11 | |
210 signed int v7; // [sp-4h] [bp-70h]@11 | |
211 GUIWindow v8; // [sp+Ch] [bp-60h]@1 | |
212 unsigned int v9; // [sp+60h] [bp-Ch]@1 | |
213 unsigned int v10; // [sp+64h] [bp-8h]@1 | |
214 int a3; // [sp+6Bh] [bp-1h]@11 | |
215 | |
216 memcpy(&v8, pPrimaryWindow, sizeof(v8)); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1299
diff
changeset
|
217 v10 = pMapStats->GetMapInfo(pCurrentMapName); |
1298 | 218 v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name); |
219 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); | |
220 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C)); | |
221 pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); | |
222 uTextureID_right_panel_loop = uTextureID_right_panel; | |
223 pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel)); | |
224 pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u)); | |
225 pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); | |
226 if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != ' ' ) | |
227 v10 = pMapStats->GetMapInfo(dword_591164_teleport_map_name); | |
228 pMapInfo = &pMapStats->pInfos[v10]; | |
229 v8.uFrameX = 493; | |
230 v8.uFrameWidth = 126; | |
231 v8.uFrameZ = 366; | |
232 v8.DrawTitleText(pFontCreate, 0, 5u, 0, pMapInfo->pName, 3); | |
233 v8.uFrameX = 483; | |
234 v8.uFrameWidth = 148; | |
235 v8.uFrameZ = 334; | |
236 | |
237 v1 = ""; | |
238 if ( uCurrentHouse_Animation ) | |
239 { | |
240 v1 = pTransitionStrings[uCurrentHouse_Animation]; | |
241 v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101; | |
242 v8.DrawTitleText(pFontCreate, 0, v4, 0, v1, 3); | |
243 } | |
244 else if ( v10 ) | |
245 { | |
246 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?" | |
247 v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &v8, 0, 0)) / 2 + 101; | |
248 v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf.data(), 3); | |
249 } | |
1545 | 250 else Error("Troubles in da house"); |
1298 | 251 |
252 _unused_5B5924_is_travel_ui_drawn = true; | |
253 } |