changeset 553:b8339415fa98

WeaponShopDialog clean
author zipi
date Mon, 04 Mar 2013 19:39:44 +0000
parents bee46636df95
children a09757c2c5e1
files mm7_2.cpp
diffstat 1 files changed, 437 insertions(+), 366 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_2.cpp	Mon Mar 04 20:29:31 2013 +0200
+++ b/mm7_2.cpp	Mon Mar 04 19:39:44 2013 +0000
@@ -1098,65 +1098,62 @@
   v101.uFrameZ = 334;
   v105 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v104 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  if ( dword_F8B19C > 5 )
-  {
-    if ( dword_F8B19C == 94 )
-    {
-      draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-      pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
-      pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
-      pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];
-      v65 = 0;
-      v66 = pShopOptions;
-      do
-      {
-        v67 = pFontArrus->CalcTextHeight(*v66, &v101, 0, 0);
-        ++v66;
-        v65 += v67;
-      }
-      while ( (signed int)v66 < (signed int)&pShopOptions[3] );
-      v68 = pDialogueWindow;
-      v109 = (const char **)((174 - v65) / 3);
-      result = (char *)pDialogueWindow->pStartingPosActiveItem;
-      v69 = (int)&result[pDialogueWindow->pNumPresenceButton];
-      v70 = (3 * (58 - (signed int)v109) - v65) / 2 - (174 - v65) / 3 / 2 + 138;
-      v20 = -pDialogueWindow->pNumPresenceButton < 0;
-      v106.y = pDialogueWindow->pStartingPosActiveItem;
-      if ( v20 ^ __OFSUB__((int)result, (int)v69) )
-      {
-        _this = (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, &v101, 0, 0);
-          v74 = v71->uY;
-          v75 = _this;
-          v71->uHeight = v73;
-          v70 = v73 + v74 - 1;
-          v71->uW = v70;
-          v76 = v104;
-          if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v75 )
-            v76 = v105;
-          v101.DrawTitleText(pFontArrus, 0, v74, v76, *(const char **)v108, 3u);
-          v68 = pDialogueWindow;
-          _this = (Player *)((char *)_this + 1);
-          v108 += 4;
-          ++v106.y;
-          result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-        }
-        while ( v106.y < (signed int)result );
-      }
-      return result;
-    }
-    if ( dword_F8B19C != 95 )
-    {
-      result = (char *)(dword_F8B19C - 96);
-      if ( dword_F8B19C == 96 )
-      {
+  switch(dword_F8B19C)
+  {
+	case 94:
+		{
+		draw_leather();
+		CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+		pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
+		pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
+		pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];
+		v65 = 0;
+		v66 = pShopOptions;
+		do
+		{
+			v67 = pFontArrus->CalcTextHeight(*v66, &v101, 0, 0);
+			++v66;
+			v65 += v67;
+		}
+		while ( (signed int)v66 < (signed int)&pShopOptions[3] );
+		v68 = pDialogueWindow;
+		v109 = (const char **)((174 - v65) / 3);
+		result = (char *)pDialogueWindow->pStartingPosActiveItem;
+		v69 = (int)&result[pDialogueWindow->pNumPresenceButton];
+		v70 = (3 * (58 - (signed int)v109) - v65) / 2 - (174 - v65) / 3 / 2 + 138;
+		v20 = -pDialogueWindow->pNumPresenceButton < 0;
+		v106.y = pDialogueWindow->pStartingPosActiveItem;
+		if ( v20 ^ __OFSUB__((int)result, (int)v69) )
+		{
+			_this = (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, &v101, 0, 0);
+				v74 = v71->uY;
+				v75 = _this;
+				v71->uHeight = v73;
+				v70 = v73 + v74 - 1;
+				v71->uW = v70;
+				v76 = v104;
+				if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v75 )
+				v76 = v105;
+				v101.DrawTitleText(pFontArrus, 0, v74, v76, *(const char **)v108, 3u);
+				v68 = pDialogueWindow;
+				_this = (Player *)((char *)_this + 1);
+				v108 += 4;
+				++v106.y;
+				result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
+			}
+			while ( v106.y < (signed int)result );
+		}
+		break;	
+		}
+	case 96:
+		{
         result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
         if ( result )
         {
@@ -1173,7 +1170,20 @@
           v34 = v33 + v30->pNumPresenceButton;
           v109 = 0;
           if ( (signed int)v33 >= v34 )
-            goto LABEL_105;
+		  {
+		    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->classType]);
+            strcat(pTmpBuf, "\n \n");
+            strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
+            v7 = pTmpBuf;
+            v86 = 3;
+            v84 = pTmpBuf;
+            v82 = v104;
+            v80 = 0;
+            v78 = 0;
+            v77 = &v101;
+            v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+            return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+          }
           do
           {
             v35 = v30->GetControl(v33)->uControlParam - 36;
@@ -1188,7 +1198,7 @@
           while ( (signed int)v33 < v30->pNumPresenceButton + v30->pStartingPosActiveItem );
           if ( !v109 )
           {
-LABEL_105:
+//LABEL_105:
             sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->classType]);
             strcat(pTmpBuf, "\n \n");
             strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
