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