diff UI/UIShops.cpp @ 1739:1776d4f033a7

WeaponShop cleared
author Ritor1
date Fri, 27 Sep 2013 15:19:32 +0600
parents f44b6e02e81c
children 4b0e19d91505
line wrap: on
line diff
--- a/UI/UIShops.cpp	Thu Sep 26 17:39:39 2013 +0600
+++ b/UI/UIShops.cpp	Fri Sep 27 15:19:32 2013 +0600
@@ -16,241 +16,166 @@
 //----- (004B910F) --------------------------------------------------------
 void  WeaponShopDialog()
 {
-  int v0; // ebx@1
-  int pNumActiveItem; // eax@6
-  signed int v2; // esi@8
-  ItemGen *v4; // eax@11
-  char *v5; // ecx@12
-  unsigned __int8 v6; // dl@13
-  char *v7; // edx@14
-  int v9; // ST08_4@16
-  int v10; // eax@16
-  signed int v11; // esi@18
-  int v12; // ST08_4@21
-  int v13; // eax@21
-  int v14; // edi@23
-  char **v15; // esi@23
-  int v16; // eax@24
-  //int v18; // edx@25
+  int phrases_id; // eax@16
   int v19; // edi@25
-  unsigned __int8 v20; // sf@25
   GUIButton *pButton; // esi@27
-  int pNewItem; // eax@27
-  unsigned int v24; // ecx@27
-  int v25; // edx@27
   unsigned int pColorText; // ax@27
-  signed int v27; // esi@32
-  int v28; // ST08_4@36
-  int v29; // eax@36
   signed int v32; // esi@41
-  unsigned int v33; // esi@43
-  int v34; // eax@43
-  unsigned int v35; // eax@44
-  int v36; // eax@46
-  __int32 v37; // ecx@51
-  int v40; // eax@53
-  char *v41; // eax@55
-  unsigned int v43; // ecx@55
-  const char **v44; // edx@55
-  int v45; // eax@55
-  int v47; // eax@59
-  const char **v48; // eax@63
-  unsigned int v49; // esi@65
-  Texture *v50; // eax@65
-  int v51; // edi@65
-  int v52; // esi@70
-  Texture *v53; // ST1C_4@70
-  int v54; // edi@70
-  signed int v55; // ecx@73
-  SHORT v56; // di@82
-  bool v57; // eax@82
-  const char *v58; // ecx@84
-  POINT *v59; // esi@89
-  LONG v60; // ecx@90
-  int v61; // eax@90
-  int v62; // ecx@90
-  ItemGen *pItemInShop; // esi@90
-  //int v64; // eax@95
+  const char *pText; // ecx@84
   int all_text_height; // esi@96
-  char **v66; // edi@96
-  int v67; // eax@97
-  int v69; // edx@98
-  int v70; // edi@98
-  int v71;
-  const char **v72; // eax@100
-  int pTextHeight; // eax@100
-  unsigned int v74; // ecx@100
-  int v78; // [sp-14h] [bp-10Ch]@14
-  ItemGen *v79; // [sp-10h] [bp-108h]@12
-  int v80; // [sp-10h] [bp-108h]@14
-  void *v81; // [sp-Ch] [bp-104h]@12
-  unsigned __int16 v82; // [sp-Ch] [bp-104h]@14
-  int v83; // [sp-8h] [bp-100h]@11
-  char *v84; // [sp-8h] [bp-100h]@14
-  __int64 *v85; // [sp-4h] [bp-FCh]@11
-  unsigned int v86; // [sp-4h] [bp-FCh]@14
-  POINT v87; // [sp+Ch] [bp-ECh]@8
-  POINT v88; // [sp+14h] [bp-E4h]@18
-  POINT v89; // [sp+1Ch] [bp-DCh]@89
-  POINT v90; // [sp+24h] [bp-D4h]@19
-  POINT v91; // [sp+2Ch] [bp-CCh]@89
-  POINT v92; // [sp+34h] [bp-C4h]@9
-  POINT v93; // [sp+3Ch] [bp-BCh]@33
-  POINT v94; // [sp+44h] [bp-B4h]@18
-  POINT v95; // [sp+4Ch] [bp-ACh]@32
-  POINT v96; // [sp+54h] [bp-A4h]@18
-  POINT v97; // [sp+5Ch] [bp-9Ch]@32
-  POINT a2; // [sp+64h] [bp-94h]@8
-  POINT v99; // [sp+6Ch] [bp-8Ch]@32
-  POINT v100; // [sp+74h] [bp-84h]@8
+  ItemGen *item; 
+  int pItemID;
+  POINT mouse; // [sp+64h] [bp-94h]@8
   GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1
-  char *Str; // [sp+D0h] [bp-28h]@55
   __int32 v103; // [sp+D4h] [bp-24h]@25
-  int pColorYellow; // [sp+D8h] [bp-20h]@1
-  int pColorWhite; // [sp+DCh] [bp-1Ch]@1
-  POINT v106; // [sp+E0h] [bp-18h]@8
-  Player *pPlayer; // [sp+E8h] [bp-10h]@1
-  int pItemNum; // [sp+ECh] [bp-Ch]@26
-  const char **v109; // [sp+F0h] [bp-8h]@26
-  unsigned __int8 v110; // [sp+F7h] [bp-1h]@16
+  int pPrice; // [sp+ECh] [bp-Ch]@26
+  unsigned int v109;
   int pNumString;
+  int item_X;
 
-  pPlayer = pPlayers[uActiveCharacter];
   memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
 
   switch(dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
     {
-      pNumActiveItem = HouseUI_CheckIfPlayerCanInteract();
-      if ( pNumActiveItem )
+      if ( HouseUI_CheckIfPlayerCanInteract() )
       {
         pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
         pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
         pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
         pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
         all_text_height = 0;
-        for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
+        for ( int i = 0; i < 4; ++i )
           all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
         v103 = (174 - all_text_height) / 4;
-        pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
         v19 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
-        v20 = -pDialogueWindow->pNumPresenceButton < 0;
-        if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton ))
+        pNumString = 0;
+        for ( uint i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
+        {
+          pButton = pDialogueWindow->GetControl(i);
+          pButton->uY = v103 + v19;
+          pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
+          v19 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
+          pButton->uW = v19;
+          pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+          if ( pDialogueWindow->pCurrentPosActiveItem != i )
+            pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
+          ++pNumString;
+        }
+      }
+      break;
+    }
+    case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
+    {
+      pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
+      item_X = 0;
+      for ( uint i = 0; i < 6; ++i )
+      {
+        if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
         {
-          pItemNum = 2;
-          pNumString = 0;
-          do
+          pRenderer->DrawTextureTransparent((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + 640 * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
+        }
+        item_X += 70;
+      }
+      if ( HouseUI_CheckIfPlayerCanInteract() )
+      {
+        uint item_num = 0;
+        for ( uint i = 0; i < 6; ++i )
+        {
+          if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
+            ++item_num;
+        }
+        if ( GetAsyncKeyState(17) && pPlayers[uActiveCharacter]->CanSteal() )
+          pText = pGlobalTXT_LocalizationStrings[185];//Украсть предмет
+        else
+        {
+          pText = pGlobalTXT_LocalizationStrings[195];//Выберите предмет для покупки
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
+            pText = pGlobalTXT_LocalizationStrings[196];//Выберите особый предмет для покупки
+        }
+        DrawTextAtStatusBar(pText, 0);
+        if ( item_num )
+        {
+          pMouse->GetCursorPos(&mouse);
+          if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF )
           {
-            pButton = pDialogueWindow->GetControl(pItemNum);
-            pButton->uY = v103 + v19;
-            pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
-            pButton->uHeight = pTextHeight;
-            v19 = pButton->uY + pTextHeight - 1;
-            pButton->uW = v19;
-            pColorText = pColorYellow;
-            if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-              pColorText = pColorWhite;
-            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
-            ++pItemNum;
-            ++pNumString;
-            pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
+            item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1];
+            if ( !GetAsyncKeyState(17) || !pPlayers[uActiveCharacter]->CanSteal() )
+            {
+              pText = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 2)],
+                                       uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+            }
+            else
+            {
+              pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+            }
           }
-          while ( pItemNum < pNumActiveItem );
         }
+        else
+          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);//Приходите через 7 дней
       }
       break;
     }
 
