diff mm7_2.cpp @ 625:483b5ecb4005

WeaponShop little clean
author Ritor1
date Sun, 10 Mar 2013 18:59:04 +0600
parents bd9f43d4fc3d
children 59713bb36033 afc4cbf38aac
line wrap: on
line diff
--- a/mm7_2.cpp	Sat Mar 09 00:35:19 2013 +0600
+++ b/mm7_2.cpp	Sun Mar 10 18:59:04 2013 +0600
@@ -979,14 +979,14 @@
 void __cdecl WeaponShopDialog()
 {
   //Player *v0; // ebx@1
-  char *result; // eax@6
+  int pNumActiveItem; // eax@6
   signed int v2; // esi@8
   unsigned int v3; // ebx@10
   ItemGen *v4; // eax@11
   char *v5; // ecx@12
   unsigned __int8 v6; // dl@13
   char *v7; // edx@14
-  int v8; // eax@15
+  //int v8; // eax@15
   int v9; // ST08_4@16
   int v10; // eax@16
   signed int v11; // esi@18
@@ -999,9 +999,9 @@
   int v18; // edx@25
   int v19; // edi@25
   unsigned __int8 v20; // sf@25
-  GUIButton *v21; // esi@27
-  const char **v22; // eax@27
-  int v23; // eax@27
+  GUIButton *pButton; // esi@27
+  int pNewItem; // eax@27
+  //int v23; // eax@27
   unsigned int v24; // ecx@27
   int v25; // edx@27
   unsigned __int16 v26; // ax@27
@@ -1020,7 +1020,7 @@
   GUIButton *v39; // esi@53
   int v40; // eax@53
   char *v41; // eax@55
-  int v42; // eax@55
+  //int v42; // eax@55
   unsigned int v43; // ecx@55
   const char **v44; // edx@55
   int v45; // eax@55
@@ -1049,9 +1049,9 @@
   GUIWindow *v68; // ecx@98
   int v69; // edx@98
   int v70; // edi@98
-  GUIButton *v71; // esi@100
+  //GUIButton *pButton; // esi@100
   const char **v72; // eax@100
-  int v73; // eax@100
+  int pTextHeight; // eax@100
   unsigned int v74; // ecx@100
   Player *v75; // edx@100
   unsigned __int16 v76; // ax@100
@@ -1086,9 +1086,10 @@
   int pColorWhite; // [sp+DCh] [bp-1Ch]@1
   POINT v106; // [sp+E0h] [bp-18h]@8
   Player *pPlayer; // [sp+E8h] [bp-10h]@1
-  int v108; // [sp+ECh] [bp-Ch]@26
+  int pItemNum; // [sp+ECh] [bp-Ch]@26
   const char **v109; // [sp+F0h] [bp-8h]@26
   unsigned __int8 v110; // [sp+F7h] [bp-1h]@16
+  int pNumString;
 
   //v0 = pPlayers[uActiveCharacter];
   pPlayer = pPlayers[uActiveCharacter];
@@ -1100,560 +1101,423 @@
   pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   switch(dialog_menu_id)
   {
-	case DIALOG_SHOP_DISPLAY_EQUIPMENT:
-	{
-		draw_leather();
-		CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-		pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];//sell
-		pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];//identify
-		pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];//repair
+    case DIALOG_SHOP_MAIN:
+    {
+      pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+      if ( pNumActiveItem )
+      {
+        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 < 3; ++i)
-            all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
-		v68 = pDialogueWindow;
-		v109 = (const char **)((174 - all_text_height) / 3);
-		result = (char *)pDialogueWindow->pStartingPosActiveItem;
-		v69 = (int)&result[pDialogueWindow->pNumPresenceButton];
-		v70 = (3 * (58 - (signed int)v109) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138;
-		v20 = -pDialogueWindow->pNumPresenceButton < 0;
-		v106.y = pDialogueWindow->pStartingPosActiveItem;
-		if ( v20 ^ __OFSUB__((int)result, (int)v69) )
-		{
-			pPlayer = (Player *)2;
-			v108 = (int)pShopOptions;
-			do
-			{
-				v71 = v68->GetControl(v106.y);
-				v72 = (const char **)v108;
-				v71->uY = (unsigned int)((char *)v109 + v70);
-				v73 = pFontArrus->CalcTextHeight(*v72, &dialog_window, 0, 0);
-				v74 = v71->uY;
-				v75 = pPlayer;
-				v71->uHeight = v73;
-				v70 = v73 + v74 - 1;
-				v71->uW = v70;
-				v76 = pColor2;
-				if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v75 )
-				v76 = pColorWhite;
-				dialog_window.DrawTitleText(pFontArrus, 0, v74, v76, *(const char **)v108, 3u);
-				v68 = pDialogueWindow;
-				pPlayer = (Player *)((char *)pPlayer + 1);
-				v108 += 4;
-				++v106.y;
-				result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-			}
-			while ( v106.y < (signed int)result );
-		}
-		break;	
-		}
-	case DIALOG_SHOP_SKILLS:
-		{
-        result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-        if ( result )
-        {
-          v30 = pDialogueWindow;
-          v3 = 0;
-          v31 = window_SpeakInHouse->ptr_1C;
-          v106.y = 0;
-          //v32 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v31] * 500.0);
-          v32 = (signed __int64)(p2DEvents[(signed int)v31 - 1].flt_24 * 500.0);
-          v108 = v32 * (100 - pPlayer->GetMerchant()) / 100;
-          if ( v108 < v32 / 3 )
-            v108 = v32 / 3;
-          v33 = v30->pStartingPosActiveItem;
-          v34 = v33 + v30->pNumPresenceButton;
-          v109 = 0;
-          if ( (signed int)v33 >= v34 )
-		  {
-		    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
-            strcat(pTmpBuf, "\n \n");
-            strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
-            v7 = pTmpBuf;
-            v86 = 3;
-            v84 = pTmpBuf;
-            v82 = pColor2;
-            v80 = 0;
-            v78 = 0;
-            v77 = &dialog_window;
-            v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-            dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-          }
+        for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
+          all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
+        v103 = (174 - all_text_height) / 4;
+        pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
+        v18 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
+        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 > v18 )
+        {
+          pItemNum = 2;
+          pNumString = 0;
           do
           {
-            v35 = v30->GetControl(v33)->uControlParam - 36;
-            if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v35] && !pPlayer->pActiveSkills[v35] )
-            {
-              v36 = pFontArrus->CalcTextHeight(pSkillNames[v35], &dialog_window, 0, 0);
-              v106.y += v36;
-              v109 = (const char **)((char *)v109 + 1);
-            }
-            ++v33;
-          }
-          while ( (signed int)v33 < v30->pNumPresenceButton + v30->pStartingPosActiveItem );
-          if ( !v109 )
-          {
-//LABEL_105:
-            sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
-            strcat(pTmpBuf, "\n \n");
-            strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
-            v7 = pTmpBuf;
-            v86 = 3;
-            v84 = pTmpBuf;
-            v82 = pColor2;
-            v80 = 0;
-            v78 = 0;
-            v77 = &dialog_window;
-            v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-            dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-          }
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v108);
-          dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
-          v108 = (149 - v106.y) / (signed int)v109;
-          if ( (149 - v106.y) / (signed int)v109 > 32 )
-            v108 = 32;
-          result = (char *)v30->pStartingPosActiveItem;
-          v37 = (149 - (signed int)v109 * v108 - v106.y) / 2 - v108 / 2 + 162;
-          v106.y = (LONG)result;
-          v103 = v37;
-          if ( (signed int)result < (signed int)&result[v30->pNumPresenceButton] )
-          {
-            v109 = (const char **)2;
-            do
-            {
-              v38 = v30->GetControl(v106.y);
-              v39 = v38;
-              v40 = v38->uControlParam - 36;
-              if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v40] || pPlayer->pActiveSkills[v40] )
-              {
-                v39->uW = 0;
-                v39->uHeight = 0;
-                v39->uY = 0;
-              }
-              else
-              {
-                v41 = pSkillNames[v40];
-                v39->uY = v108 + v103;
-                Str = v41;
-                v42 = pFontArrus->CalcTextHeight(v41, &dialog_window, 0, 0);
-                v43 = v39->uY;
-                v44 = v109;
-                v39->uHeight = v42;
-                v45 = v43 + v42 - 1;
-                v39->uW = v45;
-                v103 = v45;
-                v46 = pColor2;
-                if ( (const char **)pDialogueWindow->pCurrentPosActiveItem != v44 )
-                  v46 = pColorWhite;
-                dialog_window.DrawTitleText(pFontArrus, 0, v43, v46, Str, 3u);
-              }
-              v47 = v30->pStartingPosActiveItem;
-              ++v106.y;
-              result = (char *)(v30->pNumPresenceButton + v47);
-              v109 = (const char **)((char *)v109 + 1);
-            }
-            while ( v106.y < (signed int)result );
-          }
-        }
-		break;
-		}
-	case DIALOG_SHOP_BUY_SPECIAL:
-		{
-		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
-		v3 = 0;
-		v109 = 0;
-		v108 = 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 + v108, word_F8B158[(signed int)v109] + 30, v53);
-			sub_40F92A(
-			  &pRenderer->pActiveZBuffer[v54 + v108 + 640 * v52],
-			  ItemsInShopTexture[(signed int)v109],
-			  (int)((char *)v109 + 1));
-		  }
-		  v109 = (const char **)((char *)v109 + 1);
-		  v108 += 70;
-		}
-		while ( (signed int)v109 < 6 );
-		result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-		if ( result )
-		{
-			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 != 2 )
-				v58 = pGlobalTXT_LocalizationStrings[196];
-			}
-			DrawTextAtStatusBar(v58, 0);
-			if ( v106.x )
-			{
-			  v59 = pMouse->GetCursorPos(&v91);
-			  result = (char *)(v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]);
-			  if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
-			  {
-				v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
-				v106.x = v60;
-				v61 = (int)window_SpeakInHouse->ptr_1C;
-			  //  v62 = 9 * (v60 + 12 * v61);
-				v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-				if ( dialog_menu_id != 2 )
-				  v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
-				if ( !v56 || !Str )
-				{
-				  v85 = 0;
-				  v83 = 2;
-				  v81 = window_SpeakInHouse->ptr_1C;
-				  v79 = v63;
-				  v110 = uActiveCharacter - 1;
-				  v64 = pPlayer->_490EEE(v63, 1, v61, 2);
-				  v6 = v110;
-				  v5 = (char *)pMerchantsBuyPhrases[v64];
-				  v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-				  v86 = 3;
-				  v84 = v7;
-				  v82 = pColorWhite;
-				  v80 = v3;
-				  v78 = v3;
-				  v77 = &dialog_window;
-	  			  v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-				  dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-				}
-				v5 = pGlobalTXT_LocalizationStrings[181];
-				v85 = 0;
-				v83 = 2;
-				v81 = window_SpeakInHouse->ptr_1C;
-				v79 = v63;
-				v6 = uActiveCharacter - 1;
-				v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-				v86 = 3;
-				v84 = v7;
-				v82 = pColorWhite;
-				v80 = v3;
-				v78 = v3;
-				v77 = &dialog_window;
-				v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-				dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-			  }
-			}
-			else
-			{
-			  dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
-			  result =0; //added
-			}
-		}
-		break;
-		}
-	case DIALOG_SHOP_BUY_STANDART:
-		{
-		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
-		v3 = 0;
-		v48 = 0;
-		v108 = 0;
-		v109 = 0;
-		do
-		{
-		//  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);
-			{
-			v49 = word_F8B158[(signed int)v48];
-			v50 = ItemsInShopTexture[(signed int)v48];
-			v49 += 30;
-			v51 = 60 - ((signed int)v50->uTextureWidth >> 1);
-			pRenderer->DrawTextureTransparent(v51 + v108, v49, v50);
-			sub_40F92A(
-				&pRenderer->pActiveZBuffer[v51 + v108 + 640 * v49],
-				ItemsInShopTexture[(signed int)v109],
-				(int)((char *)v109 + 1));
-			v48 = v109;
-			}
-			v108 += 70;
-			v48 = (const char **)((char *)v48 + 1);
-			v109 = v48;
-		}
-		while ( (signed int)v48 < 6 );
-		  result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-		if ( result )
-		{
-			v55 = 0;
-			v106.x = 0;
-			v106.x = 0;
-			do
-			{
-			if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-				++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 != 2 )
-				v58 = pGlobalTXT_LocalizationStrings[196];
-			}
-			DrawTextAtStatusBar(v58, 0);
-			if ( v106.x )
-			{
-				v59 = pMouse->GetCursorPos(&v91);
-				result = (char *)(v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]);
-				if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
-				{
-					v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
-					v106.x = v60;
-					v61 = (int)window_SpeakInHouse->ptr_1C;
-					//  v62 = 9 * (v60 + 12 * v61);
-					v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-					if ( dialog_menu_id != 2 )
-						v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
-					if ( !v56 || !Str )
-					{
-						v85 = 0;
-						v83 = 2;
-						v81 = window_SpeakInHouse->ptr_1C;
-						v79 = v63;
-						v110 = uActiveCharacter - 1;
-						v64 = pPlayer->_490EEE(v63, 1, v61, 2);
-						v6 = v110;
-						v5 = (char *)pMerchantsBuyPhrases[v64];
-						v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-						v86 = 3;
-						v84 = v7;
-						v82 = pColorWhite;
-						v80 = v3;
-						v78 = v3;
-						v77 = &dialog_window;
-	  					v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-						dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-					}
-					v5 = pGlobalTXT_LocalizationStrings[181];
-					v85 = 0;
-					v83 = 2;
-					v81 = window_SpeakInHouse->ptr_1C;
-					v79 = v63;
-					v6 = uActiveCharacter - 1;
-					v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-					v86 = 3;
-					v84 = v7;
-					v82 = pColorWhite;
-					v80 = v3;
-					v78 = v3;
-					v77 = &dialog_window;
-					v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-					dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-				}
-			}
-			else
-			{
-				dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
-				result =0; //added
-			}
-		}
-		break;
-		}
-	case DIALOG_SHOP_SELL:
-		{
-        draw_leather();
-        CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-        DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
-        result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-        if ( result )
-        {
-          v11 = pMouse->GetCursorPos(&v96)->x - 14;
-          v106.x = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v88)->y - 17) >> 5);
-          result = (char *)pMouse->GetCursorPos(&v94);
-          if ( *(int *)result > 13 )
-          {
-            result = (char *)pMouse->GetCursorPos(&v90);
-            if ( *(int *)result < 462 )
-            {
-              result = (char *)pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x);
-              v3 = 0;
-              if ( result )
-              {
-                v85 = 0;
-                v83 = 3;
-                v81 = window_SpeakInHouse->ptr_1C;
-                v79 = (ItemGen *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
-                v12 = (int)window_SpeakInHouse->ptr_1C;
-                v110 = uActiveCharacter - 1;
-                v13 = pPlayer->_490EEE(v79, 1, v12, 3);
-                v6 = v110;
-                v5 = (char *)pMerchantsSellPhrases[v13];
-                v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-                v86 = 3;
-                v84 = v7;
-                v82 = pColorWhite;
-                v80 = v3;
-                v78 = v3;
-                v77 = &dialog_window;
-				v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-                dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-              }
-            }
-          }
-        }
-		break;
-		}
-	case DIALOG_SHOP_IDENTIFY:
-		{
-		draw_leather();
-		CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-		DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
-		result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-		if ( result )
-		{
-			v2 = pMouse->GetCursorPos(&a2)->x - 14;
-			v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5);
-			result = (char *)pMouse->GetCursorPos(&v100);
-			if ( *(int *)result > 13 )
-			{
-				result = (char *)pMouse->GetCursorPos(&v92);
-				if ( *(int *)result < 462 )
-				{
-					result = (char *)pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x);
-					v3 = 0;
-					if ( result )
-					{
-						v85 = 0;
-						v83 = 4;
-						v4 = (ItemGen *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * (int)result + 5];
-						if (!v4->Identified())
-						{
-							v81 = window_SpeakInHouse->ptr_1C;
-							v79 = v4;
-							v9 = (int)window_SpeakInHouse->ptr_1C;
-							v110 = uActiveCharacter - 1;
-							v10 = pPlayer->_490EEE(v4, 1, v9, 4);
-							v6 = v110;
-							v5 = (char *)pMerchantsIdentifyPhrases[v10];
-							v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-							v86 = 3;
-							v84 = v7;
-							v82 = pColorWhite;
-							v80 = v3;
-							v78 = v3;
-							v77 = &dialog_window;
-							v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-							dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-						}
-						v81 = window_SpeakInHouse->ptr_1C;
-						v5 = "%24";
-						v79 = v4;
-				//LABEL_13:
-						v6 = uActiveCharacter - 1;
-				//LABEL_14:
-						v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
-						v86 = 3;
-						v84 = v7;
-						v82 = pColorWhite;
-						v80 = v3;
-						v78 = v3;
-						v77 = &dialog_window;
-				//LABEL_15:
-						v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-						dialog_window.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-					}
-				}
-			}
-		}
-		break;
-		}
-	case DIALOG_SHOP_MAIN:
-		{
-		result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-		if ( result )
-		{
-			pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
-			pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
-			pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
-			//v14 = 0;
-			pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
-            all_text_height = 0;
-			/*v15 = pShopOptions;
-			do
-			{
-				v16 = pFontArrus->CalcTextHeight(*v15, &dialog_window, 0, 0);
-				++v15;
-				v14 += v16;
-			}
-			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);
-			v17 = pDialogueWindow;
-			v103 = (174 - all_text_height) / 4;
-			result = (char *)pDialogueWindow->pStartingPosActiveItem;
-			v18 = (int)&result[pDialogueWindow->pNumPresenceButton];
-			v19 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
-			v20 = -pDialogueWindow->pNumPresenceButton < 0;
-			pPlayer = (Player *)pDialogueWindow->pStartingPosActiveItem;
-			if ( v20 ^ __OFSUB__((int)result, v18) )
-			{
-				v108 = 2;
-				v109 = (const char **)pShopOptions;
-				do
-				{
-					v21 = v17->GetControl((unsigned int)pPlayer);
-					v22 = v109;
-					v21->uY = v103 + v19;
-					v23 = pFontArrus->CalcTextHeight(*v22, &dialog_window, 0, 0);
-					v24 = v21->uY;
-					v25 = v108;
-					v21->uHeight = v23;
-					v19 = v24 + v23 - 1;
-					v21->uW = v19;
-					v26 = pColor2;
-					if ( pDialogueWindow->pCurrentPosActiveItem != v25 )
-						v26 = pColorWhite;
-					dialog_window.DrawTitleText(pFontArrus, 0, v24, v26, *v109, 3u);
-					v17 = pDialogueWindow;
-					++v108;
-					++v109;
-					pPlayer = (Player *)((char *)pPlayer + 1);
-					result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-				}
-				while ( (signed int)pPlayer < (signed int)result );
-			}
-		}
-		break;
-		}
-	default:
-		{
-		if( dialog_menu_id > 5 )
-			result = (char *)(dialog_menu_id - 96);
-		else
-			result = (char *)(dialog_menu_id - 4);
-		break;
-		}
-  }
-}
+            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;
+            v26 = pColor2;
+            if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
+              v26 = pColorWhite;
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v26, (const char *)pShopOptions[pNumString], 3);
+            ++pItemNum;
+            ++pNumString;
+            pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
+          }
+          while ( pItemNum < pNumActiveItem );
+        }
+      }
+      break;
+    }
+    case DIALOG_SHOP_BUY_STANDART:
+    {
+      pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
+      v3 = 0;
+      v48 = 0;
+      pItemNum = 0;
+      v109 = 0;
+      do
+      {
+        //  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);
+        {
+          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);
+          sub_40F92A(&pRenderer->pActiveZBuffer[v51 + pItemNum + 640 * v49], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1));
+          v48 = v109;
+        }
+        pItemNum += 70;
+        v48 = (const char **)((char *)v48 + 1);
+        v109 = v48;
+      }
+      while ( (signed int)v48 < 6 );
+      pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+      if ( pNumActiveItem )
+      {
+        v55 = 0;
+        v106.x = 0;
+        v106.x = 0;
+        do
+        {
+          if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+            ++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 != 2 )
+            v58 = pGlobalTXT_LocalizationStrings[196];
+        }
+        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);
+            v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
+            if ( dialog_menu_id != 2 )
+              v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
+            if ( !v56 || !Str )
+            {
+              v64 = pPlayer->_490EEE(v63, 1, v61, 2);
+              v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, v3, v3);
+              dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+            }
+            else
+            {
+            v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+            pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, v3, v3);
+            dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+            }
+          }
+        }
+        else
+        {
+          dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+          pNumActiveItem = 0; //added
+        }
+      }
+      break;
+    }
+    case DIALOG_SHOP_SELL:
+    {
+      draw_leather();
+      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
+      if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+        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), v3 = 0, !pNumActiveItem) )
+        return;
+      v79 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
+      v13 = pPlayer->_490EEE(v79, 1, (int)window_SpeakInHouse->ptr_1C, 3);
+      v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
+      pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, v3, v3);
+      dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+      break;
+    }
+    case DIALOG_SHOP_IDENTIFY:
+    {
+      draw_leather();
+      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
+      if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+        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), v3 = 0, !pNumActiveItem) )
+        return;
+      v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
+      if (!v4->Identified())
+      {
+        v10 = pPlayer->_490EEE(v4, 1, (int)window_SpeakInHouse->ptr_1C, 4);
+        v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
+        pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, v3, v3);
+        dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+      }
+      v7 = BuilDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
+      pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, v3, v3);
+      dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+      break;
+    }
+    case DIALOG_SHOP_REPAIR:
+    {
+      draw_leather();
+      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
+      if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
+            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), v3 = 0, !pNumActiveItem)
+            || (pNumActiveItem = 9 * pNumActiveItem, !(pPlayer->field_1F5[4 * pNumActiveItem + 15] & 2)) )
+            return;
+      v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
+      v10 = pPlayer->_490EEE(v4, 2, (int)window_SpeakInHouse->ptr_1C, 5);
+      v7 = BuilDialogueString((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;
+    }
+    break;
+    case DIALOG_SHOP_DISPLAY_EQUIPMENT:
+    {
+      draw_leather();
+      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];//sell
+      pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];//identify
+      pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];//repair
+      all_text_height = 0;
+      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;
+      v18 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
+      v70 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138;
+      v20 = -pDialogueWindow->pNumPresenceButton < 0;
+      if ( v20 ^ pNumActiveItem > v18 )
+      {
+        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;
+          v76 = pColor2;
+          if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
+            v76 = pColorWhite;
+          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v76, (const char *)pShopOptions[pNumString], 3);
+          ++pItemNum;
+          ++pNumString;
+          pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
+        }
+        while ( pItemNum < pNumActiveItem );
+      }
+      break;
+    }
+    case DIALOG_SHOP_BUY_SPECIAL:
+    {
+      pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
+      v3 = 0;
+      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);
+          sub_40F92A(&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 = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+      if ( pNumActiveItem )
+      {
+        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 != 2 )
+            v58 = pGlobalTXT_LocalizationStrings[196];
+        }
+        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);
+            v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
+            if ( dialog_menu_id != 2 )
+              v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
+            if ( !v56 || !Str )
+            {
+              v64 = pPlayer->_490EEE(v63, 1, v61, 2);
+              v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, v3, v3);
+              dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+            }
+            else
+            {
+              v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+              pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, v3, v3);
+              dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
+            }
+          }
+        }
+        else
+        {
+          dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+          pNumActiveItem = 0; //added
+        }
+      }
+      break;
+    }
+    case DIALOG_SHOP_SKILLS:
+    {
+      pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+      if ( pNumActiveItem )
+      {
+        v3 = 0;
+        v31 = window_SpeakInHouse->ptr_1C;
+        v106.y = 0;
+        //v32 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v31] * 500.0);
+        v32 = (signed __int64)(p2DEvents[(signed int)v31 - 1].flt_24 * 500.0);
+        pItemNum = v32 * (100 - pPlayer->GetMerchant()) / 100;
+        if ( pItemNum < v32 / 3 )
+          pItemNum = v32 / 3;
+        pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
+        v34 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
+        v109 = 0;
+        if ( pNumActiveItem >= v34 )
+        {
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
+          strcat(pTmpBuf, "\n \n");
+          strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
+          pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0);
+          dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColor2, pTmpBuf, 3);
+        }
+        do
+        {
+          v35 = pDialogueWindow->GetControl(pNumActiveItem)->uControlParam - 36;
+          if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v35] && !pPlayer->pActiveSkills[v35] )
+          {
+            pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v35], &dialog_window, 0, 0);
+            v106.y += pTextHeight;
+            v109 = (const char **)((char *)v109 + 1);
+          }
+          ++pNumActiveItem;
+        }
+        while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+        if ( !v109 )
+        {
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
+          strcat(pTmpBuf, "\n \n");
+          strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
+          pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0);
+          dialog_window.DrawTitleText(pFontArrus, v3, (174 - pTextHeight) / 2 + 138, pColor2, pTmpBuf, 3);
+        }
+        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pItemNum);
+        dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3);
+        pItemNum = (149 - v106.y) / (signed int)v109;
+        if ( (149 - v106.y) / (signed int)v109 > 32 )
+          pItemNum = 32;
+        pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
+        v37 = (149 - (signed int)v109 * pItemNum - v106.y) / 2 - pItemNum / 2 + 162;
+        v106.y = (LONG)pNumActiveItem;
+        v103 = v37;
+        if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+        {
+          v109 = (const char **)2;
+          do
+          {
+            pButton = pDialogueWindow->GetControl(v106.y);
+            v40 = pButton->uControlParam - 36;
+            if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v40] || pPlayer->pActiveSkills[v40] )
+            {
+              pButton->uW = 0;
+              pButton->uHeight = 0;
+              pButton->uY = 0;
+            }
+            else
+            {
+              pButton->uY = pItemNum + v103;
+              pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v40], &dialog_window, 0, 0);
+              v43 = pButton->uY;
+              v44 = v109;
+              pButton->uHeight = pTextHeight;
+              v45 = v43 + pTextHeight - 1;
+              pButton->uW = v45;
+              v103 = v45;
+              v46 = pColor2;
+              if ( (const char **)pDialogueWindow->pCurrentPosActiveItem != v44 )
+                v46 = pColorWhite;
+              dialog_window.DrawTitleText(pFontArrus, 0, v43, v46, pSkillNames[v40], 3);
+            }
+            v47 = pDialogueWindow->pStartingPosActiveItem;
+            ++v106.y;
+            pNumActiveItem = pDialogueWindow->pNumPresenceButton + v47;
+            v109 = (const char **)((char *)v109 + 1);
+          }
+          while ( v106.y < pNumActiveItem );
+        }
+      }
+      break;
+    }
+    default:
+    {
+      if( dialog_menu_id > 5 )
+        pNumActiveItem = dialog_menu_id - 96;
+      else
+        pNumActiveItem = dialog_menu_id - 4;
+      break;
+    }
+  }
+}
+
 
 
 //----- (004B9CC6) --------------------------------------------------------
@@ -2643,32 +2507,27 @@
         }
         break;
     case DIALOG_SHOP_SELL:
-        {
-        draw_leather();
-        CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-        DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell"
-        if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
-            return;
-
-            if((v9 = pMouse->GetCursorPos(&v139)->x - 14,
-            v149 = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5),
-            pMouse->GetCursorPos(&v137)->x <= 13)
-            || pMouse->GetCursorPos(&v129)->x >= 462
-            || (v10 = v0->GetItemIDAtInventoryIndex((int *)&v149), v11 = 0, !v10) )
-            return;
+    {
+      draw_leather();
+      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell"
+      if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
+        return;
+
+      if((v9 = pMouse->GetCursorPos(&v139)->x - 14, v149 = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5),
+         pMouse->GetCursorPos(&v137)->x <= 13) || pMouse->GetCursorPos(&v129)->x >= 462 
+         || (v10 = v0->GetItemIDAtInventoryIndex((int *)&v149), v11 = 0, !v10) )
+           return;
    
-        v116 = (ItemGen *)&v0->pInventoryItems[v10-1];
-   
-        v13 = v0->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3);
-    
-        v15 = (char *)pMerchantsSellPhrases[v0->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3)];
-        v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0);
-  
-        v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
-        dialog_window.DrawTitleText(pFontArrus, 0, v115, m_text_color, v36, 3);
-        return;
-        }
-        break;
+      v116 = (ItemGen *)&v0->pInventoryItems[v10-1];
+      v13 = v0->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3);
+      v15 = (char *)pMerchantsSellPhrases[v0->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3)];
+      v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0);
+      v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
+      dialog_window.DrawTitleText(pFontArrus, 0, v115, m_text_color, v36, 3);
+      return;
+    }
+    break;
     case DIALOG_SHOP_IDENTIFY:
         {
         draw_leather();