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::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:
|
1805
|
344 if (pRenderer)
|
|
345 {
|
|
346 if ( !GetUpdateRect(api_handle, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
|
|
347 return *result = 0, true;
|
|
348 }
|
|
349 if (!api_handle)
|
|
350 return false;
|
1804
|
351 PAINTSTRUCT Paint;
|
|
352 BeginPaint(api_handle, &Paint);
|
|
353 if ( pArcomageGame->bGameInProgress )
|
|
354 {
|
|
355 pArcomageGame->field_F9 = 1;
|
|
356 }
|
|
357 else
|
|
358 {
|
|
359 if (/*!pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() ||*/ !AreRenderSurfacesOk())
|
|
360 {
|
|
361 EndPaint(api_handle, &Paint);
|
|
362 return *result = 0, true;
|
|
363 }
|
|
364 }
|
|
365 pRenderer->Present();
|
|
366 EndPaint(api_handle, &Paint);
|
|
367 return *result = 0, true;
|
|
368
|
|
369 }
|
|
370 return false;
|
|
371 }
|
|
372
|
|
373
|
|
374
|
|
375 bool OSWindow::Initialize(const wchar_t *title, int window_width, int window_height)
|
|
376 {
|
|
377 WNDCLASSEXW wcxw;
|
|
378 wcxw.cbClsExtra = 0;
|
|
379 wcxw.cbSize = sizeof(wcxw);
|
|
380 wcxw.cbWndExtra = 0;
|
|
381 wcxw.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
|
|
382 wcxw.hCursor = nullptr;
|
|
383 wcxw.hIcon = wcxw.hIconSm = nullptr;
|
|
384 wcxw.hInstance = GetModuleHandleW(nullptr);
|
|
385 wcxw.lpfnWndProc = WinApiMsgRouter;
|
|
386 wcxw.lpszClassName = L"M&MTrilogy";
|
|
387 wcxw.lpszMenuName = nullptr;
|
|
388 wcxw.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
|
389 if (!RegisterClassExW(&wcxw))
|
|
390 return false;
|
|
391
|
|
392 api_handle = CreateWindowExW(0, wcxw.lpszClassName, title,
|
|
393 0,
|
|
394 0, 0, window_width, window_height, nullptr,
|
|
395 nullptr, wcxw.hInstance, this);
|
|
396 if (!api_handle)
|
|
397 {
|
|
398 UnregisterClassW(wcxw.lpszClassName, wcxw.hInstance);
|
|
399 return false;
|
|
400 }
|
|
401
|
|
402 SetWindowedMode(window_width, window_height);
|
|
403 Show();
|
|
404
|
|
405 SetActiveWindow(api_handle);
|
|
406
|
|
407 MSG msg;
|
|
408 while (PeekMessageW(&msg, api_handle, 0, 0, PM_REMOVE))
|
|
409 {
|
|
410 TranslateMessage(&msg);
|
|
411 DispatchMessageW(&msg);
|
|
412 }
|
|
413
|
|
414 return true;
|
|
415 }
|
|
416
|
|
417
|
|
418
|
|
419
|
|
420 OSWindow *OSWindow::Create(const wchar_t *title, int window_width, int window_height)
|
|
421 {
|
|
422 auto window = new OSWindow;
|
|
423 if (window)
|
|
424 if (!window->Initialize(title, window_width, window_height))
|
|
425 {
|
|
426 delete window;
|
|
427 window = nullptr;
|
|
428 }
|
|
429
|
|
430 return window;
|
|
431 }
|
|
432
|
|
433
|
|
434
|
|
435 LRESULT __stdcall OSWindow::WinApiMsgRouter(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
436 {
|
|
437 if (msg == WM_NCCREATE)
|
|
438 {
|
|
439 auto cs = (CREATESTRUCTA *)(lparam);
|
|
440 auto window = (OSWindow *)cs->lpCreateParams;
|
|
441
|
|
442 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)window);
|
|
443 return DefWindowProcW(hwnd, msg, wparam, lparam);
|
|
444 }
|
|
445
|
|
446 auto window = (OSWindow *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
|
447 if (window && window->api_handle == hwnd)
|
|
448 {
|
|
449 LPARAM result;
|
|
450 if (window->WinApiMessageProc(msg, wparam, lparam, &result))
|
|
451 return result;
|
|
452 }
|
|
453 return DefWindowProcW(hwnd, msg, (WPARAM)wparam, (LPARAM)lparam);
|
|
454 }
|
|
455
|
|
456
|
|
457 void OSWindow::Show()
|
|
458 {
|
|
459 ShowWindow(api_handle, SW_SHOWNORMAL);
|
|
460 UpdateWindow(api_handle);
|
|
461 }
|
|
462
|
|
463
|
|
464 void OSWindow::SetCursor(const char *cursor_name)
|
|
465 {
|
|
466 POINT cursor_pos;
|
|
467 GetCursorPos(&cursor_pos);
|
|
468
|
|
469 if (!strcmp(cursor_name, "MICON1") )
|
|
470 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_ARROW));
|
|
471 else if (!strcmp(cursor_name, "MICON2") )
|
|
472 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), L"Target"));
|
|
473 else if (!strcmp(cursor_name, "MICON3") )
|
|
474 SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_WAIT));
|
|
475
|
|
476 //ClientToScreen(api_handle, &cursor_pos);
|
|
477 SetCursorPos(cursor_pos.x, cursor_pos.y);
|
|
478 }
|
|
479
|
|
480 void OSWindow::SetFullscreenMode()
|
|
481 {
|
|
482 SetMenu(api_handle, nullptr);
|
|
483 SetWindowLongW(api_handle, GWL_EXSTYLE, WS_EX_TOPMOST);
|
|
484 SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_POPUP);
|
|
485
|
|
486 SetWindowPos(api_handle, HWND_TOP, 0, 0, -1, -1, SWP_NOSIZE | SWP_SHOWWINDOW);
|
|
487 }
|
|
488
|
|
489 void OSWindow::SetWindowedMode(int new_window_width, int new_window_height)
|
|
490 {
|
|
491 SetWindowLongW(api_handle, GWL_EXSTYLE, 0);
|
|
492 SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW);
|
|
493
|
|
494 RECT rcWindow;
|
|
495 GetWindowRect(api_handle, &rcWindow);
|
|
496
|
|
497 RECT rcClient;
|
|
498 GetClientRect(api_handle, &rcClient);
|
|
499
|
|
500 int window_borders_width = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left),
|
|
501 window_borders_height = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
|
|
502 int window_total_width = new_window_width + window_borders_width,
|
|
503 window_total_height = new_window_height + window_borders_height;
|
|
504
|
|
505 #ifdef _DEBUG
|
|
506 if (!GetMenu(api_handle))
|
|
507 window_total_height += GetSystemMetrics(SM_CYMENU);
|
|
508 #endif
|
|
509 MoveWindow(api_handle, (GetSystemMetrics(SM_CXSCREEN) - window_total_width) / 2,
|
|
510 (GetSystemMetrics(SM_CYSCREEN) - window_total_height) / 2,
|
|
511 window_total_width,
|
|
512 window_total_height, 0);
|
|
513 #ifdef _DEBUG
|
|
514 static HMENU debug_menu = CreateDebugMenuPanel();
|
|
515 SetMenu(api_handle, debug_menu);
|
|
516 #endif
|
|
517 }
|
|
518
|
|
519
|
|
520
|
|
521
|
|
522 HMENU OSWindow::CreateDebugMenuPanel()
|
|
523 {
|
|
524 HMENU menu = CreateMenu();
|
|
525 {
|
|
526 HMENU file = CreatePopupMenu();
|
|
527 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)file, L"&File");
|
|
528 {
|
|
529 AppendMenuW(file, MF_ENABLED | MF_STRING, 40001, L"Exit");
|
|
530 }
|
|
531
|
|
532 HMENU debug = CreatePopupMenu();
|
|
533 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug, L"&Debug");
|
|
534 {
|
|
535 HMENU debug_party = CreatePopupMenu();
|
|
536 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party, L"&Party");
|
|
537 {
|
|
538 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40007, L"Give Gold (10 000)");
|
|
539 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40008, L"Give Exp (20 000)");
|
|
540 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40059, L"Give Skills (50 each)");
|
|
541 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40013, L"Remove Gold");
|
|
542
|
|
543 HMENU debug_party_setconditions = CreatePopupMenu();
|
|
544 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_setconditions, L"Set Condition");
|
|
545 {
|
|
546 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40044, L"Afraid");
|
|
547 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40043, L"Asleep");
|
|
548 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40037, L"Curse");
|
|
549 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40036, L"Disease1");
|
|
550 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40035, L"Disease2");
|
|
551 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40034, L"Disease3");
|
|
552 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40041, L"Dead");
|
|
553 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40039, L"Drunk");
|
|
554 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40042, L"Eradicated");
|
|
555 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40038, L"Insane");
|
|
556 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40045, L"Paralyzed");
|
|
557 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40033, L"Poison1");
|
|
558 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40032, L"Poison2");
|
|
559 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40031, L"Poison3");
|
|
560 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40029, L"&Stone");
|
|
561 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40040, L"Unconscious");
|
|
562 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40030, L"Weak");
|
|
563 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40073, L"Zombie");
|
|
564 }
|
|
565
|
|
566 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40006, L"Set Food (20)");
|
|
567
|
|
568 HMENU debug_party_alignment = CreatePopupMenu();
|
|
569 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_alignment, L"Alignment");
|
|
570 {
|
|
571 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40062, L"Good");
|
|
572 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING | MF_CHECKED, 40063, L"Neutral");
|
|
573 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40064, L"Evil");
|
|
574 }
|
|
575 }
|
|
576
|
|
577 HMENU debug_time = CreatePopupMenu();
|
|
578 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_time, L"&Time");
|
|
579 {
|
|
580 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40009, L"Add 1 Day");
|
|
581 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40010, L"Add 1 Week");
|
|
582 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40011, L"Add 1 Month");
|
|
583 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40012, L"Add 1 Year");
|
|
584 }
|
|
585
|
|
586 HMENU debug_items = CreatePopupMenu();
|
|
587 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_items, L"&Items");
|
|
588 {
|
|
589 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40015, L"Generate level &1 item");
|
|
590 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40016, L"Generate level &2 item");
|
|
591 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40017, L"Generate level &3 item");
|
|
592 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40018, L"Generate level &4 item");
|
|
593 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40019, L"Generate level &5 item");
|
|
594 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40020, L"Generate level &6 item");
|
|
595 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40061, L"Generate special item");
|
|
596 }
|
|
597
|
|
598 HMENU debug_graphics = CreatePopupMenu();
|
|
599 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_graphics, L"&Graphics");
|
|
600 {
|
|
601 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40023, L"Lighting Mode");
|
|
602 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40024, L"Lighting Geometry");
|
|
603 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING | MF_GRAYED, 40104, L"Lights Off");
|
|
604 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40105, L"Colored Lights");
|
|
605 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40025, L"Debug Lights");
|
|
606 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40101, L"Debug Decals");
|
|
607 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40027, L"HWID Portals");
|
|
608 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40047, L"SWID Portals");
|
|
609 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40051, L"OD Frustum");
|
|
610 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40054, L"SWOD Constant Redraw");
|
|
611 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40055, L"SWOD Lit Rasterizer");
|
|
612 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40056, L"Party Light off");
|
|
613 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40060, L"SWOD Nice Lighting off");
|
|
614 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40067, L"HWOD Additive Fog Lights");
|
|
615 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40072, L"HWID Nice Lighting");
|
|
616 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40048, L"Wireframe");
|
|
617 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40049, L"Fog");
|
|
618 }
|
|
619
|
|
620 HMENU debug_misc = CreatePopupMenu();
|
|
621 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_misc, L"&Misc");
|
|
622 {
|
|
623 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40066, L"Object Viewcone Culling");
|
|
624 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40068, L"Red Tint");
|
|
625 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40071, L"Display Secrets");
|
|
626 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40102, L"Massive Bloodsplat");
|
|
627 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40103, L"Underwater Gravity");
|
|
628 }
|
|
629
|
|
630 HMENU debug_eax = CreatePopupMenu();
|
|
631 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_eax, L"EAX Environs");
|
|
632 {
|
|
633 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40074, L"NONE");
|
|
634 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40075, L"GENERIC");
|
|
635 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40076, L"PADDEDCELL");
|
|
636 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40077, L"ROOM");
|
|
637 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40078, L"BATHROOM");
|
|
638 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40079, L"LIVINGROOM");
|
|
639 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40080, L"STONEROOM");
|
|
640 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40081, L"AUDITORIUM");
|
|
641 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40082, L"CONCERTHALL");
|
|
642 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40083, L"CAVE");
|
|
643 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40084, L"ARENA");
|
|
644 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40085, L"HANGAR");
|
|
645 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40086, L"CARPETEDHALLWAY");
|
|
646 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40087, L"HALLWAY");
|
|
647 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40088, L"STONECORRIDOR");
|
|
648 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40089, L"ALLEY");
|
|
649 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40090, L"FOREST");
|
|
650 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40091, L"CITY");
|
|
651 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40092, L"MOUNTAINS");
|
|
652 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40093, L"QUARRY");
|
|
653 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40094, L"PLAIN");
|
|
654 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40095, L"PARKINGLOT");
|
|
655 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40096, L"SEWERPIPE");
|
|
656 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40097, L"UNDERWATER");
|
|
657 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40098, L"DRUGGED");
|
|
658 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40099, L"DIZZY");
|
|
659 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40100, L"PSICHOTIC");
|
|
660 }
|
|
661 }
|
|
662 }
|
|
663 return menu;
|
|
664 }
|
|
665
|
|
666
|
|
667
|
|
668
|
|
669 bool OSWindow::OnOSMenu(int item_id)
|
|
670 {
|
|
671 switch (item_id)
|
|
672 {
|
|
673 default: return false;
|
|
674
|
|
675
|
|
676 case 103: pRenderer->SavePCXScreenshot(); break;
|
|
677 case 101: // Quit game
|
|
678 case 40001:
|
|
679 SendMessageW(api_handle, WM_DESTROY, 0, 0);
|
|
680 break;
|
|
681
|
|
682 case 104:
|
|
683 pRenderer->ChangeBetweenWinFullscreenModes();
|
|
684 if (pArcomageGame->bGameInProgress)
|
|
685 pArcomageGame->field_F6 = 1;
|
|
686 break;
|
|
687
|
|
688 //SubMenu "Party"
|
|
689 case 40006: pParty->SetFood(pParty->uNumFoodRations + 20); break;
|
|
690 case 40007: pParty->SetGold(pParty->uNumGold + 10000); break;
|
|
691 case 40008: GivePartyExp(20000); break;
|
|
692 case 40013: pParty->SetGold(0); break;
|
|
693
|
|
694 case 40059:
|
|
695 for (uint i = 0; i < 4; ++i)
|
|
696 pParty->pPlayers[i].uSkillPoints = 50;
|
|
697 break;
|
|
698
|
|
699 case 40029: pPlayers[uActiveCharacter]->SetPertified(true); break;
|
|
700 case 40030: pPlayers[uActiveCharacter]->SetWeak(true); break;
|
|
701 case 40031: pPlayers[uActiveCharacter]->SetPoison3(true); break;
|
|
702 case 40032: pPlayers[uActiveCharacter]->SetPoison2(true); break;
|
|
703 case 40033: pPlayers[uActiveCharacter]->SetPoison1(true); break;
|
|
704 case 40034: pPlayers[uActiveCharacter]->SetDisease3(true); break;
|
|
705 case 40035: pPlayers[uActiveCharacter]->SetDisease2(true); break;
|
|
706 case 40036: pPlayers[uActiveCharacter]->SetDisease1(true); break;
|
|
707 case 40037: pPlayers[uActiveCharacter]->SetCursed(true); break;
|
|
708 case 40038: pPlayers[uActiveCharacter]->SetInsane(true); break;
|
|
709 case 40039: pPlayers[uActiveCharacter]->SetDrunk(true); break;
|
|
710 case 40040: pPlayers[uActiveCharacter]->SetUnconcious(true); break;
|
|
711 case 40041: pPlayers[uActiveCharacter]->SetDead(true); break;
|
|
712 case 40042: pPlayers[uActiveCharacter]->SetEradicated(true); break;
|
|
713 case 40043: pPlayers[uActiveCharacter]->SetAsleep(true); break;
|
|
714 case 40044: pPlayers[uActiveCharacter]->SetAfraid(true); break;
|
|
715 case 40045: pPlayers[uActiveCharacter]->SetParalyzed(true); break;
|
|
716 case 40073: pPlayers[uActiveCharacter]->SetZombie(true); break;
|
|
717
|
|
718 case 40062:
|
|
719 pParty->alignment = PartyAlignment_Good;
|
|
720 SetUserInterface(pParty->alignment, true);
|
|
721 break;
|
|
722 case 40063:
|
|
723 pParty->alignment = PartyAlignment_Neutral;
|
|
724 SetUserInterface(pParty->alignment, true);
|
|
725 break;
|
|
726 case 40064:
|
|
727 pParty->alignment = PartyAlignment_Evil;
|
|
728 SetUserInterface(pParty->alignment, true);
|
|
729 break;
|
|
730
|
|
731
|
|
732
|
|
733 //SubMenu "Time"
|
|
734 case 40009: pParty->uTimePlayed += Timer::Day; break;
|
|
735 case 40010: pParty->uTimePlayed += Timer::Week; break;
|
|
736 case 40011: pParty->uTimePlayed += Timer::Month; break;
|
|
737 case 40012: pParty->uTimePlayed += Timer::Year; break;
|
|
738
|
|
739 //SubMenu "Items"
|
|
740 case 40015: // uItemID_Rep_St == 1
|
|
741 case 40016: // uItemID_Rep_St == 2
|
|
742 case 40017: // uItemID_Rep_St == 3
|
|
743 case 40018: // uItemID_Rep_St == 4
|
|
744 case 40019: // uItemID_Rep_St == 5
|
|
745 case 40020: // uItemID_Rep_St == 6
|
|
746 {
|
|
747 int pItemID = rand() % 500;
|
|
748 for (uint i = 0; i < 500; ++i)
|
|
749 {
|
|
750 if (pItemID + i > 499)
|
|
751 pItemID = 0;
|
|
752 if (pItemsTable->pItems[pItemID + i].uItemID_Rep_St == (item_id - 40015 + 1))
|
|
753 {
|
|
754 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
|
|
755 break;
|
|
756 }
|
|
757 }
|
|
758 }
|
|
759 break;
|
|
760
|
|
761 case 40061:
|
|
762 {
|
|
763 int pItemID = rand() % 500;
|
|
764 for (uint i = 0; i < 500; ++i)
|
|
765 {
|
|
766 if (pItemID + i > 499)
|
|
767 pItemID = 0;
|
|
768 if (pItemsTable->pItems[pItemID + i].uItemID_Rep_St > 6)
|
|
769 {
|
|
770 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
|
|
771 break;
|
|
772 }
|
|
773 }
|
|
774 }
|
|
775 break;
|
|
776 }
|
|
777
|
|
778 return true;
|
|
779 } |