changeset 983:1462a5f12b65

Character Skills tab drawing fixed.
author Nomad
date Sat, 11 May 2013 17:00:43 +0200
parents 08fd1436ef35
children d982fffb8b96
files GUIWindow.h Game.cpp Player.cpp UICharacter.cpp UIPopup.cpp mm7_1.cpp mm7_2.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 10 files changed, 189 insertions(+), 551 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.h	Sat May 11 13:19:55 2013 +0200
+++ b/GUIWindow.h	Sat May 11 17:00:43 2013 +0200
@@ -472,11 +472,15 @@
 
 
 //character ui
-unsigned int __fastcall GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level);
-const char *__fastcall CharacterUI_GetSkillDescText(unsigned int uPlayerID, PLAYER_SKILL_TYPE uPlayerSkillType);
-char __cdecl CharacterUI_SkillsTab_ShowHint();
-void __cdecl CharacterUI_StatsTab_ShowHint();
-char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID); // idb
+unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level);
+const char *CharacterUI_GetSkillDescText(unsigned int uPlayerID, PLAYER_SKILL_TYPE uPlayerSkillType);
+char CharacterUI_SkillsTab_ShowHint();
+void CharacterUI_StatsTab_ShowHint();
+char CharacterUI_StatsTab_Draw(unsigned int uPlayerID); // idb
+void CharacterUI_SkillsTab_Draw(Player *player);
+void CharacterUI_AwardsTab_Draw(unsigned int uPlayerID); // idb
+void CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2);
+void CharacterUI_CharacterScreen_Draw(unsigned int uPlayerIdx); // idb
 
 
 
@@ -638,4 +642,13 @@
 extern GUIButton *pCreationUI_BtnPressRight2[4];
 extern GUIButton *pCreationUI_BtnPressLeft2[4];
 extern GUIButton *pCreationUI_BtnPressLeft[4];
-extern GUIButton *pCreationUI_BtnPressRight[4];
\ No newline at end of file
+extern GUIButton *pCreationUI_BtnPressRight[4];
+
+
+extern unsigned int ui_color_text_default;
+extern unsigned int ui_color_text_highlight;
+extern unsigned int ui_color_text_header;
+extern unsigned int ui_color_text_bonus;
+extern unsigned int ui_color_text_bonus_neg;
+extern unsigned int ui_color_text_skill_upgradeable;
+extern unsigned int ui_color_text_skill_not_upgradeable;
\ No newline at end of file
--- a/Game.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/Game.cpp	Sat May 11 17:00:43 2013 +0200
@@ -358,6 +358,14 @@
         pMouse->_469EA4();
         pRenderer->EndScene();
       }
+      
+      pEventTimer->Update();
+      pMiscTimer->Update();
+
+      static int gtc_old = GetTickCount();
+      int gtc = GetTickCount();
+      Log::Warning(L"Evt/Msc/GTC dt: %u/%u/%u", pEventTimer->uTimeElapsed, pMiscTimer->uTimeElapsed, gtc - gtc_old);
+      gtc_old = gtc;
 
       OnTimer(0);
       GameUI_StatusBar_UpdateTimedString(0);
--- a/Player.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/Player.cpp	Sat May 11 17:00:43 2013 +0200
@@ -2167,7 +2167,7 @@
   signed int v8; // [sp-4h] [bp-10h]@4
 
   v1 = this;
-  LOBYTE(v2) = GetActualSkillLevel(PLAYER_SKILL_PERCEPTION);
+  v2 = (char)GetActualSkillLevel(PLAYER_SKILL_PERCEPTION);
   v3 = v1->pActiveSkills[26];
   v4 = v2 & 0x3F;
   v5 = v1->pActiveSkills[26] & 0x3F;
--- a/UICharacter.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/UICharacter.cpp	Sat May 11 17:00:43 2013 +0200
@@ -45,514 +45,143 @@
 
 
 
