diff mm7_1.cpp @ 315:2a09e1d6fc8f

Some 0041D895 GameUI_DrawItemInfo overhaul
author Nomad
date Wed, 20 Feb 2013 01:17:13 +0200
parents e33f5a1cdc46
children 922a96fdcc86
line wrap: on
line diff
--- a/mm7_1.cpp	Tue Feb 19 22:06:49 2013 +0200
+++ b/mm7_1.cpp	Wed Feb 20 01:17:13 2013 +0200
@@ -881,11 +881,10 @@
         v17 = uCellX + ((v15 - v10) >> 1) + pSRZBufferLineOffsets[uCellY + ((((v14 - 14) & 0xFFFFFFE0) - v9 + 32) >> 1)];
         if ( !(v16 & 0xF0) )
         {
-          if ( v16 & 1
-            || pCurrentScreen != SCREEN_HOUSE )
+          if (pItem->Identified() || pCurrentScreen != SCREEN_HOUSE )
           {
-            if ( v16 & 2 )
-              pRenderer->_4A6776(uCellX, uCellY, v7);
+            if (pItem->Broken())
+              pRenderer->DrawTransparentRedShade(uCellX, uCellY, v7);
             else
               pRenderer->DrawTextureTransparent(uCellX, uCellY, v7);
           }
@@ -2305,31 +2304,31 @@
 
 
 //----- (0041D895) --------------------------------------------------------
-void __thiscall GameUI_DrawItemInfo(ItemGen *ecx0)
+void GameUI_DrawItemInfo(ItemGen *ecx0)
 {
   ItemGen *v1; // esi@1
   unsigned int v2; // eax@3
-  char *v3; // edi@5
-  unsigned int v4; // eax@5
-  unsigned int v5; // esi@5
+  //char *v3; // edi@5
+  //unsigned int v4; // eax@5
+  //unsigned int v5; // esi@5
   signed int v6; // eax@5
   int v7; // edx@5
   ItemGen *v8; // ecx@10
-  unsigned int v9; // eax@12
+  //unsigned int v9; // eax@12
   char v10; // zf@16
   ItemGen *v11; // eax@16
   ItemGen *v12; // eax@25
-  unsigned int v13; // ecx@32
-  unsigned int v14; // eax@32
-  Render *v15; // edi@33
+  //unsigned int v13; // ecx@32
+  //unsigned int v14; // eax@32
+  //Render *v15; // edi@33
   const char *v16; // eax@34
   int v17; // eax@36
   int v18; // esi@37
   unsigned __int16 v19; // ax@37
-  char v20; // al@40
+  //char v20; // al@40
   char v21; // al@44
-  char v22; // al@48
-  char v23; // al@51
+  //char v22; // al@48
+  //char v23; // al@51
   int v24; // eax@52
   int v25; // eax@57
   int v26; // eax@60
@@ -2349,28 +2348,28 @@
   GUIFont *v40; // edx@113
   signed int v41; // [sp-20h] [bp-298h]@113
   int v42; // [sp-1Ch] [bp-294h]@113
-  char *v43; // [sp-18h] [bp-290h]@46
+  //char *v43; // [sp-18h] [bp-290h]@46
   unsigned int v44; // [sp-18h] [bp-290h]@113
-  int v45; // [sp-14h] [bp-28Ch]@46
+  //int v45; // [sp-14h] [bp-28Ch]@46
   const char *v46; // [sp-14h] [bp-28Ch]@58
   char *v47; // [sp-14h] [bp-28Ch]@110
-  char *v48; // [sp-10h] [bp-288h]@46
+  //char *v48; // [sp-10h] [bp-288h]@46
   const char *v49; // [sp-10h] [bp-288h]@56
   char *v50; // [sp-10h] [bp-288h]@58
   int v51; // [sp-10h] [bp-288h]@110
   const char *v52; // [sp-Ch] [bp-284h]@36
-  int v53; // [sp-Ch] [bp-284h]@46
+  //int v53; // [sp-Ch] [bp-284h]@46
   char *v54; // [sp-Ch] [bp-284h]@56
   int v55; // [sp-Ch] [bp-284h]@58
   int v56; // [sp-Ch] [bp-284h]@110
   unsigned int v57; // [sp-8h] [bp-280h]@36
-  int v58; // [sp-8h] [bp-280h]@46
+  //int v58; // [sp-8h] [bp-280h]@46
   int v59; // [sp-8h] [bp-280h]@56
   int v60; // [sp-8h] [bp-280h]@58
   unsigned int v61; // [sp-8h] [bp-280h]@110
-  char a1[100]; // [sp+8h] [bp-270h]@40
-  char Dest[100]; // [sp+6Ch] [bp-20Ch]@40
-  char v64[100]; // [sp+D0h] [bp-1A8h]@40
+  char a1[300]; // [sp+8h] [bp-270h]@40
+  //char Dest[100]; // [sp+6Ch] [bp-20Ch]@40
+  //char v64[100]; // [sp+D0h] [bp-1A8h]@40
   char v65[120]; // [sp+134h] [bp-144h]@92
   char Source[40]; // [sp+1ACh] [bp-CCh]@49
   int v67; // [sp+1D4h] [bp-A4h]@91
@@ -2381,8 +2380,8 @@
   int v72; // [sp+1ECh] [bp-8Ch]@91
   int var88; // [sp+1F0h] [bp-88h]@1
   Texture *v73; // [sp+1F4h] [bp-84h]@5
-  unsigned int v75; // [sp+1F8h] [bp-80h]@5
-  char *v76; // [sp+1FCh] [bp-7Ch]@5
+  //unsigned int v75; // [sp+1F8h] [bp-80h]@5
+  //char *v76; // [sp+1FCh] [bp-7Ch]@5
   int v77; // [sp+200h] [bp-78h]@12
   int v78; // [sp+204h] [bp-74h]@5
   GUIWindow v79; // [sp+208h] [bp-70h]@2
@@ -2409,14 +2408,16 @@
     else
       v2 = pMouse->GetCursorPos(&a2)->x - v79.uFrameWidth - 30;
     v79.uFrameX = v2;
-    v3 = (char *)&pItemsTable->pItems[_this->uItemID].pIconName;
-    v76 = v3;
-    v4 = pIcons_LOD->LoadTexture(*(const char **)v3, TEXTURE_16BIT_PALETTE);
-    v5 = v4;
-    v4 *= 72;
-    v75 = v4;
-    v73 = (struct Texture *)((char *)pIcons_LOD->pTextures + v4);
-    v6 = 100 - *(unsigned __int16 *)((char *)&pIcons_LOD->pTextures[0].uTextureWidth + v4);
+    auto item_desc = &pItemsTable->pItems[_this->uItemID];
+    //v3 = (char *)&pItemsTable->pItems[_this->uItemID].pIconName;
+    //v76 = v3;
+    //v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[_this->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+    //v5 = v4;
+    //v4 *= 72;
+    //v75 = v4;
+    //v73 = &pIcons_LOD->pTextures[v4];
+    v73 = pIcons_LOD->LoadTexturePtr(item_desc->pIconName, TEXTURE_16BIT_PALETTE);
+    v6 = 100 - v73->uTextureWidth;
     v7 = v73->uTextureHeight;
     v78 = v6;
     v81 = 144 - v7;
@@ -2427,22 +2428,22 @@
     else
       v81 >>= 1;
     v8 = _this;
-    if ( !v3[46] )
-      _this->uAttributes |= 1u;
-    v9 = v8->uAttributes;
+    if ( !item_desc->uItemID_Rep_St )
+      _this->SetIdentified();
+    //v9 = v8->uAttributes;
     v77 = 0;
-    a2.y = v9 & 2;
-    if ( pItemsTable->pItems[v8->uItemID].uEquipType == 18 )
+    //a2.y = v8->uAttributes & 2;
+    if (pItemsTable->pItems[v8->uItemID].uEquipType == EQUIP_GOLD)
       v77 = v8->uAdditionalValue;
     if ( uActiveCharacter )
     {
-      if ( !(v9 & 1) )
+      if (!v8->Identified())
       {
         v10 = pPlayers[uActiveCharacter]->CanIdentify(_this) == 1;
         v11 = _this;
         if ( v10 )
-          _this->uAttributes |= 1u;
-        v10 = (v11->uAttributes & 1) == 0;
+          _this->SetIdentified();
+        v10 = !v11->Identified();
         v83 = (char *)9;
         if ( v10 )
         {
@@ -2461,13 +2462,13 @@
         }
       }
       _this->UpdateTempBonus(pParty->uTimePlayed);
-      if ( a2.y )
+      if (v8->Broken())
       {
         v10 = pPlayers[uActiveCharacter]->CanRepair(_this) == 1;
         v12 = _this;
         if ( v10 )
           _this->uAttributes = _this->uAttributes & 0xFFFFFFFD | 1;
-        v10 = (v12->uAttributes & 2) == 0;
+        v10 = !v12->Broken();
         v83 = (char *)SPEECH_11;
         if ( v10 )
           v83 = (char *)SPEECH_10;
@@ -2480,54 +2481,42 @@
         }
       }
     }
-    v13 = _this->uAttributes;
-    v14 = _this->uAttributes & 1;
-    a2.y = _this->uAttributes & 1;
-    if ( v13 & 2 )
+    //v13 = _this->uAttributes;
+    //v14 = _this->Identified();
+    a2.y = _this->Identified();
+    if (_this->Broken())
     {
       v79.DrawMessageBox(0);
       //v15 = &;
-      pRenderer->Clip(
-        v79.uFrameX + 12,
-        v79.uFrameY + 12,
-        v79.uFrameX + v79.uFrameWidth - 12,
-        v79.uFrameY + v79.uFrameHeight - 12);
+      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
+                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
       v79.uFrameWidth -= 24;
       v79.uFrameHeight -= 12;
       v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
       v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->_4A6776(
-        v79.uFrameX + v78,
-        v81 + v79.uFrameY + 30,
-        (Texture *)(v5 != -1 ? (int)((char *)pIcons_LOD->pTextures + v75) : 0));
+      pRenderer->DrawTransparentRedShade(v79.uFrameX + v78, v81 + v79.uFrameY + 30, v73);
       if ( a2.y )
         v16 = _this->GetIdentifiedName();
       else
-        v16 = (const char *)*((int *)v76 + 2);
+        v16 = item_desc->pUnidentifiedName;
       v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
       v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &v79, 0, 0);
       v57 = 3;
       v52 = pGlobalTXT_LocalizationStrings[32];
       goto LABEL_37;
     }
