changeset 644:527a052c2a98

TavernDialog little clean
author Ritor1
date Tue, 12 Mar 2013 01:20:36 +0600
parents 748f5c7e4012
children 2c906e6c6926
files UIHouses.cpp UIHouses.h
diffstat 2 files changed, 385 insertions(+), 494 deletions(-) [+]
line wrap: on
line diff
--- a/UIHouses.cpp	Mon Mar 11 20:11:19 2013 +0600
+++ b/UIHouses.cpp	Tue Mar 12 01:20:36 2013 +0600
@@ -914,23 +914,23 @@
 //----- (004B8285) --------------------------------------------------------
 void __cdecl TavernDialog()
 {
-  GUIWindow *v0; // ebx@1
-  Player *v1; // edi@1
+  int v0;
+  int pItemNum;
   double v2; // st7@1
   signed int v3; // ebx@1
   int v4; // ecx@1
   int v5; // esi@3
   signed int v6; // edi@5
   int v7; // ecx@5
-  GUIWindow *v8; // edi@16
+  int pNumString; // edi@16
   signed int v9; // esi@16
-  unsigned int v10; // esi@18
+  unsigned int pNumActiveItem; // esi@18
   int v11; // eax@18
   unsigned int v12; // eax@19
   int v13; // eax@21
   int v14; // ecx@26
-  GUIButton *v15; // eax@28
-  GUIButton *v16; // esi@28
+  //GUIButton *v15; // eax@28
+  //GUIButton *v16; // esi@28
   int v17; // eax@28
   char *v18; // eax@30
   int v19; // eax@30
@@ -942,17 +942,14 @@
   int v25; // eax@34
   char *v26; // esi@36
   int v27; // edi@46
-  unsigned int v28; // eax@53
-  unsigned int v29; // eax@55
-  unsigned int v30; // eax@57
+  unsigned int pColorText; // eax@57
   signed int v31; // eax@59
-  unsigned int v32; // eax@61
-  GUIWindow *v33; // edi@64
+  //GUIWindow *v33; // edi@64
   int v34; // eax@64
   int v35; // ecx@64
   int v36; // esi@64
   char v37; // sf@64
-  GUIButton *v38; // eax@65
+  GUIButton *pButton; // eax@65
   int v39; // edx@69
   int v40; // ecx@69
   int v41; // ecx@69
@@ -965,18 +962,17 @@
   signed int v48; // edi@77
   signed int i; // esi@79
   int v50; // eax@80
-  GUIWindow *v51; // ecx@81
+  //GUIWindow *v51; // ecx@81
   _QWORD v52; // qax@81
   signed int v53; // edi@81
   int v54; // edi@81
-  GUIButton *v55; // esi@83
+  //GUIButton *v55; // esi@83
   const char **v56; // eax@83
   int v57; // eax@83
   unsigned int v58; // ecx@83
-  Player *v59; // edx@83
+  //Player *v59; // edx@83
   unsigned __int16 v60; // ax@83
   int v61; // eax@99
-  int v62; // edi@99
   char *v63; // eax@99
   GUIFont *v64; // edx@99
   GUIFont *v65; // edi@100
@@ -992,36 +988,34 @@
   char v75[100]; // [sp+70h] [bp-204h]@59
   char a1[100]; // [sp+D4h] [bp-1A0h]@57
   char v77[100]; // [sp+138h] [bp-13Ch]@59
-  GUIWindow v78; // [sp+19Ch] [bp-D8h]@99
-  GUIWindow v79; // [sp+1F0h] [bp-84h]@1
+  //GUIWindow v78; // [sp+19Ch] [bp-D8h]@99
+  GUIWindow dialog_window; // [sp+1F0h] [bp-84h]@1
   char *Str[2]; // [sp+244h] [bp-30h]@30
-  unsigned int v81; // [sp+24Ch] [bp-28h]@1
+  unsigned int pColorWhite; // [sp+24Ch] [bp-28h]@1
   unsigned __int8 v82; // [sp+253h] [bp-21h]@59
   int v83; // [sp+254h] [bp-20h]@1
-  __int16 v84[2]; // [sp+258h] [bp-1Ch]@1
-  Player *v85; // [sp+25Ch] [bp-18h]@1
-  int v86; // [sp+260h] [bp-14h]@18
+  int pColorYellow; // [sp+258h] [bp-1Ch]@1
+  Player *pPlayer; // [sp+25Ch] [bp-18h]@1
+  int all_text_height; // [sp+260h] [bp-14h]@18
   unsigned __int8 v87; // [sp+266h] [bp-Eh]@59
   unsigned __int8 v88; // [sp+267h] [bp-Dh]@57
   int v89; // [sp+268h] [bp-Ch]@1
-  unsigned __int8 v90; // [sp+26Fh] [bp-5h]@55
-  GUIFont *pOutString; // [sp+270h] [bp-4h]@3
+  unsigned int pTextHeight; // [sp+26Fh] [bp-5h]@55
+  int v91; // [sp+270h] [bp-4h]@3
+  GUIFont *pOutString;
 
-  v0 = window_SpeakInHouse;
-  memcpy(&v79, window_SpeakInHouse, sizeof(v79));
-  v85 = pPlayers[uActiveCharacter];
-  v1 = v85;
-  v79.uFrameX = 483;
-  v79.uFrameWidth = 148;
-  v79.uFrameZ = 334;
-  v81 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  *(int *)v84 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  //v2 = p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C];
-  v2 = p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier;
+  pPlayer = pPlayers[uActiveCharacter];
+  memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
+  dialog_window.uFrameX = 483;
+  dialog_window.uFrameWidth = 148;
+  dialog_window.uFrameZ = 334;
+  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v2 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
   *(float *)&v83 = v2;
   *(float *)&v89 = v2 * v2;
   v3 = (signed __int64)(*(float *)&v89 * 0.1);
-  v4 = v3 * (100 - v1->GetMerchant()) / 100;
+  v4 = v3 * (100 - pPlayer->GetMerchant()) / 100;
   if ( v4 < v3 / 3 )
     v4 = v3 / 3;
   v5 = 1;
@@ -1029,7 +1023,7 @@
   if ( v4 <= 0 )
     pOutString = (GUIFont *)1;
   v6 = (signed __int64)(*(float *)&v89 * *(float *)&v83 * 0.0099999998);
-  v7 = v6 * (100 - v85->GetMerchant()) / 100;
+  v7 = v6 * (100 - pPlayer->GetMerchant()) / 100;
   if ( v7 < v6 / 3 )
     v7 = v6 / 3;
   v83 = v7;
@@ -1040,405 +1034,333 @@
   }
   switch(dialog_menu_id)
   {
-	case 102:
-		{
-		v65 = pFontArrus;
-		pOutString = pFontArrus;
-		strcpy(pTmpBuf, pNPCTopics[354].pText);
-		v78.uFrameWidth = 460;
-		v78.uFrameZ = 452;
-		v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
-		if ( 352 - v62 < 8 )
-		{
-			pOutString = pFontCreate;
-			v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
-		}
-
-		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-		pRenderer->_4A6A68(8u, 352 - v62, pTex, (pTex ? pTex->uTextureHeight : 26) - v62);
-
-		pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
-		v73 = 0;
-		v70 = 0;
-		v68 = 0;
-		v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0);
-		v64 = pOutString;
-		window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
-		break;
-		}
-	case 103:
-		{
-		strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
-		v78.uFrameWidth = 460;
-		v78.uFrameZ = 452;
-		v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0);
-		v62 = v61 + 7;
-
-		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-		pRenderer->_4A6A68(8u, 352 - (v61 + 7), pTex, (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
-
-		pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
-		v73 = 0;
-		v70 = 0;
-		v68 = 0;
-		v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0);
-		v64 = pFontArrus;
-		window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
-		break;
-		}
-	case 104:
-		{
-		if ( pArcomageGame->bGameInProgress == 1 )
+    case DIALOG_SHOP_MAIN:
+    {
+      if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
           return;
-        v26 = pTmpBuf;
-        if ( pArcomageGame->uGameResult )
+      pColorText = pColorYellow;
+      if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
+        pColorText = pColorWhite;
+      sprintf(Dest, format_4E2DC8, pColorText);
+      sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
+      strcat(Dest, pTmpBuf2);
+      pTextHeight = pFontArrus->CalcTextHeight(Dest, &dialog_window, 0, 0);
+      strcat(Dest, "\n \n");
+      pColorText = pColorYellow;
+      if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
+        pColorText = pColorWhite;
+      sprintf(a1, format_4E2DC8, pColorText);
+      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[86],
+        (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier,
+         v83);
+      strcat(a1, pTmpBuf2);
+      v88 = pFontArrus->CalcTextHeight(a1, &dialog_window, 0, 0);
+      strcat(a1, "\n \n");
+      pColorText = pColorYellow;
+      if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
+        pColorText = pColorWhite;
+      sprintf(v77, format_4E2DC8, pColorText);
+      strcat(v77, pGlobalTXT_LocalizationStrings[160]);
+      v82 = pFontArrus->CalcTextHeight(v77, &dialog_window, 0, 0);
+      strcat(v77, "\n \n");
+      v75[0] = 0;
+      pTextHeight = 0;
+      v31 = (signed int)window_SpeakInHouse->ptr_1C;
+      if ( v31 >= 108 && v31 <= 120 )
+      {
+        pColorText = pColorYellow;
+        if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
+          pColorText = pColorWhite;
+        sprintf(v75, format_4E2DC8, pColorText);
+        strcat(v75, pGlobalTXT_LocalizationStrings[611]);
+        pTextHeight = pFontArrus->CalcTextHeight(v75, &dialog_window, 0, 0);
+      }
+      v34 = pDialogueWindow->pStartingPosActiveItem;
+      v35 = v34 + pDialogueWindow->pNumPresenceButton;
+      v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
+      v37 = -pDialogueWindow->pNumPresenceButton < 0;
+      pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
+      if ( !(v37 ^ v34 < v35) )
+      {
+        sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
+        dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf, 3);
+        return;
+      }
+      while ( 1 )
+      {
+        pButton = pDialogueWindow->GetControl((unsigned int)pOutString);
+        if ( pButton->uControlParam == 15 )
         {
-          if ( pArcomageGame->uGameResult == 1 )
-            v72 = pGlobalTXT_LocalizationStrings[640];// You won!
-          else
-            v72 = pGlobalTXT_LocalizationStrings[641];// You lost!
-        }
-        else
-        {
-          v72 = pGlobalTXT_LocalizationStrings[639];// A tie!
+          v46 = pTextHeight;
+          pButton->uHeight = pTextHeight;
+          pButton->uY = 146;
+          v41 = v46 + 145;
+          pButton->uW = v41;
         }
-        strcpy(pTmpBuf, v72);
-//LABEL_97:
-        v71 = 3;
-        v69 = v26;
-        v67 = v84[0];
-        v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138;
-        v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
-		break;
-		}
-	case 15:
-		{
-        if ( pParty->uNumGold >= (unsigned int)pOutString )
+        else if ( pButton->uControlParam == 16 )
+        {
+          v44 = v88;
+          v45 = pTextHeight + v36 + 146;
+          pButton->uHeight = v88;
+          pButton->uY = v45;
+          v41 = v45 + v44 - 1;
+          pButton->uW = v41;
+        }
+        else if ( pButton->uControlParam == 96 )
         {
-          Party::TakeGold((unsigned int)pOutString);
-          v27 = (int)window_SpeakInHouse->ptr_1C;
-          HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
-          dialog_menu_id = 0;
-          while ( sub_4BD8B5() )
-            ;
-          sub_4B1D27();
-          pVideoPlayer->Unload();
-          window_SpeakInHouse->Release();
-          window_SpeakInHouse = 0;
-
-          if ( pMessageQueue_50CBD0->uNumMessages )
-            pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          pMessageQueue_50CBD0->pMessages[0].eType = UIMSG_OpenRestUI;
-          pMessageQueue_50CBD0->pMessages[0].param = v27;
-          pMessageQueue_50CBD0->pMessages[0].field_8 = 1;
-//LABEL_51:
-          ++pMessageQueue_50CBD0->uNumMessages;
+          v42 = pTextHeight + v88 + 2 * v36 + 146;
+          v43 = v82;
+          pButton->uY = v42;
+          pButton->uHeight = v43;
+          v41 = v43 + v42 - 1;
+          pButton->uW = v41;
+        }
+        else if ( pButton->uControlParam == 101 )
+        {
+          v39 = pTextHeight + 3 * v36 + pTextHeight + v88 + 146;
+          v40 = v87;
+          pButton->uHeight = pTextHeight;
+          pButton->uY = v39;
+          v41 = v39 + v40 - 1;
+          pButton->uW = v41;
+        }
+        pOutString = (GUIFont *)((char *)pOutString + 1);
+        if ( (signed int)pOutString >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem )
+        {
+          sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
+          dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf, 3);
           return;
         }
-		ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
-		break;
-		}
-	case 96:
-		{
-		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-			return;
-		v8 = pDialogueWindow;
-		*(float *)&v89 = 0.0;
-
-		//v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
-		v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-
-		pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100);
-		if ( (signed int)pOutString < v9 / 3 )
-			pOutString = (GUIFont *)(v9 / 3);
-		v10 = v8->pStartingPosActiveItem;
-		v11 = v10 + v8->pNumPresenceButton;
-		v86 = 0;
-		if ( (signed int)v10 < v11 )
-		{
-			do
-			{
-				v12 = v8->GetControl(v10)->uControlParam - 36;
-				if ( byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v12] && !v85->pActiveSkills[v12] )
-				{
-					v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0);
-					v89 += v13;
-					++v86;
-				}
-				++v10;
-			}
-			while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
-			if ( v86 )
-			{
-				sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
-				v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
-				pOutString = (GUIFont *)((149 - v89) / v86);
-				if ( (149 - v89) / v86 > 32 )
-					pOutString = (GUIFont *)32;
-				v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162;
-				v89 = v8->pStartingPosActiveItem;
-				v83 = v14;
-				if ( v89 < v89 + v8->pNumPresenceButton )
-				{
-					v86 = 2;
-					do
-					{
-						v15 = v8->GetControl(v89);
-						v16 = v15;
-						v17 = v15->uControlParam - 36;
-						if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v17] || v85->pActiveSkills[v17] )
-						{
-							v16->uW = 0;
-							v16->uHeight = 0;
-							v16->uY = 0;
-						}
-						else
-						{
-							v18 = pSkillNames[v17];
-							v16->uY = (unsigned int)((char *)pOutString + v83);
-							Str[1] = v18;
-							v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0);
-							v20 = v16->uY;
-							v21 = v86;
-							v16->uHeight = v19;
-							v22 = v19 + v20 - 1;
-							v16->uW = v22;
-							v83 = v22;
-							v23 = v84[0];
-							if ( pDialogueWindow->pCurrentPosActiveItem != v21 )
-								v23 = v81;
-							v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u);
-						}
-						v24 = v8->pNumPresenceButton;
-						++v89;
-						v25 = v8->pStartingPosActiveItem + v24;
-						++v86;
-					}
-					while ( v89 < v25 );
-				}
-				return;
-			}
-		}
-		v26 = pTmpBuf;
-		sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->classType]);
-		strcat(pTmpBuf, "\n \n");
-		strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
-		v71 = 3;
-		v69 = v26;
-		v67 = v84[0];
-		v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138;
-		v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
-		return;
-		break;
-		}
-	case 16:
-		{
-        *(_QWORD *)Str = pParty->uNumFoodRations;
-        //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] )
-        if ( (double)pParty->uNumFoodRations >= p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier )
+      }
+      break;
+    }
+    case DIALOG_SHOP_ARCOMAGE_102:
+    {
+      __debugbreak;
+      pOutString = pFontArrus;
+      strcpy(pTmpBuf, pNPCTopics[354].pText);
+      dialog_window.uFrameWidth = 460;
+      dialog_window.uFrameZ = 452;
+      pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 12, 0) + 7;
+      if ( 352 - pTextHeight < 8 )
+      {
+        pOutString = pFontCreate;
+        pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf, &dialog_window, 12, 0) + 7;
+      }
+      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
+      pRenderer->_4A6A68(8, 352 - pTextHeight, pTex, (pTex ? pTex->uTextureHeight : 26) - pTextHeight);
+      pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
+      v63 = FitTextInAWindow(pTmpBuf, pOutString, &dialog_window, 0xCu, 0);
+      window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
+      break;
+    }
+    case DIALOG_SHOP_ARCOMAGE_103:
+    {
+      __debugbreak;
+      strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
+      dialog_window.uFrameWidth = 460;
+      dialog_window.uFrameZ = 452;
+      v61 = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 12, 0);
+      pTextHeight = v61 + 7;
+      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
+      pRenderer->_4A6A68(8, 352 - (v61 + 7), pTex, (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
+      pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
+      v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &dialog_window, 0xCu, 0);
+      window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
+      break;
+    }
+    case DIALOG_SHOP_ARCOMAGE_RESULT:
+    {
+      if ( pArcomageGame->bGameInProgress == 1 )
+        return;
+      if ( pArcomageGame->uGameResult )
+      {
+        if ( pArcomageGame->uGameResult == 1 )
+          v72 = pGlobalTXT_LocalizationStrings[640];// You won!
+        else
+          v72 = pGlobalTXT_LocalizationStrings[641];// You lost!
+      }
+      else
+      {
+        v72 = pGlobalTXT_LocalizationStrings[639];// A tie!
+      }
+      strcpy(pTmpBuf, v72);
+      v66 = (174 - pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0)) / 2 + 138;
+      dialog_window.DrawTitleText(pFontArrus, 0, v66, pColorYellow, pTmpBuf, 3);
+      break;
+    }
+    case DIALOG_SHOP_REST:
+    {
+      if ( pParty->uNumGold >= (unsigned int)pOutString )
+      {
+        Party::TakeGold((unsigned int)pOutString);
+        v27 = (int)window_SpeakInHouse->ptr_1C;
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
+        dialog_menu_id = 0;
+        sub_4BD8B5();
+        sub_4B1D27();
+        pVideoPlayer->Unload();
+        window_SpeakInHouse->Release();
+        window_SpeakInHouse = 0;
+        if ( pMessageQueue_50CBD0->uNumMessages )
+          pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+        pMessageQueue_50CBD0->pMessages[0].eType = UIMSG_OpenRestUI;
+        pMessageQueue_50CBD0->pMessages[0].param = v27;
+        pMessageQueue_50CBD0->pMessages[0].field_8 = 1;
+        ++pMessageQueue_50CBD0->uNumMessages;
+        return;
+      }
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
+      HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+      break;
+    }
+    case DIALOG_SHOP_SKILLS:
+    {
+      if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+        return;
+      v0 = 0;
+      v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
+      pItemNum = v9 * (100 - pPlayer->GetMerchant()) / 100;
+      if ( pItemNum < v9 / 3 )
+        pItemNum = v9 / 3;
+      pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
+      all_text_height = 0;
+      if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+      {
+        do
         {
-          ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u);
-          if ( uActiveCharacter )
-            pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0);
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+          v12 = pDialogueWindow->GetControl(pNumActiveItem)->uControlParam - 36;
+          if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v12] && !pPlayer->pActiveSkills[v12] )
+          {
+            all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v12], &dialog_window, 0, 0);
+            v0++;
+          }
+          ++pNumActiveItem;
+        }
+        while ( pNumActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton );
+        if ( v0 )
+        {
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pItemNum);
+          dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3);
+          v91 = (149 - all_text_height) / v0;
+          if ( (149 - all_text_height) / v0 > 32 )
+            v91 = 32;
+          v14 = (149 - v0 * v91 - all_text_height) / 2 - v91 / 2 + 162;
+          pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
+          if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+          {
+            pItemNum = 2;
+            do
+            {
+              pButton = pDialogueWindow->GetControl(pItemNum);
+              v17 = pButton->uControlParam - 36;
+              if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v17] || pPlayer->pActiveSkills[v17] )
+              {
+                pButton->uW = 0;
+                pButton->uHeight = 0;
+                pButton->uY = 0;
+              }
+              else
+              {
+                pButton->uY = v91 + v14;
+                pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v17], &dialog_window, 0, 0);
+                pButton->uHeight = pTextHeight;
+                v14 = pTextHeight + pButton->uY - 1;
+                pButton->uW = v14;
+                pColorText = pColorYellow;
+                if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
+                  pColorText = pColorWhite;
+                dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v17], 3);
+              }
+              pNumActiveItem = pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton;
+              pItemNum++;
+            }
+            while ( pItemNum < pNumActiveItem );
+          }
           return;
         }
