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