+unsigned int ui_color_text_default;
+unsigned int ui_color_text_highlight;
+unsigned int ui_color_text_header;
+unsigned int ui_color_text_bonus;
+unsigned int ui_color_text_bonus_neg;
+unsigned int ui_color_text_skill_upgradeable;
+unsigned int ui_color_text_skill_not_upgradeable;
+void set_default_ui_skin()
+{
+  ui_color_text_default = TargetColor(255, 255, 255);
+  ui_color_text_highlight = TargetColor(255, 0, 0);
+  ui_color_text_header = TargetColor(255, 255, 155);
+  ui_color_text_bonus = TargetColor(0, 255, 0);
+  ui_color_text_bonus_neg = TargetColor(255, 0, 0);
+
+  ui_color_text_skill_upgradeable = TargetColor(0, 175, 255);
+  ui_color_text_skill_not_upgradeable = TargetColor(255, 0, 0);
+}
+
+
+
+static int CharacterUI_SkillsTab_Draw__DrawSkillTable(Player *player, int x, int y, int *skill_list, int skill_list_size, int right_margin, const char *skill_group_name)
+{
+  int y_offset = y;
+  
+  sprintf(pTmpBuf, "%s\r%03d%s", skill_group_name, right_margin, pGlobalTXT_LocalizationStrings[131]); //"Level"
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, x, y, ui_color_text_header, pTmpBuf, 0, 0, 0);
+
+  int num_skills_drawn = 0;
+  for (uint i = 0; i < skill_list_size; ++i)
+  {
+    auto skill = (PLAYER_SKILL_TYPE)skill_list[i];
+    for (uint j = 0; j < pGUIWindow_CurrentMenu->uNumControls; ++j)
+    {
+      auto v8 = pGUIWindow_CurrentMenu->pControlsHead;
+
+      for (int v7 = j; v7 > 0; --v7)
+        v8 = v8->pNext;
+
+      auto v9 = v8->field_1C;
+      if ((short)(v8->field_1C) >= 0)
+        continue;
+      if ( (v9 & 0x7FFF) != skill )
+        continue;
+
+      ++num_skills_drawn;
+      y_offset = v8->uY;
+
+      auto skill_value = player->pActiveSkills[skill];
+      auto skill_level = skill_value & 0x3F;
+
+      uint skill_color = 0;
+      uint skill_mastery_color = 0;
+      if (player->uSkillPoints > skill_level)
+        skill_color = ui_color_text_skill_upgradeable;
+
+      if (pGUIWindow_CurrentMenu->pCurrentPosActiveItem == j)
+      {
+        if (player->uSkillPoints > skill_level)
+          skill_mastery_color = ui_color_text_bonus;
+        else
+          skill_mastery_color = ui_color_text_skill_not_upgradeable;
+        skill_color = skill_mastery_color;
+      }
+
+      if (SkillToMastery(skill_value) == 1)
+      {
+        sprintfex(pTmpBuf, "%s\r%03d%2d", pSkillNames[skill], right_margin, skill_level);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, x, v8->uY, skill_color, pTmpBuf, 0, 0, 0);
+      }
+      else
+      {
+        const char *v46 = nullptr;
+
+        switch (SkillToMastery(skill_value))
+        {
+          case 4: v46 = pGlobalTXT_LocalizationStrings[96];  break; // "Grand"
+          case 3: v46 = pGlobalTXT_LocalizationStrings[432]; break; // Master
+          case 2: v46 = pGlobalTXT_LocalizationStrings[433]; break; // Expert
+        }
+
+        if (!skill_mastery_color)
+          skill_mastery_color = ui_color_text_header;
+
+        
+        sprintfex(pTmpBuf, "%s \f%05d%s\f%05d\r%03d%2d", pSkillNames[skill], skill_mastery_color, v46, skill_color, right_margin, skill_level);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, x, v8->uY, skill_color, pTmpBuf, 0, 0, 0);
+      }
+    }
+  }
+
+  if (!num_skills_drawn)
+  {
+    y_offset += LOBYTE(pFontLucida->uFontHeight) - 3;
+    pGUIWindow_CurrentMenu->DrawText(pFontLucida, x, y_offset, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0); //"None"
+  }
+
+  return y_offset;
+}
+
 
 
 //----- (00419719) --------------------------------------------------------
