Mercurial > mm7
annotate Game/MainMenu.cpp @ 2546:4087cbc62706
GameMenu logic moved to GUIWindow_GameMenu
the same for game menu options
author | a.parshin |
---|---|
date | Mon, 11 May 2015 17:45:02 +0200 |
parents | c674d547cc7c |
children | fed97f15d1e1 |
rev | line source |
---|---|
2541 | 1 #include "Engine/Engine.h" |
2 #include "Engine/Timer.h" | |
3 #include "Engine/Party.h" | |
4 #include "Engine/LOD.h" | |
5 #include "Engine/SaveLoad.h" | |
6 #include "Engine/Graphics/IRender.h" | |
7 #include "Engine/Graphics/Viewport.h" | |
8 | |
9 #include "IO/Mouse.h" | |
10 #include "IO/Keyboard.h" | |
11 | |
12 #include "GUI/GUIWindow.h" | |
13 #include "GUI/GUIButton.h" | |
14 #include "GUI/UI/UIPartyCreation.h" | |
15 | |
16 #include "Media/Audio/AudioPlayer.h" | |
17 | |
18 #include "Game/MainMenu.h" | |
19 | |
20 | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
21 GUIButton *pMainMenu_BtnExit = nullptr; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
22 GUIButton *pMainMenu_BtnCredits = nullptr; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
23 GUIButton *pMainMenu_BtnLoad = nullptr; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
24 GUIButton *pMainMenu_BtnNew = nullptr; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
25 |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
26 RGBTexture main_menu_background; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
27 |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
28 |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
29 |
2541 | 30 //----- (00435748) -------------------------------------------------------- |
31 void MainMenu_EventLoop() | |
32 { | |
33 Player *pPlayer; // ebx@2 | |
34 void *v3; // edi@21 | |
35 signed int v4; // eax@29 | |
36 // int v5; // ecx@29 | |
37 // PLAYER_SKILL_TYPE v6; // edi@37 | |
38 GUIWindow *pWindow; // eax@56 | |
39 GUIButton *pButton; // eax@59 | |
40 int v15; // edi@70 | |
41 char v20; // dl@116 | |
42 unsigned int v21; // eax@116 | |
43 unsigned int v25; // eax@120 | |
44 unsigned int v26; // ecx@127 | |
45 // SoundID pSoundID; // [sp-2Ch] [bp-3Ch]@36 | |
46 // signed int v41; // [sp-10h] [bp-20h]@29 | |
47 int pParam; // [sp+4h] [bp-Ch]@3 | |
48 UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3 | |
49 int pSex; // [sp+Ch] [bp-4h]@3 | |
50 | |
51 if (pMessageQueue_50CBD0->uNumMessages) | |
52 { | |
53 pPlayer = pParty->pPlayers.data(); | |
54 do | |
55 { | |
56 int param2; | |
57 pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, ¶m2); | |
58 //auto player = &pParty->pPlayers[pParam]; | |
59 | |
60 switch (pUIMessageType) // For buttons of window MainMenu | |
61 { | |
62 case UIMSG_MainMenu_ShowPartyCreationWnd: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
63 new OnButtonClick2(495, 172, 0, 0, (int)pMainMenu_BtnNew, 0); |
2541 | 64 SetCurrentMenuID(MENU_NEWGAME); |
65 break; | |
66 case UIMSG_MainMenu_ShowLoadWindow: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
67 new OnButtonClick2(495, 227, 0, 0, (int)pMainMenu_BtnLoad, 0); |
2541 | 68 SetCurrentMenuID(MENU_SAVELOAD); |
69 break; | |
70 case UIMSG_ShowCredits: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
71 new OnButtonClick2(495, 282, 0, 0, (int)pMainMenu_BtnCredits, 0); |
2541 | 72 SetCurrentMenuID(MENU_CREDITS); |
73 break; | |
74 case UIMSG_ExitToWindows: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
75 new OnButtonClick2(495, 337, 0, 0, (int)pMainMenu_BtnExit, 0); |
2541 | 76 SetCurrentMenuID(MENU_EXIT_GAME); |
77 break; | |
78 case UIMSG_PlayerCreation_SelectAttribute: | |
79 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) | |
80 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; | |
81 uPlayerCreationUI_SelectedCharacter = pParam; | |
82 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); | |
83 break; | |
84 case UIMSG_PlayerCreation_VoicePrev: | |
85 pSex = pParty->pPlayers[pParam].GetSexByVoice(); | |
86 do | |
87 { | |
88 if (pParty->pPlayers[pParam].uVoiceID == 0) | |
89 pParty->pPlayers[pParam].uVoiceID = 19; | |
90 else --pParty->pPlayers[pParam].uVoiceID; | |
91 } while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); | |
92 pButton = pCreationUI_BtnPressLeft2[pParam]; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
93 new OnButtonClick(pButton->uX, pButton->uY, 0, 0, (int)pButton, (char *)1); |
2541 | 94 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); |
95 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); | |
96 break; | |
97 case UIMSG_PlayerCreation_VoiceNext: | |
98 pSex = pParty->pPlayers[pParam].GetSexByVoice(); | |
99 do | |
100 { | |
101 pParty->pPlayers[pParam].uVoiceID = (pParty->pPlayers[pParam].uVoiceID + 1) % 20; | |
102 } while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); | |
103 pButton = pCreationUI_BtnPressRight2[pParam]; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
104 new OnButtonClick(pButton->uX, pButton->uY, 0, 0, (int)pButton, (char *)1); |
2541 | 105 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); |
106 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); | |
107 break; | |
108 case UIMSG_PlayerCreation_FacePrev: | |
109 //pPlayer = &pParty->pPlayers[pParam]; | |
110 if (!pParty->pPlayers[pParam].uCurrentFace) | |
111 pParty->pPlayers[pParam].uCurrentFace = 19; | |
112 else | |
113 pParty->pPlayers[pParam].uCurrentFace -= 1; | |
114 pParty->pPlayers[pParam].uVoiceID = pParty->pPlayers[pParam].uCurrentFace; | |
115 pParty->pPlayers[pParam].SetInitialStats(); | |
116 pParty->pPlayers[pParam].SetSexByVoice(); | |
117 pParty->pPlayers[pParam].RandomizeName(); | |
118 v25 = pParam; | |
119 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) | |
120 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; | |
121 uPlayerCreationUI_SelectedCharacter = v25; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
122 new OnButtonClick(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, (int)pCreationUI_BtnPressLeft[v25], (char *)1); |
2541 | 123 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0.0, 0); |
124 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); | |
125 break; | |
126 case UIMSG_PlayerCreation_FaceNext: | |
127 //pPlayer = &pParty->pPlayers[pParam]; | |
128 v20 = (char)((int)pParty->pPlayers[pParam].uCurrentFace + 1) % 20; | |
129 pParty->pPlayers[pParam].uCurrentFace = v20; | |
130 pParty->pPlayers[pParam].uVoiceID = v20; | |
131 pParty->pPlayers[pParam].SetInitialStats(); | |
132 pParty->pPlayers[pParam].SetSexByVoice(); | |
133 pParty->pPlayers[pParam].RandomizeName(); | |
134 v21 = pParam; | |
135 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) | |
136 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; | |
137 uPlayerCreationUI_SelectedCharacter = v21; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
138 new OnButtonClick(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, (int)pCreationUI_BtnPressRight[v21], (char *)1); |
2541 | 139 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); |
140 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); | |
141 break; | |
142 case UIMSG_PlayerCreationClickPlus: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
143 new OnButtonClick2(613, 393, 0, 0, (int)pPlayerCreationUI_BtnPlus, (char *)1); |
2541 | 144 pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); |
145 pAudioPlayer->PlaySound(SOUND_ClickMinus, 0, 0, -1, 0, 0, 0, 0); | |
146 break; | |
147 case UIMSG_PlayerCreationClickMinus: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
148 new OnButtonClick2(523, 393, 0, 0, (int)pPlayerCreationUI_BtnMinus, (char *)1); |
2541 | 149 pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); |
150 pAudioPlayer->PlaySound(SOUND_ClickPlus, 0, 0, -1, 0, 0, 0, 0); | |
151 break; | |
152 case UIMSG_PlayerCreationSelectActiveSkill: | |
153 if (pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(3) == 37) | |
154 pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pParam + 4)] = 1; | |
155 pAudioPlayer->PlaySound(SOUND_ClickSkill, 0, 0, -1, 0, 0, 0, 0); | |
156 break; | |
157 case UIMSG_PlayerCreationSelectClass: | |
158 pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)pParam); | |
159 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); | |
160 break; | |
161 case UIMSG_PlayerCreationClickOK: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
162 new OnButtonClick2(580, 431, 0, 0, (int)pPlayerCreationUI_BtnOK, 0); |
2541 | 163 if (PlayerCreation_GetUnspentAttributePointCount() || !PlayerCreation_Choose4Skills()) |
164 GameUI_Footer_TimeLeft = GetTickCount() + 4000; | |
165 else | |
166 uGameState = GAME_STATE_STARTING_NEW_GAME; | |
167 break; | |
168 case UIMSG_PlayerCreationClickReset: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
169 new OnButtonClick2(527, 431, 0, 0, (int)pPlayerCreationUI_BtnReset, 0); |
2541 | 170 pParty->Reset(); |
171 break; | |
172 case UIMSG_PlayerCreationRemoveUpSkill: | |
173 v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem; | |
174 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; | |
175 if (pPlayer[pParam].GetSkillIdxByOrder(2) != 37)//37 - None(Íåò) | |
176 pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(2)] = 0; | |
177 break; | |
178 case UIMSG_PlayerCreationRemoveDownSkill: | |
179 v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem; | |
180 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; | |
181 if (pPlayer[pParam].GetSkillIdxByOrder(3) != 37)//37 - None(Íåò) | |
182 pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(3)] = 0; | |
183 break; | |
184 case UIMSG_PlayerCreationChangeName: | |
185 pAudioPlayer->PlaySound(SOUND_ClickSkill, 0, 0, -1, 0, 0, 0, 0); | |
186 v3 = (void *)pParam; | |
187 uPlayerCreationUI_SelectedCharacter = pParam; | |
188 pKeyActionMap->EnterText(0, 15, pGUIWindow_CurrentMenu); | |
189 pGUIWindow_CurrentMenu->ptr_1C = v3; | |
190 break; | |
191 case UIMSG_ChangeGameState: | |
192 uGameState = GAME_FINISHED; | |
193 break; | |
194 case UIMSG_ChangeCursor: | |
195 pMouse->SetCursorBitmap("MICON2"); | |
196 break; | |
197 case UIMSG_3A: | |
198 SetCurrentMenuID(MENU_DebugBLVLevel); | |
199 break; | |
200 case UIMSG_LoadGame: | |
201 if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot]) | |
202 break; | |
203 SetCurrentMenuID(MENU_LoadingProcInMainMenu); | |
204 break; | |
205 case UIMSG_SelectLoadSlot: | |
206 //main menu save/load wnd clicking on savegame lines | |
207 if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) | |
208 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); | |
209 if (current_screen_type != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pParam + pSaveListPosition) | |
210 { | |
211 //load clicked line | |
212 v26 = pParam + pSaveListPosition; | |
213 if (dword_6BE138 == pParam + pSaveListPosition) | |
214 { | |
215 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0); | |
216 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0); | |
217 } | |
218 uLoadGameUI_SelectedSlot = v26; | |
219 dword_6BE138 = v26; | |
220 } | |
221 else | |
222 { | |
223 //typing in the line | |
224 pKeyActionMap->EnterText(0, 19, pGUIWindow_CurrentMenu); | |
225 strcpy(pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); | |
226 pKeyActionMap->uNumKeysPressed = strlen(pKeyActionMap->pPressedKeysBuffer); | |
227 } | |
228 break; | |
229 case UIMSG_SaveLoadBtn: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
230 new OnSaveLoad(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnLoadSlot, 0); |
2541 | 231 break; |
232 case UIMSG_DownArrow: | |
233 ++pSaveListPosition; | |
234 if (pSaveListPosition >= pParam) | |
235 pSaveListPosition = pParam - 1; | |
236 if (pSaveListPosition < 1) | |
237 pSaveListPosition = 0; | |
238 pWindow = pGUIWindow_CurrentMenu; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
239 new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, (int)pBtnDownArrow, 0); |
2541 | 240 break; |
241 case UIMSG_Cancel: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
242 new OnCancel3(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnCancel, 0); |
2541 | 243 break; |
244 case UIMSG_ArrowUp: | |
245 --pSaveListPosition; | |
246 if (pSaveListPosition < 0) | |
247 pSaveListPosition = 0; | |
248 pWindow = pGUIWindow_CurrentMenu; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
249 new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, (int)pBtnArrowUp, 0); |
2541 | 250 break; |
251 case UIMSG_AD: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
252 new OnButtonClick2(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (int)pMainMenu_BtnNew, 0); |
2541 | 253 SetCurrentMenuID(MENU_LoadingProcInMainMenu); |
254 break; | |
255 case UIMSG_AE: | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
256 new OnButtonClick2(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (int)pMainMenu_BtnExit, 0); |
2541 | 257 SetCurrentMenuID(MENU_DebugBLVLevel); |
258 break; | |
259 case UIMSG_Escape: | |
260 if (pModalWindow) | |
261 { | |
262 ModalWindow_Release(); | |
263 break; | |
264 } | |
265 if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_4000)) | |
266 break; | |
267 v15 = 1; | |
268 pMediaPlayer->bStopBeforeSchedule = 1; | |
269 viewparams->bRedrawGameUI = 1; | |
270 viewparams->field_48 = 1; | |
271 if (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_MMT_MAIN_MENU | |
272 || GetCurrentMenuID() == MENU_CREATEPARTY || GetCurrentMenuID() == MENU_NAMEPANELESC) | |
273 { | |
274 //if ( current_screen_type == SCREEN_VIDEO ) | |
275 //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); | |
276 if (GetCurrentMenuID() == MENU_NAMEPANELESC) //èç ïàíåëè èçìåíåíèÿ èìåíè | |
277 { | |
278 SetCurrentMenuID(MENU_CREATEPARTY);//â îêíî ñîçäàíèÿ ãðóïïû | |
279 break; | |
280 } | |
281 if (GetCurrentMenuID() == MENU_CREDITSPROC) //èç îêíà Ñîçäàòåëè | |
282 { | |
283 SetCurrentMenuID(MENU_CREDITSCLOSE);//â çàêðûòèå Ñîçäàòåëè | |
284 break; | |
285 } | |
286 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); | |
287 break; | |
288 } | |
289 if (GetCurrentMenuID() == MENU_CREDITSPROC && !current_screen_type) | |
290 { | |
291 //if ( current_screen_type == SCREEN_VIDEO ) | |
292 //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); | |
293 if (GetCurrentMenuID() == MENU_NAMEPANELESC) | |
294 { | |
295 SetCurrentMenuID(MENU_CREATEPARTY); | |
296 break; | |
297 } | |
298 if (GetCurrentMenuID() == MENU_CREDITSPROC) | |
299 { | |
300 SetCurrentMenuID(MENU_CREDITSCLOSE); | |
301 break; | |
302 } | |
303 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); | |
304 break; | |
305 } | |
306 if (current_screen_type == SCREEN_LOADGAME) | |
307 { | |
308 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
309 //crt_deconstruct_ptr_6A0118(); | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
310 main_menu_background.Release(); |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
311 main_menu_background.Load("title.pcx", 0); |
2541 | 312 SetCurrentMenuID(MENU_MAIN); |
313 v15 = 1; | |
314 pGUIWindow_CurrentMenu->Release(); | |
315 pGUIWindow2->Release(); | |
316 pGUIWindow2 = 0; | |
317 pEventTimer->Resume(); | |
318 current_screen_type = SCREEN_GAME; | |
319 viewparams->bRedrawGameUI = v15; | |
320 break; | |
321 } | |
322 if (current_screen_type == SCREEN_VIDEO) | |
323 { | |
324 //pVideoPlayer->Unload(); | |
325 } | |
326 else | |
327 { | |
328 if (current_screen_type != SCREEN_1B) | |
329 { | |
330 pGUIWindow_CurrentMenu->Release(); | |
331 pGUIWindow2->Release(); | |
332 pGUIWindow2 = 0; | |
333 pEventTimer->Resume(); | |
334 current_screen_type = SCREEN_GAME; | |
335 viewparams->bRedrawGameUI = v15; | |
336 break; | |
337 } | |
338 //VideoPlayer::dtor(); | |
339 } | |
340 break; | |
341 default: | |
342 break; | |
343 } | |
344 } while (pMessageQueue_50CBD0->uNumMessages); | |
345 } | |
346 } | |
347 | |
348 | |
349 //----- (004627B7) -------------------------------------------------------- | |
350 void MainMenu_Loop() | |
351 { | |
352 GUIButton *pButton; // eax@27 | |
353 unsigned int pControlParam; // ecx@35 | |
354 unsigned int pY; // [sp-18h] [bp-54h]@39 | |
355 Texture *pTexture; // [sp-14h] [bp-50h]@39 | |
356 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 | |
357 MSG msg; | |
358 | |
359 current_screen_type = SCREEN_GAME; | |
360 | |
361 pGUIWindow2 = 0; | |
362 pAudioPlayer->StopChannels(-1, -1); | |
363 pMouse->RemoveHoldingItem(); | |
364 | |
365 pIcons_LOD->_inlined_sub2(); | |
366 | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
367 pWindow_MainMenu = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0); |
2541 | 368 Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); |
369 Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); | |
370 Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); | |
371 Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); | |
372 | |
373 pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); | |
374 pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); | |
375 pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); | |
376 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); | |
377 | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
378 main_menu_background.Release(); |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
379 main_menu_background.Load("title.pcx", 0); |
2541 | 380 SetCurrentMenuID(MENU_MAIN); |
381 SetForegroundWindow(window->GetApiHandle()); | |
382 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); | |
383 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) | |
384 { | |
385 POINT pt; | |
386 pMouse->GetCursorPos(&pt); | |
387 pWindow = pWindow_MainMenu; | |
388 if (GetCurrentMenuID() == MENU_SAVELOAD) | |
389 { | |
390 if (current_screen_type != SCREEN_LOADGAME) | |
391 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
392 main_menu_background.Release(); |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
393 main_menu_background.Load("lsave640.pcx", 0); |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
394 pGUIWindow2 = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0); |
2541 | 395 current_screen_type = SCREEN_LOADGAME; |
396 LoadUI_Load(0); | |
397 } | |
398 pWindow = pGUIWindow_CurrentMenu; | |
399 } | |
400 | |
401 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) | |
402 { | |
403 if (msg.message == WM_QUIT) | |
404 Engine_DeinitializeAndTerminate(0); | |
405 TranslateMessage(&msg); | |
406 DispatchMessageW(&msg); | |
407 } | |
408 | |
409 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) | |
410 { | |
411 WaitMessage(); | |
412 continue; | |
413 } | |
414 | |
415 pRenderer->BeginScene(); | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
416 pRenderer->DrawTextureNew(0, 0, &main_menu_background); |
2541 | 417 |
418 MainMenu_EventLoop(); | |
419 GUI_UpdateWindows(); | |
420 | |
421 if (GetCurrentMenuID() != MENU_MAIN) | |
422 { | |
423 if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) | |
424 { | |
425 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
426 pGUIWindow_CurrentMenu->Release(); | |
427 pGUIWindow_CurrentMenu = 0; | |
428 current_screen_type = SCREEN_GAME; | |
429 viewparams->bRedrawGameUI = 1; | |
430 } | |
431 } | |
432 else | |
433 { | |
434 if (!pModalWindow)// ??? | |
435 { | |
436 pButton = pWindow->pControlsHead; | |
437 for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) | |
438 { | |
439 if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ | |
440 && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW | |
441 && pWindow == pWindow_MainMenu) | |
442 { | |
443 pControlParam = pButton->msg_param; | |
444 switch (pControlParam) // backlight for buttons | |
445 { | |
446 case 0: | |
447 pTexture = pNew; | |
448 pY = 172; | |
449 break; | |
450 case 1: | |
451 pTexture = pLoad; | |
452 pY = 227; | |
453 break; | |
454 case 2: | |
455 pTexture = pCredits; | |
456 pY = 282; | |
457 break; | |
458 case 3: | |
459 pTexture = pExit; | |
460 pY = 337; | |
461 break; | |
462 } | |
463 pRenderer->DrawTextureIndexed(495, pY, pTexture); | |
464 } | |
465 } | |
466 } | |
467 } | |
468 pRenderer->EndScene(); | |
469 pRenderer->Present(); | |
470 } | |
471 MainMenu_EventLoop(); | |
472 pRenderer->BeginScene(); | |
473 GUI_UpdateWindows(); | |
474 pRenderer->EndScene(); | |
475 pRenderer->Present(); | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
476 main_menu_background.Release(); |
2541 | 477 if (pGUIWindow2) |
478 { | |
479 pGUIWindow2->Release(); | |
480 pGUIWindow2 = 0; | |
481 } | |
482 pWindow_MainMenu->Release(); | |
483 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
484 } |