@@ -1199,7 +1209,8 @@
             v80 = 0;
             v78 = 0;
             v77 = &v101;
-            goto LABEL_15;
+            v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+            return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
           }
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v108);
           v101.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
@@ -1249,115 +1260,232 @@
             while ( v106.y < (signed int)result );
           }
         }
-      }
-      return result;
-    }
-  }
-  else
-  {
-    if ( dword_F8B19C == 5 )
-    {
-      draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
-      DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
-      result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-      if ( result )
-      {
-        v27 = pMouse->GetCursorPos(&v99)->x - 14;
-        v106.x = (v27 >> 5) + 14 * ((pMouse->GetCursorPos(&v97)->y - 17) >> 5);
-        result = (char *)pMouse->GetCursorPos(&v95);
-        if ( *(int *)result > 13 )
-        {
-          result = (char *)pMouse->GetCursorPos(&v93);
-          if ( *(int *)result < 462 )
-          {
-            result = (char *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
-            v3 = 0;
-            if ( result )
-            {
-              result = (char *)(9 * (int)result);
-              if ( _this->field_1F5[4 * (int)result + 15] & 2 )
-              {
-                v85 = 0;
-                v83 = 5;
-                v81 = window_SpeakInHouse->ptr_1C;
-                v79 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5];
-                v28 = (int)window_SpeakInHouse->ptr_1C;
-                v110 = uActiveCharacter - 1;
-                v29 = _this->_490EEE(
-                        (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * (int)result + 5],
-                        1,
-                        v28,
-                        5);
-                v6 = v110;
-                v5 = (char *)pMerchantsRepairPhrases[v29];
-                goto LABEL_14;
-              }
-            }
-          }
-        }
-      }
-      return result;
-    }
-    if ( dword_F8B19C == 1 )
-    {
-      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];
-        v15 = pShopOptions;
-        do
-        {
-          v16 = pFontArrus->CalcTextHeight(*v15, &v101, 0, 0);
-          ++v15;
-          v14 += v16;
-        }
-        while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
-        v17 = pDialogueWindow;
-        v103 = (174 - v14) / 4;
-        result = (char *)pDialogueWindow->pStartingPosActiveItem;
-        v18 = (int)&result[pDialogueWindow->pNumPresenceButton];
-        v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
-        v20 = -pDialogueWindow->pNumPresenceButton < 0;
-        _this = (Player *)pDialogueWindow->pStartingPosActiveItem;
-        if ( v20 ^ __OFSUB__((int)result, v18) )
-        {
-          v108 = 2;
-          v109 = (const char **)pShopOptions;
-          do
-          {
-            v21 = v17->GetControl((unsigned int)_this);
-            v22 = v109;
-            v21->uY = v103 + v19;
-            v23 = pFontArrus->CalcTextHeight(*v22, &v101, 0, 0);
-            v24 = v21->uY;
-            v25 = v108;
-            v21->uHeight = v23;
-            v19 = v24 + v23 - 1;
-            v21->uW = v19;
-            v26 = v104;
-            if ( pDialogueWindow->pCurrentPosActiveItem != v25 )
-              v26 = v105;
-            v101.DrawTitleText(pFontArrus, 0, v24, v26, *v109, 3u);
-            v17 = pDialogueWindow;
-            ++v108;
-            ++v109;
-            _this = (Player *)((char *)_this + 1);
-            result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-          }
-          while ( (signed int)_this < (signed int)result );
-        }
-      }
-      return result;
-    }
-    if ( dword_F8B19C != 2 )
-    {
-      if ( dword_F8B19C == 3 )
-      {
+		break;
+		}
+	case 95:
+		{
+		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 = _this->CanSteal();
+			Str = (char *)v57;
+			if ( v56 && v57 )
+			{
+			  v58 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else
+			{
+			  v58 = pGlobalTXT_LocalizationStrings[195];
+			  if ( dword_F8B19C != 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 ( dword_F8B19C != 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 = _this->_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 = v105;
+				  v80 = v3;
+				  v78 = v3;
+				  v77 = &v101;
+	  			  v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+				  return v101.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 = v105;
+				v80 = v3;
+				v78 = v3;
+				v77 = &v101;
+				v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+				return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+			  }
+			}
+			else
+			{
+			  v101.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+			  result =0; //added
+			}
+		}
+		break;
+		}
+	case 2:
+		{
+		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 = _this->CanSteal();
+			Str = (char *)v57;
+			if ( v56 && v57 )
+			{
+				v58 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else
+			{
+				v58 = pGlobalTXT_LocalizationStrings[195];
+				if ( dword_F8B19C != 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 ( dword_F8B19C != 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 = _this->_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 = v105;
+						v80 = v3;
+						v78 = v3;
+						v77 = &v101;
+	  					v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+						return v101.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 = v105;
+					v80 = v3;
+					v78 = v3;
+					v77 = &v101;
+					v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+					return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+				}
+			}
+			else
+			{
+				v101.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
+				result =0; //added
+			}
+		}
+		break;
+		}
+	case 3:
+		{
         draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
@@ -1385,205 +1513,148 @@
                 v13 = _this->_490EEE(v79, 1, v12, 3);
                 v6 = v110;
                 v5 = (char *)pMerchantsSellPhrases[v13];
-                goto LABEL_14;
-              }
-            }
-          }
-        }
-      }
-      else
-      {
-        result = (char *)(dword_F8B19C - 4);
-        if ( dword_F8B19C == 4 )
-        {
-          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 *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
-                v3 = 0;
-                if ( result )
-                {
-                  v85 = 0;
-                  v83 = 4;
-                  v4 = (ItemGen *)&_this->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 = _this->_490EEE(v4, 1, v9, 4);
-                    v6 = v110;
-                    v5 = (char *)pMerchantsIdentifyPhrases[v10];
-                    goto LABEL_14;
-                  }
-                  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 = v105;
-                  v80 = v3;
-                  v78 = v3;
-                  v77 = &v101;
-LABEL_15:
-                  v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
-                  return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
-                }
+                v7 = BuilDialogueString(v5, v6, v79, (char *)v81, v83, v85);
+                v86 = 3;
+                v84 = v7;
+                v82 = v105;
+                v80 = v3;
+                v78 = v3;
+                v77 = &v101;
+				v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+                return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
               }
             }
           }
         }