-    case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
+    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
     {
       pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
-      v48 = 0;
-      pItemNum = 0;
-      v109 = 0;
-      do
+      item_X = 0;
+      for ( uint i = 0; i < 6; ++i )
       {
-        //  if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] )
-        if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID)
+        if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
         {
-          v49 = word_F8B158[(signed int)v48];
-          v50 = ItemsInShopTexture[(signed int)v48];
-          v49 += 30;
-          v51 = 60 - ((signed int)v50->uTextureWidth >> 1);
-          pRenderer->DrawTextureTransparent(v51 + pItemNum, v49, v50);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v51 + pItemNum + 640 * v49], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1));
-          v48 = v109;
+          pRenderer->DrawTextureTransparent((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + 640 * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
         }
-        pItemNum += 70;
-        v48 = (const char **)((char *)v48 + 1);
-        v109 = v48;
+        item_X += 70;
       }
-      while ( (signed int)v48 < 6 );
-      pNumActiveItem = HouseUI_CheckIfPlayerCanInteract();
-      if ( pNumActiveItem )
+      if ( HouseUI_CheckIfPlayerCanInteract() )
       {
-        v55 = 0;
-        v106.x = 0;
-        v106.x = 0;
-        do
+        uint item_num = 0;
+        for ( uint i = 0; i < 6; ++i )
         {
-          if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-            ++v106.x;
-          ++v55;
+          if ( pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID )
+            ++item_num;
         }
-        while ( v55 < 6 );
-        v56 = GetAsyncKeyState(17);
-        v57 = pPlayer->CanSteal();
-        Str = (char *)v57;
-        if ( v56 && v57 )
-        {
-          v58 = pGlobalTXT_LocalizationStrings[185];
-        }
+        if ( GetAsyncKeyState(17) && pPlayers[uActiveCharacter]->CanSteal() )
+          pText = pGlobalTXT_LocalizationStrings[185];
         else
         {
-          v58 = pGlobalTXT_LocalizationStrings[195];
+          pText = pGlobalTXT_LocalizationStrings[195];
           if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-            v58 = pGlobalTXT_LocalizationStrings[196];
+            pText = pGlobalTXT_LocalizationStrings[196];
         }
-        DrawTextAtStatusBar(v58, 0);
-        if ( v106.x )
+        DrawTextAtStatusBar(pText, 0);
+        if ( item_num )
         {
-          v59 = pMouse->GetCursorPos(&v91);
-          pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y];
-          if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
+          pMouse->GetCursorPos(&mouse);
+          if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF )
           {
-            v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
-            v106.x = v60;
-            v61 = (int)window_SpeakInHouse->ptr_1C;//maybe ptr_1C - BuildID_2Events
-            //  v62 = 9 * (v60 + 12 * v61);
-            pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-              pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];
-            if ( !v56 || !Str )
+            item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1];
+            if ( !GetAsyncKeyState(17) || !pPlayers[uActiveCharacter]->CanSteal() )
             {
-              v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2)],
-                                       uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+              pText = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 2)],
+                                       uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
             }
             else
             {
-              v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+              pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
             }
           }
         }
         else
