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