-      }
-      return result;
-    }
-  }
-  pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
-  v3 = 0;
-  if ( dword_F8B19C == 2 )
-  {
-    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 );
-  }
-  else
-  {
-    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;
-    if ( dword_F8B19C == 2 )
-    {
-      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 );
-    }
-    else
-    {
-      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 = _this->CanSteal();
-    Str = (char *)v57;
-    if ( v56 && v57 )
-    {
-      v58 = pGlobalTXT_LocalizationStrings[185];
-    }
-    else
-    {
-      v58 = pGlobalTXT_LocalizationStrings[195];
-      if ( dword_F8B19C != 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 ( dword_F8B19C != 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 = _this->_490EEE(v63, 1, v61, 2);
-          v6 = v110;
-          v5 = (char *)pMerchantsBuyPhrases[v64];
-          goto LABEL_14;
-        }
-        v5 = pGlobalTXT_LocalizationStrings[181];
-        v85 = 0;
-        v83 = 2;
-        v81 = window_SpeakInHouse->ptr_1C;
-        v79 = v63;
-        goto LABEL_13;
-      }
-    }
-    else
-    {
-      v101.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C]  - pParty->uTimePlayed);
-	  result =0; //added
-    }
+		break;
+		}
+	case 4:
+		{
+		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 *)v0->GetItemIDAtInventoryIndex((int *)&v106.x);
+					v3 = 0;
+					if ( result )
+					{
+						v85 = 0;
+						v83 = 4;
+						v4 = (ItemGen *)&_this->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 = _this->_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 = v105;
+							v80 = v3;
+							v78 = v3;
+							v77 = &v101;
+							v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+							return v101.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 = v105;
+						v80 = v3;
+						v78 = v3;
+						v77 = &v101;
+				//LABEL_15:
+						v8 = pFontArrus->CalcTextHeight(v7, v77, v78, v80);
+						return v101.DrawTitleText(pFontArrus, v3, (174 - v8) / 2 + 138, v82, v84, v86);
+					}
+				}
+			}
+		}
+		break;
+		}
+	case 1:
+		{
+		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];
+			v15 = pShopOptions;
+			do
+			{
+				v16 = pFontArrus->CalcTextHeight(*v15, &v101, 0, 0);
+				++v15;
+				v14 += v16;
+			}
+			while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
+			v17 = pDialogueWindow;
+			v103 = (174 - v14) / 4;
+			result = (char *)pDialogueWindow->pStartingPosActiveItem;
+			v18 = (int)&result[pDialogueWindow->pNumPresenceButton];
+			v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
+			v20 = -pDialogueWindow->pNumPresenceButton < 0;
+			_this = (Player *)pDialogueWindow->pStartingPosActiveItem;
+			if ( v20 ^ __OFSUB__((int)result, v18) )
+			{
+				v108 = 2;
+				v109 = (const char **)pShopOptions;
+				do
+				{
+					v21 = v17->GetControl((unsigned int)_this);
+					v22 = v109;
+					v21->uY = v103 + v19;
+					v23 = pFontArrus->CalcTextHeight(*v22, &v101, 0, 0);
+					v24 = v21->uY;
+					v25 = v108;
+					v21->uHeight = v23;
+					v19 = v24 + v23 - 1;
+					v21->uW = v19;
+					v26 = v104;
+					if ( pDialogueWindow->pCurrentPosActiveItem != v25 )
+						v26 = v105;
+					v101.DrawTitleText(pFontArrus, 0, v24, v26, *v109, 3u);
+					v17 = pDialogueWindow;
+					++v108;
+					++v109;
+					_this = (Player *)((char *)_this + 1);
+					result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
+				}
+				while ( (signed int)_this < (signed int)result );
+			}
+		}
+		break;
+		}
+	default:
+		{
+		if( dword_F8B19C > 5 )
+			result = (char *)(dword_F8B19C - 96);
+		else
+			result = (char *)(dword_F8B19C - 4);
+		break;
+		}
   }
   return result;
 }