comparison mm7_2.cpp @ 1823:24b70fa98474

Merge
author Grumpy7
date Wed, 09 Oct 2013 08:09:48 +0200
parents 5f9eeb7bf8e6 bd899dfd976c
children bdac32c645c5
comparison
equal deleted inserted replaced
1822:5f9eeb7bf8e6 1823:24b70fa98474
62 #include "Log.h" 62 #include "Log.h"
63 #include "UI\UIHouses.h" 63 #include "UI\UIHouses.h"
64 #include "texts.h" 64 #include "texts.h"
65 #include "MM7.h" 65 #include "MM7.h"
66 #include "Lights.h" 66 #include "Lights.h"
67 #include "NewUI/MainMenu.h"
67 68
68 //----- (004BB756) -------------------------------------------------------- 69 //----- (004BB756) --------------------------------------------------------
69 int UseNPCSkill(NPCProf profession) 70 int UseNPCSkill(NPCProf profession)
70 { 71 {
71 switch (profession) 72 switch (profession)
2750 } 2751 }
2751 2752
2752 //----- (0045828B) -------------------------------------------------------- 2753 //----- (0045828B) --------------------------------------------------------
2753 unsigned int __fastcall GetSpellColor(signed int a1) 2754 unsigned int __fastcall GetSpellColor(signed int a1)
2754 { 2755 {
2755 unsigned __int16 v1; // dx@3 2756 if ( a1 == 0 )
2756 unsigned __int16 v2; // cx@6 2757 return TargetColor(0, 0, 0);
2757 unsigned __int16 v4; // [sp-4h] [bp-4h]@3 2758 if ( a1 < 12 )
2758 2759 return TargetColor(255, 85, 0);
2759 if ( a1 < 1 ) 2760 if ( a1 < 23 )
2760 { 2761 return TargetColor(150, 212, 255);
2761 if ( a1 < 12 ) 2762 if ( a1 < 34 )
2762 { 2763 return TargetColor(0, 128, 255);
2763 if ( a1 < 23 ) 2764 if ( a1 < 45 )
2764 { 2765 return TargetColor(128, 128, 128);
2765 if ( a1 < 34 ) 2766 if ( a1 < 56 )
2766 { 2767 return TargetColor(225, 225, 225);
2767 if ( a1 < 45 ) 2768 if ( a1 < 67 )
2768 { 2769 return TargetColor(235, 15, 255);
2769 if ( a1 < 56 ) 2770 if ( a1 < 78 )
2770 { 2771 return TargetColor(255, 128, 0);
2771 if ( a1 < 67 ) 2772 if ( a1 < 89 )
2772 { 2773 return TargetColor(255, 255, 155);
2773 if ( a1 < 78 ) 2774 if ( a1 < 100 )
2774 { 2775 return TargetColor(192, 192, 240);
2775 if ( a1 < 89 )
2776 {
2777 v4 = 0;
2778 v1 = 0;
2779 v2 = 0;
2780 return TargetColor(v2, v1, v4);
2781 }
2782 }
2783 else
2784 {
2785 LABEL_25:
2786 if ( a1 < 89 )
2787 {
2788 v4 = 155;
2789 v2 = 255;
2790 v1 = v2;
2791 return TargetColor(v2, v1, v4);
2792 }
2793 }
2794 if ( a1 < 100 )
2795 {
2796 v4 = 240;
2797 v2 = 192;
2798 v1 = v2;
2799 return TargetColor(v2, v1, v4);
2800 }
2801 v4 = 0;
2802 v1 = 0;
2803 v2 = 0;
2804 return TargetColor(v2, v1, v4);
2805 }
2806 LABEL_21:
2807 if ( a1 < 78 )
2808 {
2809 v4 = 0;
2810 v1 = 128;
2811 v2 = 255;
2812 return TargetColor(v2, v1, v4);
2813 }
2814 goto LABEL_25;
2815 }
2816 LABEL_18:
2817 if ( a1 < 67 )
2818 {
2819 v4 = 255;
2820 v1 = 15;
2821 v2 = 235;
2822 return TargetColor(v2, v1, v4);
2823 }
2824 goto LABEL_21;
2825 }
2826 LABEL_15:
2827 if ( a1 < 56 )
2828 {
2829 v2 = 225;
2830 v4 = v2;
2831 v1 = v2;
2832 return TargetColor(v2, v1, v4);
2833 }
2834 goto LABEL_18;
2835 }
2836 LABEL_11:
2837 if ( a1 < 45 )
2838 {
2839 v2 = 128;
2840 v4 = v2;
2841 v1 = v2;
2842 return TargetColor(v2, v1, v4);
2843 }
2844 goto LABEL_15;
2845 }
2846 LABEL_8:
2847 if ( a1 < 34 )
2848 {
2849 v4 = 255;
2850 v1 = 128;
2851 v2 = 0;
2852 return TargetColor(v2, v1, v4);
2853 }
2854 goto LABEL_11;
2855 }
2856 }
2857 else
2858 {
2859 if ( a1 < 12 )
2860 {
2861 v4 = 0;
2862 v1 = 85;
2863 v2 = 255;
2864 return TargetColor(v2, v1, v4);
2865 }
2866 }
2867 if ( a1 >= 23 )
2868 goto LABEL_8;
2869 v4 = 255;
2870 v1 = 212;
2871 v2 = 150;
2872 return TargetColor(v2, v1, v4);
2873 } 2776 }
2874 2777
2875 //----- (004610AA) -------------------------------------------------------- 2778 //----- (004610AA) --------------------------------------------------------
2876 void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2) 2779 void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2)
2877 { 2780 {
2935 //v2 = (char *)&pActors[0].uNPC_ID; 2838 //v2 = (char *)&pActors[0].uNPC_ID;
2936 //do 2839 //do
2937 //{ 2840 //{
2938 v3 = pActor->pMonsterInfo.uID; 2841 v3 = pActor->pMonsterInfo.uID;
2939 v17 = 0; 2842 v17 = 0;
2940 if ( v3 >= 115 && v3 <= 186 || v3 >= 232 && v3 <= 249 ) 2843 if ( pActor->pMonsterInfo.uID >= 115 && pActor->pMonsterInfo.uID <= 186
2844 || pActor->pMonsterInfo.uID >= 232 && pActor->pMonsterInfo.uID <= 249 )
2941 v17 = 1; 2845 v17 = 1;
2942 //v1 = 0; 2846 //v1 = 0;
2943 v4 = (v3 - 1) % 3; 2847 v4 = (v3 - 1) % 3;
2944 if ( 2 == v4 ) 2848 if ( 2 == v4 )
2945 { 2849 {
3106 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); 3010 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0);
3107 3011
3108 pTexture_PCX.Release(); 3012 pTexture_PCX.Release();
3109 pTexture_PCX.Load("title.pcx", 0); 3013 pTexture_PCX.Load("title.pcx", 0);
3110 SetCurrentMenuID(MENU_MAIN); 3014 SetCurrentMenuID(MENU_MAIN);
3111 SetForegroundWindow(hWnd); 3015 //SetForegroundWindow(hWnd);
3112 SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0); 3016 //SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0);
3113 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) 3017 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD)
3114 { 3018 {
3115 POINT pt; 3019 POINT pt;
3116 pMouse->GetCursorPos(&pt); 3020 pMouse->GetCursorPos(&pt);
3117 pWindow = pWindow_MainMenu; 3021 pWindow = pWindow_MainMenu;
3211 } 3115 }
3212 pWindow_MainMenu->Release(); 3116 pWindow_MainMenu->Release();
3213 pIcons_LOD->RemoveTexturesPackFromTextureList(); 3117 pIcons_LOD->RemoveTexturesPackFromTextureList();
3214 } 3118 }
3215 3119
3216 //----- (004637EB) --------------------------------------------------------
3217 int __stdcall aWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3218 {
3219 //HANDLE v6; // eax@32
3220 //HDC v10; // edi@50
3221 //int v11; // esi@50
3222 //signed int v13; // eax@135
3223 //char v29; // dl@209
3224 //bool v31; // ebx@211
3225 //float v33; // ST04_4@246
3226 //float v34; // ST04_4@254
3227 //struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13
3228 //int pXY[2]; // [sp+64h] [bp-8h]@261
3229 //int a2; // [sp+7Ch] [bp+10h]@50
3230
3231 switch (uMsg)
3232 {
3233 case WM_SIZING: return 1;
3234
3235 case WM_CREATE: case WM_NCCREATE:
3236 case WM_GETTEXT: case WM_SETTEXT:
3237 case WM_SHOWWINDOW:
3238 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3239
3240 case WM_DESTROY:
3241 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
3242 PostQuitMessage(0);
3243 return 0;
3244
3245 case WM_WINDOWPOSCHANGED:
3246 {
3247 if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
3248 BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
3249
3250 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3251 }
3252
3253 case WM_CHAR:
3254 {
3255 if (!pKeyActionMap->_459F10(wParam) && !viewparams->field_4C)
3256 GUI_HandleHotkey(wParam);
3257 }
3258 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3259
3260
3261 case WM_DEVICECHANGE:
3262 {
3263 if (wParam == 0x8000) // CD or some device has been inserted - notify InsertCD dialog
3264 PostMessageW(hInsertCDWindow, WM_USER + 1, 0, 0);
3265 return 0;
3266 }
3267
3268 case WM_COMMAND:
3269 {
3270 switch (wParam)
3271 {
3272 case 103: pRenderer->SavePCXScreenshot(); return 0;
3273
3274 case 101: // Quit game
3275 case 40001:
3276 SendMessageW(hWnd, WM_DESTROY, 0, 0);
3277 return 0;
3278
3279
3280 case 104:
3281 pRenderer->ChangeBetweenWinFullscreenModes();
3282 if ( pArcomageGame->bGameInProgress )
3283 pArcomageGame->field_F6 = 1;
3284 return 0;
3285
3286 //SubMenu "Party"
3287 case 40007: pParty->SetGold(pParty->uNumGold + 10000); return 0;
3288 case 40008: GivePartyExp(20000); return 0;
3289 case 40013: pParty->SetGold(0); return 0;
3290
3291 case 40059:
3292 for (uint i = 0; i < 4; ++i)
3293 pParty->pPlayers[i].uSkillPoints = 50;
3294 return 0;
3295
3296 case 40029: pPlayers[uActiveCharacter]->SetPertified(true); return 0;
3297 case 40030: pPlayers[uActiveCharacter]->SetWeak(true); return 0;
3298 case 40031: pPlayers[uActiveCharacter]->SetPoison3(true); return 0;
3299 case 40032: pPlayers[uActiveCharacter]->SetPoison2(true); return 0;
3300 case 40033: pPlayers[uActiveCharacter]->SetPoison1(true); return 0;
3301 case 40034: pPlayers[uActiveCharacter]->SetDisease3(true); return 0;
3302 case 40035: pPlayers[uActiveCharacter]->SetDisease2(true); return 0;
3303 case 40036: pPlayers[uActiveCharacter]->SetDisease1(true); return 0;
3304 case 40037: pPlayers[uActiveCharacter]->SetCursed(true); return 0;
3305 case 40038: pPlayers[uActiveCharacter]->SetInsane(true); return 0;
3306 case 40039: pPlayers[uActiveCharacter]->SetDrunk(true); return 0;
3307 case 40040: pPlayers[uActiveCharacter]->SetUnconcious(true); return 0;
3308 case 40041: pPlayers[uActiveCharacter]->SetDead(true); return 0;
3309 case 40042: pPlayers[uActiveCharacter]->SetEradicated(true); return 0;
3310 case 40043: pPlayers[uActiveCharacter]->SetAsleep(true); return 0;
3311 case 40044: pPlayers[uActiveCharacter]->SetAfraid(true); return 0;
3312 case 40045: pPlayers[uActiveCharacter]->SetParalyzed(true); return 0;
3313 case 40073: pPlayers[uActiveCharacter]->SetZombie(true); return 0;
3314
3315 case 40006: pParty->SetFood(pParty->uNumFoodRations + 20); return 0;
3316
3317 case 40062:
3318 pParty->alignment = PartyAlignment_Good;
3319 SetUserInterface(pParty->alignment, true);
3320 return 0;
3321 case 40063:
3322 pParty->alignment = PartyAlignment_Neutral;
3323 SetUserInterface(pParty->alignment, true);
3324 return 0;
3325 case 40064:
3326 pParty->alignment = PartyAlignment_Evil;
3327 SetUserInterface(pParty->alignment, true);
3328 return 0;
3329
3330 //SubMenu "Time"
3331 case 40009: pParty->uTimePlayed += Timer::Day; return 0;
3332 case 40010: pParty->uTimePlayed += Timer::Week; return 0;
3333 case 40011: pParty->uTimePlayed += Timer::Month; return 0;
3334 case 40012: pParty->uTimePlayed += Timer::Year; return 0;
3335
3336 //SubMenu "Items"
3337 case 40015:
3338 {
3339 int pItemID = rand() % 500;
3340 for ( uint i = 0; i < 500; ++i )
3341 {
3342 if ( pItemID + i > 499 )
3343 pItemID = 0;
3344 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 1 )
3345 {
3346 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
3347 return 0;
3348 }
3349 }
3350 }
3351 return 0;
3352 case 40016:
3353 {
3354 int pItemID = rand() % 500;
3355 for ( uint i = 0; i < 500; ++i )
3356 {
3357 if ( pItemID + i > 499 )
3358 pItemID = 0;
3359 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 2 )
3360 {
3361 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
3362 return 0;
3363 }
3364 }
3365 }
3366 return 0;
3367 case 40017:
3368 {
3369 int pItemID = rand() % 500;
3370 for ( uint i = 0; i < 500; ++i )
3371 {
3372 if ( pItemID + i > 499 )
3373 pItemID = 0;
3374 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 3 )
3375 {
3376 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
3377 return 0;
3378 }
3379 }
3380 }
3381 return 0;
3382 case 40018:
3383 {
3384 int pItemID = rand() % 500;
3385 for ( uint i = 0; i < 500; ++i )
3386 {
3387 if ( pItemID + i > 499 )
3388 pItemID = 0;
3389 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 4 )
3390 {
3391 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
3392 return 0;
3393 }
3394 }
3395 }
3396 return 0;
3397 case 40019:
3398 {
3399 int pItemID = rand() % 500;
3400 for ( uint i = 0; i < 500; ++i )
3401 {
3402 if ( pItemID + i > 499 )
3403 pItemID = 0;
3404 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 5 )
3405 {
3406 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
3407 return 0;
3408 }
3409 }
3410 }
3411 return 0;
3412 case 40020:
3413 {
3414 int pItemID = rand() % 500;
3415 for ( uint i = 0; i < 500; ++i )
3416 {
3417 if ( pItemID + i > 499 )
3418 pItemID = 0;
3419 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 6 )
3420 {
3421 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
3422 return 0;
3423 }
3424 }
3425 }
3426 return 0;
3427 case 40061:
3428 {
3429 int pItemID = rand() % 500;
3430 for ( uint i = 0; i < 500; ++i )
3431 {
3432 if ( pItemID + i > 499 )
3433 pItemID = 0;
3434 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St > 6 )
3435 {
3436 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i);
3437 return 0;
3438 }
3439 }
3440 }
3441 return 0;
3442
3443 }
3444 }
3445 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3446
3447 case WM_LBUTTONDOWN:
3448 if (pArcomageGame->bGameInProgress)
3449 {
3450 pArcomageGame->stru1.field_0 = 7;
3451 ArcomageGame::OnMouseClick(0, true);
3452 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3453 }
3454
3455 goto __handle_mouse_click;
3456
3457 case WM_RBUTTONDOWN:
3458 if (pArcomageGame->bGameInProgress)
3459 {
3460 pArcomageGame->stru1.field_0 = 8;
3461 ArcomageGame::OnMouseClick(1, true);
3462 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3463 }
3464
3465 if (pVideoPlayer->pVideoFrame.pPixels)
3466 pVideoPlayer->bStopBeforeSchedule = 1;
3467
3468 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3469
3470 if (pGame)
3471 {
3472 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 0, &vis_sprite_filter_2, &vis_door_filter);
3473 }
3474
3475 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
3476 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3477
3478
3479 case WM_LBUTTONUP:
3480 if ( !pArcomageGame->bGameInProgress )
3481 {
3482 back_to_game();
3483 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3484 }
3485 pArcomageGame->stru1.field_0 = 3;
3486 ArcomageGame::OnMouseClick(0, 0);
3487 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3488 case WM_RBUTTONUP:
3489 if ( !pArcomageGame->bGameInProgress )
3490 {
3491 back_to_game();
3492 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3493 }
3494 pArcomageGame->stru1.field_0 = 4;
3495 ArcomageGame::OnMouseClick(1, false);
3496 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3497
3498 case WM_LBUTTONDBLCLK:
3499 if ( pArcomageGame->bGameInProgress )
3500 {
3501 pArcomageGame->stru1.field_0 = 7;
3502 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3503 }
3504
3505 __handle_mouse_click:
3506 if (pVideoPlayer->pVideoFrame.pPixels)
3507 pVideoPlayer->bStopBeforeSchedule = 1;
3508
3509 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3510
3511 if (GetCurrentMenuID() == MENU_CREATEPARTY)
3512 {
3513 UI_OnKeyDown(VK_SELECT);
3514 }
3515
3516 if (pGame)
3517 pGame->PickMouse(512.0, LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_3, &vis_door_filter);
3518
3519 UI_OnMouseLeftClick(0);
3520
3521 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3522
3523 case WM_RBUTTONDBLCLK:
3524 if ( !pArcomageGame->bGameInProgress )
3525 {
3526 if (pVideoPlayer->pVideoFrame.pPixels)
3527 pVideoPlayer->bStopBeforeSchedule = 1;
3528
3529 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3530
3531 if (pGame)
3532 {
3533 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_2, &vis_door_filter);
3534 }
3535
3536 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
3537 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3538 }
3539
3540 pArcomageGame->stru1.field_0 = 8;
3541
3542 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3543
3544 case WM_MBUTTONDOWN:
3545 if (pRenderer->pRenderD3D && pGame)
3546 {
3547 pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 1, &vis_sprite_filter_3, &vis_face_filter);
3548 }
3549
3550 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3551
3552 case WM_MOUSEMOVE:
3553 if ( pArcomageGame->bGameInProgress )
3554 {
3555 ArcomageGame::OnMouseMove(LOWORD(lParam), HIWORD(lParam));
3556 ArcomageGame::OnMouseClick(0, wParam == MK_LBUTTON);
3557 ArcomageGame::OnMouseClick(1, wParam == MK_RBUTTON);
3558 }
3559 else
3560 {
3561 pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
3562 }
3563
3564 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3565
3566 case WM_SYSCOMMAND:
3567 if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER )
3568 return 0;
3569
3570 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3571
3572 case WM_KEYUP:
3573 if (wParam == VK_CONTROL)
3574 {
3575 dword_507B98_ctrl_pressed = 0;
3576 }
3577
3578 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3579
3580 case WM_KEYDOWN:
3581 if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
3582 {
3583 pKeyActionMap->_459F10(wParam);
3584 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3585 }
3586 if ( !pArcomageGame->bGameInProgress )
3587 {
3588 if ( pVideoPlayer->pVideoFrame.pPixels )
3589 pVideoPlayer->bStopBeforeSchedule = 1;
3590 if ( wParam == VK_RETURN )
3591 {
3592 if ( !viewparams->field_4C )
3593 UI_OnKeyDown(wParam);
3594 return 0;
3595 }
3596 if ( wParam == VK_CONTROL )
3597 {
3598 dword_507B98_ctrl_pressed = 1;
3599 return 0;
3600 }
3601 if ( wParam == VK_ESCAPE )
3602 {
3603 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
3604 return 0;
3605 }
3606 if ( wParam <= VK_HOME )
3607 return 0;
3608 if ( wParam > VK_DOWN )
3609 {
3610 if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
3611 return 0;
3612 SendMessageW(hWnd, WM_COMMAND, 104, 0);
3613 return 0;
3614 }
3615 if ( wParam >= VK_LEFT && wParam <= VK_DOWN )
3616 {
3617 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
3618 {
3619 if ( !viewparams->field_4C )
3620 UI_OnKeyDown(wParam);
3621 return 0;
3622 }
3623 }
3624 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW )
3625 return 0;
3626 }
3627
3628 pArcomageGame->stru1.field_0 = 1;
3629
3630 set_stru1_field_8_InArcomage(MapVirtualKey(wParam, MAPVK_VK_TO_CHAR));
3631 if ( wParam == 27 )
3632 {
3633 pArcomageGame->GameOver = 1;
3634 pArcomageGame->field_F4 = 1;
3635 pArcomageGame->uGameResult = 2;
3636 pArcomageGame->field_B0 = -2;
3637 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3638 }
3639 if ( wParam != 114 )
3640 {
3641 if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
3642 SendMessage(hWnd, WM_COMMAND, 0x68u, 0);
3643 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3644 }
3645 SendMessageW(hWnd, WM_COMMAND, 103, 0);
3646 return 0;
3647
3648 case WM_ACTIVATEAPP:
3649 if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) )
3650 {
3651 if ( BYTE1(dword_6BE364_game_settings_1) & 1 )
3652 {
3653 dword_4E98BC_bApplicationActive = 1;
3654 if ( pRenderer->bWindowMode )
3655 {
3656 HDC hDC = GetDC(hWnd);
3657 int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL);
3658 int planes = GetDeviceCaps(hDC, PLANES);
3659 ReleaseDC(hWnd, hDC);
3660 if (bitsPerPixel != 16 || planes != 1)
3661 Error(pGlobalTXT_LocalizationStrings[62]);
3662 }
3663 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
3664
3665 if ( pArcomageGame->bGameInProgress )
3666 {
3667 pArcomageGame->field_F9 = 1;
3668 }
3669 else
3670 {
3671 if ( BYTE1(dword_6BE364_game_settings_1) & 2 )
3672 BYTE1(dword_6BE364_game_settings_1) &= 0xFDu;
3673 else
3674 pEventTimer->Resume();
3675 if ( BYTE1(dword_6BE364_game_settings_1) & 4 )
3676 BYTE1(dword_6BE364_game_settings_1) &= 0xFBu;
3677 else
3678 pMiscTimer->Resume();
3679
3680 viewparams->bRedrawGameUI = true;
3681 if ( pVideoPlayer->pSmackerMovie )
3682 {
3683 pRenderer->RestoreFrontBuffer();
3684 pRenderer->_4A184C();
3685 pVideoPlayer->_4BF5B2();
3686 }
3687 }
3688 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie )
3689 AIL_redbook_resume(pAudioPlayer->hAILRedbook);
3690 }
3691 }
3692 else
3693 {
3694 if (!(dword_6BE364_game_settings_1 & 0x100))
3695 {
3696 dword_4E98BC_bApplicationActive = 0;
3697 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie )
3698 pVideoPlayer->bStopBeforeSchedule = 1;
3699
3700 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
3701 SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
3702 ClipCursor(0);
3703 dword_6BE364_game_settings_1 |= 0x100u;
3704 if ( pEventTimer->bPaused )
3705 BYTE1(dword_6BE364_game_settings_1) |= 2u;
3706 else
3707 pEventTimer->Pause();
3708 if ( pMiscTimer->bPaused )
3709 BYTE1(dword_6BE364_game_settings_1) |= 4u;
3710 else
3711 pMiscTimer->Pause();
3712
3713 pAudioPlayer->StopChannels(-1, -1);
3714 if ( pAudioPlayer->hAILRedbook )
3715 AIL_redbook_pause(pAudioPlayer->hAILRedbook);
3716 }
3717 }
3718 return 0;
3719
3720 case WM_SETFOCUS:
3721 dword_4E98BC_bApplicationActive = 0;
3722 if (pRenderer)
3723 {
3724 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
3725 SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
3726 }
3727 ClipCursor(0);
3728 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3729
3730 case WM_KILLFOCUS:
3731 dword_4E98BC_bApplicationActive = 1;
3732 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3733
3734 case WM_PAINT:
3735 if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
3736 return 0;
3737 PAINTSTRUCT Paint;
3738 BeginPaint(hWnd, &Paint);
3739 if ( pArcomageGame->bGameInProgress )
3740 {
3741 pArcomageGame->field_F9 = 1;
3742 }
3743 else
3744 {
3745 if ( !pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() || !AreRenderSurfacesOk() )
3746 {
3747 EndPaint(hWnd, &Paint);
3748 return 0;
3749 }
3750 }
3751 pRenderer->Present();
3752 EndPaint(hWnd, &Paint);
3753 return 0;
3754
3755 default:
3756 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
3757 }
3758 }
3759 3120
3760 //----- (00464479) -------------------------------------------------------- 3121 //----- (00464479) --------------------------------------------------------
3761 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() 3122 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows()
3762 { 3123 {
3763 int v0; // esi@9 3124 int v0; // esi@9
3810 { 3171 {
3811 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); 3172 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
3812 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); 3173 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
3813 pGame->Deinitialize(); 3174 pGame->Deinitialize();
3814 pRenderer->Release2(); 3175 pRenderer->Release2();
3815 if ( !DestroyWindow(hWnd) ) 3176 delete window;
3816 GetLastError(); 3177 //if ( !DestroyWindow(hWnd) )
3817 hWnd = 0; 3178 // GetLastError();
3818 exit(exitCode); 3179 exit(exitCode);
3819 } 3180 }
3820 3181
3821 //----- (004647AB) -------------------------------------------------------- 3182 //----- (004647AB) --------------------------------------------------------
3822 void FinalInitialization() 3183 void FinalInitialization()
4272 WriteWindowsRegistryString("CDDrive", drive); 3633 WriteWindowsRegistryString("CDDrive", drive);
4273 return true; 3634 return true;
4274 } 3635 }
4275 } 3636 }
4276 3637
4277 if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", ::hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0)) 3638 if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0))
4278 continue; 3639 continue;
4279 return false; 3640 return false;
4280 } 3641 }
4281 } 3642 }
4282 3643
4283 3644
4284
4285 void CenterWindowAndAdjustSize(HWND hwnd, int client_width, int client_height)
4286 {
4287 RECT rcWindow;
4288 GetWindowRect(hWnd, &rcWindow);
4289
4290 RECT rcClient;
4291 GetClientRect(hWnd, &rcClient);
4292
4293 int window_borders_width = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left),
4294 window_borders_height = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
4295 int window_total_width = client_width + window_borders_width,
4296 window_total_height = client_height + window_borders_height;
4297
4298
4299 if (GetMenu(hwnd))
4300 window_total_height += GetSystemMetrics(SM_CYMENU);
4301
4302 MoveWindow(hWnd, (GetSystemMetrics(SM_CXSCREEN) - window_total_width) / 2,
4303 (GetSystemMetrics(SM_CYSCREEN) - window_total_height) / 2,
4304 window_total_width,
4305 window_total_height, 0);
4306 /*
4307 auto hDesktopDC = GetDC(nullptr);
4308 uint uDesktopWidth = GetDeviceCaps(hDesktopDC, HORZRES);
4309 uint uDesktopHeight = GetDeviceCaps(hDesktopDC, VERTRES);
4310 ReleaseDC(nullptr, hDesktopDC);
4311 */
4312 }
4313 3645
4314 //----- (004651F4) -------------------------------------------------------- 3646 //----- (004651F4) --------------------------------------------------------
4315 bool MM7_Initialize(int game_width, int game_height) 3647 bool MM7_Initialize(int game_width, int game_height)
4316 { 3648 {
4317 wchar_t pCurrentDir[1024]; 3649 wchar_t pCurrentDir[1024];
4323 bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); 3655 bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile);
4324 if (bNoCD) 3656 if (bNoCD)
4325 bCanLoadFromCD = false; 3657 bCanLoadFromCD = false;
4326 if (bCanLoadFromCD) 3658 if (bCanLoadFromCD)
4327 { 3659 {
4328 if (!FindMM7CD(hWnd, &cMM7GameCDDriveLetter)) 3660 if (!FindMM7CD(nullptr, &cMM7GameCDDriveLetter))
4329 return false; 3661 return false;
4330 } 3662 }
4331 3663
4332 3664
4333 srand(GetTickCount()); 3665 srand(GetTickCount());
4334 3666
4335 WNDCLASSEXW wcxw; 3667 window = OSWindow::Create(L"Might and MagicŪ Trilogy", game_width, game_height);
4336 {
4337 wcxw.cbSize = sizeof(wcxw);
4338 wcxw.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
4339 wcxw.lpfnWndProc = (WNDPROC)aWinProc;
4340 wcxw.cbClsExtra = 0;
4341 wcxw.cbWndExtra = 0;
4342 wcxw.hInstance = GetModuleHandleW(nullptr);
4343 wcxw.hCursor = 0;
4344 wcxw.hIcon = wcxw.hIconSm = LoadIconW(wcxw.hInstance, L"MM7_ICON");
4345 wcxw.lpszMenuName = nullptr;
4346 wcxw.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
4347 wcxw.lpszClassName = L"M&MTrilogy";
4348 }
4349 if (!RegisterClassExW(&wcxw))
4350 {
4351 Log::Warning(L"Cannot register window class");
4352 return false;
4353 }
4354
4355 hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and MagicŪ VII",
4356 WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER,
4357 0, 0,
4358 1, 1,
4359 nullptr,
4360 nullptr,
4361 wcxw.hInstance,
4362 nullptr);
4363
4364 HMENU menu = CreateMenu();
4365 {
4366 HMENU file = CreatePopupMenu();
4367 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)file, L"&File");
4368 {
4369 AppendMenuW(file, MF_ENABLED | MF_STRING, 40001, L"Exit");
4370 }
4371
4372 HMENU debug = CreatePopupMenu();
4373 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug, L"&Debug");
4374 {
4375 HMENU debug_party = CreatePopupMenu();
4376 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party, L"&Party");
4377 {
4378 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40007, L"Give Gold (10 000)");
4379 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40008, L"Give Exp (20 000)");
4380 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40059, L"Give Skills (50 each)");
4381 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40013, L"Remove Gold");
4382
4383 HMENU debug_party_setconditions = CreatePopupMenu();
4384 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_setconditions, L"Set Condition");
4385 {
4386 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40044, L"Afraid");
4387 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40043, L"Asleep");
4388 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40037, L"Curse");
4389 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40036, L"Disease1");
4390 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40035, L"Disease2");
4391 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40034, L"Disease3");
4392 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40041, L"Dead");
4393 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40039, L"Drunk");
4394 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40042, L"Eradicated");
4395 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40038, L"Insane");
4396 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40045, L"Paralyzed");
4397 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40033, L"Poison1");
4398 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40032, L"Poison2");
4399 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40031, L"Poison3");
4400 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40029, L"&Stone");
4401 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40040, L"Unconscious");
4402 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40030, L"Weak");
4403 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40073, L"Zombie");
4404 }
4405
4406 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40006, L"Set Food (20)");
4407
4408 HMENU debug_party_alignment = CreatePopupMenu();
4409 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_alignment, L"Alignment");
4410 {
4411 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40062, L"Good");
4412 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING | MF_CHECKED, 40063, L"Neutral");
4413 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40064, L"Evil");
4414 }
4415 }
4416
4417 HMENU debug_time = CreatePopupMenu();
4418 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_time, L"&Time");
4419 {
4420 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40009, L"Add 1 Day");
4421 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40010, L"Add 1 Week");
4422 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40011, L"Add 1 Month");
4423 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40012, L"Add 1 Year");
4424 }
4425
4426 HMENU debug_items = CreatePopupMenu();
4427 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_items, L"&Items");
4428 {
4429 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40015, L"Generate level &1 item");
4430 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40016, L"Generate level &2 item");
4431 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40017, L"Generate level &3 item");
4432 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40018, L"Generate level &4 item");
4433 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40019, L"Generate level &5 item");
4434 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40020, L"Generate level &6 item");
4435 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40061, L"Generate special item");
4436 }
4437
4438 HMENU debug_graphics = CreatePopupMenu();
4439 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_graphics, L"&Graphics");
4440 {
4441 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40023, L"Lighting Mode");
4442 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40024, L"Lighting Geometry");
4443 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING | MF_GRAYED, 40104, L"Lights Off");
4444 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40105, L"Colored Lights");
4445 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40025, L"Debug Lights");
4446 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40101, L"Debug Decals");
4447 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40027, L"HWID Portals");
4448 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40047, L"SWID Portals");
4449 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40051, L"OD Frustum");
4450 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40054, L"SWOD Constant Redraw");
4451 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40055, L"SWOD Lit Rasterizer");
4452 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40056, L"Party Light off");
4453 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40060, L"SWOD Nice Lighting off");
4454 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40067, L"HWOD Additive Fog Lights");
4455 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40072, L"HWID Nice Lighting");
4456 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40048, L"Wireframe");
4457 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40049, L"Fog");
4458 }
4459
4460 HMENU debug_misc = CreatePopupMenu();
4461 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_misc, L"&Misc");
4462 {
4463 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40066, L"Object Viewcone Culling");
4464 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40068, L"Red Tint");
4465 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40071, L"Display Secrets");
4466 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40102, L"Massive Bloodsplat");
4467 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40103, L"Underwater Gravity");
4468 }
4469
4470 HMENU debug_eax = CreatePopupMenu();
4471 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_eax, L"EAX Environs");
4472 {
4473 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40074, L"NONE");
4474 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40075, L"GENERIC");
4475 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40076, L"PADDEDCELL");
4476 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40077, L"ROOM");
4477 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40078, L"BATHROOM");
4478 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40079, L"LIVINGROOM");
4479 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40080, L"STONEROOM");
4480 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40081, L"AUDITORIUM");
4481 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40082, L"CONCERTHALL");
4482 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40083, L"CAVE");
4483 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40084, L"ARENA");
4484 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40085, L"HANGAR");
4485 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40086, L"CARPETEDHALLWAY");
4486 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40087, L"HALLWAY");
4487 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40088, L"STONECORRIDOR");
4488 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40089, L"ALLEY");
4489 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40090, L"FOREST");
4490 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40091, L"CITY");
4491 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40092, L"MOUNTAINS");
4492 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40093, L"QUARRY");
4493 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40094, L"PLAIN");
4494 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40095, L"PARKINGLOT");
4495 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40096, L"SEWERPIPE");
4496 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40097, L"UNDERWATER");
4497 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40098, L"DRUGGED");
4498 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40099, L"DIZZY");
4499 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40100, L"PSICHOTIC");
4500 }
4501 }
4502 }
4503
4504 SetMenu(hWnd, menu);
4505 CenterWindowAndAdjustSize(hWnd, game_width, game_height);
4506 ShowWindow(hWnd, SW_SHOWNORMAL);
4507
4508 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
4509 3668
4510 pRenderer = Render::Create(); 3669 pRenderer = Render::Create();
4511 if (!pRenderer) 3670 if (!pRenderer)
4512 { 3671 {
4513 Log::Warning(L"Render creation failed"); 3672 Log::Warning(L"Render creation failed");
4514 return false; 3673 return false;
4515 } 3674 }
4516 else 3675 else
4517 { 3676 {
4518 bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false); 3677 bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false);
4519 uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1); 3678 //uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1);
4520 bool bColoredLights = ReadWindowsRegistryInt("Colored Lights", false); 3679 bool bColoredLights = ReadWindowsRegistryInt("Colored Lights", false);
4521 uint uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1); 3680 uint uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1);
4522 uint bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0; 3681 uint bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0;
4523 3682
4524 if (!pRenderer->Initialize(bWindowMode, game_width, game_height, uDefaultDevice, bColoredLights, uLevelOfDetail, bTinting)) 3683 if (!pRenderer->Initialize(bWindowMode, window, bColoredLights, uLevelOfDetail, bTinting))
4525 { 3684 {
4526 Log::Warning(L"Render failed to initialize"); 3685 Log::Warning(L"Render failed to initialize");
4527 return false; 3686 return false;
4528 } 3687 }
4529 } 3688 }
4795 if (dword_6BE364_game_settings_1 & 2 || !(dword_6BE368_debug_settings_2 & 1))// 3954 if (dword_6BE364_game_settings_1 & 2 || !(dword_6BE368_debug_settings_2 & 1))//
4796 // color depth != 16 3955 // color depth != 16
4797 // or 3956 // or
4798 // not in window 3957 // not in window
4799 { 3958 {
4800 SetMenu(hWnd, 0); 3959 window->SetFullscreenMode();
4801 SetWindowLongA(hWnd, GWL_EXSTYLE, 0); 3960 pRenderer->InitializeFullscreen();
4802 SetWindowLongA(hWnd, GWL_STYLE, WS_VISIBLE);
4803 pRenderer->InitializeFullscreen(hWnd);
4804 } 3961 }
4805 else 3962 else
4806 { 3963 {
4807 ClipCursor(nullptr); 3964 window->SetWindowedMode(game_width, game_height);
4808 pRenderer->SwitchToWindow(hWnd); 3965 pRenderer->SwitchToWindow();
4809 } 3966 }
4810 3967
4811 uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9); 3968 uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9);
4812 if (uSoundVolumeMultiplier > 9) 3969 if (uSoundVolumeMultiplier > 9)
4813 uSoundVolumeMultiplier = 9; 3970 uSoundVolumeMultiplier = 9;
4834 3991
4835 uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 0); 3992 uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 0);
4836 dword_6BE384_2dacceloff = ReadWindowsRegistryInt("2dacceloff", 0); 3993 dword_6BE384_2dacceloff = ReadWindowsRegistryInt("2dacceloff", 0);
4837 3994
4838 if (!bNoSound) 3995 if (!bNoSound)
4839 pAudioPlayer->Initialize(hWnd); 3996 pAudioPlayer->Initialize();
4840 3997
4841 pVideoPlayer = new VideoPlayer(); 3998 pVideoPlayer = new VideoPlayer();
4842 pVideoPlayer->Initialize(); 3999 pVideoPlayer->Initialize(window);
4843 4000
4844 dword_6BE364_game_settings_1 |= 0x4000; 4001 dword_6BE364_game_settings_1 |= 0x4000;
4845 4002
4846 switch ( uTurnSpeed ) 4003 switch ( uTurnSpeed )
4847 { 4004 {
4867 4024
4868 return true; 4025 return true;
4869 } 4026 }
4870 4027
4871 //----- (00465D0B) -------------------------------------------------------- 4028 //----- (00465D0B) --------------------------------------------------------
4872 void SecondaryInitialization() 4029 void SecondaryInitialization()
4873 { 4030 {
4874 __int16 v4; // ax@4 4031 __int16 v4; // ax@4
4875 signed int v5; // esi@5 4032 signed int v5; // esi@5
4876 int v6; // ecx@6 4033 int v6; // ecx@6
4877 int v7; // edx@7 4034 int v7; // edx@7
4878 ObjectDesc *v8; // eax@7 4035 ObjectDesc *v8; // eax@7
4879 char pContainer[32]; // [sp+10h] [bp-Ch]@9 4036 char pContainer[32]; // [sp+10h] [bp-Ch]@9
4880 4037
4881 pMouse->Initialize(hWnd); 4038 pMouse->Initialize(window);
4882 4039
4883 pItemsTable = new ItemsTable; 4040 pItemsTable = new ItemsTable;
4884 pItemsTable->Initialize(); 4041 pItemsTable->Initialize();
4885 4042
4886 pBitmaps_LOD->dword_011BA8 = 1; 4043 pBitmaps_LOD->dword_011BA8 = 1;
5180 FinalInitialization(); 4337 FinalInitialization();
5181 4338
5182 Log::Warning(L"MM: entering main loop"); 4339 Log::Warning(L"MM: entering main loop");
5183 while ( 1 ) 4340 while ( 1 )
5184 { 4341 {
4342 auto main_menu_window = MainMenuWindow::Create();
4343 window->AddControl(main_menu_window);
4344
5185 MainMenu_Loop(); 4345 MainMenu_Loop();
5186 uGameState = GAME_STATE_PLAYING; 4346 uGameState = GAME_STATE_PLAYING;
5187 while ( 1 ) 4347 while ( 1 )
5188 { 4348 {
5189 if (uGameState == GAME_FINISHED || 4349 if (uGameState == GAME_FINISHED ||