-        if ( pParty->uNumGold >= v7 )
-        {
-          Party::TakeGold(v7);
-          //pParty->uNumFoodRations = (signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
-          pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
-          HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3);
-          v5 = 1;
-//LABEL_43:
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
-          return;
-          //goto LABEL_51;
-        }
-		ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
+      }
+      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
+      strcat(pTmpBuf, "\n \n");
+      strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
+      pTextHeight = (174 - pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0)) / 2 + 138;
+      dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorYellow, pTmpBuf, 3);
+      return;
+    }
+    case DIALOG_SHOP_BYE_FOOD:
+    {
+      *(_QWORD *)Str = pParty->uNumFoodRations;
+      //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] )
+      if ( (double)pParty->uNumFoodRations >= p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier )
+      {
+        ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2);
+        if ( uActiveCharacter )
+          pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0);
         pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
-		break;
-		}
-	case 1:
-		{
-		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-		  return;
-		v28 = *(int *)v84;
-		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
-		  v28 = v81;
-		sprintf(Dest, format_4E2DC8, v28);
-		sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
-		strcat(Dest, pTmpBuf2);
-		v90 = pFontArrus->CalcTextHeight(Dest, &v79, 0, 0);
-		strcat(Dest, "\n \n");
-		v29 = *(int *)v84;
-		if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
-		  v29 = v81;
-		sprintf(a1, format_4E2DC8, v29);
-		sprintf(pTmpBuf2,
-		  pGlobalTXT_LocalizationStrings[86],
-		  //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C],
-		  (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier,
-		  v83);
-		strcat(a1, pTmpBuf2);
-		v88 = pFontArrus->CalcTextHeight(a1, &v79, 0, 0);
-		strcat(a1, "\n \n");
-		v30 = *(int *)v84;
-		if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
-		  v30 = v81;
-		sprintf(v77, format_4E2DC8, v30);
-		strcat(v77, pGlobalTXT_LocalizationStrings[160]);
-		v82 = pFontArrus->CalcTextHeight(v77, &v79, 0, 0);
-		strcat(v77, "\n \n");
-		v75[0] = 0;
-		v87 = 0;
-		v31 = (signed int)window_SpeakInHouse->ptr_1C;
-		if ( v31 >= 108 && v31 <= 120 )
-		{
-		  v32 = *(int *)v84;
-		  if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
-			v32 = v81;
-		  sprintf(v75, format_4E2DC8, v32);
-		  strcat(v75, pGlobalTXT_LocalizationStrings[611]);
-		  v87 = pFontArrus->CalcTextHeight(v75, &v79, 0, 0);
-		}
-		v33 = pDialogueWindow;
-		Str[1] = (char *)pDialogueWindow;
-		v34 = pDialogueWindow->pStartingPosActiveItem;
-		v35 = v34 + pDialogueWindow->pNumPresenceButton;
-		v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
-		v37 = -pDialogueWindow->pNumPresenceButton < 0;
-		pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
-		if ( !(v37 ^ __OFSUB__(v34, v35)) )
-		{
-	//LABEL_75:
-		  sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
-		  v71 = 3;
-		  v69 = pTmpBuf;
-		  v67 = 0;
-		  v66 = 146;
-	//LABEL_98:
-		  v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
-		  return;
-		}
-		while ( 1 )
-		{
-		  v38 = v33->GetControl((unsigned int)pOutString);
-		  if ( v38->uControlParam == 15 )
-		  {
-			v46 = v90;
-			v38->uHeight = v90;
-			v38->uY = 146;
-			v41 = v46 + 145;
-			v38->uW = v41;
-		  }
-		  else if ( v38->uControlParam == 16 )
-		  {
-			v44 = v88;
-			v45 = v90 + v36 + 146;
-			v38->uHeight = v88;
-			v38->uY = v45;
-			v41 = v45 + v44 - 1;
-			v38->uW = v41;
-		  }
-		  else if ( v38->uControlParam == 96 )
-		  {
-			v42 = v90 + v88 + 2 * v36 + 146;
-			v43 = v82;
-			v38->uY = v42;
-			v38->uHeight = v43;
-			v41 = v43 + v42 - 1;
-			v38->uW = v41;
-		  }
-		  else if ( v38->uControlParam == 101 )
-		  {
-			v39 = v90 + 3 * v36 + v87 + v88 + 146;
-			v33 = (GUIWindow *)Str[1];
-			v40 = v87;
-			v38->uHeight = v87;
-			v38->uY = v39;
-			v41 = v39 + v40 - 1;
-	//LABEL_73:
-			v38->uW = v41;
-		  }
-		  v47 = v33->pStartingPosActiveItem;
-		  pOutString = (GUIFont *)((char *)pOutString + 1);
-		  if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 )
-		  {
-			  sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
-			  v71 = 3;
-			  v69 = pTmpBuf;
-			  v67 = 0;
-			  v66 = 146;
-			  v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
-			  return;
-		  }
-		}
-		break;
-		}
-	case 101:
-		{
-		if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-		{
-			v48 = 2;
-			pShopOptions[0] = pGlobalTXT_LocalizationStrings[620];
-			pOutString = 0;
-			pShopOptions[1] = pGlobalTXT_LocalizationStrings[622];
-			if ( pParty->HasItem(0x28Bu) )
-			{
-				pShopOptions[2] = pGlobalTXT_LocalizationStrings[621];
-				v48 = 3;
-			}
-			for ( i = 0; i < v48; ++i )
-			{
-				v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0);
-				pOutString = (GUIFont *)((char *)pOutString + v50);
-			}
-			v86 = (174 - (signed int)pOutString) / v48;
-			v51 = pDialogueWindow;
-			v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString;
-			v53 = v52 - HIDWORD(v52);
-			LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem;
-			HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton;
-			v54 = (v53 >> 1) - v86 / 2 + 138;
-			v37 = -pDialogueWindow->pNumPresenceButton < 0;
-			v89 = pDialogueWindow->pStartingPosActiveItem;
-			if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) )
-			{
-				v85 = (Player *)2;
-				pOutString = (GUIFont *)pShopOptions;
-				do
-				{
-					v55 = v51->GetControl(v89);
-					v56 = (const char **)pOutString;
-					v55->uY = v86 + v54;
-					v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0);
-					v58 = v55->uY;
-					v59 = v85;
-					v55->uHeight = v57;
-					v54 = v57 + v58 - 1;
-					v55->uW = v54;
-					v60 = v84[0];
-					if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 )
-						v60 = v81;
-					v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u);
-					v51 = pDialogueWindow;
-					v85 = (Player *)((char *)v85 + 1);
-					pOutString = (GUIFont *)((char *)pOutString + 4);
-					++v89;
-				}
-				while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-			}
-		}
-		break;
-		}
-	default:
-		{
-		break;
-		}
+        return;
+      }
+      if ( pParty->uNumGold >= v7 )
+      {
+        Party::TakeGold(v7);
+        //pParty->uNumFoodRations = (signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
+        pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        return;
+      }
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+      HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+      break;
+    }
+    case DIALOG_SHOP_ARCOMAGE_MAIN:
+    {
+      if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+      {
+        v48 = 2;
+        pShopOptions[0] = pGlobalTXT_LocalizationStrings[620];
+        pShopOptions[1] = pGlobalTXT_LocalizationStrings[622];
+        pOutString = 0;
+        if ( pParty->HasItem(0x28Bu) )
+        {
+          pShopOptions[2] = pGlobalTXT_LocalizationStrings[621];
+          v48 = 3;
+        }
+        for ( i = 0; i < v48; ++i )
+          all_text_height = pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
+        all_text_height = (174 - all_text_height) / v48;
+        pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
+        v54 = (174 - v48 * (174 - all_text_height) / v48 - all_text_height) / 2 - (174 - all_text_height) / v48 / 2 + 138;
+        v37 = -pDialogueWindow->pNumPresenceButton < 0;
+        if ( v37 ^ pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+        {
+          pItemNum = 2;
+          pNumString = 0;
+          do
+          {
+            pButton = pDialogueWindow->GetControl(pItemNum);
+            pButton->uY = all_text_height + v54;
+            pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
+            pButton->uHeight = pTextHeight;
+            v54 = pButton->uY + pTextHeight - 1;
+            pButton->uW = v54;
+            pColorText = pColorYellow;
+            if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
+              pColorText = pColorWhite;
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, *(const char **)&pOutString->cFirstChar, 3);
+            pItemNum++;
+            pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
+          }
+          while ( pItemNum < pNumActiveItem );
+        }
+      }
+      break;
+    }
+    default:
+    {
+      break;
+    }
   }
 }
 
