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