-        {
-          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);//Приходите через 7 дней
-          pNumActiveItem = 0; //added
-        }
+          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
       }
       break;
     }
@@ -262,18 +187,19 @@
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
       if ( !HouseUI_CheckIfPlayerCanInteract() )
         return;
-      if((v11 = pMouse->GetCursorPos(&v96)->x - 14, v106.x = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v88)->y - 17) >> 5),
-        pMouse->GetCursorPos(&v94)->x <= 13) || pMouse->GetCursorPos(&v90)->x >= 462 
-        || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) )
+      pMouse->GetCursorPos(&mouse);
+      v109 = ((mouse.x + 14) >> 5) + 14 * ((mouse.y - 17) >> 5);
+      if( mouse.x <= 13 || mouse.x >= 462 )
         return;
-      v79 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1];
-      v13 = pPlayer->SelectPhrasesTransaction(v79, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3);
-      v7 = BuildDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
-      pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+      pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v109);
+      if ( !pItemID )
+        return;
+      item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1];
+      phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3);
+      pText = BuildDialogueString((char *)pMerchantsSellPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       break;
     }
-
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       draw_leather();
@@ -281,23 +207,24 @@
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
       if ( !HouseUI_CheckIfPlayerCanInteract() )
         return;
-      if((v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5),
-        pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462 
-        || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) )
+      pMouse->GetCursorPos(&mouse);
+      v109 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5);
+      if( mouse.x <= 13 || mouse.x >= 462 )
+        return;
+      pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v109);
+      if ( !pItemID )
         return;