@@ -1449,12 +1371,10 @@
   int v0; // ebx@1
   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 v9; // ST08_4@16
   int v10; // eax@16
   signed int v11; // esi@18
@@ -1463,36 +1383,28 @@
   int v14; // edi@23
   char **v15; // esi@23
   int v16; // eax@24
-  GUIWindow *v17; // ecx@25
-  int v18; // edx@25
+  //int v18; // edx@25
   int v19; // edi@25
   unsigned __int8 v20; // sf@25
   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
+  unsigned int pColorText; // ax@27
   signed int v27; // esi@32
   int v28; // ST08_4@36
   int v29; // eax@36
-  GUIWindow *v30; // edi@41
-  //void *v31; // eax@41
   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
-  GUIButton *v38; // eax@53
-  GUIButton *v39; // esi@53
   int v40; // eax@53
   char *v41; // eax@55
-  //int v42; // eax@55
   unsigned int v43; // ecx@55
   const char **v44; // edx@55
   int v45; // eax@55
-  unsigned __int16 v46; // ax@55
   int v47; // eax@59
   const char **v48; // eax@63
   unsigned int v49; // esi@65
@@ -1514,16 +1426,12 @@
   int all_text_height; // esi@96
   char **v66; // edi@96
   int v67; // eax@97
-  GUIWindow *v68; // ecx@98
   int v69; // edx@98
   int v70; // edi@98
   int v71;
   const char **v72; // eax@100
   int pTextHeight; // eax@100
   unsigned int v74; // ecx@100
