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