World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
GameWindowHandler.cpp
См. документацию.
2 
3 #include "Arcomage/Arcomage.h"
4 
5 #include "Engine/Engine.h"
6 #include "Engine/IocContainer.h"
7 #include "Engine/Party.h"
8 #include "Engine/Time.h"
9 
12 #include "Engine/Graphics/Vis.h"
13 
14 #include "GUI/GUIWindow.h"
15 
16 #include "IO/Keyboard.h"
17 #include "IO/Mouse.h"
18 
20 #include "Media/MediaPlayer.h"
21 
23 
24 
28 
29 
30 GameWindowHandler::GameWindowHandler() {
32 }
33 
35  if (render) {
36  render->SavePCXScreenshot();
37  }
38 }
39 
42  return GUI_HandleHotkey(c);
43  }
44  return 0;
45 }
46 
53  } else {
55 
57 
59  UI_OnVkKeyDown(VK_SELECT);
60  }
61 
62  if (engine) {
63  engine->PickMouse(512.0, x, y, false, &vis_sprite_filter_3, &vis_door_filter);
64  }
65 
67  }
68 }
69 
76  } else {
78 
80 
81  if (engine) {
83  }
84 
86  }
87 }
88 
93  } else {
94  back_to_game();
95  }
96 }
97 
101  ArcomageGame::OnMouseClick(1, false);
102  } else {
103  back_to_game();
104  }
105 }
106 
110  } else {
111  OnMouseLeftClick(x, y);
112  }
113 }
114 
118  } else {
120  }
121 }
122 
123 void GameWindowHandler::OnMouseMove(int x, int y, bool left_button, bool right_button) {
126  ArcomageGame::OnMouseClick(0, left_button);
127  ArcomageGame::OnMouseClick(1, right_button);
128  } else {
129  if (mouse) {
130  mouse->SetMouseClick(x, y);
131  }
132  }
133 }
134 
135 void GameWindowHandler::OnVkDown(int vk, int vk_to_char) {
138  } else if (pArcomageGame->bGameInProgress) {
140 
141  set_stru1_field_8_InArcomage(vk_to_char);
142  if (vk == VK_ESCAPE) {
144  } else if (pArcomageGame->check_exit) {
147  }
148 
149  if (vk == VK_F3) {
150  OnScreenshot();
151  } else if (vk == VK_F4 && !pMovie_Track) {
154  }
155  } else {
157  if (vk == VK_RETURN) {
159  } else if (vk == VK_CONTROL) {
160  extern bool _507B98_ctrl_pressed;
161  _507B98_ctrl_pressed = true;
162  } else if (vk == VK_ESCAPE) {
163  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
164  } else if (vk == VK_F4 && !pMovie_Track) {
166  } else if (vk == VK_NUMPAD0) {
168  } else if (vk >= VK_LEFT && vk <= VK_DOWN) {
171  if (!viewparams->field_4C) {
172  UI_OnVkKeyDown(vk);
173  }
174  }
175  }
176  }
177 }
178 
180  __debugbreak();
181 }
182 
184  __debugbreak();
185 }
186 
190  }
191  if (render && render->AreRenderSurfacesOk()) {
192  render->Present();
193  }
194 }
195 
197  if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) {
198  // dword_4E98BC_bApplicationActive = 1;
199  // Resume video playback
200  // pMediaPlayer->
201  // if (pMovie_Track)
202  // pMediaPlayer->bPlaying_Movie = true;
203 
204  dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_APP_INACTIVE;
205 
208  } else {
209  if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0200_EVENT_TIMER)
210  dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0200_EVENT_TIMER;
211  else
212  pEventTimer->Resume();
213  if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0400_MISC_TIMER)
214  dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0400_MISC_TIMER;
215  else
216  pMiscTimer->Resume();
217 
218  viewparams->bRedrawGameUI = true;
219  if (pMovie_Track) { // pVideoPlayer->pSmackerMovie )
220  render->RestoreFrontBuffer();
221  render->RestoreBackBuffer();
222  // BackToHouseMenu();
223  }
224  }
225 
226  if (!bGameoverLoop && !pMovie_Track) { // continue an audio track
228  }
229  }
230 }
231 
233  if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)) {
234  // dword_4E98BC_bApplicationActive = 0;
235 
236  dword_6BE364_game_settings_1 |= GAME_SETTINGS_APP_INACTIVE;
237  if (pEventTimer->bPaused)
238  dword_6BE364_game_settings_1 |= GAME_SETTINGS_0200_EVENT_TIMER;
239  else
240  pEventTimer->Pause();
241  if (pMiscTimer->bPaused)
242  dword_6BE364_game_settings_1 |= GAME_SETTINGS_0400_MISC_TIMER;
243  else
244  pMiscTimer->Pause();
245 
246  if (pAudioPlayer) {
247  pAudioPlayer->StopChannels(-1, -1);
249  }
250  }
251 }
252 
254  __debugbreak();
255 }
UI_OnVkKeyDown
bool UI_OnVkKeyDown(unsigned int vkKey)
Definition: Mouse.cpp:336
Engine_::IocContainer
Definition: IocContainer.h:15
Application::GameWindowHandler::OnFocus
void OnFocus()
Definition: GameWindowHandler.cpp:179
GUI_HandleHotkey
GUIButton * GUI_HandleHotkey(uint8_t uHotkey)
Definition: GUIWindow.cpp:215
IocContainer.h
UIMSG_Escape
@ UIMSG_Escape
Definition: GUIWindow.h:96
Viewport.h
Mouse::SetMouseClick
void SetMouseClick(int x, int y)
Definition: Mouse.cpp:251
IocContainer.h
Timer::Resume
void Resume()
Definition: Time.cpp:27
ArcomageGame::OnMouseClick
static void OnMouseClick(char right_left, bool bDown)
Definition: Arcomage.cpp:196
vis_sprite_filter_3
Vis_SelectionFilter vis_sprite_filter_3
Definition: Vis.cpp:30
UI_OnMouseRightClick
void UI_OnMouseRightClick(int mouse_x, int mouse_y)
Definition: UIPopup.cpp:1459
Application::GameWindowHandler::OnMouseRightClick
void OnMouseRightClick(int x, int y)
Definition: GameWindowHandler.cpp:70
pArcomageGame
ArcomageGame * pArcomageGame
Definition: Arcomage.cpp:97
engine
std::shared_ptr< Engine > engine
Definition: Engine.cpp:130
AudioPlayer::MusicResume
void MusicResume()
Definition: AudioPlayer.cpp:157
Application::GameWindowHandler::mouse
Mouse * mouse
Definition: GameWindowHandler.h:30
MPlayer::StopMovie
bool StopMovie()
Definition: MediaPlayer.cpp:785
IndoorCameraD3D::GetPickDepth
float GetPickDepth()
Definition: IndoorCameraD3D.cpp:61
Timer::bPaused
unsigned int bPaused
Definition: Time.h:127
pMediaPlayer
MPlayer * pMediaPlayer
Definition: MediaPlayer.cpp:43
Application::GameWindowHandler::OnMouseRightDoubleClick
void OnMouseRightDoubleClick(int x, int y)
Definition: GameWindowHandler.cpp:115
pMovie_Track
PMovie pMovie_Track
Definition: MediaPlayer.cpp:44
vis_door_filter
Vis_SelectionFilter vis_door_filter
Definition: Vis.cpp:28
GameWindowHandler.h
Engine.h
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
Application::GameWindowHandler::OnMouseLeftDoubleClick
void OnMouseLeftDoubleClick(int x, int y)
Definition: GameWindowHandler.cpp:107
ViewingParams::field_4C
int field_4C
Definition: Viewport.h:76
GetCurrentMenuID
MENU_STATE GetCurrentMenuID()
Definition: GUIWindow.cpp:133
y
EGLSurface EGLint EGLint y
Definition: SDL_egl.h:1596
Application::GameWindowHandler::OnActivated
void OnActivated()
Definition: GameWindowHandler.cpp:196
window_SpeakInHouse
GUIWindow * window_SpeakInHouse
Definition: GUIWindow.cpp:51
Application::GameWindowHandler::OnDeactivated
void OnDeactivated()
Definition: GameWindowHandler.cpp:232
Application::GameWindowHandler::OnToggleFullscreen
void OnToggleFullscreen()
Definition: GameWindowHandler.cpp:253
UIMSG_OpenDebugMenu
@ UIMSG_OpenDebugMenu
Definition: GUIWindow.h:246
vis_sprite_filter_2
Vis_SelectionFilter vis_sprite_filter_2
Definition: Vis.cpp:24
x
EGLSurface EGLint x
Definition: SDL_egl.h:1596
viewparams
struct ViewingParams * viewparams
Definition: mm7_data.cpp:22
Application::GameWindowHandler::OnVkDown
void OnVkDown(int vk, int vk_to_char)
Definition: GameWindowHandler.cpp:135
ArcomageGame::stru1
ArcomageGame_InputMSG stru1
Definition: Arcomage.h:134
Engine_::IocContainer::ResolveMouse
static Mouse * ResolveMouse()
Definition: IocContainer.cpp:88
Application::GameWindowHandler
Definition: GameWindowHandler.h:8
AudioPlayer::StopChannels
void StopChannels(int uStartChannel, int uEndChannel)
Definition: AudioPlayer.cpp:331
MediaPlayer.h
Arcomage.h
Party.h
back_to_game
void back_to_game()
Definition: Engine.cpp:1609
Application::GameWindowHandler::OnScreenshot
void OnScreenshot()
Definition: GameWindowHandler.cpp:34
Timer::Pause
void Pause()
Definition: Time.cpp:19
_507B98_ctrl_pressed
bool _507B98_ctrl_pressed
Definition: Mouse.cpp:256
ArcomageGame::OnMouseMove
static void OnMouseMove(int x, int y)
Definition: Arcomage.cpp:203
pMiscTimer
Timer * pMiscTimer
Definition: Time.cpp:7
AudioPlayer.h
CURRENT_SCREEN::SCREEN_GAME
@ SCREEN_GAME
ArcomageGame::check_exit
char check_exit
Definition: Arcomage.h:161
ArcomageGame_InputMSG::am_input_type
int am_input_type
Definition: Arcomage.h:107
Application::GameWindowHandler::OnMouseRightUp
void OnMouseRightUp()
Definition: GameWindowHandler.cpp:98
pKeyActionMap
struct KeyboardActionMapping * pKeyActionMap
Definition: Keyboard.cpp:35
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11096
bGameoverLoop
int bGameoverLoop
Definition: mm7_data.cpp:785
IndoorCameraD3D.h
__debugbreak
void __cdecl __debugbreak(void)
Application::GameWindowHandler::OnMouseLeftUp
void OnMouseLeftUp()
Definition: GameWindowHandler.cpp:89
CURRENT_SCREEN::SCREEN_MODAL_WINDOW
@ SCREEN_MODAL_WINDOW
ViewingParams::bRedrawGameUI
int bRedrawGameUI
Definition: Viewport.h:74
dword_6BE364_game_settings_1
int dword_6BE364_game_settings_1
Definition: mm7_data.cpp:714
Application::GameWindowHandler::OnPaint
void OnPaint()
Definition: GameWindowHandler.cpp:187
Application::GameWindowHandler::OnFocusLost
void OnFocusLost()
Definition: GameWindowHandler.cpp:183
Application::IocContainer
Definition: IocContainer.h:8
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
Application::GameWindowHandler::OnMouseMove
void OnMouseMove(int x, int y, bool left_button, bool right_button)
Definition: GameWindowHandler.cpp:123
GUIWindow.h
Application::GameWindowHandler::OnChar
bool OnChar(int c)
Definition: GameWindowHandler.cpp:40
pMessageQueue_50CBD0
struct GUIMessageQueue * pMessageQueue_50CBD0
Definition: GUIWindow.cpp:86
AudioPlayer::MusicPause
void MusicPause()
Definition: AudioPlayer.cpp:149
ArcomageGame::bGameInProgress
char bGameInProgress
Definition: Arcomage.h:162
pIndoorCameraD3D
IndoorCameraD3D * pIndoorCameraD3D
Definition: IndoorCameraD3D.cpp:21
set_stru1_field_8_InArcomage
void set_stru1_field_8_InArcomage(int inValue)
Definition: Arcomage.cpp:3081
KeyboardActionMapping::ProcessTextInput
bool ProcessTextInput(unsigned int a2)
Definition: Keyboard.cpp:201
Application::GameWindowHandler::OnMouseLeftClick
void OnMouseLeftClick(int x, int y)
Definition: GameWindowHandler.cpp:47
Keyboard.h
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
Mouse::UI_OnMouseLeftClick
void UI_OnMouseLeftClick()
Definition: Mouse.cpp:258
Mouse.h
ArcomageGame::force_redraw_1
char force_redraw_1
Definition: Arcomage.h:158
uGameMenuUI_CurentlySelectedKeyIdx
int uGameMenuUI_CurentlySelectedKeyIdx
Definition: mm7_data.cpp:540
Vis.h
Time.h
MENU_CREATEPARTY
@ MENU_CREATEPARTY
Definition: GUIWindow.h:257
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52