-  Player *v75; // edx@100
-  unsigned __int16 v76; // ax@100
-  GUIWindow *v77; // [sp-18h] [bp-110h]@14
   int v78; // [sp-14h] [bp-10Ch]@14
   ItemGen *v79; // [sp-10h] [bp-108h]@12
   int v80; // [sp-10h] [bp-108h]@14
@@ -1550,7 +1458,7 @@
   GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1
   char *Str; // [sp+D0h] [bp-28h]@55
   __int32 v103; // [sp+D4h] [bp-24h]@25
-  int pColor2; // [sp+D8h] [bp-20h]@1
+  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
@@ -1565,7 +1473,7 @@
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
   pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   switch(dialog_menu_id)
   {
     case DIALOG_SHOP_MAIN:
@@ -1582,10 +1490,9 @@
           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 )
+        if ( v20 ^ pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )
         {
           pItemNum = 2;
           pNumString = 0;
@@ -1597,10 +1504,10 @@
             pButton->uHeight = pTextHeight;
             v19 = pButton->uY + pTextHeight - 1;
             pButton->uW = v19;
-            v26 = pColor2;
+            pColorText = pColorYellow;
             if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-              v26 = pColorWhite;
-            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v26, (const char *)pShopOptions[pNumString], 3);
+              pColorText = pColorWhite;
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
             ++pItemNum;
             ++pNumString;
             pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
