changeset 1625:2d374de0a364

TrainingDialog cleaning(continue)
author Ritor1
date Mon, 16 Sep 2013 01:14:17 +0600
parents 15667a0ec5b9
children 2149b14614ad d17247968bd6
files UI/UIHouses.cpp
diffstat 1 files changed, 150 insertions(+), 258 deletions(-) [+]
line wrap: on
line diff
--- a/UI/UIHouses.cpp	Sun Sep 15 19:19:43 2013 +0600
+++ b/UI/UIHouses.cpp	Mon Sep 16 01:14:17 2013 +0600
@@ -1920,7 +1920,6 @@
   int schedule_id; // esi@39
   GUIButton *pButton; // ebx@39
   signed int v25; // eax@41
-  unsigned int v30; // ecx@62
   MapInfo pMap; // [sp-3Ch] [bp-2CCh]@62
   char pTopicArray[5][100]; // [sp+14h] [bp-27Ch]@37
   GUIWindow travel_window; // [sp+208h] [bp-88h]@1
@@ -1969,7 +1968,7 @@
         }
 
         if (schedule_id != 255 && v25 && (!transport_schedule[schedule_id].uQuestBit
-           || _449B57_test_bit(pParty->_quest_bits, transport_schedule[schedule_id].uQuestBit)) )
+           || _449B57_test_bit(pParty->_quest_bits, transport_schedule[schedule_id].uQuestBit)) )//ошибка: рисуется несколько строчек одного направления путешествия
         {
   //get color for current string(определение цвета текущей строки)----------
           if ( pDialogueWindow->pCurrentPosActiveItem == pCurrentButton )
@@ -2005,9 +2004,8 @@
             strcat(pTopicArray[index], "\n \n");
             pButton->uY = pRealTextHeight;
             pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &travel_window, 0, 0);
-            v30 = pButton->uY;
             pButton->uHeight = pTextHeight;
-            pButton->uW = v30 + pTextHeight - 1;
+            pButton->uW = pButton->uY + pTextHeight - 1;
             pRealTextHeight += (LOBYTE(pFontArrus->uFontHeight) - 3) + pTextHeight;
           }
         }
@@ -2149,7 +2147,6 @@
   int v17; // ebx@28
   GUIButton *pButton; // eax@30
   int pTextHeight; // eax@30
-  unsigned int v23; // ecx@30
   unsigned __int16 pTextColor; // ax@30
   GUIWindow window; // [sp+60h] [bp-BCh]@21
   GUIWindow townHall_window; // [sp+B4h] [bp-68h]@1
@@ -2190,14 +2187,13 @@
           pButton = pDialogueWindow->GetControl(i);
           pButton->uY = v29 + v17;
           pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &townHall_window, 0, 0);
-          v23 = pButton->uY;
           pButton->uHeight = pTextHeight;
-          v17 = v23 + pTextHeight - 1;
+          v17 = pButton->uY + pTextHeight - 1;
           pButton->uW = v17;
           pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
           if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
             pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
-          townHall_window.DrawTitleText(pFontArrus, 0, v23, pTextColor, pShopOptions[j], 3);
+          townHall_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[j], 3);
           ++v31;
           ++j;
         }
