Mercurial > mm7
comparison Game/MainMenuLoad.cpp @ 2552:ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
author | a.parshin |
---|---|
date | Wed, 13 May 2015 01:33:20 +0200 |
parents | |
children | 48708da03b7f |
comparison
equal
deleted
inserted
replaced
2551:4008b2f34be0 | 2552:ac16f4a3a91e |
---|---|
1 #include "Engine/Engine.h" | |
2 #include "Engine/SaveLoad.h" | |
3 #include "Engine/LOD.h" | |
4 #include "Engine/Timer.h" | |
5 #include "Engine/Graphics/IRender.h" | |
6 #include "Engine/Graphics/Viewport.h" | |
7 | |
8 #include "IO/Keyboard.h" | |
9 | |
10 #include "GUI/UI/UISaveLoad.h" | |
11 | |
12 #include "Game/MainMenu.h" | |
13 #include "Game/MainMenuLoad.h" | |
14 | |
15 void MainMenuLoad_EventLoop() | |
16 { | |
17 while (pMessageQueue_50CBD0->uNumMessages) | |
18 { | |
19 UIMessageType msg; | |
20 int param, param2; | |
21 pMessageQueue_50CBD0->PopMessage(&msg, ¶m, ¶m2); | |
22 | |
23 switch (msg) | |
24 { | |
25 case UIMSG_LoadGame: | |
26 { | |
27 if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot]) | |
28 break; | |
29 SetCurrentMenuID(MENU_LoadingProcInMainMenu); | |
30 } | |
31 break; | |
32 | |
33 case UIMSG_SelectLoadSlot: | |
34 { | |
35 //main menu save/load wnd clicking on savegame lines | |
36 if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) | |
37 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); | |
38 if (current_screen_type != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != param + pSaveListPosition) | |
39 { | |
40 //load clicked line | |
41 int v26 = param + pSaveListPosition; | |
42 if (dword_6BE138 == v26) | |
43 { | |
44 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0); | |
45 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0); | |
46 } | |
47 uLoadGameUI_SelectedSlot = v26; | |
48 dword_6BE138 = v26; | |
49 } | |
50 else | |
51 { | |
52 //typing in the line | |
53 pKeyActionMap->EnterText(0, 19, pGUIWindow_CurrentMenu); | |
54 strcpy(pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); | |
55 pKeyActionMap->uNumKeysPressed = strlen(pKeyActionMap->pPressedKeysBuffer); | |
56 } | |
57 } | |
58 break; | |
59 | |
60 case UIMSG_SaveLoadBtn: | |
61 new OnSaveLoad(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnLoadSlot, 0); | |
62 break; | |
63 | |
64 | |
65 case UIMSG_DownArrow: | |
66 { | |
67 ++pSaveListPosition; | |
68 if (pSaveListPosition >= param) | |
69 pSaveListPosition = param - 1; | |
70 if (pSaveListPosition < 1) | |
71 pSaveListPosition = 0; | |
72 new OnButtonClick2(pGUIWindow_CurrentMenu->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, (int)pBtnDownArrow, 0); | |
73 } | |
74 break; | |
75 | |
76 | |
77 case UIMSG_ArrowUp: | |
78 { | |
79 --pSaveListPosition; | |
80 if (pSaveListPosition < 0) | |
81 pSaveListPosition = 0; | |
82 new OnButtonClick2(pGUIWindow_CurrentMenu->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, (int)pBtnArrowUp, 0); | |
83 } | |
84 break; | |
85 | |
86 case UIMSG_Cancel: | |
87 new OnCancel3(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnCancel, 0); | |
88 break; | |
89 | |
90 | |
91 case UIMSG_Escape: | |
92 { | |
93 viewparams->field_48 = 1; | |
94 //if (current_screen_type == SCREEN_LOADGAME) | |
95 { | |
96 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
97 //crt_deconstruct_ptr_6A0118(); | |
98 main_menu_background.Release(); | |
99 main_menu_background.Load("title.pcx", 0); | |
100 SetCurrentMenuID(MENU_MAIN); | |
101 current_screen_type = SCREEN_GAME; | |
102 pEventTimer->Resume(); | |
103 viewparams->bRedrawGameUI = true; | |
104 break; | |
105 } | |
106 } | |
107 break; | |
108 } | |
109 } | |
110 } | |
111 | |
112 void MainMenuLoad_Loop() | |
113 { | |
114 SetCurrentMenuID(MENU_SAVELOAD); | |
115 current_screen_type = SCREEN_LOADGAME; | |
116 | |
117 main_menu_background.Release(); | |
118 main_menu_background.Load("lsave640.pcx", 0); | |
119 | |
120 //LoadUI_Load(0); | |
121 pGUIWindow_CurrentMenu = new GUIWindow_Load(false); | |
122 | |
123 | |
124 while (GetCurrentMenuID() == MENU_SAVELOAD && current_screen_type == SCREEN_LOADGAME) | |
125 { | |
126 MSG msg; | |
127 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) | |
128 { | |
129 if (msg.message == WM_QUIT) | |
130 Engine_DeinitializeAndTerminate(0); | |
131 TranslateMessage(&msg); | |
132 DispatchMessageW(&msg); | |
133 } | |
134 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) | |
135 { | |
136 WaitMessage(); | |
137 continue; | |
138 } | |
139 | |
140 pRenderer->BeginScene(); | |
141 pRenderer->DrawTextureNew(0, 0, &main_menu_background); | |
142 | |
143 MainMenuLoad_EventLoop(); | |
144 GUI_UpdateWindows(); | |
145 | |
146 pRenderer->EndScene(); | |
147 pRenderer->Present(); | |
148 } | |
149 | |
150 pGUIWindow_CurrentMenu->Release(); | |
151 pGUIWindow_CurrentMenu = nullptr; | |
152 } |