@@ -1774,10 +1681,9 @@
         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 )
+      if ( v20 ^ pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )
       {
         pItemNum = 2;
         pNumString = 0;
@@ -1789,10 +1695,10 @@
           pButton->uHeight = pTextHeight;
           v70 = pButton->uY + pTextHeight - 1;
           pButton->uW = v70;
-          v76 = pColor2;
+          pColorText = pColorYellow;
           if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-            v76 = pColorWhite;
-          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v76, (const char *)pShopOptions[pNumString], 3);
+            pColorText = pColorWhite;
+          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
           ++pItemNum;
           ++pNumString;
           pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
@@ -1902,7 +1808,7 @@
         strcat(pTmpBuf, "\n \n");
         strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
         pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColor2, pTmpBuf, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf, 3);
         return;
       }
       do
@@ -1922,7 +1828,7 @@
         strcat(pTmpBuf, "\n \n");
         strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
         pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColor2, pTmpBuf, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf, 3);
         return;
       }
       sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pItemNum);
@@ -1952,10 +1858,10 @@
             pButton->uHeight = pTextHeight;
             v37 = pButton->uY + pTextHeight - 1;
             pButton->uW = v37;
-            v46 = pColor2;
+            pColorText = pColorYellow;
             if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-              v46 = pColorWhite;
