# HG changeset patch # User Grumpy7 # Date 1379492627 -7200 # Node ID 55bdb9b043e35c5699539f0da2d63c4cb6e9c5e6 # Parent 51a74615d956ef9af0c80e962d9cbbcea8ab3749# Parent a7eebb6ee7a25c575ff81d9e2869e9dd82ba30f9 Merge diff -r 51a74615d956 -r 55bdb9b043e3 NPC.cpp --- a/NPC.cpp Wed Sep 18 10:22:16 2013 +0200 +++ b/NPC.cpp Wed Sep 18 10:23:47 2013 +0200 @@ -480,7 +480,7 @@ uNumNewNPCs = 501; pNPCGreetTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgreet.txt", 0); strtok(pNPCGreetTXT_Raw, "\r"); - for (i=0; i<205; ++i) + for ( i = 1; i <= 205; ++i ) { test_string = strtok(NULL, "\r") + 1; break_loop = false; @@ -503,10 +503,10 @@ switch (decode_step) { case 1: - pNPCGreetings[i].pGreeting1 = RemoveQuotes(test_string); + pNPCGreetings[i].pGreetings[0] = RemoveQuotes(test_string); break; case 2: - pNPCGreetings[i].pGreeting2 = RemoveQuotes(test_string); + pNPCGreetings[i].pGreetings[1] = RemoveQuotes(test_string); break; } } diff -r 51a74615d956 -r 55bdb9b043e3 NPC.h --- a/NPC.h Wed Sep 18 10:22:16 2013 +0200 +++ b/NPC.h Wed Sep 18 10:23:47 2013 +0200 @@ -132,8 +132,15 @@ #pragma pack(push, 1) struct NPCGreeting { - char *pGreeting1; //at first meet - char *pGreeting2; // at latest meets + union + { + struct + { + char *pGreeting1; //at first meet + char *pGreeting2; // at latest meets + }; + char *pGreetings[2]; + }; }; #pragma pack(pop) diff -r 51a74615d956 -r 55bdb9b043e3 Render.cpp --- a/Render.cpp Wed Sep 18 10:22:16 2013 +0200 +++ b/Render.cpp Wed Sep 18 10:23:47 2013 +0200 @@ -2094,10 +2094,14 @@ hd_water_current_frame = 0; } -bool Render::Initialize(bool bWindowed, uint32_t uDefaultDevice, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) +bool Render::Initialize(bool bWindowed, int windowed_width, int windowed_height, uint32_t uDefaultDevice, + bool bColoredLights, uint32_t uDetailLevel, bool bTinting) { bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); + bStartInWindow = bWindowed; + windowed_mode_width = windowed_width; + windowed_mode_height = windowed_height; uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); @@ -2177,30 +2181,21 @@ //----- (0049ED18) -------------------------------------------------------- void Render::PresentBlackScreen() { - LONG w; // edx@3 IDirectDrawSurface *v2; // eax@3 DDBLTFX v3; // [sp+4h] [bp-74h]@5 RECT x; // [sp+68h] [bp-10h]@3 memset(&v3, 0, sizeof(DDBLTFX)); + GetWindowRect(hWnd, &x); if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5) { - x.left = uWindowX; - x.right = uWindowX + uWindowHeight; - x.top = uWindowY; - w = uWindowY + uWindowWidth; v2 = (IDirectDrawSurface *)this->pBackBuffer4; } else { - x.left = uWindowX; - x.right = uWindowX + uWindowHeight; - x.top = uWindowY; - w = uWindowY + uWindowWidth; v2 = (IDirectDrawSurface *)this->pBackBuffer2; } - x.bottom = w; v3.dwFillColor = 0; v3.dwSize = 100; v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); @@ -8361,13 +8356,6 @@ } if ( pRenderer->bWindowMode ) { - if ( GetWindowRect(hWnd, &Rect) ) - { - WriteWindowsRegistryInt("window X", Rect.left); - WriteWindowsRegistryInt("window Y", Rect.top); - uWindowX = Rect.left; - uWindowY = Rect.top; - } SetMenu(hWnd, 0); SetWindowLongA(hWnd, -20, 0); SetWindowLongA(hWnd, -16, 0x10000000u); @@ -8379,7 +8367,6 @@ { ClipCursor(0); pRenderer->SwitchToWindow(hWnd); - SetWindowLongA(hWnd, -16, uWindowStyle); } if ( pRenderer->pRenderD3D ) { @@ -8434,14 +8421,14 @@ pMouse->SetCurrentCursorBitmap(); if ( pRenderer->bWindowMode ) { - InvalidateRect(0, 0, 0); - MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); + //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); + CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); ShowWindow(hWnd, SW_SHOWNORMAL); } pMouse->bActive = 1; if ( pVideoPlayer->AnyMovieLoaded() ) pVideoPlayer->SelectMovieType(); - if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) + if (dword_6BE364_game_settings_1 & 0x0800 ) BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; else pEventTimer->Resume(); diff -r 51a74615d956 -r 55bdb9b043e3 Render.h --- a/Render.h Wed Sep 18 10:22:16 2013 +0200 +++ b/Render.h Wed Sep 18 10:23:47 2013 +0200 @@ -269,7 +269,7 @@ static Render *Create() {return new Render;} - bool Initialize(bool bWindowed, uint32_t uDefaultDevice, + bool Initialize(bool bWindowed, int window_width, int window_height, uint32_t uDefaultDevice, bool bColoredLights, uint32_t uDetailLevel, bool bTinting); @@ -457,6 +457,10 @@ unsigned int uCurrentlyLockedSurfacePitch; unsigned __int16 *pCurrentlyLockedSurfaceDataPtr; unsigned __int16 *pCurrentlyLockedSoftSurface; + + + int windowed_mode_width; + int windowed_mode_height; }; #pragma pack(pop) diff -r 51a74615d956 -r 55bdb9b043e3 UI/UIHouses.cpp --- a/UI/UIHouses.cpp Wed Sep 18 10:22:16 2013 +0200 +++ b/UI/UIHouses.cpp Wed Sep 18 10:23:47 2013 +0200 @@ -3232,7 +3232,7 @@ unsigned int v5; // esi@5 int v6; // edi@6 int result; // eax@13 - int v12; // eax@20 + int all_text_height; // eax@20 int v13; // eax@21 GUIButton *pButton; // esi@27 unsigned int v16; // eax@28 @@ -3242,7 +3242,7 @@ int v27; // [sp-4h] [bp-80h]@8 GUIWindow dialog_window; // [sp+Ch] [bp-70h]@1 int v32; // [sp+6Ch] [bp-10h]@1 - int v34; // [sp+74h] [bp-8h]@17 + int index; // [sp+74h] [bp-8h]@17 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; @@ -3265,18 +3265,19 @@ } if ( !HouseUI_CheckIfPlayerCanInteract() ) return; - v34 = 0; + all_text_height = 0; + index = 0; for ( int i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) { if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType / 3][pDialogueWindow->GetControl(i)->msg_param - 36] && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] ) { - v12 += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0); - ++v34; + all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0); + ++index; } } - if ( !v34 ) + if ( !index ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); strcat(pTmpBuf.data(), "\n \n"); @@ -3287,10 +3288,10 @@ } sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);//Стоимость навыка: %lu dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); - v32 = (149 - v12) / v34; - if ( (149 - v12) / v34 > 32 ) + v32 = (149 - all_text_height) / index; + if ( v32 > 32 ) v32 = 32; - v34 = (149 - v34 * v32 - v12) / 2 - v32 / 2 + 162; + index = (149 - index * v32 - all_text_height) / 2 - v32 / 2 + 162; if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) { for ( int i = pDialogueWindow->pStartingPosActiveItem; @@ -3301,11 +3302,11 @@ { if ( !pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] ) { - pButton->uY = v32 + v34; + pButton->uY = v32 + index; pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; pButton->uW = pButton->uY + pTextHeight - 1; - v34 = pButton->uY + pTextHeight - 1; + index = pButton->uY + pTextHeight - 1; pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu); if ( pDialogueWindow->pCurrentPosActiveItem != i ) pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu); @@ -3366,26 +3367,18 @@ //----- (004B2A74) -------------------------------------------------------- void SimpleHouseDialog() { - char *v2; // eax@3 - unsigned int i; // eax@5 NPCData *pNPC; // esi@6 char *v15; // esi@14 GUIButton *pButton; // eax@15 - int v18; // ecx@17 char *v29; // esi@42 int v31; // ST1C_4@42 - int v34; // esi@51 - unsigned int v36; // edi@51 - GUIButton *v37; // eax@52 - int v38; // eax@52 - signed int v39; // ecx@54 + int index; // esi@51 + int v36; + signed int all_text_height; // ecx@54 int v40; // edi@57 - const char *v43; // ebx@60 - int v44; // eax@60 - unsigned int v45; // ecx@60 - unsigned __int16 v46; // ax@60 - GUIFont *v47; // ebx@64 - int v48; // esi@64 + unsigned __int16 pTextColor; // ax@60 + GUIFont *pTextFont; // ebx@64 + int pTextHeight; GUIWindow w; // [sp+Ch] [bp-110h]@64 GUIWindow right_panel_window; // [sp+60h] [bp-BCh]@13 GUIWindow house_window; // [sp+B4h] [bp-68h]@1 @@ -3401,13 +3394,14 @@ house_window.uFrameX = 483; house_window.uFrameWidth = 148; house_window.uFrameZ = 334; - v2 = pTransitionStrings[uHouse_ExitPic]; - if ( !v2 ) + if ( !pTransitionStrings[uHouse_ExitPic] ) { sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName);//Войти в ^Pv[%s] - v2 = pTmpBuf.data(); + house_window.DrawTitleText(pFontCreate, 0, (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &house_window, 0, 0)) / 2 + 101, 0, pTmpBuf.data(), 3); + return; } - house_window.DrawTitleText(pFontCreate, 0, (212 - pFontCreate->CalcTextHeight(v2, &house_window, 0, 0)) / 2 + 101, 0, v2, 3); + house_window.DrawTitleText(pFontCreate, 0, + (212 - pFontCreate->CalcTextHeight(pTransitionStrings[uHouse_ExitPic], &house_window, 0, 0)) / 2 + 101, 0, pTransitionStrings[uHouse_ExitPic], 3); return; } house_window.uFrameWidth -= 10; @@ -3426,7 +3420,8 @@ { house_window.uFrameWidth = game_viewport_width; house_window.uFrameZ = 452; - pInString = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * pNPC->greet); + pInString = pNPCStats->pNPCGreetings[pNPC->greet].pGreetings[((pNPC->uFlags & 3) == 2)]; + //pInString = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * pNPC->greet); pRenderer->GetLeather(8, 352 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7), pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7)); @@ -3462,140 +3457,133 @@ { pButton->msg_param = 0; v15 = ""; - } - if ( uDialogueType != 84 ) - { - strcpy(pButton->pButtonName, v15); - continue; - } - sprintf(pTmpBuf.data(), format_4E2D80, TargetColor(0xE1u, 0xCDu, 0x23u), pItemsTable->pItems[contract_approved].pUnidentifiedName); - sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data()); - current_npc_text = pTmpBuf2.data(); - strcpy(pButton->pButtonName, v15); - continue; - case 21://evt_C - v15 = (char *)pNPCTopics[pNPC->evt_C-1].pTopic; - if ( !v15 ) - { - pButton->msg_param = 0; - v15 = ""; - } - strcpy(pButton->pButtonName, v15); - continue; - case 22://evt_D - v15 = (char *)pNPCTopics[pNPC->evt_D-1].pTopic; - if ( !v15 ) - { - pButton->msg_param = 0; - v15 = ""; - } - strcpy(pButton->pButtonName, v15); - continue; - case 23://evt_E - v15 = (char *)pNPCTopics[pNPC->evt_E-1].pTopic; - if ( !v15 ) - { - pButton->msg_param = 0; - v15 = ""; - } - strcpy(pButton->pButtonName, v15); - continue; - case 24://evt_F - v15 = (char *)pNPCTopics[pNPC->evt_F-1].pTopic; - if ( !v15 ) - { - pButton->msg_param = 0; - v15 = ""; - } - strcpy(pButton->pButtonName, v15); - continue; - case 76: - strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[406]);//Нанять - continue; - case 77: - strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[407]);//Подробнее - continue; - case 79: - strcpy(pButton->pButtonName, _4B254D_SkillMasteryTeacher((int)right_panel_window.ptr_1C)); - continue; - case 82: - strcpy(pButton->pButtonName, ContractSelectText((int)right_panel_window.ptr_1C)); - continue; - case 83: - v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName; - v31 = *(int *)v29; - sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu), v31, TargetColor(0xFFu, 0xFFu, 0xFFu)); - sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); - current_npc_text = pTmpBuf2.data(); - strcpy(pButton->pButtonName, ""); - continue; } - if ( pButton->msg_param < 13 ) + if ( uDialogueType != 84 ) { - strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[122]);//Вступить + strcpy(pButton->pButtonName, v15); continue; } - if ( pButton->msg_param > 13 && pButton->msg_param < 19 ) + sprintf(pTmpBuf.data(), format_4E2D80, TargetColor(0xE1u, 0xCDu, 0x23u), pItemsTable->pItems[contract_approved].pUnidentifiedName); + sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data()); + current_npc_text = pTmpBuf2.data(); + strcpy(pButton->pButtonName, v15); + continue; + case 21://evt_C + v15 = (char *)pNPCTopics[pNPC->evt_C-1].pTopic; + if ( !v15 ) { - strcpy(pButton->pButtonName, ""); - continue; + pButton->msg_param = 0; + v15 = ""; + } + strcpy(pButton->pButtonName, v15); + continue; + case 22://evt_D + v15 = (char *)pNPCTopics[pNPC->evt_D-1].pTopic; + if ( !v15 ) + { + pButton->msg_param = 0; + v15 = ""; + } + strcpy(pButton->pButtonName, v15); + continue; + case 23://evt_E + v15 = (char *)pNPCTopics[pNPC->evt_E-1].pTopic; + if ( !v15 ) + { + pButton->msg_param = 0; + v15 = ""; } - if ( pButton->msg_param != 93 ) + strcpy(pButton->pButtonName, v15); + continue; + case 24://evt_F + v15 = (char *)pNPCTopics[pNPC->evt_F-1].pTopic; + if ( !v15 ) { - strcpy(pButton->pButtonName, ""); - continue; + pButton->msg_param = 0; + v15 = ""; } + strcpy(pButton->pButtonName, v15); + continue; + case 76: + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[406]);//Нанять + continue; + case 77: + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[407]);//Подробнее + continue; + case 79: + strcpy(pButton->pButtonName, _4B254D_SkillMasteryTeacher((int)right_panel_window.ptr_1C)); + continue; + case 82: + strcpy(pButton->pButtonName, ContractSelectText((int)right_panel_window.ptr_1C)); + continue; + case 83: + v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName; + v31 = *(int *)v29; + sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu), v31, TargetColor(0xFFu, 0xFFu, 0xFFu)); + sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); + current_npc_text = pTmpBuf2.data(); + strcpy(pButton->pButtonName, ""); + continue; } - v34 = 0; - v36 = pDialogueWindow->pStartingPosActiveItem; - for ( i = v36 + pDialogueWindow->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton - + pDialogueWindow->pStartingPosActiveItem ) - { - v37 = pDialogueWindow->GetControl(v36); - v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &right_panel_window, 0, 0); - v34 += v38; - ++v36; + if ( pButton->msg_param > 0 && pButton->msg_param < 13 ) + { + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[122]);//Вступить + continue; + } + if ( pButton->msg_param > 13 && pButton->msg_param < 19 ) + { + strcpy(pButton->pButtonName, ""); + continue; + } + if ( pButton->msg_param != 93 ) + { + strcpy(pButton->pButtonName, ""); + continue; + } } - v39 = pDialogueWindow->pNumPresenceButton; - if ( v39 ) + index = 0; + all_text_height = 0; + for ( int i = pDialogueWindow->pStartingPosActiveItem; + i < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++i ) { - pNPC = (NPCData *)((174 - v34) / v39); - if ( (signed int)pNPC > 32 ) - pNPC = (NPCData *)32; - pInString = (char *)2; - v40 = (174 - (signed int)pNPC * v39 - v34) / 2 - (signed int)pNPC / 2 + 138; - for ( i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) + pButton = pDialogueWindow->GetControl(i); + all_text_height += pFontArrus->CalcTextHeight(pButton->pButtonName, &right_panel_window, 0, 0); + index++; + } + if ( index ) + { + v36 = (174 - all_text_height) / index; + if ( v36 > 32 ) + v36 = 32; + v40 = (174 - v36 * index - all_text_height) / 2 - v36 / 2 + 138; + for ( int i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) { pButton = pDialogueWindow->GetControl(i); - //v42 = v41; - v43 = pButton->pButtonName; - pButton->uY = (unsigned int)((char *)pNPC + v40); - v44 = pFontArrus->CalcTextHeight(pButton->pButtonName, &right_panel_window, 0, 0); - v45 = pButton->uY; - pButton->uHeight = v44; - v40 = v45 + v44 - 1; + pButton->uY = v36 + v40; + pTextHeight = pFontArrus->CalcTextHeight(pButton->pButtonName, &right_panel_window, 0, 0); + pButton->uHeight = pTextHeight; + v40 = pButton->uY + pTextHeight - 1; pButton->uW = v40; - v46 = TargetColor(0xE1u, 0xCDu, 0x23u); - if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString ) - v46 = TargetColor(0xFFu, 0xFFu, 0xFFu); - right_panel_window.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3); - ++pInString; + pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u); + if ( pDialogueWindow->pCurrentPosActiveItem != i ) + pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu); + right_panel_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pButton->pButtonName, 3); } } if ( current_npc_text ) { w.uFrameWidth = 458; w.uFrameZ = 457; - v47 = pFontArrus; - v48 = pFontArrus->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; - if ( 352 - v48 < 8 ) + pTextFont = pFontArrus; + pTextHeight = pFontArrus->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; + if ( 352 - pTextHeight < 8 ) { - v47 = pFontCreate; - v48 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; + pTextFont = pFontCreate; + pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; } - pRenderer->GetLeather(8, 352 - v48, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v48); - pRenderer->DrawTextureIndexed(8, 347 - v48, pTexture_591428); - house_window.DrawText(v47, 13, 354 - v48, 0, FitTextInAWindow(current_npc_text, v47, &w, 13, 0), 0, 0, 0); + pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight); + pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); + house_window.DrawText(pTextFont, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pTextFont, &w, 13, 0), 0, 0, 0); } } diff -r 51a74615d956 -r 55bdb9b043e3 UI/UIMainMenu.cpp --- a/UI/UIMainMenu.cpp Wed Sep 18 10:22:16 2013 +0200 +++ b/UI/UIMainMenu.cpp Wed Sep 18 10:23:47 2013 +0200 @@ -17,16 +17,11 @@ #include "..\mm7_data.h" - //----- (0041B578) -------------------------------------------------------- void MainMenuUI_LoadFontsAndSomeStuff() { - pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, - pRenderer->uTargetGBits, - pRenderer->uTargetBBits); - pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, - pRenderer->uTargetGBits, - pRenderer->uTargetBBits); + pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); + pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); pPaletteManager->RecalculateAll(); for (uint i = 0; i < 480; ++i) diff -r 51a74615d956 -r 55bdb9b043e3 UI/UiGame.cpp --- a/UI/UiGame.cpp Wed Sep 18 10:22:16 2013 +0200 +++ b/UI/UiGame.cpp Wed Sep 18 10:23:47 2013 +0200 @@ -434,9 +434,9 @@ if (pNPC->greet) { if ((pNPC->uFlags & 3) == 2) - pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting2; + pInString = pNPCStats->pNPCGreetings[pNPC->greet].pGreeting2; else - pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting1; + pInString = pNPCStats->pNPCGreetings[pNPC->greet].pGreeting1; } } else if (pGreetType == 2)//HiredNPC_greet diff -r 51a74615d956 -r 55bdb9b043e3 mm7_2.cpp --- a/mm7_2.cpp Wed Sep 18 10:22:16 2013 +0200 +++ b/mm7_2.cpp Wed Sep 18 10:23:47 2013 +0200 @@ -4277,8 +4277,35 @@ } } + + +void CenterWindowAndAdjustSize(HWND hwnd, int client_width, int client_height) +{ + RECT rcWindow; + GetWindowRect(hWnd, &rcWindow); + + RECT rcClient; + GetClientRect(hWnd, &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 = client_width + window_borders_width, + window_total_height = client_height + window_borders_height; + + MoveWindow(hWnd, (GetSystemMetrics(SM_CXSCREEN) - window_total_width) / 2, + (GetSystemMetrics(SM_CYSCREEN) - window_total_height) / 2, + window_total_width, + window_total_height, 0); +/* + auto hDesktopDC = GetDC(nullptr); + uint uDesktopWidth = GetDeviceCaps(hDesktopDC, HORZRES); + uint uDesktopHeight = GetDeviceCaps(hDesktopDC, VERTRES); + ReleaseDC(nullptr, hDesktopDC); +*/ +} + //----- (004651F4) -------------------------------------------------------- -bool MM7_Initialize() +bool MM7_Initialize(int game_width, int game_height) { wchar_t pCurrentDir[1024]; _wgetcwd(pCurrentDir, 1024); @@ -4318,29 +4345,10 @@ return false; } - auto hDesktopDC = GetDC(nullptr); - uint uDesktopWidth = GetDeviceCaps(hDesktopDC, HORZRES); - uint uDesktopHeight = GetDeviceCaps(hDesktopDC, VERTRES); - ReleaseDC(nullptr, hDesktopDC); - - uint uTotalWinWidth = 2 * GetSystemMetrics(SM_CXFRAME) + 640; - uint uTotalWinHeight = GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYFRAME) + 480; - - uint uWinCenteredPosX = (uDesktopWidth - uTotalWinWidth) / 2; - uint uWinCenteredPosY = (uDesktopHeight - uTotalWinHeight) / 2; - - uWindowX = ReadWindowsRegistryInt("window X", uWinCenteredPosX); - uWindowX = uDesktopWidth / 2 - 640 / 2; - WriteWindowsRegistryInt("window X", uWindowX); - - uWindowY = ReadWindowsRegistryInt("window Y", uWinCenteredPosY); - uWindowY = uDesktopHeight / 2 - 480 / 2; - WriteWindowsRegistryInt("window Y", uWindowY); - hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and Magic® VII", - uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER, - uWindowX, uWindowY, - 640, 480, + WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER, + 0, 0, + 1, 1, nullptr, nullptr, wcxw.hInstance, @@ -4485,7 +4493,10 @@ } } } + SetMenu(hWnd, menu); + CenterWindowAndAdjustSize(hWnd, game_width, game_height); + ShowWindow(hWnd, SW_SHOWNORMAL); SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); @@ -4503,7 +4514,7 @@ uint uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1); uint bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0; - if (!pRenderer->Initialize(bWindowMode, uDefaultDevice, bColoredLights, uLevelOfDetail, bTinting)) + if (!pRenderer->Initialize(bWindowMode, game_width, game_height, uDefaultDevice, bColoredLights, uLevelOfDetail, bTinting)) { Log::Warning(L"Render failed to initialize"); return false; @@ -4532,18 +4543,7 @@ GameUI_StatusBar_UpdateTimedString(1); pGame = Game::Create(); pMouse = pGame->pMouseInstance; - - - RECT rcWindow; - GetWindowRect(hWnd, &rcWindow); - - RECT rcClient; - GetClientRect(hWnd, &rcClient); - uWindowWidth = rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640; - uWindowHeight = rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480; - MoveWindow(hWnd, uWindowX, uWindowY, - rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640, - rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0); + pIcons_LOD = new LODFile_IconsBitmaps; if (!pIcons_LOD->Load("data\\icons.lod", "icons")) @@ -4858,7 +4858,6 @@ break; } - ShowWindow(hWnd, SW_SHOWNORMAL); return true; } @@ -5065,7 +5064,7 @@ assert(sizeof(MonsterInfo) == 0x58); assert(sizeof(MonsterStats) == 0x5BA0); assert(sizeof(RenderD3D) == 0x148); - assert(sizeof(Render) == 0x129844); +// assert(sizeof(Render) == 0x129844); assert(sizeof(Player) == 0x1B3C); assert(sizeof(Party_stru0) == 0x678); assert(sizeof(Party) == 0x16238); @@ -5153,7 +5152,7 @@ uCPUSpeed = 2048; // about 2GHz - if (!MM7_Initialize()) + if (!MM7_Initialize(640, 480)) { Log::Warning(L"MM init: failed"); pGame->Deinitialize(); diff -r 51a74615d956 -r 55bdb9b043e3 mm7_data.cpp --- a/mm7_data.cpp Wed Sep 18 10:22:16 2013 +0200 +++ b/mm7_data.cpp Wed Sep 18 10:23:47 2013 +0200 @@ -1198,11 +1198,6 @@ float fTurnSpeedMultiplier = 1.0f; // weak float flt_6BE150_look_up_down_dangle = 1.0f; // weak HWND hWnd; // idb -int uWindowWidth; // idb -int uWindowHeight; // idb -int uWindowX; // idb -int uWindowY; // idb -LONG uWindowStyle; // idb int dword_6BE340; // weak char pCurrentMapName[32]; // idb unsigned int uLevelMapStatsID; diff -r 51a74615d956 -r 55bdb9b043e3 mm7_data.h --- a/mm7_data.h Wed Sep 18 10:22:16 2013 +0200 +++ b/mm7_data.h Wed Sep 18 10:23:47 2013 +0200 @@ -885,11 +885,6 @@ //extern HINSTANCE hInstance; // idb //extern char *pCmdLine; extern HWND hWnd; // idb -extern int uWindowWidth; // idb -extern int uWindowHeight; // idb -extern int uWindowX; // idb -extern int uWindowY; // idb -extern LONG uWindowStyle; // idb extern int dword_6BE340; // weak extern char pCurrentMapName[32]; // idb extern unsigned int uLevelMapStatsID; @@ -1407,6 +1402,7 @@ } //inline void __fastcall j_memset32(int a2, void *a1, unsigned int a3) {memset32(a1, a2, a3);} +void CenterWindowAndAdjustSize(HWND hwnd, int client_width, int client_height); #define ErrD3D(hr) do {extern void ErrHR(HRESULT, const char *, const char *, const char *, int); ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__);} while(0)