4
|
1 #include <direct.h>
|
|
2 #include <io.h>
|
94
|
3 #include <assert.h>
|
4
|
4
|
|
5 #include "GUIWindow.h"
|
|
6 #include "GUIFont.h"
|
|
7 #include "LOD.h"
|
|
8 #include "SaveLoad.h"
|
|
9 #include "Render.h"
|
|
10
|
|
11 #include "mm7_data.h"
|
|
12
|
|
13
|
|
14 //----- (0045E361) --------------------------------------------------------
|
|
15 void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType)
|
|
16 {
|
|
17 unsigned int v1; // ebp@5
|
|
18 unsigned int v2; // eax@5
|
94
|
19 //signed int v3; // ebp@11
|
4
|
20 FILE *v4; // eax@14
|
|
21 FILE *v5; // eax@18
|
|
22 unsigned int v6; // eax@25
|
|
23 GUIButton *v7; // eax@27
|
|
24 const char *v8; // [sp-8h] [bp-26Ch]@25
|
94
|
25 //char *v9; // [sp-4h] [bp-268h]@19
|
4
|
26 enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25
|
|
27 unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1
|
94
|
28 //RGBTexture *pTex; // [sp+10h] [bp-254h]@12
|
|
29 //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12
|
|
30 //const char *Str1; // [sp+18h] [bp-24Ch]@12
|
4
|
31 LODWriteableFile v15; // [sp+1Ch] [bp-248h]@1
|
|
32 int v16; // [sp+260h] [bp-4h]@1
|
|
33
|
|
34 uDialogueType_ = uDialogueType;
|
|
35 dword_6BE138 = -1;
|
|
36 ++pIcons_LOD->uTexturePacksCount;
|
|
37 v16 = 0;
|
|
38 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
39 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
40
|
|
41 memset(pSavegameUsedSlots, 0, 45 * sizeof(int));
|
|
42 memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture));
|
|
43
|
|
44 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
|
|
45 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
|
|
46 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
|
|
47 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
|
|
48 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
|
|
49 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
|
|
50 if ( uDialogueType_ )
|
|
51 {
|
|
52 pRenderer->DrawTextureIndexed(
|
|
53 8u,
|
|
54 8u,
|
94
|
55 (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
|
44
|
56 if ( pCurrentScreen == 11 )
|
4
|
57 {
|
|
58 v1 = uTextureID_save_up;
|
|
59 v2 = uTextureID_LS_saveU;
|
|
60 }
|
|
61 else
|
|
62 {
|
|
63 v1 = uTextureID_load_up;
|
|
64 v2 = uTextureID_LS_loadU;
|
|
65 }
|
|
66 pRenderer->DrawTextureIndexed(241u, 302u, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
|
|
67 pRenderer->DrawTextureIndexed(18u, 141u, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
|
|
68 pRenderer->DrawTextureIndexed(
|
|
69 351u,
|
|
70 302u,
|
94
|
71 (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
|
4
|
72 }
|
|
73 else
|
|
74 {
|
44
|
75 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
|
4
|
76 }
|
|
77 pGUIWindow_CurrentMenu = GUIWindow::Create(
|
|
78 saveload_dlg_xs[uDialogueType_],
|
|
79 saveload_dlg_ys[uDialogueType_],
|
|
80 saveload_dlg_zs[uDialogueType_],
|
|
81 saveload_dlg_ws[uDialogueType_],
|
|
82 WINDOW_MainMenu_Load,
|
|
83 0,
|
|
84 0);
|
|
85 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..."
|
|
86 pRenderer->Present();
|
|
87 pSavegameList->Initialize(0);
|
|
88 if ( dword_6A0C9C > (signed int)uNumSavegameFiles )
|
|
89 {
|
|
90 dword_6A0C9C = 0;
|
|
91 uLoadGameUI_SelectedSlot = 0;
|
|
92 }
|
|
93 v15.AllocSubIndicesAndIO(0x12Cu, 0);
|
94
|
94
|
|
95 assert(sizeof(SavegameHeader) == 0x64);
|
|
96
|
|
97 //v3 = 0;
|
|
98 for (uint i = 0; i < uNumSavegameFiles; ++i)
|
4
|
99 {
|
94
|
100 //Dest = pSavegameHeader;
|
|
101 //pTex = pSavegameThumbnails;
|
|
102 //Str1 = (const char *)pSavegameList->pSavesNames;
|
|
103 //while ( 1 )
|
|
104 //{
|
|
105 sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[i]);
|
|
106 if (_access(pTmpBuf, 6))
|
4
|
107 {
|
94
|
108 pSavegameUsedSlots[i] = 0;
|
|
109 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
|
|
110 continue;
|
|
111 }
|
|
112
|
|
113 v15.LoadFile(pTmpBuf, 1);
|
|
114 v4 = v15.FindContainer("header.bin", true);
|
|
115 if ( v4 )
|
|
116 fread(&pSavegameHeader[i], 0x64u, 1u, v4);
|
|
117 if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
|
|
118 strcpy(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[16]);// "Autosave"
|
|
119
|
|
120 v5 = v15.FindContainer("image.pcx", true);
|
|
121 if ( !v5 )
|
|
122 {
|
|
123 pSavegameUsedSlots[i] = 0;
|
|
124 strcpy(pSavegameList->pSavesNames[i], "");
|
|
125 }
|
|
126 else
|
|
127 {
|
|
128 pSavegameThumbnails[i].LoadFromFILE(v5, 0, true);
|
4
|
129 v15.CloseWriteFile();
|
94
|
130 pSavegameUsedSlots[i] = 1;
|
4
|
131 }
|
94
|
132 //LABEL_23:
|
|
133 //Str1 += 280;
|
|
134 //++pTex;
|
|
135 //++Dest;
|
|
136 //++v3;
|
|
137 //if ( v3 >= (signed int)uNumSavegameFiles )
|
|
138 // goto LABEL_24;
|
|
139 //}
|
|
140 //goto LABEL_22;
|
4
|
141 }
|
94
|
142
|
4
|
143 LABEL_24:
|
|
144 v15.FreeSubIndexAndIO();
|
44
|
145 if ( pCurrentScreen == 11 )
|
4
|
146 {
|
|
147 v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
148 v10 = (TEXTURE_TYPE)2;
|
|
149 v8 = "LS_saveD";
|
|
150 }
|
|
151 else
|
|
152 {
|
|
153 v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
154 v10 = (TEXTURE_TYPE)2;
|
|
155 v8 = "LS_loadD";
|
|
156 }
|
|
157 uTextureID_x_d = v6;
|
|
158 uTextureID_LS_ = pIcons_LOD->LoadTexture(v8, v10);
|
|
159 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
|
|
160 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
|
59
|
161 pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 191u, 18u, 1, 0, 0xA5u, 0, 0, "", 0);
|
|
162 pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, "", 0);
|
|
163 pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, "", 0);
|
|
164 pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, "", 0);
|
|
165 pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, "", 0);
|
|
166 pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, "", 0);
|
|
167 pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, "", 0);
|
4
|
168 ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
|
|
169 241u,
|
|
170 302u,
|
|
171 105u,
|
|
172 40u,
|
|
173 1,
|
|
174 0,
|
|
175 0xA4u,
|
|
176 0,
|
|
177 0,
|
59
|
178 "",
|
4
|
179 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
|
|
180 0);
|
|
181 ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
|
|
182 350u,
|
|
183 302u,
|
|
184 105u,
|
|
185 40u,
|
|
186 1,
|
|
187 0,
|
|
188 0xA6u,
|
|
189 0,
|
|
190 0,
|
59
|
191 "",
|
4
|
192 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
|
|
193 0);
|
|
194 ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
|
|
195 215u,
|
|
196 199u,
|
|
197 17u,
|
|
198 17u,
|
|
199 1,
|
|
200 0,
|
|
201 0xA2u,
|
|
202 0,
|
|
203 0,
|
59
|
204 "",
|
4
|
205 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
|
|
206 0);
|
|
207 v7 = pGUIWindow_CurrentMenu->CreateButton(
|
|
208 215u,
|
|
209 0x143u,
|
|
210 0x11u,
|
|
211 0x11u,
|
|
212 1,
|
|
213 0,
|
|
214 0xA3u,
|
|
215 uNumSavegameFiles,
|
|
216 0,
|
59
|
217 "",
|
4
|
218 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
|
|
219 0);
|
|
220 v16 = -1;
|
|
221 ptr_69BD58 = v7;
|
|
222 }
|
|
223
|
|
224 //----- (0045E93E) --------------------------------------------------------
|
|
225 void __cdecl GameUI_DrawSaveMenu()
|
|
226 {
|
|
227 unsigned int v0; // ebp@4
|
|
228 unsigned int v1; // eax@4
|
|
229 unsigned int *v2; // ebp@6
|
|
230 char *v3; // eax@7
|
|
231 FILE *v4; // eax@11
|
|
232 FILE *v5; // eax@11
|
|
233 const char *v6; // ST64_4@14
|
|
234 GUIButton *v7; // eax@16
|
|
235 char *v8; // [sp+10h] [bp-254h]@6
|
|
236 SavegameHeader *Dest; // [sp+14h] [bp-250h]@6
|
|
237 RGBTexture *this_; // [sp+18h] [bp-24Ch]@6
|
|
238 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1
|
|
239 int v12; // [sp+260h] [bp-4h]@1
|
|
240
|
|
241 ++pIcons_LOD->uTexturePacksCount;
|
|
242 v12 = 0;
|
|
243 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
244 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
245 memset(pSavegameUsedSlots, 0, 0xB4u);
|
|
246 memset(&pSavegameThumbnails, 0, 0x708u);
|
|
247 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
|
|
248 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
|
|
249 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
|
|
250 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
|
|
251 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
|
|
252 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
|
|
253 pRenderer->DrawTextureIndexed(
|
|
254 8u,
|
|
255 8u,
|
|
256 (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
|
44
|
257 if ( pCurrentScreen == 11 )
|
4
|
258 {
|
|
259 v0 = uTextureID_save_up;
|
|
260 v1 = uTextureID_LS_saveU;
|
|
261 }
|
|
262 else
|
|
263 {
|
|
264 v0 = uTextureID_load_up;
|
|
265 v1 = uTextureID_LS_loadU;
|
|
266 }
|
|
267 pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
|
|
268 pRenderer->DrawTextureIndexed(
|
|
269 0x15Fu,
|
|
270 0x12Eu,
|
|
271 (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
|
|
272 pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
|
|
273 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
|
|
274 pRenderer->Present();
|
|
275 pSavegameList->Initialize(1u);
|
|
276 v11.AllocSubIndicesAndIO(0x12Cu, 0);
|
|
277 v2 = pSavegameUsedSlots;
|
|
278 Dest = pSavegameHeader;
|
|
279 this_ = pSavegameThumbnails;
|
|
280 v8 = (char *)pSavegameList->pSavesNames;
|
|
281 do
|
|
282 {
|
|
283 v3 = v8;
|
|
284 if ( !*v8 )
|
|
285 v3 = "1.mm7";
|
80
|
286 sprintf(pTmpBuf, "saves\\%s", v3);
|
4
|
287 if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
|
|
288 {
|
|
289 v6 = pGlobalTXT_LocalizationStrings[72];
|
|
290 *v2 = 0;
|
|
291 strcpy(Dest->pName, v6);
|
|
292 }
|
|
293 else
|
|
294 {
|
|
295 v11.LoadFile(pTmpBuf, 1);
|
|
296 v4 = v11.FindContainer("header.bin", 1);
|
|
297 fread(Dest, 0x64u, 1u, v4);
|
|
298 v5 = v11.FindContainer("image.pcx", 1);
|
|
299 if ( v5 )
|
|
300 {
|
|
301 this_->LoadFromFILE(v5, 0, 1u);
|
|
302 v11.CloseWriteFile();
|
|
303 *v2 = 1;
|
|
304 }
|
|
305 else
|
|
306 {
|
|
307 *v2 = 0;
|
|
308 }
|
|
309 }
|
|
310 v8 += 280;
|
|
311 ++this_;
|
|
312 ++Dest;
|
|
313 ++v2;
|
|
314 }
|
|
315 while ( (signed int)v8 < (signed int)&_69FBB4_ptr_iterator_end );
|
|
316 v11.FreeSubIndexAndIO();
|
|
317 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
318 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
|
|
319 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
|
|
320 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
|
|
321 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0);
|
59
|
322 pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, "", 0);
|
|
323 pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, "", 0);
|
|
324 pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, "", 0);
|
|
325 pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, "", 0);
|
|
326 pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, "", 0);
|
|
327 pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, "", 0);
|
|
328 pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, "", 0);
|
4
|
329 ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
|
|
330 0xF1u,
|
|
331 0x12Eu,
|
|
332 0x69u,
|
|
333 0x28u,
|
|
334 1,
|
|
335 0,
|
|
336 0xA4u,
|
|
337 0,
|
|
338 0,
|
59
|
339 "",
|
4
|
340 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
|
|
341 0);
|
|
342 ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
|
|
343 0x15Eu,
|
|
344 0x12Eu,
|
|
345 0x69u,
|
|
346 0x28u,
|
|
347 1,
|
|
348 0,
|
|
349 0xA6u,
|
|
350 0,
|
|
351 0,
|
59
|
352 "",
|
4
|
353 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
|
|
354 0);
|
|
355 ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
|
|
356 0xD7u,
|
|
357 0xC7u,
|
|
358 0x11u,
|
|
359 0x11u,
|
|
360 1,
|
|
361 0,
|
|
362 0xA2u,
|
|
363 0,
|
|
364 0,
|
59
|
365 "",
|
4
|
366 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
|
|
367 0);
|
|
368 v7 = pGUIWindow_CurrentMenu->CreateButton(
|
|
369 0xD7u,
|
|
370 0x143u,
|
|
371 0x11u,
|
|
372 0x11u,
|
|
373 1,
|
|
374 0,
|
|
375 0xA3u,
|
|
376 0x22u,
|
|
377 0,
|
59
|
378 "",
|
4
|
379 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
|
|
380 0);
|
|
381 v12 = -1;
|
|
382 ptr_69BD58 = v7;
|
|
383 } |