-    if ( !v14 )
+    if (!_this->Identified())
     {
       v79.DrawMessageBox(0);
-      v15 = pRenderer;
-      pRenderer->Clip(
-        v79.uFrameX + 12,
-        v79.uFrameY + 12,
-        v79.uFrameX + v79.uFrameWidth - 12,
-        v79.uFrameY + v79.uFrameHeight - 12);
+      //v15 = pRenderer;
+      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
+                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
       v79.uFrameWidth -= 24;
       v79.uFrameHeight -= 12;
       v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
       v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->DrawTextureTransparent(
-        v79.uFrameX + v78,
-        v81 + v79.uFrameY + 30,
-        (Texture *)(v5 != -1 ? (int)((char *)pIcons_LOD->pTextures + v75) : 0));
-      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, *((const char **)v76 + 2), 3u);
+      pRenderer->DrawTextureTransparent(v79.uFrameX + v78, v81 + v79.uFrameY + 30, v73);
+      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u);
       v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &v79, 0, 0);
       v57 = 3;
       v52 = pGlobalTXT_LocalizationStrings[232];
@@ -2537,55 +2526,52 @@
       v79.DrawTitleText(pFontArrus, 0x64u, ((signed int)v79.uFrameHeight >> 1) - v18, v19, v52, v57);
       goto LABEL_116;
     }