-      v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1];
-      if (!v4->IsIdentified())
+      item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1];
+      if (!item->IsIdentified())
       {
-        v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4);
-        v7 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-        pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+        phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4);
+        pText = BuildDialogueString((char *)pMerchantsIdentifyPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       }
       else
       {
-        v7 = BuildDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-        pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+        pText = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       }
       break;
     }
@@ -308,17 +235,18 @@
       CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
       if ( !HouseUI_CheckIfPlayerCanInteract())
-            return;
-      if( (v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5),
-          pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462
-            || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem)
-            || (!(pPlayer->pOwnItems[pNumActiveItem-1].uAttributes& 2)) )
-            return;
-      v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1];
-      v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5);
-      v7 = BuildDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
-      pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138;
-      dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3);
+        return;
+      pMouse->GetCursorPos(&mouse);
+      v109 = ((mouse.x - 14) >> 5) + 14 * (mouse.y - 17) >> 5;
+      if( ( mouse.x <= 13) || mouse.x >= 462 )
+        return;
+      pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v109);
+      if ( !pItemID || (!(pPlayers[uActiveCharacter]->pOwnItems[pItemID - 1].uAttributes & 2)) )
+        return;
+      item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1];
+      phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5);
+      pText = BuildDialogueString((char *)pMerchantsRepairPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
     break;
@@ -334,113 +262,21 @@
       for ( int i = 0; i < 3; ++i )
         all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
       v103 = (174 - all_text_height) / 3;
-      pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
-      v70 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138;
-      v20 = -pDialogueWindow->pNumPresenceButton < 0;
-      if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton ))
-      {
-        pItemNum = 2;
-        pNumString = 0;
-        do
-        {
-          pButton = pDialogueWindow->GetControl(pItemNum);
-          pButton->uY = v103 + v70;
-          pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
-          pButton->uHeight = pTextHeight;
-          v70 = pButton->uY + pTextHeight - 1;
-          pButton->uW = v70;
-          pColorText = pColorYellow;
-          if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-            pColorText = pColorWhite;
-          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
-          ++pItemNum;
-          ++pNumString;
-          pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
-        }
-        while ( pItemNum < pNumActiveItem );
-      }
-      break;
-    }
-
-    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
-    {
-      pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
-      v109 = 0;
-      pItemNum = 0;
-      do
-      {
-        //   if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] )
-        if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID)
-        {
-          v52 = word_F8B158[(signed int)v109] + 30;
-          v53 = ItemsInShopTexture[(signed int)v109];
-          v54 = 60 - ((signed int)v53->uTextureWidth >> 1);
-          pRenderer->DrawTextureTransparent(v54 + pItemNum, word_F8B158[(signed int)v109] + 30, v53);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v54 + pItemNum + 640 * v52], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1));
-        }
-        v109 = (const char **)((char *)v109 + 1);
-        pItemNum += 70;
-      }
-      while ( (signed int)v109 < 6 );
-      pNumActiveItem = HouseUI_CheckIfPlayerCanInteract();
-      if ( pNumActiveItem )
+      v19 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138;
+      pNumString = 0;
+      for ( uint i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
       {
-        v55 = 0;
-        v106.x = 0;
-        do
-        {
-          // if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
-          if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)
-            ++v106.x;
-          ++v55;
-        }
-        while ( v55 < 6 );
-        v56 = GetAsyncKeyState(17);
-        v57 = pPlayer->CanSteal();
-        Str = (char *)v57;
-        if ( v56 && v57 )
-        {
-          v58 = pGlobalTXT_LocalizationStrings[185];
-        }
-        else
-        {
-          v58 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-            v58 = pGlobalTXT_LocalizationStrings[196];
+        pButton = pDialogueWindow->GetControl(i);
+        pButton->uY = v103 + v19;
+        pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
+        v19 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
+        pButton->uW = v19;
+        pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+        if ( pDialogueWindow->pCurrentPosActiveItem != i )
+          pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+        dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
+        ++pNumString;
         }
-        DrawTextAtStatusBar(v58, 0);
-        if ( v106.x )
-        {
-          v59 = pMouse->GetCursorPos(&v91);
-          pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y];
-          if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
-          {
-            v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
-            v106.x = v60;
-            v61 = (int)window_SpeakInHouse->ptr_1C;
-            //  v62 = 9 * (v60 + 12 * v61);
-            pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-              pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
-            if ( !v56 || !Str )
-            {
-              v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2)],
-                                       uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138, pColorWhite, v7, 3);
-            }
-            else
-            {
-              v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138, pColorWhite, v7, 3);
-            }
-          }
-        }
-        else
-        {
-          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
-          pNumActiveItem = 0; //added
-        }
-      }
       break;
     }
 