@@ -3082,24 +3078,15 @@
 //----- (004B4710) --------------------------------------------------------
 void TrainingDialog()
 {
-  int color2; // eax@1
-  //unsigned int v2; // ecx@1
-  //int v3; // eax@1
-  //signed int v4; // edx@1
   unsigned __int64 v5; // edi@3
-  //unsigned int v6; // esi@3
-  //void *v7; // ecx@3
   int v8; // edx@4
   double v9; // st7@6
   signed int v10; // esi@6
-  int v11; // ecx@6
-  //int result; // eax@9
-  GUIWindow *v13; // edi@14
+  int pPrice; // ecx@6
   signed int v14; // esi@14
   unsigned int v15; // esi@16
   int v16; // eax@16
   unsigned int v17; // eax@17
-  int v18; // eax@19
   int v19; // ecx@24
   GUIButton *v20; // eax@26
   GUIButton *v21; // esi@26
@@ -3109,222 +3096,130 @@
   unsigned int v25; // ecx@28
   int v26; // eax@28
   unsigned __int16 v27; // ax@28
-  //int v28; // eax@32
   unsigned __int16 v29; // ST14_2@34
   int v30; // eax@34
-  //const char *v31; // ST18_4@36
-  //unsigned __int16 v32; // ST14_2@36
   int v33; // eax@36
-  int v34; // eax@37
-  unsigned int v35; // edi@38
   unsigned int v36; // eax@38
-  //int v37; // ecx@41
-  //char *v38; // eax@41
-  //int *v39; // eax@45
-  unsigned int v40; // eax@46
-  //void *v41; // ecx@46
   unsigned int v42; // eax@46
-  GUIWindow *v43; // ecx@59
-  int v44; // edx@59
-  char **v45; // esi@60
-  //int v46; // eax@62
-  int v47; // eax@68
-  //int v48; // edx@69
+  int index;
+  int all_text_height; // eax@68
   int v49; // ebx@69
-  //unsigned __int8 v50; // sf@69
-  char **v51; // edi@70
-  GUIButton *v52; // eax@71
-  GUIButton *v53; // esi@71
-  int v54; // eax@71
-  unsigned int v55; // ecx@71
-  int v56; // eax@71
-  unsigned __int16 v57; // ax@71
-  unsigned __int16 v58; // [sp-Ch] [bp-90h]@38
-  //const char *v59; // [sp-Ch] [bp-90h]@63
-  char *v60; // [sp-8h] [bp-8Ch]@38
-  //char *v61; // [sp-8h] [bp-8Ch]@63
-  unsigned int v62; // [sp-4h] [bp-88h]@38
-  int v63; // [sp-4h] [bp-88h]@52
-  //char *v64; // [sp-4h] [bp-88h]@63
-  GUIWindow v65; // [sp+Ch] [bp-78h]@1
-  //__int64 v66; // [sp+60h] [bp-24h]@3
-  unsigned int white; // [sp+68h] [bp-1Ch]@1
+  GUIButton *pButton; // eax@71
+  int pTextHeight; // eax@71
+  unsigned __int16 pTextColor; // ax@71
+  GUIWindow training_dialog_window; // [sp+Ch] [bp-78h]@1
   int v68; // [sp+6Ch] [bp-18h]@3
   int v69; // [sp+70h] [bp-14h]@6
-  //unsigned int i; // [sp+74h] [bp-10h]@1
-  //int v71; // [sp+78h] [bp-Ch]@1
-  int v72; // [sp+7Ch] [bp-8h]@16
   int v73; // [sp+80h] [bp-4h]@14
 
-  //v0 = pPlayers[uActiveCharacter];
-  memcpy(&v65, window_SpeakInHouse, sizeof(v65));
-  v65.uFrameX = 483;
-  v65.uFrameWidth = 148;
-  v65.uFrameZ = 334;
-  white = TargetColor(255, 255, 255);
-  color2 = TargetColor(0xE1u, 0xCDu, 0x23u);
-  //v71 = color2;
-  //v2 = v0->uLevel;
-  //v3 = 0;
-  //v4 = 0;
-  //for ( i = v2; v4 < (signed int)v2; ++v4 )
-  //  v3 += v4 + 1;
-  //v5 = 1000 * v3;
+  memcpy(&training_dialog_window, window_SpeakInHouse, sizeof(training_dialog_window));
+  training_dialog_window.uFrameX = 483;
+  training_dialog_window.uFrameWidth = 148;
+  training_dialog_window.uFrameZ = 334;
   v5 = 1000ui64 * pPlayers[uActiveCharacter]->uLevel * (pPlayers[uActiveCharacter]->uLevel + 1) / 2;  // E n = n(n + 1) / 2
-  //v6 = HIDWORD(v0->uExperience);
-  //v7 = window_SpeakInHouse->ptr_1C;
   v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_TRAINING_HALL_EMERALD_ISLE];
-  //v66 = 1000 * v3;
   if (pPlayers[uActiveCharacter]->uExperience >= v5)
   {
     v8 = pPlayers[uActiveCharacter]->classType % 4 + 1;
     if ( v8 == 4 )
       v8 = 3;
     v9 = (double)pPlayers[uActiveCharacter]->uLevel;
-    //i = 0;
     v69 = v8;
-    //v10 = (signed __int64)(v9 * p2DEvents_minus1__20[13 * (signed int)v7] * (double)v8);
     v10 = (signed __int64)(v9 * p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * (double)v8);
-    v11 = v10 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
-    if ( v11 < v10 / 3 )
-      v11 = v10 / 3;
-    //i = v11;
+    pPrice = v10 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+    if ( pPrice < v10 / 3 )
+      pPrice = v10 / 3;
   }