-    sprintf(a1, pGlobalTXT_LocalizationStrings[463], *((int *)v3 + 2));
-    strcpy(Dest, "");
-    strcpy(v64, "");
-    v20 = v3[28];
-    if ( (unsigned __int8)v20 <= 1u )
-    {
-      v58 = (unsigned __int8)v3[31];
-      v53 = (unsigned __int8)v3[30];
-      v48 = pGlobalTXT_LocalizationStrings[53];
-      v45 = (unsigned __int8)v3[32];
-      v43 = pGlobalTXT_LocalizationStrings[18];
-    }
-    else
-    {
-      if ( v20 != 2 )
-      {
-        if ( (unsigned __int8)v20 > 2u )
+
+    sprintfex(a1, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName);
+    a1[100] = 0;
+    a1[200] = 0;
+    //v20 = item_desc->uEquipType;
+    switch (item_desc->uEquipType)
+    {
+      case EQUIP_ONE_OR_TWO_HANDS:
+      case EQUIP_TWO_HANDED:
+        sprintfex(a1 + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[18], (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
+        if (item_desc->uDamageMod)
         {
-          if ( (unsigned __int8)v20 <= 0xBu )
-          {
-            v21 = v3[30];
-            if ( v21 )
-              sprintf(
-                Dest,
-                "%s: +%d",
-                pGlobalTXT_LocalizationStrings[11],
-                (unsigned __int8)v21 + (unsigned __int8)v3[32]);
-          }
+          char mod[16];
+          sprintf(mod, "+%d", (int)item_desc->uDamageMod);
+          strcat(a1 + 100, mod);
+        }
+      break;
+
+      case EQUIP_BOW:
+        sprintfex(a1 + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[203], (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
+        if (item_desc->uDamageMod)
+        {
+          char mod[16];
+          sprintf(mod, "+%d", (int)item_desc->uDamageMod);
+          strcat(a1 + 100, mod);
         }
-        goto LABEL_50;
-      }
-      v58 = (unsigned __int8)v3[31];
-      v53 = (unsigned __int8)v3[30];
-      v48 = pGlobalTXT_LocalizationStrings[53];
-      v45 = (unsigned __int8)v3[32];
-      v43 = pGlobalTXT_LocalizationStrings[203];
-    }
-    sprintf(Dest, "%s: +%d   %s: %dd%d", v43, v45, v48, v53, v58);
-    v22 = v3[32];
-    if ( v22 )
-    {
-      sprintf(Source, " +%d", (unsigned __int8)v22);
-      strcat(Dest, Source);
-    }
-LABEL_50:
+      break;
+
+      case EQUIP_ARMOUR:
+      case EQUIP_SHIELD:
+      case EQUIP_HELMET:
+      case EQUIP_BELT:
+      case EQUIP_CLOAK:
+      case EQUIP_GAUNTLETS:
+      case EQUIP_BOOTS:
+      case EQUIP_RING:
+      case EQUIP_AMULET:
+        if (item_desc->uDamageDice)
+          sprintfex(a1 + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod);
+      break;
+    }
+
     if ( v77 )
       goto LABEL_65;
-    v23 = v3[28];
-    if ( v23 == 14 )
+    //v23 = item_desc->uEquipType;
+    if (item_desc->uEquipType == 14)
     {
       v24 = _this->_bonus_type;
       if ( v24 )
@@ -2608,7 +2594,7 @@
         --a2.y;
       }
       while ( a2.y );
-      v28 = (const char *)*((int *)v3 + 3);
+      v28 = item_desc->pDescription;
       if ( *v28 )
       {
         v29 = pFontSmallnum->CalcTextHeight(v28, &v79, 100, 0);
@@ -2634,12 +2620,9 @@
       v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
       v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
       v79.DrawMessageBox(0);
-      v15 = pRenderer;
-      pRenderer->Clip(
-        v79.uFrameX + 12,
-        v79.uFrameY + 12,
-        v79.uFrameX + v79.uFrameWidth - 12,
-        v79.uFrameY + v79.uFrameHeight - 12);
+      //v15 = pRenderer;
+      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
+                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
       v79.uFrameWidth -= 12;
       v32 = v73->uTextureHeight;
       v33 = v79.uFrameHeight;
@@ -2649,7 +2632,7 @@
       pRenderer->DrawTextureTransparent(
         v79.uFrameX + v78,
         v79.uFrameY + (signed int)(v33 - v32) / 2,
-        (Texture *)(v5 != -1 ? (int)((char *)pIcons_LOD->pTextures + v75) : 0));
+        v73);
       a2.y = 3;
       v34 = (int)(v83 + 35);
       Str = a1;
@@ -2664,7 +2647,7 @@
         --a2.y;
       }
       while ( a2.y );
-      v35 = (const char *)*((int *)v76 + 3);
+      v35 = item_desc->pDescription;
       if ( *v35 )
         v79.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0);
       v79.uFrameX += 12;
@@ -2745,7 +2728,7 @@
       }
       return;
     }
