Mercurial > mm7
comparison GUI/UI/UISaveLoad.cpp @ 2541:a902abdfc7f2
1. Renamed class Game to class Engine.
2. Separated game logic as state of FSM from game logic as engine.
3. Found out that many UI screen initializers were optimized away, intially
they all returned newly created window as separate object like it is done
in CharacterUI_Initialize.
author | a.parshin |
---|---|
date | Sun, 10 May 2015 01:29:11 +0200 |
parents | 4cc81f981afb |
children | c674d547cc7c |
comparison
equal
deleted
inserted
replaced
2540:abc6a9d079b9 | 2541:a902abdfc7f2 |
---|---|
3 #include <crtdbg.h> | 3 #include <crtdbg.h> |
4 | 4 |
5 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
6 #include <io.h> | 6 #include <io.h> |
7 | 7 |
8 #include "..\../Engine/MM7.h" | 8 #include "Engine/Engine.h" |
9 #include "..\../Engine/ErrorHandling.h" | |
10 | 9 |
11 #include "..\../IO/Keyboard.h" | 10 #include "..\../IO/Keyboard.h" |
12 | 11 |
13 #include "..\../Engine/MapInfo.h" | 12 #include "..\../Engine/MapInfo.h" |
14 #include "..\../GUI/GUIWindow.h" | 13 #include "..\../GUI/GUIWindow.h" |
15 #include "..\../GUI/GUIFont.h" | 14 #include "..\../GUI/GUIFont.h" |
16 #include "..\../Engine/Graphics/Render.h" | 15 #include "..\../Engine/Graphics/Render.h" |
17 #include "..\../Engine/LOD.h" | 16 #include "..\../Engine/LOD.h" |
18 #include "..\../Engine/SaveLoad.h" | 17 #include "..\../Engine/SaveLoad.h" |
19 #include "..\../Engine/texts.h" | 18 #include "..\../Engine/texts.h" |
20 | |
21 #include "..\../Engine/mm7_data.h" | |
22 | |
23 #include "..\../Engine/Game.h" | |
24 | 19 |
25 | 20 |
26 //----- (004601B7) -------------------------------------------------------- | 21 //----- (004601B7) -------------------------------------------------------- |
27 static void UI_DrawSaveLoad(bool save) | 22 static void UI_DrawSaveLoad(bool save) |
28 { | 23 { |
170 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); | 165 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); |
171 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); | 166 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); |
172 if ( uDialogueType ) | 167 if ( uDialogueType ) |
173 { | 168 { |
174 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); | 169 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); |
175 if ( pCurrentScreen == SCREEN_SAVEGAME ) | 170 if ( current_screen_type == SCREEN_SAVEGAME ) |
176 { | 171 { |
177 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU)); | 172 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU)); |
178 pRenderer->DrawTextureIndexed( 18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); | 173 pRenderer->DrawTextureIndexed( 18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); |
179 } | 174 } |
180 else | 175 else |
224 pSavegameUsedSlots[i] = 1; | 219 pSavegameUsedSlots[i] = 1; |
225 } | 220 } |
226 } | 221 } |
227 | 222 |
228 pLODFile.FreeSubIndexAndIO(); | 223 pLODFile.FreeSubIndexAndIO(); |
229 if ( pCurrentScreen == SCREEN_SAVEGAME ) | 224 if ( current_screen_type == SCREEN_SAVEGAME ) |
230 { | 225 { |
231 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); | 226 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); |
232 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE); | 227 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE); |
233 } | 228 } |
234 else | 229 else |
250 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); | 245 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); |
251 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); | 246 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); |
252 } | 247 } |
253 | 248 |
254 //----- (0045E93E) -------------------------------------------------------- | 249 //----- (0045E93E) -------------------------------------------------------- |
255 void SaveUI_Load() | 250 GUIWindow *SaveUI_Load(enum CURRENT_SCREEN screen) |
256 { | 251 { |
257 char *v3; // eax@7 | 252 char *v3; // eax@7 |
258 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1 | 253 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1 |
259 | 254 |
260 ++pIcons_LOD->uTexturePacksCount; | 255 ++pIcons_LOD->uTexturePacksCount; |
267 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); | 262 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); |
268 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); | 263 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); |
269 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); | 264 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); |
270 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); | 265 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); |
271 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); | 266 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); |
272 if ( pCurrentScreen == SCREEN_SAVEGAME ) | 267 if (screen == SCREEN_SAVEGAME) |
273 { | 268 { |
274 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU)); | 269 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_saveU)); |
275 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u)); | 270 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u)); |
276 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); | 271 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); |
277 } | 272 } |
279 { | 274 { |
280 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_loadU)); | 275 pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(uTextureID_LS_loadU)); |
281 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u)); | 276 pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u)); |
282 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_load_up)); | 277 pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_load_up)); |
283 } | 278 } |
284 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);//Read...(Чтение...) | 279 |
280 //pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);//Read...(Чтение...) | |
285 pRenderer->Present(); | 281 pRenderer->Present(); |
286 pSavegameList->Initialize(1); | 282 pSavegameList->Initialize(1); |
287 pLODFile.AllocSubIndicesAndIO(300, 0); | 283 pLODFile.AllocSubIndicesAndIO(300, 0); |
288 for (uint i = 0; i < 40; ++i) | 284 for (uint i = 0; i < 40; ++i) |
289 { | 285 { |
313 pLODFile.FreeSubIndexAndIO(); | 309 pLODFile.FreeSubIndexAndIO(); |
314 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); | 310 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); |
315 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); | 311 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); |
316 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); | 312 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); |
317 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); | 313 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); |
318 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SaveLoadButtons, 0, 0); | 314 |
319 pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); | 315 auto wnd = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SaveLoadButtons, 0, 0); |
320 pGUIWindow_CurrentMenu->CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0); | 316 wnd->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); |
321 pGUIWindow_CurrentMenu->CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0); | 317 wnd->CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0); |
322 pGUIWindow_CurrentMenu->CreateButton(21, 258, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0); | 318 wnd->CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0); |
323 pGUIWindow_CurrentMenu->CreateButton(21, 278, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0); | 319 wnd->CreateButton(21, 258, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0); |
324 pGUIWindow_CurrentMenu->CreateButton(21, 298, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0); | 320 wnd->CreateButton(21, 278, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0); |
325 pGUIWindow_CurrentMenu->CreateButton(21, 318, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0); | 321 wnd->CreateButton(21, 298, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0); |
326 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0); | 322 wnd->CreateButton(21, 318, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0); |
327 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0); | 323 pBtnLoadSlot = wnd->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0); |
328 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); | 324 pBtnCancel = wnd->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0); |
329 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, 34, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); | 325 pBtnArrowUp = wnd->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); |
330 } | 326 pBtnDownArrow = wnd->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, 34, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); |
327 | |
328 return wnd; | |
329 } |