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