-char __fastcall CharacterUI_SkillsTab_Draw(unsigned int uPlayerID)
-    {
-    unsigned int v1; // esi@1
-    Player *pPlayer; // ebp@1
-    unsigned int v3; // eax@1
-    signed int v4; // ecx@1
-    int v5; // edi@3
-    GUIWindow *v6; // ecx@3
-    int v7; // eax@4
-    GUIButton *v8; // edx@5
-    int v9; // eax@7
-    unsigned int v10; // ecx@9
-    unsigned __int16 v11; // ax@9
-    int v12; // eax@9
-    unsigned __int8 v13; // cf@12
-    unsigned __int8 v14; // zf@12
-    unsigned int v15; // eax@12
-    char *v16; // ecx@22
-    GUIWindow *v17; // ecx@33
-    int v18; // edx@34
-    GUIButton *v19; // eax@35
-    int v20; // edx@37
-    unsigned __int16 v21; // cx@39
-    unsigned int v22; // eax@39
-    int v23; // edi@39
-    unsigned int v24; // eax@42
-    char v25; // sf@52
-    char *v26; // ecx@52
-    int v27; // edi@63
-    GUIWindow *v28; // ecx@63
-    int v29; // edx@64
-    GUIButton *v30; // eax@65
-    int v31; // edx@67
-    unsigned int v32; // ecx@69
-    int v33; // eax@69
-    unsigned int v34; // eax@72
-    char *v35; // ecx@82
-    GUIWindow *v36; // ecx@93
-    int v37; // edx@94
-    GUIButton *v38; // eax@94
-    int v39; // edx@97
-    unsigned __int16 v40; // cx@99
-    unsigned int v41; // eax@99
-    int v42; // edi@99
-    unsigned int v43; // eax@102
-    char *v44; // ecx@112
-    char *v46; // [sp-Ch] [bp-4Ch]@19
-    char *v47; // [sp-Ch] [bp-4Ch]@49
-    char *v48; // [sp-Ch] [bp-4Ch]@79
-    char *v49; // [sp-Ch] [bp-4Ch]@109
-    unsigned int v50; // [sp-8h] [bp-48h]@19
-    unsigned int v51; // [sp-8h] [bp-48h]@49
-    unsigned int v52; // [sp-8h] [bp-48h]@79
-    unsigned int v53; // [sp-8h] [bp-48h]@109
-    int v54; // [sp-4h] [bp-44h]@19
-    int v55; // [sp-4h] [bp-44h]@49
-    int v56; // [sp-4h] [bp-44h]@79
-    int v57; // [sp-4h] [bp-44h]@109
-    unsigned int v58; // [sp+10h] [bp-30h]@9
-    unsigned int v59; // [sp+10h] [bp-30h]@39
-    unsigned int v60; // [sp+10h] [bp-30h]@69
-    unsigned int v61; // [sp+10h] [bp-30h]@99
-    int v62; // [sp+14h] [bp-2Ch]@4
-    int v63; // [sp+14h] [bp-2Ch]@34
-    int v64; // [sp+14h] [bp-2Ch]@64
-    int v65; // [sp+14h] [bp-2Ch]@94
-    signed int i; // [sp+18h] [bp-28h]@4
-    signed int v67; // [sp+18h] [bp-28h]@34
-    signed int v68; // [sp+18h] [bp-28h]@64
-    signed int v69; // [sp+18h] [bp-28h]@94
-    int v70; // [sp+1Ch] [bp-24h]@3
-    int v71; // [sp+1Ch] [bp-24h]@33
-    int v72; // [sp+1Ch] [bp-24h]@63
-    int v73; // [sp+1Ch] [bp-24h]@93
-    int uY; // [sp+20h] [bp-20h]@9
-    int uYa; // [sp+20h] [bp-20h]@33
-    int uYb; // [sp+20h] [bp-20h]@69
-    int uYc; // [sp+20h] [bp-20h]@93
-    unsigned int a5; // [sp+24h] [bp-1Ch]@1
-    unsigned int v79; // [sp+28h] [bp-18h]@1
-    int *v80; // [sp+2Ch] [bp-14h]@3
-    int *v81; // [sp+2Ch] [bp-14h]@33
-    int *v82; // [sp+2Ch] [bp-14h]@63
-    int *v83; // [sp+2Ch] [bp-14h]@93
-    unsigned int v84; // [sp+30h] [bp-10h]@1
-    int v85; // [sp+34h] [bp-Ch]@1
-    unsigned int v86; // [sp+38h] [bp-8h]@1
-    unsigned __int16 v87; // [sp+3Ch] [bp-4h]@9
-    char *v88; // [sp+3Ch] [bp-4h]@24
-    char *v89; // [sp+3Ch] [bp-4h]@54
-    unsigned __int16 v90; // [sp+3Ch] [bp-4h]@69
-    char *v91; // [sp+3Ch] [bp-4h]@84
-    char *v92; // [sp+3Ch] [bp-4h]@114
+void CharacterUI_SkillsTab_Draw(Player *player)
+{
+  pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_skill", TEXTURE_16BIT_PALETTE));
+
+  sprintfex(pTmpBuf, "%s \f%05d^Pv[%s]\f00000\r177%s: \f%05d%d\f00000",
+            pGlobalTXT_LocalizationStrings[206],        // Skills for
+            ui_color_text_header,
+            player->pName,
+            pGlobalTXT_LocalizationStrings[207],        // Skill Points
+            player->uSkillPoints ? ui_color_text_bonus : ui_color_text_default,
+            player->uSkillPoints);
+  pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
 
-    v1 = uPlayerID;
-    a5 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-    v84 = TargetColor(0, 0xAFu, 0xFFu);
-    v85 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
-    v86 = TargetColor(0xFFu, 0, 0);
-    v79 = TargetColor(0, 0xFFu, 0);
-    pPlayer = &pParty->pPlayers[v1-1];
-    v3 = pIcons_LOD->LoadTexture("fr_skill", TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(v3));
-    v4 = v79;
-    if ( !pPlayer->uSkillPoints )
-        v4 = 65535;
-    sprintf(
-        pTmpBuf,
-        "%s \f%05d%s\f00000\r177%s: \f%05d%d\f00000",
-        pGlobalTXT_LocalizationStrings[206],        // Skills for
-        a5,
-        pPlayer->pName,
-        pGlobalTXT_LocalizationStrings[207],        // Skill Points
-        v4,
-        pPlayer->uSkillPoints);
-    pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
-    v5 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;// Weapons,   Level
-    sprintf(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[242], pGlobalTXT_LocalizationStrings[131]);
-    pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, v5, a5, pTmpBuf, 0, 0, 0);
-    v6 = pGUIWindow_CurrentMenu;
-    v70 = 0;
-    v80 = pWeaponSkills;
-    do
-        {
-        v62 = *v80;
-        v7 = 0;
-        for ( i = 0; i < (signed int)v6->uNumControls; v7 = i++ + 1 )
-            {
-            v8 = v6->pControlsHead;
-            if ( v7 > 0 )
-                {
-                do
-                    {
-                    v8 = v8->pNext;
-                    --v7;
-                    }
-                    while ( v7 );
-                }
-            v9 = v8->field_1C;
-            if ( SBYTE1(v9) >= 0 )
-                continue;
-            BYTE1(v9) &= 0x7Fu;
-            if ( v9 != v62 )
-                continue;
-            v5 = v8->uY;
-            v10 = pPlayer->uSkillPoints;
-            ++v70;
-            v11 = pPlayer->pActiveSkills[v62];
-            v87 = pPlayer->pActiveSkills[v62];
-            v12 = v11 & 0x3F;
-            v58 = 0;
-            uY = v12;
-            if ( v10 >= v12 + 1 )
-                v58 = v84;
-            if ( v85 == i )
-                {
-                v13 = v10 < v12;
-                v14 = v10 == v12;
-                v15 = v86;
-                if ( !(v13 | v14) )
-                    v15 = v79;
-                v58 = v15;
-                }
-            else
-                {
-                v15 = v58;
-                }
-            if ( HIBYTE(v87) & 1 )
-                {
-                if ( !v15 )
-                    v15 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                v54 = uY;
-                v50 = v58;
-                v46 = pGlobalTXT_LocalizationStrings[96];
-                }
-            else
-                {
-                if ( !(v87 & 0xC0) )
-                    {
-                    sprintf(pTmpBuf, "%s\r400%2d", pSkillNames[v62], uY);
-                    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, v5, v58, pTmpBuf, 0, 0, 0);
-                    v6 = pGUIWindow_CurrentMenu;
-                    continue;
-                    }
-                v16 = pGlobalTXT_LocalizationStrings[432];
-                if ( (v87 & 0x80u) == 0 )
-                    v16 = pGlobalTXT_LocalizationStrings[433];
-                v88 = v16;
-                if ( !v15 )
-                    v15 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                v54 = uY;
-                v50 = v58;
-                v46 = v88;
-                }
-            sprintf(pTmpBuf, "%s ", pSkillNames[v62], v15, v46, v50, v54);
-            pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, v5, v58, pTmpBuf, 0, 0, 0);
-            v6 = pGUIWindow_CurrentMenu;
-            }
-        ++v80;
-        }
-        while ( v80 <= &pWeaponSkills[8]);
-        if ( !v70 )
-            {
-            v5 = v5 + LOBYTE(pFontLucida->uFontHeight) - 3;
-            v6->DrawText(pFontLucida, 24, v5, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0);
-            }
-        uYa = v5 + 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
-        sprintf(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[138], pGlobalTXT_LocalizationStrings[131]);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, uYa, a5, pTmpBuf, 0, 0, 0);
-        v17 = pGUIWindow_CurrentMenu;
-        v71 = 0;
-        v81 = pMagicSkills;
-        do
-            {
-            v18 = 0;
-            v67 = 0;
-            v63 = *v81;
-            while ( v67 < (signed int)v17->uNumControls )
-                {
-                v19 = v17->pControlsHead;
-                if ( v18 > 0 )
-                    {
-                    do
-                        {
-                        v19 = v19->pNext;
-                        --v18;
-                        }
-                        while ( v18 );
-                    }
-                v20 = v19->field_1C;
-                if ( SBYTE1(v20) >= 0 || (BYTE1(v20) &= 0x7Fu, v20 != v63) )
-                    {
-                    v18 = v67++ + 1;
-                    continue;
-                    }
-                ++v71;
-                uYa = v19->uY;
-                v21 = pPlayer->pActiveSkills[v63];
-                v22 = pPlayer->uSkillPoints;
-                v23 = pPlayer->pActiveSkills[v63] & 0x3F;
-                v59 = 0;
-                if ( v22 >= v23 + 1 )
-                    v59 = v84;
-                if ( v85 == v67 )
-                    {
-                    v13 = v22 < v23;
-                    v14 = v22 == v23;
-                    v24 = v86;
-                    if ( !(v13 | v14) )
-                        v24 = v79;
-                    v59 = v24;
-                    }
-                else
-                    {
-                    v24 = v59;
-                    }
-                if ( HIBYTE(v21) & 1 )
-                    {
-                    if ( !v24 )
-                        v24 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                    v55 = v23;
-                    v51 = v59;
-                    v47 = pGlobalTXT_LocalizationStrings[96];
-                    }
-                else
-                    {
-                    if ( !(v21 & 0xC0) )
-                        {
-                        sprintf(pTmpBuf, "%s\r400%2d", pSkillNames[v63], v23);
-                        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, uYa, v59, pTmpBuf, 0, 0, 0);
-                        v17 = pGUIWindow_CurrentMenu;
-                        v18 = v67++ + 1;
-                        continue;
-                        }
-                    v25 = (v21 & 0x80u) != 0;
-                    v26 = pGlobalTXT_LocalizationStrings[432];
-                    if ( !v25 )
-                        v26 = pGlobalTXT_LocalizationStrings[433];
-                    v89 = v26;
-                    if ( !v24 )
-                        v24 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                    v55 = v23;
-                    v51 = v59;
-                    v47 = v89;
-                    }
-                sprintf(pTmpBuf, "%s ", pSkillNames[v63], v24, v47, v51, v55);
-                //LABEL_58:
-                pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, uYa, v59, pTmpBuf, 0, 0, 0);
-                v17 = pGUIWindow_CurrentMenu;
-                //LABEL_59:
-                v18 = v67++ + 1;
-                }
-            ++v81;
-            }
-            while ( v81 <= &pMagicSkills[8]);
-            if ( !v71 )
-                v17->DrawText(
-                pFontLucida,
-                24,
-                LOBYTE(pFontLucida->uFontHeight) + uYa - 3,
-                0,
-                pGlobalTXT_LocalizationStrings[153],
-                0,
-                0,
-                0);
-            v27 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
-            sprintf(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[11], pGlobalTXT_LocalizationStrings[131]);
-            pGUIWindow_CurrentMenu->DrawText(pFontArrus, 248, v27, a5, pTmpBuf, 0, 0, 0);
-            v28 = pGUIWindow_CurrentMenu;
-            v72 = 0;
-            v82 = pArmorSkills;
-            do
-                {
-                v29 = 0;
-                v68 = 0;
-                v64 = *v82;
-                while ( v68 < (signed int)v28->uNumControls )
-                    {
-                    v30 = v28->pControlsHead;
-                    if ( v29 > 0 )
-                        {
-                        do
-                            {
-                            v30 = v30->pNext;
-                            --v29;
-                            }
-                            while ( v29 );
-                        }
-                    v31 = v30->field_1C;
-                    if ( SBYTE1(v31) >= 0 || (BYTE1(v31) &= 0x7Fu, v31 != v64) )
-                        {
-                        v29 = v68++ + 1;
-                        continue;
-                        }
-                    v27 = v30->uY;
-                    ++v72;
-                    v60 = 0;
-                    v90 = pPlayer->pActiveSkills[v64];
-                    v32 = pPlayer->uSkillPoints;
-                    v33 = pPlayer->pActiveSkills[v64] & 0x3F;
-                    uYb = v33;
-                    if ( v32 >= v33 + 1 )
-                        v60 = v84;
-                    if ( v85 == v68 )
-                        {
-                        v13 = v32 < v33;
-                        v14 = v32 == v33;
-                        v34 = v86;
-                        if ( !(v13 | v14) )
-                            v34 = v79;
-                        v60 = v34;
-                        }
-                    else
-                        {
-                        v34 = v60;
-                        }
-                    if ( (pPlayer->pActiveSkills[v64] >> 8) & 1 )
-                        {
-                        if ( !v34 )
-                            v34 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                        v56 = uYb;
-                        v52 = v60;
-                        v48 = pGlobalTXT_LocalizationStrings[96];
-                        }
-                    else
-                        {
-                        if ( !(v90 & 0xC0) )
-                            {
-                            sprintf(pTmpBuf, "%s\r177%2d", pSkillNames[v64], uYb);
-                            pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, v27, v60, pTmpBuf, 0, 0, 0);
-                            v28 = pGUIWindow_CurrentMenu;
-                            v29 = v68++ + 1;
-                            continue;
-                            }
-                        v35 = pGlobalTXT_LocalizationStrings[432];
-                        if ( (v90 & 0x80u) == 0 )
-                            v35 = pGlobalTXT_LocalizationStrings[433];
-                        v91 = v35;
-                        if ( !v34 )
-                            v34 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                        v56 = uYb;
-                        v52 = v60;
-                        v48 = v91;
-                        }
-                    sprintf(pTmpBuf, "%s ", pSkillNames[v64], v34, v48, v52, v56);
-                    //LABEL_88:
-                    pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, v27, v60, pTmpBuf, 0, 0, 0);
-                    v28 = pGUIWindow_CurrentMenu;
-                    //LABEL_89:
-                    v29 = v68++ + 1;
-                    }
-                ++v82;
-                }
-                while ( v82 <= &pArmorSkills[4]);
-                if ( !v72 )
-                    {
-                    v27 = v27 + LOBYTE(pFontLucida->uFontHeight) - 3;
-                    v28->DrawText(pFontLucida, 248, v27, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0);
-                    }
-                uYc = v27 + 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
-                sprintf(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[143], pGlobalTXT_LocalizationStrings[131]);
-                pGUIWindow_CurrentMenu->DrawText(pFontArrus, 248, uYc, a5, pTmpBuf, 0, 0, 0);
-                v36 = pGUIWindow_CurrentMenu;
-                v73 = 0;
-                v83 = pMiscSkills;
-                do
-                    {
-                    v37 = 0;
-                    v69 = 0;
-                    v38 = (GUIButton *)*v83;
-                    v65 = *v83;
-                    while ( v69 < (signed int)v36->uNumControls )
-                        {
-                        v38 = v36->pControlsHead;
-                        if ( v37 > 0 )
-                            {
-                            do
-                                {
-                                v38 = v38->pNext;
-                                --v37;
-                                }
-                                while ( v37 );
-                            }
-                        v39 = v38->field_1C;
-                        if ( SBYTE1(v39) >= 0 || (BYTE1(v39) &= 0x7Fu, v39 != v65) )
-                            {
-                            //goto LABEL_119;
-                            v37 = v69++ + 1;
-                            continue;
-                            }
-                        ++v73;
-                        uYc = v38->uY;
-                        v40 = pPlayer->pActiveSkills[v65];
-                        v41 = pPlayer->uSkillPoints;
-                        v42 = pPlayer->pActiveSkills[v65] & 0x3F;
-                        v61 = 0;
-                        if ( v41 >= v42 + 1 )
-                            v61 = v84;
-                        if ( v85 == v69 )
-                            {
-                            v13 = v41 < v42;
-                            v14 = v41 == v42;
-                            v43 = v86;
-                            if ( !(v13 | v14) )
-                                v43 = v79;
-                            v61 = v43;
-                            }
-                        else
-                            {
-                            v43 = v61;
-                            }
-                        if ( HIBYTE(v40) & 1 )
-                            {
-                            if ( !v43 )
-                                v43 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                            v57 = v42;
-                            v53 = v61;
-                            v49 = pGlobalTXT_LocalizationStrings[96];
-                            }
-                        else
-                            {
-                            if ( !(v40 & 0xC0) )
-                                {
-                                sprintf(pTmpBuf, "%s\r177%2d", pSkillNames[v65], v42);
-                                LOBYTE(v38) = pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, uYc, v61, pTmpBuf, 0, 0, 0);
-                                v36 = pGUIWindow_CurrentMenu;
-                                v37 = v69++ + 1;
-                                continue;
-                                }
-                            v25 = (v40 & 0x80u) != 0;
-                            v44 = pGlobalTXT_LocalizationStrings[432];
-                            if ( !v25 )
-                                v44 = pGlobalTXT_LocalizationStrings[433];
-                            v92 = v44;
-                            if ( !v43 )
-                                v43 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-                            v57 = v42;
-                            v53 = v61;
-                            v49 = v92;
-                            }
-                        sprintf(pTmpBuf, "%s ", pSkillNames[v65], v43, v49, v53, v57);
-                        LOBYTE(v38) = pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, uYc, v61, pTmpBuf, 0, 0, 0);
-                        v36 = pGUIWindow_CurrentMenu;
-                        v37 = v69++ + 1;
-                        }
-                    ++v83;
-                    }
-                    while ( v83 <= &pMiscSkills[11]);
-                    if ( !v73 )
-                        LOBYTE(v38) = v36->DrawText(
-                        pFontLucida,
-                        248,
-                        LOBYTE(pFontLucida->uFontHeight) + uYc - 3,
-                        0,
-                        pGlobalTXT_LocalizationStrings[153],
-                        0,
-                        0,
-                        0);
-                    return (char)v38;
+  int y = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
+  y = CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 24, y, pWeaponSkills, 9, 400, pGlobalTXT_LocalizationStrings[242]); // "Weapons"
+
+  y += 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
+  CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 24, y, pMagicSkills, 9, 400, pGlobalTXT_LocalizationStrings[138]); // "Magic"
+
+  y = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
+  y = CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 248, y, pArmorSkills, 5, 177, pGlobalTXT_LocalizationStrings[11]); // "Armor"
+ 
+  y += 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
+  y = CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 248, y, pMiscSkills, 12, 177, pGlobalTXT_LocalizationStrings[143]); //"Misc"
 }
 
 
 
 
 