-
+//-------------------------------------------------------
+  all_text_height = 0;
   if (HouseUI_CheckIfPlayerCanInteract())
   {
-    if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN )
     {
-      if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
+      if (HouseUI_CheckIfPlayerCanInteract())
       {
-        if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
+        index = 0;
+        pShopOptions[0] = pTmpBuf.data();
+        pShopOptions[1] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills"
+        if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
         {
-          if (HouseUI_CheckIfPlayerCanInteract())
+          for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
           {
-            //i = 0;
-            int _v0 = 0;
-            v13 = pDialogueWindow;
-            //v14 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
-            v14 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-            v73 = v14 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
-            if ( v73 < v14 / 3 )
-              v73 = v14 / 3;
-            v15 = v13->pStartingPosActiveItem;
-            v16 = v13->pNumPresenceButton;
-            v72 = 0;
-            if ( (signed int)v15 >= (signed int)(v15 + v16) )
-              goto LABEL_76;
-            do
-            {
-              v17 = v13->GetControl(v15)->msg_param - 36;
-              if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v17] && !pPlayers[uActiveCharacter]->pActiveSkills[v17] )
-              {
-                v18 = pFontArrus->CalcTextHeight(pSkillNames[v17], &v65, 0, 0);
-                _v0 += v18;
-                ++v72;
-              }
-              ++v15;
-            }
-            while ( (signed int)v15 < v13->pNumPresenceButton + v13->pStartingPosActiveItem );
-            if ( v72 )
+            if ( pDialogueWindow->GetControl(i)->msg_param == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
             {
-              sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
-              v65.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u);
-              v73 = (signed int)(149 - _v0) / v72;
-              if ( v73 > 32 )
-                v73 = 32;
-              //result = v13->pStartingPosActiveItem;
-              v19 = (signed int)(149 - v72 * v73 - _v0) / 2 - v73 / 2 + 162;
-              int _v1 = v13->pStartingPosActiveItem;
-              v68 = v19;
-              if (v13->pStartingPosActiveItem < v13->pStartingPosActiveItem + v13->pNumPresenceButton )
+              if (pPlayers[uActiveCharacter]->uLevel >= v68)
+                sprintfex(pShopOptions[index], "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]); //"With your skills, you should be working here as a teacher."    "Sorry, but we are unable to train you."
+              else
               {
-                v72 = 2;
-                do
-                {
-                  v20 = v13->GetControl(_v1);
-                  v21 = v20;
-                  v22 = v20->msg_param - 36;
-                  if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v22] || pPlayers[uActiveCharacter]->pActiveSkills[v22] )
-                  {
-                    v21->uW = 0;
-                    v21->uHeight = 0;
-                    v21->uY = 0;
-                  }
-                  else
-                  {
-                    v23 = pSkillNames[v22];
-                    v21->uY = v73 + v68;
-                    //HIDWORD(v66) = (int)v23;
-                    v24 = pFontArrus->CalcTextHeight(v23, &v65, 0, 0);
-                    v25 = v21->uY;
-                    v21->uHeight = v24;
-                    v26 = v25 + v24 - 1;
-                    v21->uW = v26;
-                    v68 = v26;
-                    v27 = color2;
-                    if ( pDialogueWindow->pCurrentPosActiveItem != v72 )
-                      v27 = white;
-                    v65.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3u);
-                  }
-                  ++_v1;
-                  ++v72;
-                }
-                while ( (signed int)_v1 < v13->pStartingPosActiveItem + v13->pNumPresenceButton );
+                if (pPlayers[uActiveCharacter]->uExperience < v5)
+                  sprintfex(pShopOptions[index], pGlobalTXT_LocalizationStrings[538], (uint)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1); // "You need %d more experience to train to level %d"
+                else
+                  sprintfex(pShopOptions[index], pGlobalTXT_LocalizationStrings[537], pPlayers[uActiveCharacter]->uLevel + 1, pPrice); // "Train to level %d for %d gold"
               }
             }
-            else
-            {
-LABEL_76:
-              sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// 
-                                                // "Seek knowledge elsewhere %s the %s"
-              strcat(pTmpBuf.data(), "\n \n");
-              strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
-              v29 = color2;
-              v30 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0);
-              v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf.data(), 3u);
-            }
+            all_text_height += pFontArrus->CalcTextHeight(pShopOptions[index], &training_dialog_window, 0, 0);
+            ++index;
           }
         }
-        return;
+        v49 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138;
+        if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton)
+        {
+          int pCurrentItem = 2;
+          index = 0;
+          for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                i < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++i )
+          {
+            pButton = pDialogueWindow->GetControl(i);
+            pButton->uY = (174 - all_text_height) / 2 + v49;
+            pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[index], &training_dialog_window, 0, 0);
+            pButton->uHeight = pTextHeight;
+            pButton->uW = pTextHeight + pButton->uY - 1;
+            v49 = pButton->uW;
+            pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+            if ( pDialogueWindow->pCurrentPosActiveItem != pCurrentItem )
+              pTextColor = TargetColor(255, 255, 255);
+            training_dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[index], 3);
+            ++pCurrentItem;
+            ++index;
+          }
+        }
       }
