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