diff UI/UIHouses.cpp @ 1671:4bbb80c7dba7

Merge
author Ritor1
date Wed, 18 Sep 2013 20:04:49 +0600
parents 014eb02bd0e6 620b6ba3e6b8
children 8251e59fd7c1
line wrap: on
line diff
--- a/UI/UIHouses.cpp	Wed Sep 18 20:04:30 2013 +0600
+++ b/UI/UIHouses.cpp	Wed Sep 18 20:04:49 2013 +0600
@@ -459,7 +459,7 @@
     }
     break;
 
-    case BuildingType_14:
+    case BuildingType_ElementalGuild:
     {
       CreateButtonInColumn(0, 18);
       CreateButtonInColumn(1, 48);
@@ -470,7 +470,7 @@
     }
     break;
 
-    case BuildingType_15:
+    case BuildingType_SelfGuild:
     {
       CreateButtonInColumn(0, 18);
       CreateButtonInColumn(1, 52);
@@ -1087,8 +1087,8 @@
     case BuildingType_BodyGuild:
     case BuildingType_LightGuild:
     case BuildingType_DarkGuild:
-    case BuildingType_14:
-    case BuildingType_15:
+    case BuildingType_ElementalGuild:
+    case BuildingType_SelfGuild:
     case BuildingType_16:
     {
       if ( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed )
@@ -2984,20 +2984,8 @@
   signed int v10; // esi@6
   int pPrice; // ecx@6
   signed int v14; // esi@14
-  //unsigned int v15; // esi@16
   int v16; // eax@16
-  //unsigned int v17; // eax@17
   int v19; // ecx@24
-  //GUIButton *v20; // eax@26
-  //GUIButton *v21; // esi@26
-  //int v22; // eax@26
-  //const char *v23; // eax@28
-  //int v24; // eax@28
-  //unsigned int v25; // ecx@28
-  //int v26; // eax@28
-  //unsigned __int16 v27; // ax@28
-  //unsigned __int16 v29; // ST14_2@34
-  //int v30; // eax@34
   int v33; // eax@36
   unsigned int v36; // eax@38
   unsigned int v42; // eax@46
@@ -3008,7 +2996,6 @@
   int pTextHeight; // eax@71
   unsigned __int16 pTextColor; // ax@71
   GUIWindow training_dialog_window; // [sp+Ch] [bp-78h]@1
-  //int v68; // [sp+6Ch] [bp-18h]@3
   int v69; // [sp+70h] [bp-14h]@6
   int v73; // [sp+80h] [bp-4h]@14
 
@@ -3065,7 +3052,6 @@
         v49 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138;
         if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton)
         {
-          //int pCurrentItem = 2;
           index = 0;
           for ( int i = pDialogueWindow->pStartingPosActiveItem;
                 i < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++i )
@@ -3080,7 +3066,6 @@
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
               pTextColor = TargetColor(255, 255, 255);
             training_dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[index], 3);
-            //++pCurrentItem;
             ++index;
           }
         }
@@ -3096,7 +3081,6 @@
         pDialogueWindow->pNumPresenceButton = 0;
         return;
       }
-      //v34 = pPlayers[uActiveCharacter]->uLevel;
       if ( pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_TRAINING_HALL_EMERALD_ISLE] )
       {
         if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience >= v5 )
@@ -3232,7 +3216,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 +3226,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 +3249,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 +3272,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 +3286,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 +3351,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 +3378,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 +3404,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));
@@ -3448,7 +3427,7 @@
     switch ( pButton->msg_param )
     {
       case 19://evt_A
-        v15 = (char *)pNPCTopics[pNPC->evt_A-1].pTopic;
+        v15 = (char *)pNPCTopics[pNPC->evt_A].pTopic;
         if ( !v15 )
         {
           pButton->msg_param = 0;
@@ -3457,145 +3436,138 @@
         strcpy(pButton->pButtonName, v15);
         continue;
       case 20://evt_B
-        v15 = (char *)pNPCTopics[pNPC->evt_B-1].pTopic;
+        v15 = (char *)pNPCTopics[pNPC->evt_B].pTopic;
+        if ( !v15 )
+        {
+          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].pTopic;
+        if ( !v15 )
+        {
+          pButton->msg_param = 0;
+          v15 = "";
+        }
+        strcpy(pButton->pButtonName, v15);
+        continue;
+      case 22://evt_D
+        v15 = (char *)pNPCTopics[pNPC->evt_D].pTopic;
+        if ( !v15 )
+        {
+          pButton->msg_param = 0;
+          v15 = "";
+        }
+        strcpy(pButton->pButtonName, v15);
+        continue;
+      case 23://evt_E
+        v15 = (char *)pNPCTopics[pNPC->evt_E].pTopic;
+        if ( !v15 )
+        {
+          pButton->msg_param = 0;
+          v15 = "";
+        }
+        strcpy(pButton->pButtonName, v15);
+        continue;
+      case 24://evt_F
+        v15 = (char *)pNPCTopics[pNPC->evt_F].pTopic;
         if ( !v15 )
         {
           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 > 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;
-        }
+        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 > 0 && pButton->msg_param < 13 )
+    {
+      strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[122]);//Вступить
+      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 > 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);
   }
 }