-            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v46, pSkillNames[v40], 3);
+              pColorText = pColorWhite;
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v40], 3);
           }
           pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
           pItemNum++;
@@ -1982,40 +1888,30 @@
 {
   int v0;
   int pNumActiveItem; // eax@7
-  //GUIWindow *v2; // edi@9
-  //unsigned int v3; // ebx@9
-  //void *v4; // eax@9
   signed int v5; // esi@9
   unsigned int v6; // esi@11
   int v7; // eax@11
   unsigned int v8; // eax@12
   int v9; // eax@14
   int v10; // ecx@19
-  GUIButton *v11; // eax@21
-  GUIButton *v12; // esi@21
   int v13; // eax@21
   char *v14; // eax@23
   int v15; // eax@23
   unsigned int v16; // ecx@23
   int v17; // edx@23
   int v18; // eax@23
-  unsigned __int16 v19; // ax@23
   int v20; // eax@27
   char *v21; // edx@29
   int v22; // esi@30
   char **v23; // edi@30
   int v24; // eax@31
-  GUIWindow *v25; // ecx@32
   int v26; // edx@32
   int v27; // edi@32
   unsigned __int8 v28; // sf@32
-  GUIButton *v29; // esi@34
   const char **v30; // eax@34
   int v31; // eax@34
   unsigned int v32; // ecx@34
-  Player *v33; // edx@34
   int v34; // eax@34
-  unsigned __int16 v35; // ax@34
   signed int v36; // esi@39
   ItemGen *v37; // eax@42
   char *v38; // ecx@43
@@ -2062,9 +1958,7 @@
   const char **v79; // eax@129
   int pTextHeight; // eax@129
   unsigned int v81; // ecx@129
-  Player *v82; // edx@129
-  unsigned __int16 v83; // ax@129
-  GUIWindow *v84; // [sp-18h] [bp-F0h]@29
+  unsigned int pColorText; // ax@129
   int v85; // [sp-14h] [bp-ECh]@29
   int v86; // [sp-10h] [bp-E8h]@29
   ItemGen *v87; // [sp-10h] [bp-E8h]@43
@@ -2086,7 +1980,7 @@
   POINT a2; // [sp+54h] [bp-84h]@39
   GUIWindow dialog_window; // [sp+5Ch] [bp-7Ch]@1
   int v105; // [sp+B0h] [bp-28h]@19
-  int pColor2; // [sp+B4h] [bp-24h]@1
+  int pColorYellow; // [sp+B4h] [bp-24h]@1
   int Str; // [sp+B8h] [bp-20h]@23
   int pColorWhite; // [sp+BCh] [bp-1Ch]@1
   __int32 v109; // [sp+C0h] [bp-18h]@39
@@ -2102,7 +1996,7 @@
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
   pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   switch(dialog_menu_id)
   {
     case DIALOG_SHOP_MAIN:
@@ -2133,11 +2027,10 @@
             pButton->uHeight = pTextHeight;
             v77 = pButton->uY + pTextHeight - 1;
             pButton->uW = v77;
-            v83 = pColor2;
+            pColorText = pColorYellow;
             if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-              v83 = pColorWhite;
-            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v83, (const char *)pShopOptions[pNumString], 3);
-            pPlayer = (Player *)((char *)pPlayer + 1);
+              pColorText = pColorWhite;
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
             ++pItemNum;
             ++pNumString;
             pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
@@ -2153,7 +2046,6 @@
       v114 = 0;
       do
       {
-        // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
         if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID);
         {
           v46 = ItemsInShopTexture[v114];
@@ -2181,7 +2073,6 @@
       v114 = 0;
       do
       {
-        //  if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
         if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID);
         {
           v50 = ItemsInShopTexture[v114 + 6];
@@ -2215,7 +2106,6 @@
         v109 = 0;
         do
         {
-          // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
           if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID);
             ++v109;
           ++v62;
@@ -2247,7 +2137,6 @@
         if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
         {
           v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
-          //  v69 = 9 * (v67 + 12 * v68);
           v70 = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];
           if ( dialog_menu_id != 2 )
             v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
@@ -2338,10 +2227,10 @@
           pButton->uHeight = pTextHeight;
           v27 = pButton->uY + pTextHeight - 1;
           pButton->uW = v27;
-          v35 = pColor2;
+          pColorText = pColorYellow;
           if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-            v35 = pColorWhite;
-          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v35, (const char *)pShopOptions[pNumString], 3);
+            pColorText = pColorWhite;
+          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
           ++pItemNum;
           ++pNumString;
           pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
@@ -2356,7 +2245,6 @@
       v114 = 0;
       do
       {
-        //if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
         if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
         {
           v54 = ItemsInShopTexture[v114];
@@ -2387,7 +2275,6 @@
       v114 = 0;
       do
       {
-        // if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )   //weak 
         if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid
         {
           v58 = ItemsInShopTexture[v114 + 6];
@@ -2421,7 +2308,6 @@
         v109 = 0;
         do
         {
-          //if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
           if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
             ++v109;
           ++v62;
@@ -2479,7 +2365,6 @@
       if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
         return;
       all_text_height = 0;
-      //v5 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v4] * 500.0);
       v5 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
       pItemNum = v5 * (100 - pPlayer->GetMerchant()) / 100;
       if ( pItemNum < v5 / 3 )
@@ -2492,7 +2377,7 @@
         strcat(pTmpBuf, "\n \n");
         strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
         v40 = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColor2, pTmpBuf, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf, 3);
         return;
       }
       do
@@ -2512,7 +2397,7 @@
         strcat(pTmpBuf, "\n \n");
         strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
         v40 = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColor2, pTmpBuf, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf, 3);
         return;
       }
       if ( v114 )
@@ -2544,10 +2429,10 @@
               pButton->uHeight = pTextHeight;
               v105 = pButton->uY + pTextHeight - 1;
               pButton->uW = v105;
-              v19 = pColor2;
+              pColorText = pColorYellow;
               if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-                v19 = pColorWhite;
-              dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, v19, pSkillNames[v13], 3);
+                pColorText = pColorWhite;
+              dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v13], 3);
             }
             pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
             pItemNum++;
--- a/UIHouses.h	Mon Mar 11 20:11:19 2013 +0600
+++ b/UIHouses.h	Tue Mar 12 01:20:36 2013 +0600
@@ -9,9 +9,15 @@
     DIALOG_SHOP_SELL = 3,
     DIALOG_SHOP_IDENTIFY = 4,
     DIALOG_SHOP_REPAIR = 5,
+    DIALOG_SHOP_REST = 15,
+    DIALOG_SHOP_BYE_FOOD = 16,
     DIALOG_SHOP_DISPLAY_EQUIPMENT = 94,
     DIALOG_SHOP_BUY_SPECIAL = 95,
     DIALOG_SHOP_SKILLS = 96,
+    DIALOG_SHOP_ARCOMAGE_MAIN = 101,
+    DIALOG_SHOP_ARCOMAGE_102 = 102,
+    DIALOG_SHOP_ARCOMAGE_103 = 103,
+    DIALOG_SHOP_ARCOMAGE_RESULT = 104,
     };
 
 /*  349 */