+    }
+//------------------------------------------------------------------
+    if ( dialog_menu_id == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
+    {
       if ( !HouseUI_CheckIfPlayerCanInteract() )
       {
-        //v31 = pNPCTopics[122].pText;
-        //v32 = color2;
-        v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0);
-        v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, color2, pNPCTopics[122].pText, 3);
+        v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &training_dialog_window, 0, 0);
+        training_dialog_window.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, TargetColor(0xE1u, 0xCDu, 0x23u), pNPCTopics[122].pText, 3);
         pDialogueWindow->pNumPresenceButton = 0;
         return;
       }
-      v34 = pPlayers[uActiveCharacter]->uLevel;
-      if ( v34 < v68 )
+      //v34 = pPlayers[uActiveCharacter]->uLevel;
+      if ( pPlayers[uActiveCharacter]->uLevel < v68 )
       {
         if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience >= v5 )
         {
-          if ( pParty->uNumGold >= v11)
+          if ( pParty->uNumGold >= pPrice)
           {
-            Party::TakeGold(v11);
+            Party::TakeGold(pPrice);
             PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
             ++pPlayers[uActiveCharacter]->uLevel;
             pPlayers[uActiveCharacter]->uSkillPoints += pPlayers[uActiveCharacter]->uLevel / 10 + 5;
             pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth();
             pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana();
-
             uint max_level_in_party = player_levels[0];
             for (uint _it = 1; _it < 4; ++_it)
             {
               if (player_levels[_it] > max_level_in_party)
                 max_level_in_party = player_levels[_it];
             }
-
             ++player_levels[uActiveCharacter - 1];
             if (player_levels[uActiveCharacter - 1] > max_level_in_party) // if we reach new maximum party level
                                                                           // feature is broken thou, since this array is always zeroed in EnterHouse
             {
-              v40 = _494820_training_time(pParty->uCurrentHour);
-              //v41 = window_SpeakInHouse->ptr_1C;
-              v42 = 60 * (v40 + 4) - pParty->uCurrentMinute;
+              v42 = 60 * (_494820_training_time(pParty->uCurrentHour) + 4) - pParty->uCurrentMinute;
               if ((unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_94 ||
                   (unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_95)
                 v42 += 720;
@@ -3340,115 +3235,112 @@
             return;
           }
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
-          v63 = 4;
-LABEL_55:
-          PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v63);
-//LABEL_56:
-          /*result = pMessageQueue_50CBD0->uNumMessages;
-          if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-          {
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-            result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
-            *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
-            ++pMessageQueue_50CBD0->uNumMessages;
-          }
-          return result;*/
+          PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)4);
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
           return;
         }
-        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), v34 + 1);// 
+        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1);// 
                                                 // "You need %d more experience to train to level %d"
-        v35 = 0;
-        v62 = 3;
-        v60 = pTmpBuf.data();
-        v58 = color2;
-        v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0)) / 2 + 88;
+        v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0)) / 2 + 88;
       }
       else
       {
         sprintf(pTmpBuf.data(), "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]);// 
                                                 // ""With your skills, you should be working here as a teacher.""
                                                 // ""Sorry, but we are unable to train you.""
-        v35 = 0;
-        v62 = 3;
-        v60 = pTmpBuf.data();
-        v58 = color2;
-        v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0)) / 2 + 101;
+        v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0)) / 2 + 101;
       }
-      v65.DrawTitleText(pFontArrus, v35, v36, v58, v60, v62);
-      v63 = 3;
-      goto LABEL_55;
+      training_dialog_window.DrawTitleText(pFontArrus, 0, v36, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+      PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)3);
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      return;
     }