-    if ( v23 == 13 )
+    if (item_desc->uEquipType == 13)
     {
       v24 = pItemsTable->pItems[_this->uItemID].uDamageDice;
 LABEL_56:
@@ -2753,7 +2736,7 @@
       v54 = pGlobalTXT_LocalizationStrings[449];
       v49 = "%s: %d";
 LABEL_64:
-      sprintf(v64, v49, v54, v59);
+      sprintf(a1 + 200, v49, v54, v59);
       goto LABEL_65;
     }
     v25 = _this->_bonus_type;
@@ -2783,7 +2766,7 @@
       v50 = pGlobalTXT_LocalizationStrings[210];
       v46 = "%s: %s";
     }
-    sprintf(v64, v46, v50, v55, v60);
+    sprintf(a1 + 200, v46, v50, v55, v60);
     goto LABEL_65;
 }
 // 4E455C: using guessed type int dword_4E455C;
@@ -4279,7 +4262,7 @@
 		{
 			Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10);
 			if ( pChests[v3].uFlags & 4 )
-				v12->uAttributes |= 1u;
+				v12->SetIdentified();
 		}
       }
       ++v11;
@@ -6649,7 +6632,7 @@
   else
   {
     dword_50B700 = 0;
-    if ( !(v1->uAttributes & 1) )
+    if ( !v1->TwoSided() )
       return 0;
   }
   //v66 = v1->uNumVertices;