comparison Game/MainMenuLoad.cpp @ 2558:5d6fb8eb023c

Слияние
author Ritor1
date Wed, 13 May 2015 20:09:12 +0600
parents 48708da03b7f
children d87bfbd3bb3b
comparison
equal deleted inserted replaced
2557:bbef1435eb8d 2558:5d6fb8eb023c
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, &param, &param2);
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 current_screen_type = SCREEN_LOADGAME;
115
116 main_menu_background.Release();
117 main_menu_background.Load("lsave640.pcx", 0);
118
119 //LoadUI_Load(0);
120 pGUIWindow_CurrentMenu = new GUIWindow_Load(false);
121
122
123 while (GetCurrentMenuID() == MENU_SAVELOAD && current_screen_type == SCREEN_LOADGAME)
124 {
125 MSG msg;
126 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
127 {
128 if (msg.message == WM_QUIT)
129 Engine_DeinitializeAndTerminate(0);
130 TranslateMessage(&msg);
131 DispatchMessageW(&msg);
132 }
133 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
134 {
135 WaitMessage();
136 continue;
137 }
138
139 pRenderer->BeginScene();
140 pRenderer->DrawTextureNew(0, 0, &main_menu_background);
141
142 MainMenuLoad_EventLoop();
143 GUI_UpdateWindows();
144
145 pRenderer->EndScene();
146 pRenderer->Present();
147 }
148
149 pGUIWindow_CurrentMenu->Release();
150 pGUIWindow_CurrentMenu = nullptr;
151 }