+
+
+
+
     
 unsigned int GetAwardColor(unsigned int priority)
 {
@@ -694,7 +323,7 @@
         }
 
     //----- (0041A2D1) --------------------------------------------------------
-    void __fastcall CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2)
+    void CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2)
         {
         Player *pPlayer; // esi@1
         char v3; // bl@1
@@ -875,11 +504,11 @@
             while ( uCellID < 126 );
         }
 
-    //----- (0041A556) --------------------------------------------------------
-    void __cdecl draw_leather()
-        {
-        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Leather));
-        }
+//----- (0041A556) --------------------------------------------------------
+void draw_leather()
+{
+  pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Leather));
+}
 
     //----- (0041A57E) --------------------------------------------------------
     void QuickRefDraw()
@@ -1101,7 +730,7 @@
           CharacterUI_SkillScreen_Draw();
         }
         sub_419379();
-        CharacterUI_SkillsTab_Draw(uPlayerIdx);
+        CharacterUI_SkillsTab_Draw(pPlayers[uPlayerIdx]);
         v6 = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
         pTexture = pIcons_LOD->GetTexture(v6);
         pButton = pCharacterScreen_SkillsBtn;
@@ -2593,7 +2222,7 @@
     }
 
 //----- (00418511) --------------------------------------------------------
