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