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