comparison GameUIs.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children 89240115d392
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
1 #include <direct.h>
2 #include <io.h>
3 #include <assert.h>
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
19 //signed int v3; // ebp@11
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
25 //char *v9; // [sp-4h] [bp-268h]@19
26 enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25
27 unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1
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
31 LODWriteableFile pLODFile; // [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 memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots));
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 {
50 pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
51 if ( pCurrentScreen == 11 )//save or load
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 }
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));
64 }
65 else
66 {
67 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
68 }
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);
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 }
79 pLODFile.AllocSubIndicesAndIO(0x12C, 0);
80 assert(sizeof(SavegameHeader) == 0x64);
81 //v3 = 0;
82 for (uint i = 0; i < uNumSavegameFiles; ++i)
83 {
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))
91 {
92 pSavegameUsedSlots[i] = 0;
93 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
94 continue;
95 }
96 pLODFile.LoadFile(pTmpBuf, 1);
97 v4 = pLODFile.FindContainer("header.bin", true);
98 if ( v4 )
99 fread(&pSavegameHeader[i], 0x64, 1, v4);
100 if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
101 strcpy(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[16]);// "Autosave"
102 v5 = pLODFile.FindContainer("image.pcx", true);
103 if ( !v5 )
104 {
105 pSavegameUsedSlots[i] = 0;
106 strcpy(pSavegameList->pSavesNames[i], "");
107 }
108 else
109 {
110 pSavegameThumbnails[i].LoadFromFILE(v5, 0, true);
111 pLODFile.CloseWriteFile();
112 pSavegameUsedSlots[i] = 1;
113 }
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;
123 }
124
125 //LABEL_24:
126 pLODFile.FreeSubIndexAndIO();
127 if ( pCurrentScreen == 11 ) // save/load screen
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);
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);
156 ptr_69BD58 = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, 0xA3, uNumSavegameFiles, 0, "",
157 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
158 v16 = -1;
159 //ptr_69BD58 = v7;
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));
195 if ( pCurrentScreen == 11 )
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";
224 sprintf(pTmpBuf, "saves\\%s", v3);
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);
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);
267 ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
268 0xF1u,
269 0x12Eu,
270 0x69u,
271 0x28u,
272 1,
273 0,
274 0xA4u,
275 0,
276 0,
277 "",
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,
290 "",
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,
303 "",
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,
316 "",
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 }