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