-
+  }
+//-------------------------------------------------------------
+  if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
+  {
     if (HouseUI_CheckIfPlayerCanInteract())
     {
-      v43 = pDialogueWindow;
-      v72 = 0;
-      pShopOptions[0] = pTmpBuf.data();
-      pShopOptions[1] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills"
-      v44 = pDialogueWindow->pNumPresenceButton;
-      v73 = pDialogueWindow->pStartingPosActiveItem;
-      if ( v73 < v73 + v44 )
+      v14 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
+      v73 = v14 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+      if ( v73 < v14 / 3 )
+        v73 = v14 / 3;
+      v15 = pDialogueWindow->pStartingPosActiveItem;
+      v16 = pDialogueWindow->pNumPresenceButton;
+      index = 0;
+      if ( (signed int)v15 >= (signed int)(v15 + v16) )
+        goto LABEL_76;
+      do
+      {
+        v17 = pDialogueWindow->GetControl(v15)->msg_param - 36;
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v17] && !pPlayers[uActiveCharacter]->pActiveSkills[v17] )
+        {
+          all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v17], &training_dialog_window, 0, 0);
+          ++index;
+        }
+        ++v15;
+      }
+      while ( (signed int)v15 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+      if ( index )
       {
-        v45 = pShopOptions.data();
-        do
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
+        training_dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
+        v73 = (signed int)(149 - all_text_height) / index;
+        if ( v73 > 32 )
+          v73 = 32;
+        v19 = (signed int)(149 - index * v73 - all_text_height) / 2 - v73 / 2 + 162;
+        int _v1 = pDialogueWindow->pStartingPosActiveItem;
+        v68 = v19;
+        if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
         {
-          if ( v43->GetControl(v73)->msg_param == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
+          index = 2;
+          do
           {
-            //v46 = pPlayers[uActiveCharacter]->uLevel;
-            if (pPlayers[uActiveCharacter]->uLevel >= v68)
-              sprintfex(*v45, "%s\n \n%s",
-                        pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]); //"With your skills, you should be working here as a teacher."    "Sorry, but we are unable to train you."
+            v20 = pDialogueWindow->GetControl(_v1);
+            v21 = v20;
+            v22 = v20->msg_param - 36;
+            if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v22] || pPlayers[uActiveCharacter]->pActiveSkills[v22] )
+            {
+              v21->uW = 0;
+              v21->uHeight = 0;
+              v21->uY = 0;
+            }
             else
             {
-              if (pPlayers[uActiveCharacter]->uExperience < v5)
-                sprintfex(*v45, pGlobalTXT_LocalizationStrings[538],  // "You need %d more experience to train to level %d"
-                          (uint)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1);
-              else
-                sprintfex(*v45, pGlobalTXT_LocalizationStrings[537],  // "Train to level %d for %d gold"
-                          pPlayers[uActiveCharacter]->uLevel + 1, v11);
+              v23 = pSkillNames[v22];
+              v21->uY = v73 + v68;
+              //HIDWORD(v66) = (int)v23;
+              v24 = pFontArrus->CalcTextHeight(v23, &training_dialog_window, 0, 0);
+              v25 = v21->uY;
+              v21->uHeight = v24;
+              v26 = v25 + v24 - 1;
+              v21->uW = v26;
+              v68 = v26;
+              v27 = TargetColor(0xE1u, 0xCDu, 0x23u);
+              if ( pDialogueWindow->pCurrentPosActiveItem != index )
+                v27 = TargetColor(255, 255, 255);
+              training_dialog_window.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3);
             }
+            ++_v1;
+            ++index;
           }
-          v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0);
-          v43 = pDialogueWindow;
-          v72 += v47;
-          ++v45;
-          ++v73;
+          while ( (signed int)_v1 < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton );
         }
-        while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
       }
-
-      v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138;
-      v73 = v43->pStartingPosActiveItem;
-      if (v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton)
+      else
       {
-        int _v3 = 2;
-        v51 = pShopOptions.data();
-        do
-        {
-          v52 = v43->GetControl(v73);
-          v53 = v52;
-          v52->uY = (174 - v72) / 2 + v49;
-          v54 = pFontArrus->CalcTextHeight(*v51, &v65, 0, 0);
-          v55 = v53->uY;
-          v53->uHeight = v54;
-          v56 = v54 + v55 - 1;
-          v53->uW = v56;
-          v49 = v56;
-          v57 = color2;
-          if ( pDialogueWindow->pCurrentPosActiveItem != _v3 )
-            v57 = white;
-          v65.DrawTitleText(pFontArrus, 0, v55, v57, *v51, 3u);
-          v43 = pDialogueWindow;
-          ++_v3;
-          ++v51;
-          ++v73;
-        }
-        while ( v73 < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton);
+LABEL_76:
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// 
+                                              // "Seek knowledge elsewhere %s the %s"
+        strcat(pTmpBuf.data(), "\n \n");
+        strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
+        v29 = TargetColor(0xE1u, 0xCDu, 0x23u);
+        v30 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0);
+        training_dialog_window.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf.data(), 3);
       }
     }
   }
+  return;
 }
 
 //----- (004B6478) --------------------------------------------------------