Mercurial > mm7
annotate OSWindow.cpp @ 2201:34035536bbf5
Finishing keyboard.cpp stuff
author | Grumpy7 |
---|---|
date | Mon, 03 Feb 2014 23:06:14 +0100 |
parents | 9856c2f8f918 |
children | 20995bb8895a |
rev | line source |
---|---|
1804 | 1 #include "OSWindow.h" |
2 #include "mm7_data.h" | |
3 #include "Arcomage.h" | |
4 #include "AudioPlayer.h" | |
5 #include "VideoPlayer.h" | |
6 #include "Mouse.h" | |
2044 | 7 #include "Timer.h" |
1804 | 8 #include "GUIWindow.h" |
9 #include "Party.h" | |
10 #include "Game.h" | |
11 #include "IndoorCameraD3D.h" | |
12 #include "Keyboard.h" | |
13 #include "Render.h" | |
14 #include "Viewport.h" | |
15 #include "Vis.h" | |
16 #include "Texts.h" | |
17 #include "AIL.h" | |
18 #include "Bink_Smacker.h" | |
19 #include "ErrorHandling.h" | |
2052 | 20 #include "Log.h" |
1804 | 21 |
22 | |
23 bool OSWindow::OnMouseLeftClick(int x, int y) | |
24 { | |
1815 | 25 if (UIControl::OnMouseLeftClick(x, y)) |
26 return true; | |
27 | |
1804 | 28 if (pVideoPlayer->pVideoFrame.pPixels) |
29 pVideoPlayer->bStopBeforeSchedule = true; | |
30 | |
31 pMouse->SetMouseClick(x, y); | |
32 | |
33 if (GetCurrentMenuID() == MENU_CREATEPARTY) | |
34 UI_OnKeyDown(VK_SELECT); | |
35 | |
36 if (pGame) | |
37 pGame->PickMouse(512.0, x, y, false, &vis_sprite_filter_3, &vis_door_filter); | |
38 | |
39 UI_OnMouseLeftClick(0); | |
40 return true; | |
41 } | |
42 | |
43 bool OSWindow::OnMouseRightClick(int x, int y) | |
44 { | |
1815 | 45 if (UIControl::OnMouseRightClick(x, y)) |
46 return true; | |
47 | |
1804 | 48 if (pVideoPlayer->pVideoFrame.pPixels) |
49 pVideoPlayer->bStopBeforeSchedule = true; | |
50 | |
51 pMouse->SetMouseClick(x, y); | |
52 | |
53 if (pGame) | |
54 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), x, y, 0, &vis_sprite_filter_2, &vis_door_filter); | |
55 | |
56 UI_OnMouseRightClick(0); | |
57 return true; | |
58 } | |
59 | |
60 | |
1830 | 61 bool _507B98_ctrl_pressed = false; |
1804 | 62 bool OSWindow::WinApiMessageProc(UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *result) |
63 { | |
64 switch (msg) | |
65 { | |
66 case WM_KEYUP: | |
67 { | |
1830 | 68 if (wparam == VK_CONTROL) |
69 _507B98_ctrl_pressed = false; | |
2132 | 70 if (wparam == VK_SNAPSHOT) |
71 pRenderer->SavePCXScreenshot(); | |
1830 | 72 |
1804 | 73 OnKey(wparam); |
74 return *result = 0, true; | |
75 } | |
76 | |
77 case WM_SIZING: return *result = 1, true; | |
78 case WM_WINDOWPOSCHANGED: | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2132
diff
changeset
|
79 //if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2132
diff
changeset
|
80 //BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0); |
1804 | 81 return false; |
82 | |
83 case WM_CHAR: | |
2201 | 84 if (!pKeyActionMap->ProcessTextInput(wparam) && !viewparams->field_4C) |
1804 | 85 GUI_HandleHotkey(wparam); |
86 return false; | |
87 | |
88 case WM_DESTROY: | |
89 ExitProcess(GetLastError()); | |
90 // SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); | |
91 // PostQuitMessage(0); | |
92 // return 0; | |
93 | |
94 //case WM_DEVICECHANGE: | |
95 //{ | |
96 // if (wParam == 0x8000) // CD or some device has been inserted - notify InsertCD dialog | |
97 // PostMessageW(hInsertCDWindow, WM_USER + 1, 0, 0); | |
98 // return 0; | |
99 //} | |
100 | |
101 case WM_COMMAND: | |
102 if (OnOSMenu(wparam)) | |
103 return *result = 0, true; | |
104 return false; | |
105 | |
106 case WM_LBUTTONDOWN: | |
107 { | |
108 if (pArcomageGame->bGameInProgress) | |
109 { | |
110 pArcomageGame->stru1.field_0 = 7; | |
111 ArcomageGame::OnMouseClick(0, true); | |
112 return false; | |
113 } | |
114 | |
115 OnMouseLeftClick(LOWORD(lparam), HIWORD(lparam)); | |
116 } | |
117 return false; | |
118 | |
119 | |
120 case WM_RBUTTONDOWN: | |
121 { | |
122 if (pArcomageGame->bGameInProgress) | |
123 { | |
124 pArcomageGame->stru1.field_0 = 8; | |
125 ArcomageGame::OnMouseClick(1, true); | |
126 return false; | |
127 } | |
128 | |
129 OnMouseRightClick(LOWORD(lparam), HIWORD(lparam)); | |
130 } | |
131 return false; | |
132 | |
133 | |
134 case WM_LBUTTONUP: | |
135 if ( !pArcomageGame->bGameInProgress ) | |
136 { | |
137 back_to_game(); | |
138 return false; | |
139 } | |
140 pArcomageGame->stru1.field_0 = 3; | |
141 ArcomageGame::OnMouseClick(0, 0); | |
142 return false; | |
143 | |
144 case WM_RBUTTONUP: | |
145 if ( !pArcomageGame->bGameInProgress ) | |
146 { | |
147 back_to_game(); | |
148 return false; | |
149 } | |
150 pArcomageGame->stru1.field_0 = 4; | |
151 ArcomageGame::OnMouseClick(1, false); | |
152 return false; | |
153 | |
154 case WM_LBUTTONDBLCLK: | |
155 { | |
156 if ( pArcomageGame->bGameInProgress ) | |
157 { | |
158 pArcomageGame->stru1.field_0 = 7; | |
159 return false; | |
160 } | |
161 | |
162 OnMouseLeftClick(LOWORD(lparam), HIWORD(lparam)); | |
163 } | |
164 return false; | |
165 | |
166 case WM_RBUTTONDBLCLK: | |
167 { | |
168 if (pArcomageGame->bGameInProgress) | |
169 { | |
170 pArcomageGame->stru1.field_0 = 8; | |
171 return false; | |
172 } | |
173 | |
174 OnMouseRightClick(LOWORD(lparam), HIWORD(lparam)); | |
175 } | |
176 return false; | |
177 | |
178 /*case WM_MBUTTONDOWN: | |
179 if (pRenderer->pRenderD3D && pGame) | |
180 { | |
181 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 1, &vis_sprite_filter_3, &vis_face_filter); | |
182 } | |
183 return false;*/ | |
184 | |
185 case WM_MOUSEMOVE: | |
186 if ( pArcomageGame->bGameInProgress ) | |
187 { | |
188 ArcomageGame::OnMouseMove(LOWORD(lparam), HIWORD(lparam)); | |
189 ArcomageGame::OnMouseClick(0, wparam == MK_LBUTTON); | |
190 ArcomageGame::OnMouseClick(1, wparam == MK_RBUTTON); | |
191 } | |
192 else if (pMouse) | |
193 pMouse->SetMouseClick(LOWORD(lparam), HIWORD(lparam)); | |
194 return false; | |
195 | |
196 case WM_SYSCOMMAND: | |
197 if ( wparam == SC_SCREENSAVE || wparam == SC_MONITORPOWER ) | |
198 return *result = 0, true; | |
199 return false; | |
200 | |
201 case WM_KEYDOWN: | |
202 if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 ) | |
203 { | |
2201 | 204 pKeyActionMap->ProcessTextInput(wparam); |
1804 | 205 return false; |
206 } | |
207 if ( !pArcomageGame->bGameInProgress ) | |
208 { | |
209 if ( pVideoPlayer->pVideoFrame.pPixels ) | |
210 pVideoPlayer->bStopBeforeSchedule = 1; | |
211 if ( wparam == VK_RETURN ) | |
212 { | |
213 if ( !viewparams->field_4C ) | |
214 UI_OnKeyDown(wparam); | |
215 return 0; | |
216 } | |
1830 | 217 if (wparam == VK_CONTROL) |
218 { | |
219 _507B98_ctrl_pressed = true; | |
220 return false; | |
221 } | |
1804 | 222 if ( wparam == VK_ESCAPE ) |
223 { | |
224 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0); | |
225 return 0; | |
226 } | |
227 if ( wparam <= VK_HOME ) | |
228 return 0; | |
229 if ( wparam > VK_DOWN ) | |
230 { | |
231 if ( wparam != VK_F4 || pVideoPlayer->AnyMovieLoaded() ) | |
232 return 0; | |
233 | |
234 // F4 - toggle fullscreen | |
235 SendMessageW(api_handle, WM_COMMAND, 104, 0); | |
236 return 0; | |
237 } | |
238 if ( wparam >= VK_LEFT && wparam <= VK_DOWN ) | |
239 { | |
240 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW ) | |
241 { | |
242 if ( !viewparams->field_4C ) | |
243 UI_OnKeyDown(wparam); | |
244 return 0; | |
245 } | |
246 } | |
247 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW ) | |
248 return 0; | |
249 } | |
250 | |
251 pArcomageGame->stru1.field_0 = 1; | |
252 | |
253 set_stru1_field_8_InArcomage(MapVirtualKey(wparam, MAPVK_VK_TO_CHAR)); | |
254 if ( wparam == 27 ) | |
255 { | |
256 pArcomageGame->GameOver = 1; | |
257 pArcomageGame->field_F4 = 1; | |
258 pArcomageGame->uGameResult = 2; | |
259 pArcomageGame->field_B0 = -2; | |
260 return false; | |
261 } | |
262 if ( wparam != 114 ) | |
263 { | |
264 if ( wparam == 115 && !pVideoPlayer->AnyMovieLoaded() ) | |
265 SendMessage(api_handle, WM_COMMAND, 104, 0); | |
266 return false; | |
267 } | |
268 SendMessageW(api_handle, WM_COMMAND, 103, 0); | |
269 return *result = 0, true; | |
270 | |
271 case WM_ACTIVATEAPP: | |
272 if ( wparam && (GetForegroundWindow() == api_handle || GetForegroundWindow() == hInsertCDWindow) ) | |
273 { | |
2061 | 274 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) |
1804 | 275 { |
276 dword_4E98BC_bApplicationActive = 1; | |
2069 | 277 /*if ( pRenderer->bWindowMode ) |
1804 | 278 { |
279 HDC hDC = GetDC(api_handle); | |
280 int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL); | |
281 int planes = GetDeviceCaps(hDC, PLANES); | |
282 ReleaseDC(api_handle, hDC); | |
283 if (bitsPerPixel != 16 || planes != 1) | |
2069 | 284 Error(L"%S", pGlobalTXT_LocalizationStrings[62]); |
285 }*/ | |
2061 | 286 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_APP_INACTIVE; |
1804 | 287 |
288 if ( pArcomageGame->bGameInProgress ) | |
289 { | |
290 pArcomageGame->field_F9 = 1; | |
291 } | |
292 else | |
293 { | |
2061 | 294 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0200_EVENT_TIMER) |
295 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0200_EVENT_TIMER; | |
1804 | 296 else |
297 pEventTimer->Resume(); | |
2061 | 298 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0400_MISC_TIMER) |
299 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0400_MISC_TIMER; | |
1804 | 300 else |
301 pMiscTimer->Resume(); | |
302 | |
303 viewparams->bRedrawGameUI = true; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2132
diff
changeset
|
304 if ( pVideoPlayer->pMovie)//pVideoPlayer->pSmackerMovie ) |
1804 | 305 { |
306 pRenderer->RestoreFrontBuffer(); | |
2152 | 307 pRenderer->RestoreBackBuffer(); |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2132
diff
changeset
|
308 //pVideoPlayer->_4BF5B2(); |
1804 | 309 } |
310 } | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2132
diff
changeset
|
311 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pMovie)//!pVideoPlayer->pSmackerMovie ) |
1804 | 312 AIL_redbook_resume(pAudioPlayer->hAILRedbook); |
313 } | |
314 } | |
315 else | |
316 { | |
2061 | 317 if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)) |
1804 | 318 { |
319 dword_4E98BC_bApplicationActive = 0; | |
2142
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2132
diff
changeset
|
320 if ( pVideoPlayer->pMovie//(pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) |
ca548138d6aa
some code cleaning in video playing, loops play but there is a memory leak
zipi
parents:
2132
diff
changeset
|
321 && pVideoPlayer->bPlayingMovie ) |
1804 | 322 pVideoPlayer->bStopBeforeSchedule = 1; |
323 | |
324 ClipCursor(0); | |
2061 | 325 dword_6BE364_game_settings_1 |= GAME_SETTINGS_APP_INACTIVE; |
1804 | 326 if ( pEventTimer->bPaused ) |
2061 | 327 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0200_EVENT_TIMER; |
1804 | 328 else |
329 pEventTimer->Pause(); | |
330 if ( pMiscTimer->bPaused ) | |
2061 | 331 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0400_MISC_TIMER; |
1804 | 332 else |
333 pMiscTimer->Pause(); | |
334 | |
2104 | 335 pAudioPlayer->StopChannels(-1, -1);//ïðèîñòàíîâêà âîñïðîèçâåäåíèÿ çâóêîâ ïðè íåàêòèâíîì îêíå èãðû |
1804 | 336 if ( pAudioPlayer->hAILRedbook ) |
337 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
338 } | |
339 } | |
340 return *result = 0, true; | |
341 | |
342 case WM_SETFOCUS: | |
343 dword_4E98BC_bApplicationActive = 0; | |
344 ClipCursor(0); | |
345 return false; | |
346 | |
347 case WM_KILLFOCUS: | |
348 dword_4E98BC_bApplicationActive = 1; | |
349 return false; | |
350 | |
351 case WM_PAINT: | |
1806 | 352 if (!api_handle || !pRenderer) |
1805 | 353 return false; |
2154 | 354 |
2155 | 355 if ( !GetUpdateRect(api_handle, 0, 0))// || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode ) |
2154 | 356 return *result = 0, true; |
357 | |
1804 | 358 PAINTSTRUCT Paint; |
359 BeginPaint(api_handle, &Paint); | |
360 if ( pArcomageGame->bGameInProgress ) | |
361 { | |
362 pArcomageGame->field_F9 = 1; | |
363 } | |
2154 | 364 if (pRenderer->AreRenderSurfacesOk()) |
1804 | 365 { |
2154 | 366 pRenderer->Present(); |
367 //EndPaint(api_handle, &Paint); | |
368 //return *result = 0, true; | |
1804 | 369 } |
2154 | 370 |
1804 | 371 EndPaint(api_handle, &Paint); |
372 return *result = 0, true; | |
373 | |
374 } | |
375 return false; | |
376 } | |
377 | |
378 | |
379 | |
380 bool OSWindow::Initialize(const wchar_t *title, int window_width, int window_height) | |
381 { | |
382 WNDCLASSEXW wcxw; | |
383 wcxw.cbClsExtra = 0; | |
384 wcxw.cbSize = sizeof(wcxw); | |
385 wcxw.cbWndExtra = 0; | |
386 wcxw.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1); | |
387 wcxw.hCursor = nullptr; | |
388 wcxw.hIcon = wcxw.hIconSm = nullptr; | |
389 wcxw.hInstance = GetModuleHandleW(nullptr); | |
390 wcxw.lpfnWndProc = WinApiMsgRouter; | |
391 wcxw.lpszClassName = L"M&MTrilogy"; | |
392 wcxw.lpszMenuName = nullptr; | |
393 wcxw.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; | |
394 if (!RegisterClassExW(&wcxw)) | |
395 return false; | |
396 | |
2061 | 397 api_handle = CreateWindowExW(0, wcxw.lpszClassName, title, 0, |
2069 | 398 ReadWindowsRegistryInt("window X", (GetSystemMetrics(SM_CXSCREEN) - window_width) / 2), |
399 ReadWindowsRegistryInt("window Y", (GetSystemMetrics(SM_CYSCREEN) - window_height) / 2), | |
400 window_width, window_height, nullptr, | |
1804 | 401 nullptr, wcxw.hInstance, this); |
402 if (!api_handle) | |
403 { | |
404 UnregisterClassW(wcxw.lpszClassName, wcxw.hInstance); | |
405 return false; | |
406 } | |
407 | |
408 SetWindowedMode(window_width, window_height); | |
409 Show(); | |
410 | |
411 SetActiveWindow(api_handle); | |
412 | |
413 MSG msg; | |
414 while (PeekMessageW(&msg, api_handle, 0, 0, PM_REMOVE)) | |
415 { | |
416 TranslateMessage(&msg); | |
417 DispatchMessageW(&msg); | |
418 } | |
419 | |
420 return true; | |
421 } | |
422 | |
423 | |
424 | |
425 | |
426 OSWindow *OSWindow::Create(const wchar_t *title, int window_width, int window_height) | |
427 { | |
2061 | 428 auto window = new OSWindow; |
1804 | 429 if (window) |
430 if (!window->Initialize(title, window_width, window_height)) | |
431 { | |
432 delete window; | |
433 window = nullptr; | |
434 } | |
435 | |
436 return window; | |
437 } | |
438 | |
439 | |
440 | |
441 LRESULT __stdcall OSWindow::WinApiMsgRouter(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) | |
442 { | |
443 if (msg == WM_NCCREATE) | |
444 { | |
1980 | 445 CREATESTRUCTA* cs = (CREATESTRUCTA *)(lparam); |
446 OSWindow* window = (OSWindow *)cs->lpCreateParams; | |
1804 | 447 |
448 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)window); | |
449 return DefWindowProcW(hwnd, msg, wparam, lparam); | |
450 } | |
451 | |
1980 | 452 OSWindow* window = (OSWindow *)GetWindowLongPtrW(hwnd, GWLP_USERDATA); |
1804 | 453 if (window && window->api_handle == hwnd) |
454 { | |
455 LPARAM result; | |
456 if (window->WinApiMessageProc(msg, wparam, lparam, &result)) | |
457 return result; | |
458 } | |
459 return DefWindowProcW(hwnd, msg, (WPARAM)wparam, (LPARAM)lparam); | |
460 } | |
461 | |
462 | |
463 void OSWindow::Show() | |
464 { | |
465 ShowWindow(api_handle, SW_SHOWNORMAL); | |
466 UpdateWindow(api_handle); | |
467 } | |
468 | |
469 | |
470 void OSWindow::SetCursor(const char *cursor_name) | |
471 { | |
472 POINT cursor_pos; | |
473 GetCursorPos(&cursor_pos); | |
474 | |
475 if (!strcmp(cursor_name, "MICON1") ) | |
476 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_ARROW)); | |
477 else if (!strcmp(cursor_name, "MICON2") ) | |
478 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), L"Target")); | |
479 else if (!strcmp(cursor_name, "MICON3") ) | |
480 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_WAIT)); | |
481 | |
482 //ClientToScreen(api_handle, &cursor_pos); | |
483 SetCursorPos(cursor_pos.x, cursor_pos.y); | |
484 } | |
485 | |
486 void OSWindow::SetFullscreenMode() | |
487 { | |
488 SetMenu(api_handle, nullptr); | |
489 SetWindowLongW(api_handle, GWL_EXSTYLE, WS_EX_TOPMOST); | |
490 SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_POPUP); | |
491 | |
492 SetWindowPos(api_handle, HWND_TOP, 0, 0, -1, -1, SWP_NOSIZE | SWP_SHOWWINDOW); | |
493 } | |
494 | |
495 void OSWindow::SetWindowedMode(int new_window_width, int new_window_height) | |
496 { | |
2069 | 497 RECT rcWindowPos; |
498 GetWindowRect(api_handle, &rcWindowPos); | |
499 | |
1804 | 500 SetWindowLongW(api_handle, GWL_EXSTYLE, 0); |
501 SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW); | |
1995 | 502 SetWindowPos(api_handle, HWND_TOP, 0, 0, -1, -1, 0); |
503 | |
1804 | 504 RECT rcWindow; |
505 GetWindowRect(api_handle, &rcWindow); | |
506 | |
507 RECT rcClient; | |
508 GetClientRect(api_handle, &rcClient); | |
509 | |
510 int window_borders_width = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left), | |
511 window_borders_height = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top); | |
512 int window_total_width = new_window_width + window_borders_width, | |
513 window_total_height = new_window_height + window_borders_height; | |
514 | |
515 #ifdef _DEBUG | |
516 if (!GetMenu(api_handle)) | |
517 window_total_height += GetSystemMetrics(SM_CYMENU); | |
518 #endif | |
2069 | 519 MoveWindow(api_handle, rcWindowPos.left, |
520 rcWindowPos.top, | |
1804 | 521 window_total_width, |
522 window_total_height, 0); | |
523 #ifdef _DEBUG | |
524 static HMENU debug_menu = CreateDebugMenuPanel(); | |
525 SetMenu(api_handle, debug_menu); | |
2069 | 526 |
527 GetWindowRect(api_handle, &rcWindow); | |
528 GetClientRect(api_handle, &rcClient); | |
1804 | 529 #endif |
530 } | |
531 | |
532 | |
533 | |
534 | |
535 HMENU OSWindow::CreateDebugMenuPanel() | |
536 { | |
537 HMENU menu = CreateMenu(); | |
538 { | |
539 HMENU file = CreatePopupMenu(); | |
540 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)file, L"&File"); | |
541 { | |
542 AppendMenuW(file, MF_ENABLED | MF_STRING, 40001, L"Exit"); | |
543 } | |
544 | |
545 HMENU debug = CreatePopupMenu(); | |
546 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug, L"&Debug"); | |
547 { | |
548 HMENU debug_party = CreatePopupMenu(); | |
549 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party, L"&Party"); | |
550 { | |
551 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40007, L"Give Gold (10 000)"); | |
552 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40008, L"Give Exp (20 000)"); | |
553 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40059, L"Give Skills (50 each)"); | |
554 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40013, L"Remove Gold"); | |
555 | |
556 HMENU debug_party_setconditions = CreatePopupMenu(); | |
557 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_setconditions, L"Set Condition"); | |
558 { | |
559 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40044, L"Afraid"); | |
560 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40043, L"Asleep"); | |
561 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40037, L"Curse"); | |
2187 | 562 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40036, L"Disease Weak"); |
563 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40035, L"Disease Medium"); | |
564 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40034, L"Disease Severe"); | |
1804 | 565 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40041, L"Dead"); |
566 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40039, L"Drunk"); | |
567 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40042, L"Eradicated"); | |
568 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40038, L"Insane"); | |
569 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40045, L"Paralyzed"); | |
2187 | 570 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40033, L"Poison Weak"); |
571 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40032, L"Poison Medium"); | |
572 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40031, L"Poison Severe"); | |
1804 | 573 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40029, L"&Stone"); |
574 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40040, L"Unconscious"); | |
575 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40030, L"Weak"); | |
576 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40073, L"Zombie"); | |
577 } | |
578 | |
579 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40006, L"Set Food (20)"); | |
580 | |
581 HMENU debug_party_alignment = CreatePopupMenu(); | |
582 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_alignment, L"Alignment"); | |
583 { | |
584 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40062, L"Good"); | |
585 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING | MF_CHECKED, 40063, L"Neutral"); | |
586 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40064, L"Evil"); | |
587 } | |
588 } | |
589 | |
590 HMENU debug_time = CreatePopupMenu(); | |
591 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_time, L"&Time"); | |
592 { | |
593 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40009, L"Add 1 Day"); | |
594 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40010, L"Add 1 Week"); | |
595 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40011, L"Add 1 Month"); | |
596 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40012, L"Add 1 Year"); | |
597 } | |
598 | |
599 HMENU debug_items = CreatePopupMenu(); | |
600 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_items, L"&Items"); | |
601 { | |
602 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40015, L"Generate level &1 item"); | |
603 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40016, L"Generate level &2 item"); | |
604 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40017, L"Generate level &3 item"); | |
605 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40018, L"Generate level &4 item"); | |
606 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40019, L"Generate level &5 item"); | |
607 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40020, L"Generate level &6 item"); | |
608 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40061, L"Generate special item"); | |
609 } | |
610 | |
611 HMENU debug_graphics = CreatePopupMenu(); | |
612 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_graphics, L"&Graphics"); | |
613 { | |
614 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40023, L"Lighting Mode"); | |
615 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40024, L"Lighting Geometry"); | |
616 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING | MF_GRAYED, 40104, L"Lights Off"); | |
617 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40105, L"Colored Lights"); | |
618 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40025, L"Debug Lights"); | |
619 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40101, L"Debug Decals"); | |
620 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40027, L"HWID Portals"); | |
621 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40047, L"SWID Portals"); | |
622 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40051, L"OD Frustum"); | |
623 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40054, L"SWOD Constant Redraw"); | |
624 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40055, L"SWOD Lit Rasterizer"); | |
625 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40056, L"Party Light off"); | |
626 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40060, L"SWOD Nice Lighting off"); | |
627 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40067, L"HWOD Additive Fog Lights"); | |
628 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40072, L"HWID Nice Lighting"); | |
629 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40048, L"Wireframe"); | |
630 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40049, L"Fog"); | |
631 } | |
632 | |
633 HMENU debug_misc = CreatePopupMenu(); | |
634 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_misc, L"&Misc"); | |
635 { | |
636 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40066, L"Object Viewcone Culling"); | |
637 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40068, L"Red Tint"); | |
638 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40071, L"Display Secrets"); | |
639 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40102, L"Massive Bloodsplat"); | |
640 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40103, L"Underwater Gravity"); | |
641 } | |
642 | |
643 HMENU debug_eax = CreatePopupMenu(); | |
644 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_eax, L"EAX Environs"); | |
645 { | |
646 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40074, L"NONE"); | |
647 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40075, L"GENERIC"); | |
648 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40076, L"PADDEDCELL"); | |
649 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40077, L"ROOM"); | |
650 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40078, L"BATHROOM"); | |
651 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40079, L"LIVINGROOM"); | |
652 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40080, L"STONEROOM"); | |
653 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40081, L"AUDITORIUM"); | |
654 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40082, L"CONCERTHALL"); | |
655 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40083, L"CAVE"); | |
656 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40084, L"ARENA"); | |
657 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40085, L"HANGAR"); | |
658 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40086, L"CARPETEDHALLWAY"); | |
659 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40087, L"HALLWAY"); | |
660 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40088, L"STONECORRIDOR"); | |
661 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40089, L"ALLEY"); | |
662 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40090, L"FOREST"); | |
663 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40091, L"CITY"); | |
664 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40092, L"MOUNTAINS"); | |
665 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40093, L"QUARRY"); | |
666 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40094, L"PLAIN"); | |
667 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40095, L"PARKINGLOT"); | |
668 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40096, L"SEWERPIPE"); | |
669 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40097, L"UNDERWATER"); | |
670 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40098, L"DRUGGED"); | |
671 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40099, L"DIZZY"); | |
672 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40100, L"PSICHOTIC"); | |
673 } | |
674 } | |
675 } | |
676 return menu; | |
677 } | |
678 | |
679 | |
680 | |
681 | |
682 bool OSWindow::OnOSMenu(int item_id) | |
683 { | |
684 switch (item_id) | |
685 { | |
686 default: return false; | |
687 | |
688 | |
2132 | 689 //case 103: pRenderer->SavePCXScreenshot(); break; |
1804 | 690 case 101: // Quit game |
2132 | 691 case 40001: // Menu "File"-> "Exit" |
692 pGame->Deinitialize(); | |
1804 | 693 SendMessageW(api_handle, WM_DESTROY, 0, 0); |
694 break; | |
695 | |
2132 | 696 case 104: //F4 button |
1804 | 697 pRenderer->ChangeBetweenWinFullscreenModes(); |
698 if (pArcomageGame->bGameInProgress) | |
699 pArcomageGame->field_F6 = 1; | |
700 break; | |
701 | |
702 //SubMenu "Party" | |
703 case 40006: pParty->SetFood(pParty->uNumFoodRations + 20); break; | |
704 case 40007: pParty->SetGold(pParty->uNumGold + 10000); break; | |
1827
0c75c3e7e436
cleaned up part of party.cpp, renamed byte_AE3368 to playerAlreadyPicked + 3 vars after it, moved them to party.cpp, some player.cpp bugfixes
Grumpy7
parents:
1815
diff
changeset
|
705 case 40008: pParty->GivePartyExp(20000); break; |
1804 | 706 case 40013: pParty->SetGold(0); break; |
707 | |
708 case 40059: | |
709 for (uint i = 0; i < 4; ++i) | |
710 pParty->pPlayers[i].uSkillPoints = 50; | |
711 break; | |
712 | |
2185 | 713 case 40029: pPlayers[uActiveCharacter]->SetPertified(pParty->uTimePlayed); break; |
714 case 40030: pPlayers[uActiveCharacter]->SetWeak(pParty->uTimePlayed); break; | |
2187 | 715 case 40031: pPlayers[uActiveCharacter]->SetPoisonSevere(pParty->uTimePlayed); break; |
716 case 40032: pPlayers[uActiveCharacter]->SetPoisonMedium(pParty->uTimePlayed); break; | |
717 case 40033: pPlayers[uActiveCharacter]->SetPoisonWeak(pParty->uTimePlayed); break; | |
718 case 40034: pPlayers[uActiveCharacter]->SetDiseaseSevere(pParty->uTimePlayed); break; | |
719 case 40035: pPlayers[uActiveCharacter]->SetDiseaseMedium(pParty->uTimePlayed); break; | |
720 case 40036: pPlayers[uActiveCharacter]->SetDiseaseWeak(pParty->uTimePlayed); break; | |
2185 | 721 case 40037: pPlayers[uActiveCharacter]->SetCursed(pParty->uTimePlayed); break; |
722 case 40038: pPlayers[uActiveCharacter]->SetInsane(pParty->uTimePlayed); break; | |
723 case 40039: pPlayers[uActiveCharacter]->SetDrunk(pParty->uTimePlayed); break; | |
724 case 40040: pPlayers[uActiveCharacter]->SetUnconcious(pParty->uTimePlayed); break; | |
725 case 40041: pPlayers[uActiveCharacter]->SetDead(pParty->uTimePlayed); break; | |
726 case 40042: pPlayers[uActiveCharacter]->SetEradicated(pParty->uTimePlayed); break; | |
727 case 40043: pPlayers[uActiveCharacter]->SetAsleep(pParty->uTimePlayed); break; | |
728 case 40044: pPlayers[uActiveCharacter]->SetAfraid(pParty->uTimePlayed); break; | |
729 case 40045: pPlayers[uActiveCharacter]->SetParalyzed(pParty->uTimePlayed); break; | |
730 case 40073: pPlayers[uActiveCharacter]->SetZombie(pParty->uTimePlayed); break; | |
1804 | 731 |
732 case 40062: | |
733 pParty->alignment = PartyAlignment_Good; | |
734 SetUserInterface(pParty->alignment, true); | |
735 break; | |
736 case 40063: | |
737 pParty->alignment = PartyAlignment_Neutral; | |
738 SetUserInterface(pParty->alignment, true); | |
739 break; | |
740 case 40064: | |
741 pParty->alignment = PartyAlignment_Evil; | |
742 SetUserInterface(pParty->alignment, true); | |
743 break; | |
744 | |
745 | |
746 | |
747 //SubMenu "Time" | |
748 case 40009: pParty->uTimePlayed += Timer::Day; break; | |
749 case 40010: pParty->uTimePlayed += Timer::Week; break; | |
750 case 40011: pParty->uTimePlayed += Timer::Month; break; | |
751 case 40012: pParty->uTimePlayed += Timer::Year; break; | |
752 | |
753 //SubMenu "Items" | |
754 case 40015: // uItemID_Rep_St == 1 | |
755 case 40016: // uItemID_Rep_St == 2 | |
756 case 40017: // uItemID_Rep_St == 3 | |
757 case 40018: // uItemID_Rep_St == 4 | |
758 case 40019: // uItemID_Rep_St == 5 | |
759 case 40020: // uItemID_Rep_St == 6 | |
760 { | |
761 int pItemID = rand() % 500; | |
762 for (uint i = 0; i < 500; ++i) | |
763 { | |
764 if (pItemID + i > 499) | |
765 pItemID = 0; | |
766 if (pItemsTable->pItems[pItemID + i].uItemID_Rep_St == (item_id - 40015 + 1)) | |
767 { | |
768 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
769 break; | |
770 } | |
771 } | |
772 } | |
773 break; | |
774 | |
775 case 40061: | |
776 { | |
777 int pItemID = rand() % 500; | |
778 for (uint i = 0; i < 500; ++i) | |
779 { | |
780 if (pItemID + i > 499) | |
781 pItemID = 0; | |
782 if (pItemsTable->pItems[pItemID + i].uItemID_Rep_St > 6) | |
783 { | |
784 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
785 break; | |
786 } | |
787 } | |
788 } | |
789 break; | |
790 } | |
791 | |
792 return true; | |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1830
diff
changeset
|
793 } |