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