0
|
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"
|
189
|
10 #include "texts.h"
|
0
|
11
|
|
12 #include "mm7_data.h"
|
|
13
|
|
14
|
|
15 //----- (0045E361) --------------------------------------------------------
|
|
16 void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType)
|
|
17 {
|
|
18 unsigned int v1; // ebp@5
|
|
19 unsigned int v2; // eax@5
|
|
20 //signed int v3; // ebp@11
|
|
21 FILE *v4; // eax@14
|
|
22 FILE *v5; // eax@18
|
|
23 unsigned int v6; // eax@25
|
|
24 GUIButton *v7; // eax@27
|
|
25 const char *v8; // [sp-8h] [bp-26Ch]@25
|
|
26 //char *v9; // [sp-4h] [bp-268h]@19
|
|
27 enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25
|
|
28 unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1
|
|
29 //RGBTexture *pTex; // [sp+10h] [bp-254h]@12
|
|
30 //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12
|
|
31 //const char *Str1; // [sp+18h] [bp-24Ch]@12
|
|
32 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1
|
|
33 int v16; // [sp+260h] [bp-4h]@1
|
|
34
|
|
35 uDialogueType_ = uDialogueType;
|
|
36 dword_6BE138 = -1;
|
|
37 ++pIcons_LOD->uTexturePacksCount;
|
|
38 v16 = 0;
|
|
39 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
40 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
41 memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots));
|
|
42 memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture));
|
|
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(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
|
151
|
52 if ( pCurrentScreen == SCREEN_SAVEGAME )
|
0
|
53 {
|
|
54 v1 = uTextureID_save_up;
|
|
55 v2 = uTextureID_LS_saveU;
|
|
56 }
|
|
57 else
|
|
58 {
|
|
59 v1 = uTextureID_load_up;
|
|
60 v2 = uTextureID_LS_loadU;
|
|
61 }
|
|
62 pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
|
|
63 pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
|
|
64 pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
|
|
65 }
|
|
66 else
|
|
67 {
|
|
68 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
|
|
69 }
|
|
70 pGUIWindow_CurrentMenu = GUIWindow::Create(saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_],
|
|
71 saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0);
|
|
72 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..."
|
|
73 pRenderer->Present();
|
|
74 pSavegameList->Initialize(0);
|
2
|
75 if ( pSaveListPosition > (signed int)uNumSavegameFiles )
|
0
|
76 {
|
2
|
77 pSaveListPosition = 0;
|
0
|
78 uLoadGameUI_SelectedSlot = 0;
|
|
79 }
|
|
80 pLODFile.AllocSubIndicesAndIO(0x12C, 0);
|
|
81 assert(sizeof(SavegameHeader) == 0x64);
|
|
82 //v3 = 0;
|
|
83 for (uint i = 0; i < uNumSavegameFiles; ++i)
|
|
84 {
|
|
85 //Dest = pSavegameHeader;
|
|
86 //pTex = pSavegameThumbnails;
|
|
87 //Str1 = (const char *)pSavegameList->pSavesNames;
|
|
88 //while ( 1 )
|
|
89 //{
|
382
|
90 sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName);
|
0
|
91 if (_access(pTmpBuf, 6))
|
|
92 {
|
|
93 pSavegameUsedSlots[i] = 0;
|
|
94 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
|
|
95 continue;
|
|
96 }
|
|
97 pLODFile.LoadFile(pTmpBuf, 1);
|
|
98 v4 = pLODFile.FindContainer("header.bin", true);
|
|
99 if ( v4 )
|
|
100 fread(&pSavegameHeader[i], 0x64, 1, v4);
|
382
|
101 if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
|
43
|
102 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
|
4
|
103 v5 = pLODFile.FindContainer("image.pcx", true);
|
0
|
104 if ( !v5 )
|
|
105 {
|
|
106 pSavegameUsedSlots[i] = 0;
|
382
|
107 strcpy(pSavegameList->pFileList[i].pSaveFileName, "");
|
0
|
108 }
|
|
109 else
|
|
110 {
|
|
111 pSavegameThumbnails[i].LoadFromFILE(v5, 0, true);
|
|
112 pLODFile.CloseWriteFile();
|
|
113 pSavegameUsedSlots[i] = 1;
|
|
114 }
|
|
115 //LABEL_23:
|
|
116 //Str1 += 280;
|
|
117 //++pTex;
|
|
118 //++Dest;
|
|
119 //++v3;
|
|
120 //if ( v3 >= (signed int)uNumSavegameFiles )
|
|
121 // goto LABEL_24;
|
|
122 //}
|
|
123 //goto LABEL_22;
|
|
124 }
|
|
125
|
|
126 //LABEL_24:
|
|
127 pLODFile.FreeSubIndexAndIO();
|
151
|
128 if ( pCurrentScreen == SCREEN_SAVEGAME )
|
0
|
129 {
|
|
130 v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
131 v10 = (TEXTURE_TYPE)2;
|
|
132 v8 = "LS_saveD";
|
|
133 }
|
|
134 else
|
|
135 {
|
|
136 v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
137 v10 = (TEXTURE_TYPE)2;
|
|
138 v8 = "LS_loadD";
|
|
139 }
|
|
140 uTextureID_x_d = v6;
|
|
141 uTextureID_LS_ = pIcons_LOD->LoadTexture(v8, v10);
|
|
142 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
|
|
143 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
|
|
144 pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, 0xA5, 0, 0, "", 0);
|
|
145 pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, 0xA5, 1, 0, "", 0);
|
|
146 pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, 0xA5, 2, 0, "", 0);
|
|
147 pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, 0xA5, 3, 0, "", 0);
|
|
148 pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, 0xA5, 4, 0, "", 0);
|
|
149 pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, 0xA5, 5, 0, "", 0);
|
|
150 pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, 0xA5, 6, 0, "", 0);
|
2
|
151 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, 0xA4, 0, 0, "",
|
0
|
152 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
|
2
|
153 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, 0xA6, 0, 0, "",
|
0
|
154 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
|
2
|
155 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, 0xA2, 0, 0, "",
|
0
|
156 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
|
2
|
157 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, 0xA3, uNumSavegameFiles, 0, "",
|
0
|
158 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
|
|
159 v16 = -1;
|
|
160 //ptr_69BD58 = v7;
|
|
161 }
|
|
162
|
|
163 //----- (0045E93E) --------------------------------------------------------
|
382
|
164 void GameUI_DrawSaveMenu()
|
0
|
165 {
|
|
166 unsigned int v0; // ebp@4
|
|
167 unsigned int v1; // eax@4
|
|
168 char *v3; // eax@7
|
|
169 FILE *v4; // eax@11
|
|
170 FILE *v5; // eax@11
|
|
171 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1
|
|
172
|
|
173 ++pIcons_LOD->uTexturePacksCount;
|
|
174 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
175 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
176 memset(pSavegameUsedSlots, 0, 0xB4u);
|
|
177 memset(&pSavegameThumbnails, 0, 0x708u);
|
|
178 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
|
|
179 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
|
|
180 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
|
|
181 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
|
|
182 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
|
|
183 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
|
382
|
184 pRenderer->DrawTextureIndexed( 8u, 8u,
|
0
|
185 (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
|
151
|
186 if ( pCurrentScreen == SCREEN_SAVEGAME )
|
0
|
187 {
|
|
188 v0 = uTextureID_save_up;
|
|
189 v1 = uTextureID_LS_saveU;
|
|
190 }
|
|
191 else
|
|
192 {
|
|
193 v0 = uTextureID_load_up;
|
|
194 v1 = uTextureID_LS_loadU;
|
|
195 }
|
|
196 pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
|
382
|
197 pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu,
|
0
|
198 (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
|
|
199 pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
|
|
200 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
|
|
201 pRenderer->Present();
|
|
202 pSavegameList->Initialize(1u);
|
|
203 v11.AllocSubIndicesAndIO(0x12Cu, 0);
|
382
|
204 //v2 = pSavegameUsedSlots;
|
|
205 // Dest = pSavegameHeader;
|
|
206 // this_ = pSavegameThumbnails;
|
|
207 // v8 = (char *)pSavegameList->pSavesNames;
|
|
208 for (uint i = 0; i < 40; ++i)
|
|
209 {
|
|
210 v3 = pSavegameList->pFileList[i].pSaveFileName;
|
|
211 if ( !pSavegameList->pFileList[i].pSaveFileName )
|
0
|
212 v3 = "1.mm7";
|
|
213 sprintf(pTmpBuf, "saves\\%s", v3);
|
|
214 if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
|
|
215 {
|
382
|
216 pSavegameUsedSlots[i] = 0;
|
|
217 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]);
|
0
|
218 }
|
|
219 else
|
|
220 {
|
|
221 v11.LoadFile(pTmpBuf, 1);
|
|
222 v4 = v11.FindContainer("header.bin", 1);
|
382
|
223 fread(&pSavegameHeader[i], 100, 1u, v4);
|
0
|
224 v5 = v11.FindContainer("image.pcx", 1);
|
|
225 if ( v5 )
|
|
226 {
|
382
|
227 pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u);
|
0
|
228 v11.CloseWriteFile();
|
382
|
229 pSavegameUsedSlots[i] = 1;
|
0
|
230 }
|
|
231 else
|
|
232 {
|
382
|
233 pSavegameUsedSlots[i] = 0;
|
0
|
234 }
|
|
235 }
|
382
|
236
|
0
|
237 }
|
382
|
238
|
0
|
239 v11.FreeSubIndexAndIO();
|
|
240 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
241 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
|
|
242 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
|
|
243 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
|
|
244 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0);
|
|
245 pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, "", 0);
|
|
246 pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, "", 0);
|
|
247 pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, "", 0);
|
|
248 pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, "", 0);
|
|
249 pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, "", 0);
|
|
250 pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, "", 0);
|
|
251 pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, "", 0);
|
2
|
252 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, 0xA4u, 0, 0, "",
|
|
253 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
|
|
254 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, 0xA6u, 0, 0, "",
|
|
255 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
|
|
256 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, 0xA2u, 0, 0, "",
|
|
257 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
|
|
258 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, 0xA3u, 0x22u, 0, "",
|
|
259 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
|
0
|
260 } |