-char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
+char CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
 {
         Player *pPlayer; // edi@1
         unsigned int v4; // eax@2
--- a/UIPopup.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/UIPopup.cpp	Sat May 11 17:00:43 2013 +0200
@@ -1395,7 +1395,7 @@
 
 
 //----- (00417BB5) --------------------------------------------------------
-const char *__fastcall CharacterUI_GetSkillDescText(unsigned int uPlayerID, PLAYER_SKILL_TYPE uPlayerSkillType)
+const char *CharacterUI_GetSkillDescText(unsigned int uPlayerID, PLAYER_SKILL_TYPE uPlayerSkillType)
 {
     //enum PLAYER_SKILL_TYPE v2; // esi@1
     //unsigned int v3; // ebx@1
--- a/mm7_1.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/mm7_1.cpp	Sat May 11 17:00:43 2013 +0200
@@ -1320,6 +1320,9 @@
   unsigned __int16 v6; // [sp-4h] [bp-14h]@7
 
 
+  extern void set_default_ui_skin();
+  set_default_ui_skin();
+
     if (align == PartyAlignment_Evil)
     {
       if ( bReplace )
--- a/mm7_2.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/mm7_2.cpp	Sat May 11 17:00:43 2013 +0200
@@ -5440,28 +5440,17 @@
 }
 
 //----- (00458244) --------------------------------------------------------
-unsigned int __fastcall SkillToMastery(unsigned __int16 a1)
-{
-  unsigned int result; // eax@1
-
-  result = 1;                                   // Normal
-  if ( HIBYTE(a1) & 1 )
-  {
-    result = 4;                                 // Grandmaster
-  }
-  else
-  {
-    if ( (a1 & 0x80u) == 0 )
-    {
-      if ( a1 & 0x40 )
-        result = 2;                             // Expert
-    }
-    else
-    {
-      result = 3;                               // Master
-    }
-  }
-  return result;
+unsigned int SkillToMastery(unsigned int value)
+{
+  switch (value & 0x1C0)
+  {
+    case 0x100: return 4;     // Grandmaster
+    case 0x80:  return 3;     // Master
+    case 0x40:  return 2;     // Expert
+    case 0x00:  return 1;     // Normal
+    default:
+      assert(false);
+  }
 }
 
 //----- (0045828B) --------------------------------------------------------
--- a/mm7_5.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/mm7_5.cpp	Sat May 11 17:00:43 2013 +0200
@@ -9223,7 +9223,7 @@
 
 //----- (0040DEF3) --------------------------------------------------------
 unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
-    {
+{
   return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + 
                            LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + 
                            LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
@@ -11459,7 +11459,7 @@
 }
 
 //----- (00417AD4) --------------------------------------------------------
-unsigned int __fastcall GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level)
+unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level)
 {
   int v8; // eax@10
   int v12; // eax@14
--- a/mm7_data.cpp	Sat May 11 13:19:55 2013 +0200
+++ b/mm7_data.cpp	Sat May 11 17:00:43 2013 +0200
@@ -507,10 +507,10 @@
 __int16 RightClickPortraitXmin[4]={0x14, 0x83, 0xF2, 0x165};
 __int16 RightClickPortraitXmax[4]={0x53, 0xC6, 0x138, 0x1A7};
 void *off_4E2A12; // stat_string_control_button_count
-int pArmorSkills[5]={ 9, 10, 11, 8, 30};
-int pWeaponSkills[9]={3, 5, 2, 6, 4, 0, 1, 31, 7};
-int pMiscSkills[12]={35, 33, 24, 21, 32, 36, 29, 25, 22, 26, 23, 34};
-int pMagicSkills[9]={12, 13, 14, 15, 16, 17, 18, 19, 20};
+int pArmorSkills[5]  = {PLAYER_SKILL_LEATHER, PLAYER_SKILL_CHAIN,      PLAYER_SKILL_PLATE,        PLAYER_SKILL_SHIELD,  PLAYER_SKILL_DODGE};
+int pWeaponSkills[9] = {PLAYER_SKILL_AXE,     PLAYER_SKILL_BOW,        PLAYER_SKILL_DAGGER,       PLAYER_SKILL_MACE,    PLAYER_SKILL_SPEAR,      PLAYER_SKILL_STAFF,    PLAYER_SKILL_SWORD,       PLAYER_SKILL_UNARMED,    PLAYER_SKILL_BLASTER};
+int pMiscSkills[12]  = {PLAYER_SKILL_ALCHEMY, PLAYER_SKILL_ARMSMASTER, PLAYER_SKILL_BODYBUILDING, PLAYER_SKILL_ITEM_ID, PLAYER_SKILL_MONSTER_ID, PLAYER_SKILL_LEARNING, PLAYER_SKILL_TRAP_DISARM, PLAYER_SKILL_MEDITATION, PLAYER_SKILL_MERCHANT, PLAYER_SKILL_PERCEPTION, PLAYER_SKILL_REPAIR, PLAYER_SKILL_STEALING};
+int pMagicSkills[9]  = {PLAYER_SKILL_FIRE,    PLAYER_SKILL_AIR,        PLAYER_SKILL_WATER,        PLAYER_SKILL_EARTH,   PLAYER_SKILL_SPIRIT,     PLAYER_SKILL_MIND,     PLAYER_SKILL_BODY,        PLAYER_SKILL_LIGHT,      PLAYER_SKILL_DARK};
 unsigned int pHealthBarPos[4] = {22, 137, 251, 366};
 unsigned int pManaBarPos[4] = {102, 217, 331, 447};
 char _4E2AD8_ui_colors[72];
--- a/mm7_data.h	Sat May 11 13:19:55 2013 +0200
+++ b/mm7_data.h	Sat May 11 17:00:43 2013 +0200
@@ -1594,16 +1594,12 @@
 signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx); // idb
 char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2); // idb
 void FillAwardsData();
-void __cdecl sub_419220();
-void __cdecl sub_419379();
-void __cdecl CharacterUI_SkillScreen_Draw();
-void __cdecl sub_4196A0();
-char __fastcall CharacterUI_SkillsTab_Draw(unsigned int uPlayerID); // idb
-void CharacterUI_AwardsTab_Draw(unsigned int uPlayerID); // idb
+void sub_419220();
+void sub_419379();
+void CharacterUI_SkillScreen_Draw();
+void sub_4196A0();
 unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels);
-void __fastcall CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2);
 void __cdecl draw_leather();
-void __thiscall CharacterUI_CharacterScreen_Draw(unsigned int uPlayerIdx); // idb
 void __cdecl GameUI_DrawRightPanelItems();
 void __cdecl GameUI_DrawFoodAndGold();
 void __cdecl GameUI_DrawLifeManaBars();
@@ -1793,7 +1789,7 @@
 int __cdecl j_SetSomeItemsNames();
 
 
-unsigned int __fastcall SkillToMastery(unsigned __int16 a1);
+unsigned int SkillToMastery(unsigned int skill_value);
 unsigned int __fastcall GetSpellColor(signed int a1);
 void *__thiscall unknown_vdtor_6(void *_this, bool a2);
 unsigned short * MakeScreenshot(signed int width, signed int height);