# HG changeset patch # User Ritor1 # Date 1379480687 -21600 # Node ID d453ed393d6e4e811e66a08a9e2a0035ad6752eb # Parent 42055a4bd55074f042e3c4ac22a448e3b10bba8b NPCGreetings diff -r 42055a4bd550 -r d453ed393d6e NPC.cpp --- a/NPC.cpp Wed Sep 18 09:21:38 2013 +0600 +++ b/NPC.cpp Wed Sep 18 11:04:47 2013 +0600 @@ -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].pGreeting[0] = RemoveQuotes(test_string); break; case 2: - pNPCGreetings[i].pGreeting2 = RemoveQuotes(test_string); + pNPCGreetings[i].pGreeting[1] = RemoveQuotes(test_string); break; } } diff -r 42055a4bd550 -r d453ed393d6e NPC.h --- a/NPC.h Wed Sep 18 09:21:38 2013 +0600 +++ b/NPC.h Wed Sep 18 11:04:47 2013 +0600 @@ -132,8 +132,8 @@ #pragma pack(push, 1) struct NPCGreeting { - char *pGreeting1; //at first meet - char *pGreeting2; // at latest meets + char *pGreeting[2]; //at first meet + //char *pGreeting2; // at latest meets }; #pragma pack(pop) diff -r 42055a4bd550 -r d453ed393d6e UI/UIHouses.cpp --- a/UI/UIHouses.cpp Wed Sep 18 09:21:38 2013 +0600 +++ b/UI/UIHouses.cpp Wed Sep 18 11:04:47 2013 +0600 @@ -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].pGreeting[((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 42055a4bd550 -r d453ed393d6e UI/UIMainMenu.cpp --- a/UI/UIMainMenu.cpp Wed Sep 18 09:21:38 2013 +0600 +++ b/UI/UIMainMenu.cpp Wed Sep 18 11:04:47 2013 +0600 @@ -20,12 +20,8 @@ //----- (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 42055a4bd550 -r d453ed393d6e UI/UiGame.cpp --- a/UI/UiGame.cpp Wed Sep 18 09:21:38 2013 +0600 +++ b/UI/UiGame.cpp Wed Sep 18 11:04:47 2013 +0600 @@ -434,9 +434,9 @@ if (pNPC->greet) { if ((pNPC->uFlags & 3) == 2) - pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting2; + pInString = pNPCStats->pNPCGreetings[pNPC->greet].pGreeting[1]; else - pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting1; + pInString = pNPCStats->pNPCGreetings[pNPC->greet].pGreeting[0]; } } else if (pGreetType == 2)//HiredNPC_greet