@@ -448,58 +284,35 @@
     {
       if (!HouseUI_CheckIfPlayerCanInteract())
         return;
-      v0 = 0;
+      uint item_num = 0;
       all_text_height = 0;
-      //v32 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v31] * 500.0);
       v32 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-      pItemNum = v32 * (100 - pPlayer->GetMerchant()) / 100;
-      if ( pItemNum < v32 / 3 )
-        pItemNum = v32 / 3;
-      pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
-      if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+      pPrice = v32 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+      if ( pPrice < v32 / 3 )
+        pPrice = v32 / 3;
+      for ( uint i = pDialogueWindow->pStartingPosActiveItem;
+            i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
       {
-        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
-        strcat(pTmpBuf.data(), "\n \n");
-        strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
-        pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
-        return;
-      }
-      do
-      {
-        v35 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36;
-        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v35] && !pPlayer->pActiveSkills[v35] )
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36]
+          && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] )
         {
-          all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v35], &dialog_window, 0, 0);
-          v0++;
+          all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0);
+          item_num++;
         }
-        ++pNumActiveItem;
       }
-      while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-      if ( !v0 )
+      if ( item_num )
       {
-        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
-        strcat(pTmpBuf.data(), "\n \n");
-        strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
-        pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
-        return;
-      }
-      sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum);
-      dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
-      v103 = (149 - all_text_height) / v0;
-      if ( (149 - all_text_height) / v0 > 32 )
-        v103 = 32;
-      pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
-      v37 = (149 - v0 * v103 - all_text_height) / 2 - v103 / 2 + 162;
-      if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
-      {
-        pItemNum = 2;
-        do
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);//Стоимость навыка: %lu
+        dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
+        v103 = (149 - all_text_height) / item_num;
+        if ( (149 - all_text_height) / item_num > 32 )
+          v103 = 32;
+        v19 = (149 - item_num * v103 - all_text_height) / 2 - v103 / 2 + 162;
+        for ( uint i = pDialogueWindow->pStartingPosActiveItem;
+                   i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
         {
-          pButton = pDialogueWindow->GetControl(pItemNum);
-          v40 = pButton->msg_param - 36;
-          if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v40] || pPlayer->pActiveSkills[v40] )
+          pButton = pDialogueWindow->GetControl(i);
+          if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36] || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] )
           {
             pButton->uW = 0;
             pButton->uHeight = 0;
@@ -507,29 +320,27 @@
           }
           else
           {
-            pButton->uY = v103 + v37;
-            pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v40], &dialog_window, 0, 0);
-            pButton->uHeight = pTextHeight;
-            v37 = pButton->uY + pTextHeight - 1;
-            pButton->uW = v37;
-            pColorText = pColorYellow;
-            if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-              pColorText = pColorWhite;
-            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v40], 3);
+            pButton->uY = v103 + v19;
+            pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0);
+            v19 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1;
+            pButton->uW = v19;
+            pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+            if ( pDialogueWindow->pCurrentPosActiveItem != i )
+              pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3);
           }
-          pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
-          pItemNum++;
         }
-        while ( pItemNum < pNumActiveItem );
+        break;
       }
-      break;
+      sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);
+      strcat(pTmpBuf.data(), "\n \n");
+      strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);//Больше ничего не могу предложить.
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+      return;
     }
     default:
     {
-      if( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR)
-        pNumActiveItem = dialog_menu_id - 96;
-      else
-        pNumActiveItem = dialog_menu_id - 4;
+      __debugbreak();
       break;
     }
   }