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 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));
|
151
|
51 if ( pCurrentScreen == SCREEN_SAVEGAME )
|
0
|
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);
|
2
|
74 if ( pSaveListPosition > (signed int)uNumSavegameFiles )
|
0
|
75 {
|
2
|
76 pSaveListPosition = 0;
|
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 {
|
423
|
84
|
382
|
85 sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName);
|
0
|
86 if (_access(pTmpBuf, 6))
|
|
87 {
|
|
88 pSavegameUsedSlots[i] = 0;
|
|
89 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
|
|
90 continue;
|
|
91 }
|
|
92 pLODFile.LoadFile(pTmpBuf, 1);
|
|
93 v4 = pLODFile.FindContainer("header.bin", true);
|
|
94 if ( v4 )
|
|
95 fread(&pSavegameHeader[i], 0x64, 1, v4);
|
382
|
96 if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
|
43
|
97 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
|
4
|
98 v5 = pLODFile.FindContainer("image.pcx", true);
|
0
|
99 if ( !v5 )
|
|
100 {
|
|
101 pSavegameUsedSlots[i] = 0;
|
382
|
102 strcpy(pSavegameList->pFileList[i].pSaveFileName, "");
|
0
|
103 }
|
|
104 else
|
|
105 {
|
|
106 pSavegameThumbnails[i].LoadFromFILE(v5, 0, true);
|
|
107 pLODFile.CloseWriteFile();
|
|
108 pSavegameUsedSlots[i] = 1;
|
|
109 }
|
|
110 }
|
|
111
|
|
112 //LABEL_24:
|
|
113 pLODFile.FreeSubIndexAndIO();
|
151
|
114 if ( pCurrentScreen == SCREEN_SAVEGAME )
|
0
|
115 {
|
423
|
116 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
117 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE);
|
0
|
118 }
|
|
119 else
|
|
120 {
|
423
|
121 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
122 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE);
|
0
|
123 }
|
|
124 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
|
|
125 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
|
|
126 pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, 0xA5, 0, 0, "", 0);
|
|
127 pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, 0xA5, 1, 0, "", 0);
|
|
128 pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, 0xA5, 2, 0, "", 0);
|
|
129 pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, 0xA5, 3, 0, "", 0);
|
|
130 pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, 0xA5, 4, 0, "", 0);
|
|
131 pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, 0xA5, 5, 0, "", 0);
|
|
132 pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, 0xA5, 6, 0, "", 0);
|
2
|
133 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, 0xA4, 0, 0, "",
|
0
|
134 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
|
2
|
135 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, 0xA6, 0, 0, "",
|
0
|
136 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
|
2
|
137 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, 0xA2, 0, 0, "",
|
0
|
138 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
|
2
|
139 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, 0xA3, uNumSavegameFiles, 0, "",
|
0
|
140 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
|
423
|
141
|
0
|
142 }
|
|
143
|
|
144 //----- (0045E93E) --------------------------------------------------------
|
382
|
145 void GameUI_DrawSaveMenu()
|
0
|
146 {
|
|
147 unsigned int v0; // ebp@4
|
|
148 unsigned int v1; // eax@4
|
|
149 char *v3; // eax@7
|
|
150 FILE *v4; // eax@11
|
|
151 FILE *v5; // eax@11
|
|
152 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1
|
|
153
|
|
154 ++pIcons_LOD->uTexturePacksCount;
|
|
155 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
156 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
|
157 memset(pSavegameUsedSlots, 0, 0xB4u);
|
|
158 memset(&pSavegameThumbnails, 0, 0x708u);
|
|
159 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
|
|
160 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
|
|
161 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
|
|
162 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
|
|
163 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
|
|
164 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
|
382
|
165 pRenderer->DrawTextureIndexed( 8u, 8u,
|
0
|
166 (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
|
151
|
167 if ( pCurrentScreen == SCREEN_SAVEGAME )
|
0
|
168 {
|
|
169 v0 = uTextureID_save_up;
|
|
170 v1 = uTextureID_LS_saveU;
|
|
171 }
|
|
172 else
|
|
173 {
|
|
174 v0 = uTextureID_load_up;
|
|
175 v1 = uTextureID_LS_loadU;
|
|
176 }
|
|
177 pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
|
382
|
178 pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu,
|
0
|
179 (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
|
|
180 pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
|
|
181 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
|
|
182 pRenderer->Present();
|
|
183 pSavegameList->Initialize(1u);
|
|
184 v11.AllocSubIndicesAndIO(0x12Cu, 0);
|
382
|
185 //v2 = pSavegameUsedSlots;
|
|
186 // Dest = pSavegameHeader;
|
|
187 // this_ = pSavegameThumbnails;
|
|
188 // v8 = (char *)pSavegameList->pSavesNames;
|
|
189 for (uint i = 0; i < 40; ++i)
|
|
190 {
|
|
191 v3 = pSavegameList->pFileList[i].pSaveFileName;
|
556
|
192 if ( !*pSavegameList->pFileList[i].pSaveFileName )
|
0
|
193 v3 = "1.mm7";
|
|
194 sprintf(pTmpBuf, "saves\\%s", v3);
|
|
195 if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
|
|
196 {
|
382
|
197 pSavegameUsedSlots[i] = 0;
|
|
198 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]);
|
0
|
199 }
|
|
200 else
|
|
201 {
|
|
202 v11.LoadFile(pTmpBuf, 1);
|
|
203 v4 = v11.FindContainer("header.bin", 1);
|
382
|
204 fread(&pSavegameHeader[i], 100, 1u, v4);
|
0
|
205 v5 = v11.FindContainer("image.pcx", 1);
|
|
206 if ( v5 )
|
|
207 {
|
382
|
208 pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u);
|
0
|
209 v11.CloseWriteFile();
|
382
|
210 pSavegameUsedSlots[i] = 1;
|
0
|
211 }
|
|
212 else
|
|
213 {
|
382
|
214 pSavegameUsedSlots[i] = 0;
|
0
|
215 }
|
|
216 }
|
382
|
217
|
0
|
218 }
|
382
|
219
|
0
|
220 v11.FreeSubIndexAndIO();
|
|
221 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
|
|
222 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
|
|
223 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
|
|
224 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
|
|
225 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0);
|
|
226 pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, "", 0);
|
|
227 pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, "", 0);
|
|
228 pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, "", 0);
|
|
229 pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, "", 0);
|
|
230 pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, "", 0);
|
|
231 pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, "", 0);
|
|
232 pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, "", 0);
|
2
|
233 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, 0xA4u, 0, 0, "",
|
|
234 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
|
|
235 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, 0xA6u, 0, 0, "",
|
|
236 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
|
|
237 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, 0xA2u, 0, 0, "",
|
|
238 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
|
|
239 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, 0xA3u, 0x22u, 0, "",
|
|
240 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
|
0
|
241 } |