comparison GUI/UI/UISaveLoad.cpp @ 2547:fed97f15d1e1

* SaveLoad * QuickReference * Modal * Character
author a.parshin
date Tue, 12 May 2015 01:45:31 +0200
parents c674d547cc7c
children d87bfbd3bb3b
comparison
equal deleted inserted replaced
2546:4087cbc62706 2547:fed97f15d1e1
1 #define _CRTDBG_MAP_ALLOC 1 #define _CRTDBG_MAP_ALLOC
2 #define _CRT_SECURE_NO_WARNINGS
2 #include <stdlib.h> 3 #include <stdlib.h>
3 #include <crtdbg.h> 4 #include <crtdbg.h>
4
5 #define _CRT_SECURE_NO_WARNINGS
6 #include <io.h> 5 #include <io.h>
7 6
8 #include "Engine/Engine.h" 7 #include "Engine/Engine.h"
9 8 #include "Engine/MapInfo.h"
10 #include "..\../IO/Keyboard.h" 9 #include "Engine/Graphics/Render.h"
11 10 #include "Engine/LOD.h"
12 #include "..\../Engine/MapInfo.h" 11 #include "Engine/SaveLoad.h"
13 #include "..\../GUI/GUIWindow.h" 12 #include "Engine/texts.h"
14 #include "..\../GUI/GUIFont.h" 13
15 #include "..\../Engine/Graphics/Render.h" 14 #include "IO/Keyboard.h"
16 #include "..\../Engine/LOD.h" 15
17 #include "..\../Engine/SaveLoad.h" 16 #include "GUI/GUIFont.h"
18 #include "..\../Engine/texts.h" 17 #include "GUI/UI/UISaveLoad.h"
19 18
20 #include "Game/MainMenu.h" 19 #include "Game/MainMenu.h"
20
21 void UI_DrawSaveLoad(bool save);
22
23
24 GUIWindow_Save::GUIWindow_Save() :
25 GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr)
26 {
27 // ------------------------------------------------
28 // 0045E93E SaveUI_Load(enum CURRENT_SCREEN screen)
29 char *v3; // eax@7
30 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1
31
32 ++pIcons_LOD->uTexturePacksCount;
33 if (!pIcons_LOD->uNumPrevLoadedFiles)
34 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
35 memset(&pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots));
36 memset(&pSavegameThumbnails, 0, sizeof(pSavegameThumbnails));
37 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
38 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
39 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
40 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
41 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
42 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
43 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
44
45 //if (screen == SCREEN_SAVEGAME)
46 {
47 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU));
48 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
49 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
50 }
51 /*else
52 {
53 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_loadU));
54 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
55 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_load_up));
56 }*/
57
58 //pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);//Read...(Чтение...)
59 pRenderer->Present();
60 pSavegameList->Initialize(1);
61 pLODFile.AllocSubIndicesAndIO(300, 0);
62 for (uint i = 0; i < 40; ++i)
63 {
64 v3 = pSavegameList->pFileList[i].pSaveFileName;
65 if (!*pSavegameList->pFileList[i].pSaveFileName)
66 v3 = "1.mm7";
67 sprintf(pTmpBuf.data(), "saves\\%s", v3);
68 if (_access(pTmpBuf.data(), 0) || _access(pTmpBuf.data(), 6))
69 {
70 pSavegameUsedSlots[i] = 0;
71 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]);
72 }
73 else
74 {
75 pLODFile.LoadFile(pTmpBuf.data(), 1);
76 fread(&pSavegameHeader[i], 100, 1, pLODFile.FindContainer("header.bin", 1));
77 if (pLODFile.FindContainer("image.pcx", 1))
78 {
79 pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", 1), 0, 1);
80 pLODFile.CloseWriteFile();
81 pSavegameUsedSlots[i] = 1;
82 }
83 else
84 pSavegameUsedSlots[i] = 0;
85 }
86 }
87 pLODFile.FreeSubIndexAndIO();
88 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
89 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
90 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
91 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
92
93 // -----------------------------
94 // GUIWindow_Save c-tor --- part
95 CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
96 CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
97 CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
98 CreateButton(21, 258, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
99 CreateButton(21, 278, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
100 CreateButton(21, 298, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
101 CreateButton(21, 318, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
102 pBtnLoadSlot = CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
103 pBtnCancel = CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
104 pBtnArrowUp = CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
105 pBtnDownArrow = CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, 34, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
106 }
107
108
109 void GUIWindow_Save::Update()
110 {
111 // -----------------------------------
112 // 004156F0 GUI_UpdateWindows --- part
113 // {
114 // SaveUI_Draw();
115 // }
116
117 // ----- (004606FE) --------------------------------------------------------
118 // void SaveUI_Draw()
119 // {
120 UI_DrawSaveLoad(true);
121 }
122
123
124
125
126 GUIWindow_Load::GUIWindow_Load(bool ingame) :
127 GUIWindow(0, 0, 0, 0, 0, nullptr)
128 {
129 // ----- (0045E361) --------------------------------------------------------
130 // void LoadUI_Load(unsigned int uDialogueType)
131 // {
132 current_screen_type = SCREEN_LOADGAME;
133
134 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1
135
136 dword_6BE138 = -1;
137 pIcons_LOD->_inlined_sub2();
138
139 memset(pSavegameUsedSlots.data(), 0, sizeof(pSavegameUsedSlots));
140 memset(pSavegameThumbnails.data(), 0, 45 * sizeof(RGBTexture));
141 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
142 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
143 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
144 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
145 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
146 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
147 if (ingame)
148 {
149 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
150 if (current_screen_type == SCREEN_SAVEGAME)
151 {
152 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU));
153 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
154 }
155 else
156 {
157 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_loadU));
158 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_load_up));
159 }
160 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
161 }
162 else
163 pRenderer->DrawTextureNew(0, 0, &main_menu_background);
164
165
166 /*pGUIWindow_CurrentMenu = new GUIWindow_Load(
167 saveload_dlg_xs[uDialogueType],
168 saveload_dlg_ys[uDialogueType],
169 saveload_dlg_zs[uDialogueType],
170 saveload_dlg_ws[uDialogueType], 0, 0);*/
171
172 // GUIWindow::GUIWindow
173 this->uFrameX = saveload_dlg_xs[ingame ? 1 : 0];
174 this->uFrameY = saveload_dlg_ys[ingame ? 1 : 0];
175 this->uFrameWidth = saveload_dlg_zs[ingame ? 1 : 0];
176 this->uFrameHeight = saveload_dlg_ws[ingame ? 1 : 0];
177 this->uFrameZ = uFrameX + uFrameWidth - 1;
178 this->uFrameW = uFrameY + uFrameHeight - 1;
179
180
181
182 DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..."
183 pRenderer->Present();
184 pSavegameList->Initialize(0);
185 if (pSaveListPosition > (signed int)uNumSavegameFiles)
186 {
187 pSaveListPosition = 0;
188 uLoadGameUI_SelectedSlot = 0;
189 }
190 pLODFile.AllocSubIndicesAndIO(300, 0);
191 Assert(sizeof(SavegameHeader) == 100);
192 for (uint i = 0; i < uNumSavegameFiles; ++i)
193 {
194 sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[i].pSaveFileName);
195 if (_access(pTmpBuf.data(), 6))
196 {
197 pSavegameUsedSlots[i] = 0;
198 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
199 continue;
200 }
201 pLODFile.LoadFile(pTmpBuf.data(), 1);
202 if (pLODFile.FindContainer("header.bin", true))
203 fread(&pSavegameHeader[i], 100, 1, pLODFile.FindContainer("header.bin", true));
204 if (!_stricmp(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]))// "AutoSave.MM7"
205 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
206 if (!pLODFile.FindContainer("image.pcx", true))
207 {
208 pSavegameUsedSlots[i] = 0;
209 strcpy(pSavegameList->pFileList[i].pSaveFileName, "");
210 }
211 else
212 {
213 pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", true), 0, true);
214 pLODFile.CloseWriteFile();
215 pSavegameUsedSlots[i] = 1;
216 }
217 }
218
219 pLODFile.FreeSubIndexAndIO();
220 if (current_screen_type == SCREEN_SAVEGAME)
221 {
222 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
223 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
224 }
225 else
226 {
227 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
228 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD", TEXTURE_16BIT_PALETTE);
229 }
230 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
231 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
232 CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
233 CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
234 CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
235 CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
236 CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
237 CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
238 CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
239 pBtnLoadSlot = CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
240 pBtnCancel = CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
241 pBtnArrowUp = CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
242 pBtnDownArrow = CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
243 }
244
245
246 void GUIWindow_Load::Update()
247 {
248 // -----------------------------------
249 // 004156F0 GUI_UpdateWindows --- part
250 // {
251 // LoadUI_Draw();
252 // }
253
254 // ----- (004606F7) --------------------------------------------------------
255 // void LoadUI_Draw()
256 // {
257 UI_DrawSaveLoad(false);
258 }
21 259
22 260
23 //----- (004601B7) -------------------------------------------------------- 261 //----- (004601B7) --------------------------------------------------------
24 static void UI_DrawSaveLoad(bool save) 262 static void UI_DrawSaveLoad(bool save)
25 { 263 {
134 slot_Y += 21; 372 slot_Y += 21;
135 } 373 }
136 } 374 }
137 pRenderer->EndScene(); 375 pRenderer->EndScene();
138 } 376 }
139 // 6A0C9C: using guessed type int dword_6A0C9C;
140
141 //----- (004606F7) --------------------------------------------------------
142 void LoadUI_Draw()
143 {
144 UI_DrawSaveLoad(false);
145 }
146
147 //----- (004606FE) --------------------------------------------------------
148 void SaveUI_Draw()
149 {
150 UI_DrawSaveLoad(true);
151 }
152
153 //----- (0045E361) --------------------------------------------------------
154 void LoadUI_Load(unsigned int uDialogueType)
155 {
156 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1
157
158 dword_6BE138 = -1;
159 pIcons_LOD->_inlined_sub2();
160
161 memset(pSavegameUsedSlots.data(), 0, sizeof(pSavegameUsedSlots));
162 memset(pSavegameThumbnails.data(), 0, 45 * sizeof(RGBTexture));
163 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
164 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
165 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
166 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
167 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
168 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
169 if ( uDialogueType )
170 {
171 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
172 if ( current_screen_type == SCREEN_SAVEGAME )
173 {
174 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU));
175 pRenderer->DrawTextureIndexed( 18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
176 }
177 else
178 {
179 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_loadU));
180 pRenderer->DrawTextureIndexed( 18, 141, pIcons_LOD->GetTexture(uTextureID_load_up));
181 }
182 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
183 }
184 else
185 pRenderer->DrawTextureNew(0, 0, &main_menu_background);
186 pGUIWindow_CurrentMenu = new GUIWindow_Load(saveload_dlg_xs[uDialogueType], saveload_dlg_ys[uDialogueType], saveload_dlg_zs[uDialogueType],
187 saveload_dlg_ws[uDialogueType], 0, 0);
188 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..."
189 pRenderer->Present();
190 pSavegameList->Initialize(0);
191 if ( pSaveListPosition > (signed int)uNumSavegameFiles )
192 {
193 pSaveListPosition = 0;
194 uLoadGameUI_SelectedSlot = 0;
195 }
196 pLODFile.AllocSubIndicesAndIO(300, 0);
197 Assert(sizeof(SavegameHeader) == 100);
198 for (uint i = 0; i < uNumSavegameFiles; ++i)
199 {
200 sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[i].pSaveFileName);
201 if (_access(pTmpBuf.data(), 6))
202 {
203 pSavegameUsedSlots[i] = 0;
204 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
205 continue;
206 }
207 pLODFile.LoadFile(pTmpBuf.data(), 1);
208 if ( pLODFile.FindContainer("header.bin", true) )
209 fread(&pSavegameHeader[i], 100, 1, pLODFile.FindContainer("header.bin", true));
210 if ( !_stricmp(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
211 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
212 if ( !pLODFile.FindContainer("image.pcx", true) )
213 {
214 pSavegameUsedSlots[i] = 0;
215 strcpy(pSavegameList->pFileList[i].pSaveFileName, "");
216 }
217 else
218 {
219 pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", true), 0, true);
220 pLODFile.CloseWriteFile();
221 pSavegameUsedSlots[i] = 1;
222 }
223 }
224
225 pLODFile.FreeSubIndexAndIO();
226 if ( current_screen_type == SCREEN_SAVEGAME )
227 {
228 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
229 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE);
230 }
231 else
232 {
233 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
234 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE);
235 }
236 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
237 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
238 pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
239 pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
240 pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
241 pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
242 pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
243 pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
244 pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
245 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
246 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
247 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
248 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
249 }
250
251 //----- (0045E93E) --------------------------------------------------------
252 GUIWindow *SaveUI_Load(enum CURRENT_SCREEN screen)
253 {
254 char *v3; // eax@7
255 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1
256
257 ++pIcons_LOD->uTexturePacksCount;
258 if ( !pIcons_LOD->uNumPrevLoadedFiles )
259 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
260 memset(&pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots));
261 memset(&pSavegameThumbnails, 0, sizeof(pSavegameThumbnails));
262 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
263 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
264 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
265 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
266 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
267 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
268 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
269 if (screen == SCREEN_SAVEGAME)
270 {
271 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU));
272 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
273 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up));
274 }
275 else
276 {
277 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_loadU));
278 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
279 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_load_up));
280 }
281
282 //pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);//Read...(Чтение...)
283 pRenderer->Present();
284 pSavegameList->Initialize(1);
285 pLODFile.AllocSubIndicesAndIO(300, 0);
286 for (uint i = 0; i < 40; ++i)
287 {
288 v3 = pSavegameList->pFileList[i].pSaveFileName;
289 if ( !*pSavegameList->pFileList[i].pSaveFileName )
290 v3 = "1.mm7";
291 sprintf(pTmpBuf.data(), "saves\\%s", v3);
292 if ( _access(pTmpBuf.data(), 0) || _access(pTmpBuf.data(), 6) )
293 {
294 pSavegameUsedSlots[i] = 0;
295 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]);
296 }
297 else
298 {
299 pLODFile.LoadFile(pTmpBuf.data(), 1);
300 fread(&pSavegameHeader[i], 100, 1, pLODFile.FindContainer("header.bin", 1));
301 if ( pLODFile.FindContainer("image.pcx", 1) )
302 {
303 pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", 1), 0, 1);
304 pLODFile.CloseWriteFile();
305 pSavegameUsedSlots[i] = 1;
306 }
307 else
308 pSavegameUsedSlots[i] = 0;
309 }
310 }
311 pLODFile.FreeSubIndexAndIO();
312 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
313 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
314 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
315 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
316
317 auto wnd = new GUIWindow_Save(0, 0, window->GetWidth(), window->GetHeight(), 0, 0);
318 wnd->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
319 wnd->CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
320 wnd->CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
321 wnd->CreateButton(21, 258, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
322 wnd->CreateButton(21, 278, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
323 wnd->CreateButton(21, 298, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
324 wnd->CreateButton(21, 318, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
325 pBtnLoadSlot = wnd->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
326 pBtnCancel = wnd->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
327 pBtnArrowUp = wnd->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
328 pBtnDownArrow = wnd->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, 34, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
329
330 return wnd;
331 }