view UI/UIPopup.cpp @ 1713:e013b92030e3

UIRest cleared
author Ritor1
date Tue, 24 Sep 2013 23:40:33 +0600
parents 0f6cd60ca987
children 1c072d19e397
line wrap: on
line source

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include "..\MM7.h"

#include "..\Mouse.h"

#include "..\Sprites.h"
#include "..\Vis.h"
#include "..\Game.h"
#include "..\GUIWindow.h"
#include "..\GUIFont.h"
#include "..\Party.h"
#include "..\AudioPlayer.h"
#include "..\LOD.h"
#include "..\Actor.h"
#include "..\Viewport.h"
#include "..\SpriteObject.h"
#include "..\ObjectList.h"
#include "..\Chest.h"
#include "..\PaletteManager.h"
#include "..\Time.h"
#include "..\texts.h"

#include "..\mm7_data.h"

static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually


//----- (004179BC) --------------------------------------------------------
void CharacterUI_DrawTooltip(const char *Title, const char *content)
{
  GUIWindow popup_window; // [sp+Ch] [bp-5Ch]@1
  POINT v6; // [sp+60h] [bp-8h]@1

  memset(&popup_window, 0, 0x54u);
  popup_window.uFrameWidth = 384;
  popup_window.uFrameHeight = 256;
  popup_window.uFrameX = 128;
  popup_window.uFrameY = pMouse->GetCursorPos(&v6)->y + 30;
  popup_window.uFrameHeight = pFontSmallnum->CalcTextHeight(content, &popup_window, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
  popup_window.uFrameZ = popup_window.uFrameX + popup_window.uFrameWidth - 1;
  popup_window.uFrameW = popup_window.uFrameY + popup_window.uFrameHeight - 1;
  popup_window.DrawMessageBox(0);

  popup_window.uFrameX += 12;
  popup_window.uFrameWidth -= 24;
  popup_window.uFrameY += 12;
  popup_window.uFrameHeight -= 12;
  popup_window.uFrameZ = popup_window.uFrameX + popup_window.uFrameWidth - 1;
  popup_window.uFrameW = popup_window.uFrameY + popup_window.uFrameHeight - 1;
  sprintf(pTmpBuf.data(), "\f%05d%s\f00000\n", ui_character_tooltip_header_default_color, Title);
  popup_window.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3);
  popup_window.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, content, 0, 0, 0);
}

//----- (004151D9) --------------------------------------------------------
void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
{
  unsigned int uNumTiles; // [sp+2Ch] [bp-Ch]@6
  unsigned int coord_x; // [sp+2Ch] [bp-Ch]@3
  unsigned int coord_y; // [sp+34h] [bp-4h]@5

  pRenderer->SetTextureClipRect(uX, uY, uX + uWidth, uY + uHeight);
  if ( pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth && pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureHeight)
  {
    uNumTiles = uWidth / pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth;
    if ( uWidth % pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth )
      ++uNumTiles;
    coord_y = uY;
    for ( uint j = 0; j <= uHeight / pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureHeight; j++ )
    {
      coord_x = uX - pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth;
      for ( uint i = uNumTiles + 1; i; --i )
      {
        coord_x += pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth;
        pRenderer->DrawTextureIndexed(coord_x, coord_y, pIcons_LOD->GetTexture(uTextureID_Parchment));
      }
      coord_y += pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureHeight;
    }
    pRenderer->DrawTextureTransparent(uX,               uY,                pIcons_LOD->GetTexture(uTextureID_5076AC));
    pRenderer->DrawTextureTransparent(uX,               uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B4));
    pRenderer->DrawTextureTransparent(uX + uWidth - 32, uY,                pIcons_LOD->GetTexture(uTextureID_5076A8));
    pRenderer->DrawTextureTransparent(uX + uWidth - 32, uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B0));
    if ( uWidth > 64 )
    {
      pRenderer->SetTextureClipRect(uX + 32, uY, uX + uWidth - 32, uY + uHeight);
      pRenderer->DrawTextureTransparent(uX + 32, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
      pRenderer->DrawTextureTransparent(uX + 32, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
      if ( uWidth > 512 )
      {
        pRenderer->DrawTextureTransparent(uX + 544, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
        pRenderer->DrawTextureTransparent(uX + 544, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
      }
    }
    if ( uHeight > 64 )
    {
      pRenderer->SetTextureClipRect(uX, uY + 32, uX + uWidth, uY + uHeight - 32);
      pRenderer->DrawTextureTransparent(uX,               uY + 32, pIcons_LOD->GetTexture(uTextureID_5076A0));
      pRenderer->DrawTextureTransparent(uX + uWidth - 10, uY + 32, pIcons_LOD->GetTexture(uTextureID_50769C));
    }
    pRenderer->ResetTextureClipRect();
  }
}

//----- (0041D895) --------------------------------------------------------
void GameUI_DrawItemInfo( struct ItemGen* inspect_item )
{
  unsigned int v2; // eax@3
  const char *v28; // edi@69
  int v34; // esi@81
  char *pText; // [sp-14h] [bp-28Ch]@110
  char out_text[300]; // [sp+8h] [bp-270h]@40
  char v65[120]; // [sp+134h] [bp-144h]@92
  stru351_summoned_item v67;
  int v77; // [sp+200h] [bp-78h]@12
  int v78; // [sp+204h] [bp-74h]@5
  GUIWindow iteminfo_window; // [sp+208h] [bp-70h]@2
  POINT a2; // [sp+25Ch] [bp-1Ch]@2
  int v81; // [sp+264h] [bp-14h]@5
  PlayerSpeech v83; // [sp+26Ch] [bp-Ch]@18
  char* v84;
  int v85;
  char *Str; // [sp+270h] [bp-8h]@65

  if (!inspect_item->uItemID)
    return;
  iteminfo_window.Hint = 0;
  iteminfo_window.uFrameWidth = 384;
  iteminfo_window.uFrameHeight = 180;
  iteminfo_window.uFrameY = 40;
  if ( pMouse->GetCursorPos(&a2)->x <= 320 )
    v2 = pMouse->GetCursorPos(&a2)->x + 30;
  else
    v2 = pMouse->GetCursorPos(&a2)->x - iteminfo_window.uFrameWidth - 30;
  iteminfo_window.uFrameX = v2;
  v78 = 100 - pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->uTextureWidth;
  v81 = 144 - pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->uTextureHeight;
  if ( v78 > 0 )
    v78 = v78 / 2;
  if ( v81 <= 0 )
    v81 = 0;
  else
    v81 = v81 / 2;
  if ( !pItemsTable->pItems[inspect_item->uItemID].uItemID_Rep_St )
    inspect_item->SetIdentified();
  v77 = 0;
  if (inspect_item->GetItemEquipType() == EQUIP_GOLD)
    v77 = inspect_item->uSpecEnchantmentType;
  if ( uActiveCharacter )
  {
  //try to identify
    if (!inspect_item->IsIdentified())
    {
      if ( pPlayers[uActiveCharacter]->CanIdentify(inspect_item) == 1 )
        inspect_item->SetIdentified();
      v83 = SPEECH_9;
      if ( !inspect_item->IsIdentified() )
        ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2);//"Identify Failed"
      else
      {
        v83 = SPEECH_8;
        if ( inspect_item->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) )
          v83 = SPEECH_7;
      }
      if ( dword_4E455C )
      {
        pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0);
        dword_4E455C = 0;
      }
    }
    inspect_item->UpdateTempBonus(pParty->uTimePlayed);
    if (inspect_item->IsBroken())
    {
      if ( pPlayers[uActiveCharacter]->CanRepair(inspect_item) == 1 )
        inspect_item->uAttributes = inspect_item->uAttributes & 0xFFFFFFFD | 1;
      v83 = SPEECH_11;
      if ( !inspect_item->IsBroken() )
        v83 = SPEECH_10;
      else
        ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2);//"Repair Failed"
      if ( dword_4E455C )
      {
        pPlayers[uActiveCharacter]->PlaySound(v83, 0);
        dword_4E455C = 0;
      }
    }
  }
  if (inspect_item->IsBroken())
  {
    iteminfo_window.DrawMessageBox(0);
    pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12,
    iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12, 
    iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12);
    iteminfo_window.uFrameWidth -= 24;
    iteminfo_window.uFrameHeight -= 12;
    iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
    iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
    pRenderer->DrawTransparentRedShade(iteminfo_window.uFrameX + v78, v81 + iteminfo_window.uFrameY + 30, pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE));
    if ( inspect_item->IsIdentified())
      pText = (char *)inspect_item->GetIdentifiedName();
    else
      pText = pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName;
    iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pText, 3);
    iteminfo_window.DrawTitleText(pFontArrus, 0x64u, ((signed int)iteminfo_window.uFrameHeight >> 1) - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &iteminfo_window, 0, 0) / 2,
                   TargetColor(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
    pRenderer->ResetTextureClipRect();
    if ( !areWeLoadingTexture )
    {
      pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->Release();
      pIcons_LOD->SyncLoadedFilesCount();
    }
    return;
  }
  if (!inspect_item->IsIdentified())
  {
    iteminfo_window.DrawMessageBox(0);
    pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12,  iteminfo_window.uFrameY + 12,
          iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12,  iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12);
    iteminfo_window.uFrameWidth -= 24;
    iteminfo_window.uFrameHeight -= 12;
    iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
    iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
    pRenderer->DrawTextureTransparent(iteminfo_window.uFrameX + v78, v81 + iteminfo_window.uFrameY + 30, pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE));
    iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName, 3);
    iteminfo_window.DrawTitleText(pFontArrus, 0x64u, ((signed int)iteminfo_window.uFrameHeight >> 1) - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &iteminfo_window, 0, 0) / 2,
                        TargetColor(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[232], 3);//"Not Identified"
    pRenderer->ResetTextureClipRect();
    if ( !areWeLoadingTexture )
    {
      pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->Release();
      pIcons_LOD->SyncLoadedFilesCount();
    }
    return;
  }
  sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName); //"Type: %s"
  out_text[100] = 0;
  out_text[200] = 0;
  switch (inspect_item->GetItemEquipType())
  {
    case EQUIP_OFF_HAND:
    case EQUIP_MAIN_HAND:
      sprintfex(out_text + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[LOCSTR_ATTACK],
          (int)inspect_item->GetDamageMod(), pGlobalTXT_LocalizationStrings[53],
          (int)inspect_item->GetDamageDice(), (int)inspect_item->GetDamageRoll()); //"Damage"
      if (inspect_item->GetDamageMod())
      {
        char mod[16];
        sprintf(mod, "+%d", (int)inspect_item->GetDamageMod());
        strcat(out_text + 100, mod);
      }
      break;

    case EQUIP_BOW:
      sprintfex(out_text + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[203], //"Shoot"
          (int)inspect_item->GetDamageMod(), pGlobalTXT_LocalizationStrings[53], //"Damage"
          (int)inspect_item->GetDamageDice(), (int)inspect_item->GetDamageRoll());
      if (inspect_item->GetDamageMod())
      {
        char mod[16];
        sprintf(mod, "+%d", (int)inspect_item->GetDamageMod());
        strcat(out_text + 100, mod);
      }
      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 (inspect_item->GetDamageDice()) //"Armor"	
          sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11],
                    inspect_item->GetDamageDice() + inspect_item->GetDamageMod());
      break;
  }

  if ( !v77 )
  {
    if (inspect_item->GetItemEquipType() ==EQUIP_POTION)  //this is CORRECT! do not move to switch!
    {
      if ( inspect_item->uEnchantmentType )
           sprintf(out_text + 200,  "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power"
    }
    else if (inspect_item->GetItemEquipType() == EQUIP_REAGENT)
      sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], inspect_item->GetDamageDice()); //"Power"
    else if ( inspect_item->uEnchantmentType )
      sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210], pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->m_enchantmentStrength); //"Special"
    else  if ( inspect_item->uSpecEnchantmentType )
      sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->m_enchantmentStrength);
    else if ( inspect_item->uNumCharges )
      sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges"
  }
  iteminfo_window.uFrameWidth -= 12;
  iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
  iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
  Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8));
  v84 = &out_text[0];
  for ( uint i = 1; i <= 3; i++ )
  {
    if ( *v84 )
      Str += pFontComic->CalcTextHeight(v84, &iteminfo_window, 100, 0) + 3;
    v84 += 100;
  }
  v28 = pItemsTable->pItems[inspect_item->uItemID].pDescription;
  if ( *v28 )
    Str += pFontSmallnum->CalcTextHeight(pItemsTable->pItems[inspect_item->uItemID].pDescription, &iteminfo_window, 100, 0);
  iteminfo_window.uFrameHeight = pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(),
                                     TEXTURE_16BIT_PALETTE)->uTextureHeight + v81 + 54;
  if ( (signed int)Str > (signed int)iteminfo_window.uFrameHeight )
    iteminfo_window.uFrameHeight = (unsigned int)Str;
  if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
    iteminfo_window.uFrameHeight += LOBYTE(pFontComic->uFontHeight);
  v85 = 0;
  if ( pFontArrus->uFontHeight )
  {
    iteminfo_window.uFrameWidth -= 24;
    if ( pFontArrus->CalcTextHeight(inspect_item->GetIdentifiedName(), &iteminfo_window, 0, 0) / (signed int)pFontArrus->uFontHeight )
      v85 = pFontArrus->uFontHeight;
    iteminfo_window.uFrameWidth += 24;
  }
  iteminfo_window.uFrameWidth += 12;
  iteminfo_window.uFrameHeight += (unsigned int)v85;
  iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
  iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
  iteminfo_window.DrawMessageBox(0);
  pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12,
         iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12, iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12);
  iteminfo_window.uFrameWidth -= 12;
  iteminfo_window.uFrameHeight -= 12;
  iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
  iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
  pRenderer->DrawTextureTransparent(iteminfo_window.uFrameX + v78,
      iteminfo_window.uFrameY + (signed int)(iteminfo_window.uFrameHeight - pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->uTextureHeight) / 2,
      pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE));

  v34 = (int)(v85 + 35);
  Str = out_text;
  for ( uint i = 1; i <= 3; i++ )
  {
    if ( *Str )
    {
      iteminfo_window.DrawText(pFontComic, 100, v34, 0, Str, 0, 0, 0);
      v34 += pFontComic->CalcTextHeight(Str, &iteminfo_window, 100, 0) + 3;
    }
    Str += 100;
  }
  v28 = pItemsTable->pItems[inspect_item->uItemID].pDescription;
  if ( *v28 )
    iteminfo_window.DrawText(pFontSmallnum, 100, v34, 0, v28, 0, 0, 0);
  iteminfo_window.uFrameX += 12;
  iteminfo_window.uFrameWidth -= 24;
  iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), inspect_item->GetIdentifiedName(), 3);
  iteminfo_window.uFrameWidth += 24;
  iteminfo_window.uFrameX -= 12;
  if ( v77 )
  {
    sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);//"Value"
    iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0);
    pRenderer->ResetTextureClipRect();
  }
  else
  {
    if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
    {
      init_summoned_item(&v67, inspect_item->uExpireTime - pParty->uTimePlayed);
      strcpy(pTmpBuf.data(), "Duration:");
      Str = (char *)(v67.field_18_expire_year - game_starting_year);
      if (v67.field_18_expire_year != 1168 )
      {
        sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year);
        strcat(pTmpBuf.data(), v65);
      }
      if ( (((v67.field_14_exprie_month || Str) && 
           ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str) 
         || v67.field_C_expire_day)
         && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || 
             v67.field_C_expire_day)
         || v67.field_8_expire_hour)
         && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || 
             v67.field_C_expire_day || v67.field_8_expire_hour)
         || v67.field_4_expire_minute )
      {
        sprintf(v65, " %d:mn", v67.field_4_expire_minute);
        strcat(pTmpBuf.data(), v65);
      }
      iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - 2 * LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0);
    }
    sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], inspect_item->GetValue());
    iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0);
    if ( BYTE1(inspect_item->uAttributes) & 1 )
      pText = pGlobalTXT_LocalizationStrings[187]; //"Stolen"
    else
    {
      if ( !(BYTE1(inspect_item->uAttributes) & 2) )
      {
        pRenderer->ResetTextureClipRect();
        if ( !areWeLoadingTexture )
        {
          pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->Release();
          pIcons_LOD->SyncLoadedFilesCount();
        }
        return;
      }
      pText = pGlobalTXT_LocalizationStrings[651]; //"Hardened"
    }
    LOWORD(inspect_item->uAttributes) = LOWORD(pRenderer->uTargetRMask);
    iteminfo_window.DrawText(pFontComic, pFontComic->GetLineWidth(pTmpBuf.data()) + 132,
          iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), inspect_item->uAttributes, pText, 0, 0, 0);
    pRenderer->ResetTextureClipRect();
  }
  if ( !areWeLoadingTexture )
  {
    pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->Release();
    pIcons_LOD->SyncLoadedFilesCount();
  }
  return;
}
// 4E455C: using guessed type int dword_4E455C;
// 506128: using guessed type int areWeLoadingTexture;

//----- (0041E360) --------------------------------------------------------
void MonsterPopup_Draw(unsigned int uActorID, GUIWindow *window)
{
  int v8; // eax@4
  unsigned __int16 v9; // dx@4
  SpriteFrame *v10; // edi@17
  unsigned int v18; // ecx@19
  unsigned int v19; // eax@21
  char *v20; // esi@28
  int v21; // edx@29
  unsigned __int16 *v22; // ecx@29
  int v23; // eax@29
  int v25; // esi@32
  char *v26; // edx@34
  unsigned __int8 v27; // sf@36
  unsigned __int8 v28; // of@36
  SpellBuff *v40; // eax@60
  int v41; // edi@61
  unsigned int v42; // eax@61
  int v43; // eax@62
  int v44; // eax@63
  signed int v45; // edi@65
  int pTextHeight; // edi@90
  int v73; // [sp-8h] [bp-1F4h]@79
  DDBLTFX Dst; // [sp+Ch] [bp-1E0h]@18
  DDSURFACEDESC2 pDesc; // [sp+70h] [bp-17Ch]@18
  RECT v84; // [sp+ECh] [bp-100h]@26
  char *string_name[10]; // [sp+FCh] [bp-F0h]@145
  char *content[11]; // [sp+124h] [bp-C8h]@127
  RenderBillboardTransform_local0 v106; // [sp+150h] [bp-9Ch]@3
  unsigned int v107; // [sp+1A0h] [bp-4Ch]@18
  unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34
  unsigned int v109; // [sp+1A8h] [bp-44h]@32
  LPVOID v110; // [sp+1ACh] [bp-40h]@28
  int v115; // [sp+1C0h] [bp-2Ch]@3
  bool normal_level; // [sp+1D0h] [bp-1Ch]@18
  bool expert_level; // [sp+1C4h] [bp-28h]@18
  bool master_level; // [sp+1C8h] [bp-24h]@18
  bool grandmaster_level; // [sp+1B4h] [bp-38h]@3
  char *pText; // [sp+1D4h] [bp-18h]@18
  int pTextColorID; // [sp+1E4h] [bp-8h]@18
  int a4; // [sp+1E8h] [bp-4h]@18

  bool monster_full_informations = true;
  static Actor pMonsterInfoUI_Doll;
  /*if ( !(bMonsterInfoUI_bDollInitialized & 1) )
  {
    bMonsterInfoUI_bDollInitialized |= 1u;
    Actor::Actor(&pMonsterInfoUI_Doll);
    atexit(nullsub_3);
  }*/
  v106.uParentBillboardID = -1;
  v115 = monster_popup_y_offsets[((signed __int16)pActors[uActorID].pMonsterInfo.uID - 1) / 3] - 40;
  if ( pActors[uActorID].pMonsterInfo.uID == pMonsterInfoUI_Doll.pMonsterInfo.uID )
    v9 = pMonsterInfoUI_Doll.uCurrentActionLength;
  else
  {
    memcpy(&pMonsterInfoUI_Doll, &pActors[uActorID], sizeof(pMonsterInfoUI_Doll));
    pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Bored;
    pMonsterInfoUI_Doll.uCurrentActionTime = 0;
    v8 = rand();
    v9 = v8 % 256 + 128;
    pMonsterInfoUI_Doll.uCurrentActionLength = v8 % 256 + 128;
  }

  if ( (signed int)pMonsterInfoUI_Doll.uCurrentActionTime > (signed __int16)v9 )
  {
    pMonsterInfoUI_Doll.uCurrentActionTime = 0;
    if ( pMonsterInfoUI_Doll.uCurrentActionAnimation == ANIM_Bored || pMonsterInfoUI_Doll.uCurrentActionAnimation == ANIM_AtkMelee)
    {
      pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Standing;
      pMonsterInfoUI_Doll.uCurrentActionLength = rand() % 128 + 128;
    }
    else
    {
      //rand();
      pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Bored;
      if ( (pMonsterInfoUI_Doll.pMonsterInfo.uID < 115 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 186) &&
           (pMonsterInfoUI_Doll.pMonsterInfo.uID < 232 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 249) && rand() % 30 < 100 )
        pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_AtkMelee;
      pMonsterInfoUI_Doll.uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[pActors[uActorID].pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation]].uAnimLength;
    }
  }
  v10 = pSpriteFrameTable->GetFrame( pActors[uActorID].pSpriteIDs[pMonsterInfoUI_Doll.uCurrentActionAnimation], pMonsterInfoUI_Doll.uCurrentActionTime);
  v106.pTarget = pRenderer->pTargetSurface;
  v106.pTargetZ = pRenderer->pActiveZBuffer;
  v106.uTargetPitch = pRenderer->uTargetSurfacePitch;
  v106.uViewportX = window->uFrameX + 13;
  v106.uViewportY = window->uFrameY + 52;
  v106.uViewportW = (window->uFrameY + 52) + 128;
  v106.uViewportZ = v106.uViewportX + 128;
  v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2;
  v106._screenspace_x_scaler_packedfloat = 65536;
  v106._screenspace_y_scaler_packedfloat = 65536;
  v106.uScreenSpaceY = v115 + (window->uFrameY + 52) + pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].uHeight;
  v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1);
  v106.sZValue = 0;
  v106.uFlags = 0;
  pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu);
  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, TargetColor(0xE1u, 255, 0x9Bu));
  pRenderer->RasterLine2D( v106.uViewportX + 129,  v106.uViewportY - 1,  v106.uViewportX + 129,    v106.uViewportW + 1, TargetColor(0xE1u, 255, 0x9Bu));
  pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, TargetColor(0xE1u, 255, 0x9Bu));
  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, TargetColor(0xE1u, 255, 0x9Bu));
  if ( pRenderer->pRenderD3D )
  {
    v106.uScreenSpaceY = v115 + v106.uViewportY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight;
    memset(&Dst, 0, 0x64u);
    Dst.dwSize = 100;
    Dst.dwFillColor = 0;
    memset(&pDesc, 0, 0x7Cu);
    pDesc.dwSize = 124;
    pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->GetSurfaceDesc(&pDesc);
    v107 = 0;
    uint i = 0;
    int dst_x = v106.uScreenSpaceX + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaX - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferWidth / 2;
    int dst_y = v106.uScreenSpaceY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaY - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight;
    uint dst_z = v106.uScreenSpaceX + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaX + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferWidth / 2 - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferWidth;
    uint dst_w = v106.uScreenSpaceY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaHeight - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight;
    if (dst_x < v106.uViewportX)
    {
      v18 = v106.uViewportX - dst_x;
      dst_x = v106.uViewportX;
      v107 = v18;
    }
    if (dst_y < v106.uViewportY)
    {
      v19 = v106.uViewportY - dst_y;
      dst_y = v106.uViewportY;
      i = v19;
    }
    if (dst_z > v106.uViewportZ)
      dst_z = v106.uViewportZ;
    if (dst_w > v106.uViewportW)
      dst_w = v106.uViewportW;
    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask);
    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask);
    v84.left = v106.uViewportX;
    v84.top = v106.uViewportY;
    v84.right = v106.uViewportZ;
    v84.bottom = v106.uViewportW;
    ErrD3D(pRenderer->pBackBuffer4->Blt(&v84, 0, 0, 16778240u, &Dst));
    if ( pRenderer->uTargetGBits == 5 )
    {
      __debugbreak(); // no monster popup for r5g5b5 yet
      memset(&pDesc, 0, 0x7Cu);
      pDesc.dwSize = 124;
      if ( pRenderer->LockSurface_DDraw4(pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface, &pDesc, DDLOCK_WAIT))
      {
        v20 = (char *)dst_y;
        v110 = pDesc.lpSurface;
        if (dst_y < dst_w)
        {
          v21 = dst_x;
          v22 = &pRenderer->pTargetSurface[dst_y * pRenderer->uTargetSurfacePitch + dst_x];
          auto _v22_2 = v22;
          v23 = i - dst_y;
          v115 = i - dst_y;
          while ( 1 )
          {
            dst_y = v21;
            if ( v21 < dst_z )
            {
              v25 = v107 - v21;
              v109 = (int)&v20[v23];
              for ( i = v107 - v21; ; v25 = i )
              {
                v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaHeight);
                v26 = (char *)v108 + pDesc.dwWidth * (v25 + dst_y++) / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth;
                *v22 = *((short *)v110 + (int)v26);
                ++v22;
                if ( dst_y >= dst_z )
                  break;
              }
              v23 = v115;
            }
            v22 = (unsigned __int16 *)((char *)_v22_2 + 2 * pRenderer->uTargetSurfacePitch);
            _v22_2 = v22;
            v20 = (char *)(dst_y + 1);
            v28 = __OFSUB__(dst_y + 1, dst_w);
            v27 = (signed int)(dst_y++ + 1 - dst_w) < 0;
            if ( !(v27 ^ v28) )
              break;
            v21 = dst_x;
          }
        }
        pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0);
      }
    }
    else
    {
      memset(&pDesc, 0, 0x7Cu);
      pDesc.dwSize = 124;
      if ( pRenderer->LockSurface_DDraw4(pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface, &pDesc, DDLOCK_WAIT) )
      {
        auto src = (unsigned __int16 *)pDesc.lpSurface;
        uint num_top_scanlines_above_frame_y = i - dst_y;
        for (uint y = dst_y; y < dst_w; ++y)
        {
          auto dst = &pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + dst_x];

          uint src_y = num_top_scanlines_above_frame_y + y;
          for (uint x = dst_x; x < dst_z; ++x)
          {
            uint src_x  = v107 - dst_x + x; // num scanlines left to frame_x  + current x

            uint idx = pDesc.dwHeight * src_y / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaHeight * (pDesc.lPitch / sizeof(short)) +
                       pDesc.dwWidth  * src_x / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth;
            uint b = src[idx] & 0x1F;
            *dst++ = b | 2 * (src[idx] & 0xFFE0);
          }
        }
        pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0);
      }
    }
  }
  else
  {
    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0);
    if ( v10->pHwSpriteIDs[0] >= 0 )
      pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].DrawSprite_sw(&v106, 0);
  }
//name and profession
  if ( pActors[uActorID].sNPC_ID )
  {
    if (GetNPCData(pActors[uActorID].sNPC_ID)->uProfession)
      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], GetNPCData(pActors[uActorID].sNPC_ID)->pName, aNPCProfessionNames[GetNPCData(pActors[uActorID].sNPC_ID)->uProfession]); // "%s the %s"   /   ^Pi[%s] %s
    else
      strncpy(pTmpBuf.data(), GetNPCData(pActors[uActorID].sNPC_ID)->pName, 2000);
  }
  else
  {
    if ( pActors[uActorID].dword_000334_unique_name )
      strncpy(pTmpBuf.data(), pMonsterStats->pPlaceStrings[pActors[uActorID].dword_000334_unique_name], 2000);
    else
      strncpy(pTmpBuf.data(), pMonsterStats->pInfos[pActors[uActorID].pMonsterInfo.uID].pName, 2000);
  }
  window->DrawTitleText(pFontComic, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
  //health bar
  Actor::DrawHealthBar(&pActors[uActorID], window);

  normal_level = 0;
  expert_level = 0;
  master_level = 0;
  grandmaster_level = 0;
  pMonsterInfoUI_Doll.uCurrentActionTime += pMiscTimer->uTimeElapsed;
  v115 = 0;
  if ( !uActiveCharacter )
    v45 = 1;
  else
  {
    int i = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
    if ( !i )
      v45 = 1;
    else
    {
      v41 = (unsigned __int8)i & 0x3F;
      v42 = SkillToMastery(i) - 1;
      if ( !v42 )//not master
      {
        if ( v41 + 10 >= pActors[uActorID].pMonsterInfo.uLevel )
        {
          v45 = 1;
          normal_level = 1;
        }
        else
          v45 = 1;
      }
      else//he is master
      {
        v43 = v42 - 1;
        if ( !v43 )
        {
          if ( 2 * v41 + 10 >= pActors[uActorID].pMonsterInfo.uLevel )
          {
            v45 = 1;
            normal_level = 1;
            expert_level = 1;
          }
          else
            v45 = 1;
        }
        else
        {
          v44 = v43 - 1;
          if ( !v44 )
          {
            if ( 3 * v41 + 10 >= pActors[uActorID].pMonsterInfo.uLevel )
            {
              v45 = 1;
              normal_level = 1;
              expert_level = 1;
              master_level = 1;
            }
            else
              v45 = 1;
          }
          else
          {
            if ( v44 != 1 )
              v45 = 1;
            else
            {
              v45 = 1;
              normal_level = 1;
              expert_level = 1;
              master_level = 1;
              grandmaster_level = 1;
            }
          }
        }
      }
    }
    if ( pActors[uActorID].uAIState != Dead
      && pActors[uActorID].uAIState != Dying
      && !dword_507BF0_is_there_popup_onscreen && i )
    {
      if ( normal_level | expert_level | master_level | grandmaster_level )
      {
        if ( pActors[uActorID].pMonsterInfo.uLevel >= pPlayers[uActiveCharacter]->uLevel - 5 )
          v73 = SPEECH_105;
        else
          v73 = SPEECH_104;
      }
      else
        v73 = SPEECH_106;
      pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)v73, 0);
    }
  }

  if ( (signed int)SkillToMastery(pParty->pPlayers[uActiveCharacter].GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID)) >= 3 )
    v115 = v45;

  if ( monster_full_informations == true )
  {
    normal_level = 1;//
    expert_level = 1;//
    master_level = 1;//
    grandmaster_level = 1;//
    v115 = 1;
  }

  window->DrawText(pFontSmallnum, 12, 196, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[631], 0, 0, 0);//Effects
  if ( !v115 )
    window->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[630], 0, 0, 0);//?
  else
  {
    pText = "";
    pTextHeight = LOBYTE(pFontSmallnum->uFontHeight) + 193;
    for ( uint i = 1; i <= 21; ++i )
    {
      if ( pActors[uActorID].pActorBuffs[i].uExpireTime > 0 )
      {
        switch ( i - 1 )
        {
          case 0:
            pTextColorID = 60;
            pText = pGlobalTXT_LocalizationStrings[591];//Charmed
            break;
          case 1:
            pTextColorID = 82;
            pText = pGlobalTXT_LocalizationStrings[649];//Summoned
            break;
          case 2:
            pTextColorID = 92;
            pText = pGlobalTXT_LocalizationStrings[592];//Shrunk
            break;
          case 3:
            pTextColorID = 63;
            pText = pGlobalTXT_LocalizationStrings[4];//Afraid
            break;
          case 4:
            pText = pGlobalTXT_LocalizationStrings[220];//Stoned
            pTextColorID = 81;
            break;
          case 5:
            pText = pGlobalTXT_LocalizationStrings[162];//Paralyzed
            pTextColorID = 81;
            break;
          case 6:
            pText = pGlobalTXT_LocalizationStrings[593];//Slowed
            pTextColorID = 35;
            break;
          case 8:
            pText = pGlobalTXT_LocalizationStrings[608];//Berserk
            pTextColorID = 62;
            break;
          case 7:
          case 9:
            pText = "";
            pTextColorID = 0;
            continue;
          case 10:
            pTextColorID = 47;
            pText = pGlobalTXT_LocalizationStrings[221];//Fate
            break;
          case 11:
            pTextColorID = 66;
            pText = pGlobalTXT_LocalizationStrings[607];//Enslaved
            break;
          case 12:
            pTextColorID = 85;
            pText = pGlobalTXT_LocalizationStrings[610];//Day of Protection
            break;
          case 13:
            pTextColorID = 86;
            pText = pGlobalTXT_LocalizationStrings[609];//Hour of Power
            break;
          case 14:
            pTextColorID = 17;
            pText = pGlobalTXT_LocalizationStrings[279];//Shield
            break;
          case 15:
            pTextColorID = 38;
            pText = pGlobalTXT_LocalizationStrings[442];//Stoneskin
            break;
          case 16:
            pTextColorID = 46;
            pText = pGlobalTXT_LocalizationStrings[443];//Bless
            break;
          case 17:
            pTextColorID = 51;
            pText = pGlobalTXT_LocalizationStrings[440];//Heroism
            break;
          case 18:
            pTextColorID = 5;
            pText = pGlobalTXT_LocalizationStrings[441];//Haste
            break;
          case 19:
            pTextColorID = 95;
            pText = pGlobalTXT_LocalizationStrings[229];//Pain Reflection
            break;
          case 20:
            pTextColorID = 73;
            pText = pGlobalTXT_LocalizationStrings[228];//Hammerhands
            break;
          default:
            pText = "";
            break;
        }
        if ( pText != "" )
        {
          window->DrawText(pFontSmallnum, 28, pTextHeight, GetSpellColor(pTextColorID), pText, 0, 0, 0);
          pTextHeight = pTextHeight + *(char *)((int)pFontSmallnum + 5) - 3;
        }
      }
    }
    if ( pText == "" )
      window->DrawText(pFontSmallnum, 28, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[153], 0, 0, 0);//Нет
  }

  if ( normal_level )
  {
    sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, pActors[uActorID].pMonsterInfo.uHP);
    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
    pTextHeight = v106.uViewportY + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[12], 0, pActors[uActorID].pMonsterInfo.uAC);//Armor Class
  }
  else
  {
    sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);//?
    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
    pTextHeight = v106.uViewportY + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[12], 0, (unsigned int)pGlobalTXT_LocalizationStrings[630]);//?
  }
  window->DrawText(pFontSmallnum, 150, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
  pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 6 + LOBYTE(pFontSmallnum->uFontHeight);

  content[0] = pGlobalTXT_LocalizationStrings[87];
  content[1] = pGlobalTXT_LocalizationStrings[6];
  content[2] = pGlobalTXT_LocalizationStrings[240];
  content[3] = pGlobalTXT_LocalizationStrings[70];
  content[4] = pGlobalTXT_LocalizationStrings[624];
  content[5] = pGlobalTXT_LocalizationStrings[138];
  content[6] = pGlobalTXT_LocalizationStrings[214];
  content[7] = pGlobalTXT_LocalizationStrings[142];
  content[8] = pGlobalTXT_LocalizationStrings[29];
  content[9] = pGlobalTXT_LocalizationStrings[133];
  content[10] = pGlobalTXT_LocalizationStrings[54];

  if ( expert_level )
  {
    sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, content[pActors[uActorID].pMonsterInfo.uAttack1Type]);//Attack
    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
    pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    if ( pActors[uActorID].pMonsterInfo.uAttack1DamageBonus )
      sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d+%d\n", pGlobalTXT_LocalizationStrings[53],
        0, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceRolls, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceSides, pActors[uActorID].pMonsterInfo.uAttack1DamageBonus);
    else
      sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d\n", pGlobalTXT_LocalizationStrings[53],
        0, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceRolls, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceSides);
  }
  else
  {
    sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
    pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
  }
  window->DrawText(pFontSmallnum, 150, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
  pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 6 + LOBYTE(pFontSmallnum->uFontHeight);

  if ( !master_level )
  {
    sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[628], 0, pGlobalTXT_LocalizationStrings[630]);//"Spell" "?"
    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
    pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
  }
  else
  {
    pText = pGlobalTXT_LocalizationStrings[628];//Spell
    if ( pActors[uActorID].pMonsterInfo.uSpell1ID && pActors[uActorID].pMonsterInfo.uSpell2ID )
      pText = pGlobalTXT_LocalizationStrings[629];//Spells
    if ( pActors[uActorID].pMonsterInfo.uSpell1ID )
    {
      sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", pText, 0, pSpellStats->pInfos[pActors[uActorID].pMonsterInfo.uSpell1ID].pShortName);
      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
      pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    }
    if ( pActors[uActorID].pMonsterInfo.uSpell2ID )
    {
      sprintf(pTmpBuf.data(), "\f%05u\t070%s\n", 0, pSpellStats->pInfos[pActors[uActorID].pMonsterInfo.uSpell2ID].pShortName);
      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
      pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    }
    if ( !pActors[uActorID].pMonsterInfo.uSpell1ID && !pActors[uActorID].pMonsterInfo.uSpell2ID )
    {
      sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", pGlobalTXT_LocalizationStrings[628], 0, pGlobalTXT_LocalizationStrings[153]);
      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
      pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    }
  }
  pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
  window->DrawText(pFontSmallnum, 150, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[626], 0, 0, 0);//Immune
  pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;

  string_name[0] = pGlobalTXT_LocalizationStrings[87];//Fire
  string_name[1] = pGlobalTXT_LocalizationStrings[6];//Air
  string_name[2] = pGlobalTXT_LocalizationStrings[240];
  string_name[3] = pGlobalTXT_LocalizationStrings[70];
  string_name[4] = pGlobalTXT_LocalizationStrings[142];
  string_name[5] = pGlobalTXT_LocalizationStrings[214];
  string_name[6] = pGlobalTXT_LocalizationStrings[29];
  string_name[7] = pGlobalTXT_LocalizationStrings[133];
  string_name[8] = pGlobalTXT_LocalizationStrings[54];
  string_name[9] = pGlobalTXT_LocalizationStrings[624];

  content[0] = (char *)pActors[uActorID].pMonsterInfo.uResFire;
  content[1] = (char *)pActors[uActorID].pMonsterInfo.uResAir;
  content[2] = (char *)pActors[uActorID].pMonsterInfo.uResWater;
  content[3] = (char *)pActors[uActorID].pMonsterInfo.uResEarth;
  content[4] = (char *)pActors[uActorID].pMonsterInfo.uResMind;
  content[5] = (char *)pActors[uActorID].pMonsterInfo.uResSpirit;
  content[6] = (char *)pActors[uActorID].pMonsterInfo.uResBody;
  content[7] = (char *)pActors[uActorID].pMonsterInfo.uResLight;
  content[8] = (char *)pActors[uActorID].pMonsterInfo.uResPhysical;
  content[9] = (char *)pActors[uActorID].pMonsterInfo.uResDark;

  if ( grandmaster_level )
  {
    for ( uint i = 0; i < 10; i++ )
    {
      if ( content[i] == (char *)200 )
      {
        pText = pGlobalTXT_LocalizationStrings[625];//Immune
      }
      else
      {
        if ( content[i] )
          pText = pGlobalTXT_LocalizationStrings[627];//Resistant
        else
          pText = pGlobalTXT_LocalizationStrings[153];//None
      }
      sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", string_name[i], 0, pText);
      window->DrawText(pFontSmallnum, 170, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
      pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    }
  }
  else
  {
    for ( uint i = 0; i < 10; ++i )
    {
      sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", string_name[i], 0, pGlobalTXT_LocalizationStrings[630]); // "?"
      window->DrawText(pFontSmallnum, 170, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
      pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
    }
  }
  if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].uExpireTime > 0 )
  {
    sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[650], pActors[uActorID].sCurrentHP);//Current Hit Points
    pFontSmallnum->GetLineWidth(pTmpBuf.data());
    window->DrawTitleText(pFontSmallnum, 0, window->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12, 0, pTmpBuf.data(), 3);
  }
}


//----- (00417BB5) --------------------------------------------------------
const char *CharacterUI_GetSkillDescText(unsigned int uPlayerID, PLAYER_SKILL_TYPE uPlayerSkillType)
{
    //enum PLAYER_SKILL_TYPE v2; // esi@1
    //unsigned int v3; // ebx@1
    int v4; // edi@1
    int v5; // eax@1
    Player *pPlayer; // ebx@7
    char v7; // al@7
    char v8; // cl@7
    unsigned int v9; // eax@8
    unsigned int v10; // eax@8
    unsigned int v11; // eax@8
    PLAYER_SKILL_TYPE v12; // edi@8
    unsigned int v13; // eax@8
    unsigned int v14; // eax@8
    PLAYER_SKILL_TYPE v15; // esi@8
    int v16; // edi@8
    char v17; // al@8
    int v18; // ST5C_4@8
    int v19; // ST4C_4@8
    int v20; // ST3C_4@8
    int v21; // ST2C_4@8
    int v22; // ST1C_4@8
    char *v23; // esi@8
    unsigned int v24; // eax@9
    unsigned int v25; // eax@9
    unsigned int v26; // eax@9
    unsigned int v27; // ecx@9
    PLAYER_SKILL_TYPE v28; // ebx@9
    unsigned int v29; // eax@9
    char a2[1200]; // [sp+Ch] [bp-538h]@7
    char Source[120]; // [sp+4BCh] [bp-88h]@7
    unsigned __int16 *v33; // [sp+534h] [bp-10h]@1
    int v34; // [sp+538h] [bp-Ch]@1
    unsigned __int16 *v35; // [sp+53Ch] [bp-8h]@1
    //enum PLAYER_SKILL_TYPE v36; // [sp+540h] [bp-4h]@1

    //v2 = uPlayerSkillType;
    //v3 = uPlayerID;
    //v36 = uPlayerSkillType;
    v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);// Normal
    v34 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);// Expert
    v33 = (unsigned __int16 *)pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);// Master
    v5 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);// Grand
    v35 = (unsigned __int16 *)v4;
    if ( v34 > v4 )
        v35 = (unsigned __int16 *)v34;
    if ( (signed int)v33 > (signed int)v35 )
        v35 = v33;
    if ( v5 > (signed int)v35 )
        v35 = (unsigned __int16 *)v5;
    pPlayer = &pParty->pPlayers[uPlayerID];
    //v33 = &pPlayer->pActiveSkills[uPlayerSkillType];
    v7 = pPlayer->GetActualSkillLevel(uPlayerSkillType);
    v8 = pPlayer->pActiveSkills[uPlayerSkillType];
    a2[0] = 0;
    Source[0] = 0;
    if ( (v8 & 0x3F) == (v7 & 0x3F) )
        {
        strcpy(a2, "%s\n\n");
        v24 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 1);
        sprintf(Source, "\f%05d", v24);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
        v25 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 2);
        sprintf(Source, "\f%05d", v25);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
        v26 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 3);
        sprintf(Source, "\f%05d", v26);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
        v27 = pPlayer->classType;
        v28 = uPlayerSkillType;
        v29 = GetSkillColor(v27, uPlayerSkillType, 4);
        sprintf(Source, "\f%05d", v29);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n");

        v23 = static_sub_417BB5_out_string;
        sprintf(static_sub_417BB5_out_string, a2, pSkillDesc[v28], pGlobalTXT_LocalizationStrings[431],      // Normal
            (char *)v35 + 3, v35 + 5, pNormalSkillDesc[v28], pGlobalTXT_LocalizationStrings[433],      // Expert
            (char *)v35 + 3, v35 + 5, pExpertSkillDesc[v28], pGlobalTXT_LocalizationStrings[432],      // Master
            (char *)v35 + 3, v35 + 5, pMasterSkillDesc[v28], pGlobalTXT_LocalizationStrings[96],       // Grand
            (char *)v35 + 3, v35 + 5, pGrandSkillDesc[v28]);
        }
    else
        {
        strcpy(a2, "%s\n\n");
        v9 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 1);
        sprintf(Source, "\f%05d", v9);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
        v10 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 2);
        sprintf(Source, "\f%05d", v10);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
        v11 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 3);
        sprintf(Source, "\f%05d", v11);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n");
        v12 = uPlayerSkillType;
        v13 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 4);
        sprintf(Source, "\f%05d", v13);
        strcat(a2, Source);
        strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n");
        v14 = TargetColor(0xFFu, 0xFFu, 0xFFu);
        sprintf(Source, "\f%05d", v14);
        strcat(a2, Source);
        strcat(a2, "%s: +%d");
        v15 = v12;
        v16 = (int)(v35 + 5);
        v15 = (PLAYER_SKILL_TYPE)((int)v15 * 4);
        v34 = (int)((char *)v35 + 3);
        v17 = pPlayer->GetActualSkillLevel(uPlayerSkillType);
        v18 = *(int *)(pGrandSkillDesc[v15]);
        v19 = *(int *)(pMasterSkillDesc[v15]);
        v20 = *(int *)(pExpertSkillDesc[v15]);
        v21 = *(int *)(pNormalSkillDesc[v15]);
        v22 = *(int *)(pSkillDesc[v15]);
        v23 = static_sub_417BB5_out_string;
        sprintf(
            static_sub_417BB5_out_string,
            a2,
            v22,
            pGlobalTXT_LocalizationStrings[431],
            v34,
            v16,
            v21,
            pGlobalTXT_LocalizationStrings[433],
            v34,
            v16,
            v20,
            pGlobalTXT_LocalizationStrings[432],
            v34,
            v16,
            v19,
            pGlobalTXT_LocalizationStrings[96],
            v34,
            v16,
            v18,
            pGlobalTXT_LocalizationStrings[623],
            (v17 & 0x3F) - (*(char *)v33 & 0x3F));
        }
    return v23;
    }

//----- (00417FE5) --------------------------------------------------------
    void CharacterUI_SkillsTab_ShowHint()
        {
    unsigned int v0; // ecx@1
    unsigned int v1; // eax@1
    GUIButton *i; // esi@6
    const char *v3; // eax@12
    unsigned int pX; // [sp+4h] [bp-8h]@1
    unsigned int pY; // [sp+8h] [bp-4h]@1

    pMouse->GetClickPos(&pX, &pY);
    v0 = pX;
    v1 = pY;
    if ( (signed int)pX < 24 || (signed int)pX > 455 || (signed int)pY < 18 || (signed int)pY > 36 )
        {
        for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext )
            {
            if ( i->msg == UIMSG_SkillUp
                && (signed int)v0 >= (signed int)i->uX
                && (signed int)v0 <= (signed int)i->uZ
                && (signed int)v1 >= (signed int)i->uY
                && (signed int)v1 <= (signed int)i->uW )
                {
                v3 = CharacterUI_GetSkillDescText(uActiveCharacter - 1, (PLAYER_SKILL_TYPE)i->msg_param);
                CharacterUI_DrawTooltip(pSkillNames[i->msg_param], v3);
                v1 = pY;
                v0 = pX;
                }
            }
        }
    else
        {
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription);
        }
    
    }

//----- (00418083) --------------------------------------------------------
void  CharacterUI_StatsTab_ShowHint()
{
  int pStringNum; // edi@1
  signed int pTextColor; // eax@15
  char *pHourWord; // ecx@17
  char *pDayWord; // eax@20
  int v15; // ebx@28
  int v16; // eax@33
  POINT a2; // [sp+Ch] [bp-24h]@1
  int pHour; // [sp+14h] [bp-1Ch]@15
  unsigned int pDay; // [sp+24h] [bp-Ch]@15

  pMouse->GetCursorPos(&a2);
  for ( pStringNum = 0; pStringNum < stat_string_coord.size(); ++pStringNum )
  {
    if (a2.x >= stat_string_coord[pStringNum].x && a2.x <= stat_string_coord[pStringNum].x + stat_string_coord[pStringNum].width )
    {
      if (a2.y >= stat_string_coord[pStringNum].y && a2.y <= stat_string_coord[pStringNum].y + stat_string_coord[pStringNum].height )
        break;
    }
  }

  switch ( pStringNum )
  {
    case 0:// Attributes
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      if ( aAttributeNames[pStringNum] && pAttributeDescriptions[pStringNum] )
        CharacterUI_DrawTooltip(aAttributeNames[pStringNum], pAttributeDescriptions[pStringNum]);
      break;
    case 7:// Health Points
      if ( pGlobalTXT_LocalizationStrings[108] && pHealthPointsAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[108], pHealthPointsAttributeDescription);
      break;
    case 8:// Spell Points
      if ( pGlobalTXT_LocalizationStrings[212] && pSpellPointsAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[212], pSpellPointsAttributeDescription);
      break;
    case 9:// Armor Class
      if ( pGlobalTXT_LocalizationStrings[12] && pArmourClassAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[12], pArmourClassAttributeDescription);
      break;
    case 10:// Player Condition
      strcpy(pTmpBuf2.data(), pPlayerConditionAttributeDescription);
      strcat(pTmpBuf2.data(), "\n");
      extern std::array<unsigned int, 18> pConditionImportancyTable;
      for ( uint i = 0; i < 18; ++i )
      {
        if ( pPlayers[uActiveCharacter]->pConditions[pConditionImportancyTable[i]] )
        {
          strcat(pTmpBuf2.data(), " \n");
          pHour = pParty->uTimePlayed - pPlayers[uActiveCharacter]->pConditions[pConditionImportancyTable[i]];
          pHour = (unsigned int)((pHour * 0.234375) / 60 / 60);
          pDay = (unsigned int)pHour / 24;
          pHour %= 24i64;
          pTextColor = GetConditionDrawColor(pConditionImportancyTable[i]);
          sprintfex(pTmpBuf.data(), format_4E2DE8, pTextColor, aCharacterConditionNames[pConditionImportancyTable[i]]);
          strcat(pTmpBuf2.data(), pTmpBuf.data());
          if ( pHour && pHour <= 1 )
            pHourWord = pGlobalTXT_LocalizationStrings[109];
          else
            pHourWord = pGlobalTXT_LocalizationStrings[110];
          if ( !pDay || (pDayWord = pGlobalTXT_LocalizationStrings[56], pDay > 1) )
            pDayWord = pGlobalTXT_LocalizationStrings[57];
          sprintfex(pTmpBuf.data(), "%lu %s, %lu %s", pDay, pDayWord, pHour, pHourWord);
          strcat(pTmpBuf2.data(), pTmpBuf.data());
        }
      }
      if ( pGlobalTXT_LocalizationStrings[47] && pTmpBuf2.data() )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[47], pTmpBuf2.data());
      break;
    case 11:// Fast Spell
      if ( pGlobalTXT_LocalizationStrings[172] && pFastSpellAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[172], pFastSpellAttributeDescription);
      break;
    case 12:// Player Age
      if ( pGlobalTXT_LocalizationStrings[5] && pPlayerAgeAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[5], pPlayerAgeAttributeDescription);
      break;
    case 13:// Player Level
      if ( pGlobalTXT_LocalizationStrings[131] && pPlayerLevelAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[131], pPlayerLevelAttributeDescription);
      break;
    case 14://Experience
      v15 = pPlayers[uActiveCharacter]->uLevel;
      do
      {
        if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience < (unsigned int)GetExperienceRequiredForLevel(v15) )
          break;
        ++v15;
      }
      while ( v15 <= 10000 );
      pTmpBuf[0] = 0;
      pTmpBuf2[0] = 0;
      if ( v15 > pPlayers[uActiveCharacter]->uLevel )
        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[147], v15);
      v16 = GetExperienceRequiredForLevel(v15) - LODWORD(pPlayers[uActiveCharacter]->uExperience);
      sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[538], v16, v15 + 1);
      strcat(pTmpBuf.data(), "\n");
      strcat(pTmpBuf.data(), pTmpBuf2.data());
      sprintf(pTmpBuf2.data(), "%s\n \n%s", pPlayerExperienceAttributeDescription, pTmpBuf.data());
      if ( pGlobalTXT_LocalizationStrings[83] && pTmpBuf2.data() )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[83], pTmpBuf2.data());
      break;
    case 15:// Attack Bonus
      if ( pGlobalTXT_LocalizationStrings[587] && pAttackBonusAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[587], pAttackBonusAttributeDescription);
      break;
    case 16:// Attack Damage
      if ( pGlobalTXT_LocalizationStrings[588] && pAttackDamageAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[588], pAttackDamageAttributeDescription);
      break;
    case 17:// Missle Bonus
      if ( pGlobalTXT_LocalizationStrings[589] && pMissleBonusAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[589], pMissleBonusAttributeDescription);
      break;
    case 18:// Missle Damage
      if ( pGlobalTXT_LocalizationStrings[590] && pMissleDamageAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[590], pMissleDamageAttributeDescription);
      break;
    case 19:// Fire Resistance
      if ( pGlobalTXT_LocalizationStrings[87] && pFireResistanceAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[87], pFireResistanceAttributeDescription);
      break;
    case 20:// Air Resistance
      if ( pGlobalTXT_LocalizationStrings[6] && pAirResistanceAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[6], pAirResistanceAttributeDescription);
      break;
    case 21:// Water Resistance
      if ( pGlobalTXT_LocalizationStrings[240] && pWaterResistanceAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[240], pWaterResistanceAttributeDescription);
      break;
    case 22:// Earth Resistance
      if ( pGlobalTXT_LocalizationStrings[70] && pEarthResistanceAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[70], pEarthResistanceAttributeDescription);
      break;
    case 23:// Mind Resistance
      if ( pGlobalTXT_LocalizationStrings[142] && pMindResistanceAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[142], pMindResistanceAttributeDescription);
      break;
    case 24:// Body Resistance
      if ( pGlobalTXT_LocalizationStrings[29] && pBodyResistanceAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[29], pBodyResistanceAttributeDescription);
      break;
    case 25: // Skill Points
      if ( pGlobalTXT_LocalizationStrings[207] && pSkillPointsAttributeDescription )
        CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription);
      break;
    case 26: // Class description
    {
      if (pClassDescriptions[pPlayers[uActiveCharacter]->classType] && pClassNames[pPlayers[uActiveCharacter]->classType])
        CharacterUI_DrawTooltip(pClassNames[pPlayers[uActiveCharacter]->classType], pClassDescriptions[pPlayers[uActiveCharacter]->classType]);
    }
    break;

    default:
      break;
  }
}

    //----- (00410B28) --------------------------------------------------------
    void  DrawSpellDescriptionPopup(int spell_index)
        {
        Player *v1; // edi@1
        SpellInfo *v2; // esi@1
        unsigned int v3; // eax@2
        int v4; // eax@4
        LONG v5; // ecx@4
        int v6; // eax@10
        char *v7; // ST44_4@12
        unsigned __int16 v8; // ax@12
        GUIWindow a1; // [sp+Ch] [bp-68h]@4
        int v10; // [sp+60h] [bp-14h]@1
        POINT a2; // [sp+64h] [bp-10h]@1
        int v12; // [sp+6Ch] [bp-8h]@4
        int v13; // [sp+70h] [bp-4h]@4

        v1 = pPlayers[uActiveCharacter];
        v10 = spell_index;
        v2 = &pSpellStats->pInfos[spell_index + 11 * v1->lastOpenedSpellbookPage + 1];
        if ( pMouse->GetCursorPos(&a2)->y <= 250 )
            v3 = pMouse->GetCursorPos(&a2)->y + 30;
        else
            v3 = 30;
        a1.uFrameY = v3;
        a1.uFrameWidth = 328;
        a1.uFrameHeight = 68;
        a1.uFrameX = 90;
        a1.uFrameZ = 417;
        a1.uFrameW = v3 + 67;
        a1.Hint = 0;
        a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_NORMAL]);
        v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_MASTER]);
        v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_EXPERT]);
        v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_GRAND]);
        v5 = a2.y;
        if ( v13 > a2.y )
            v5 = v13;
        if ( v12 > v5 )
            v5 = v12;
        if ( v4 > v5 )
            v5 = v4;
        sprintf(  pTmpBuf2.data(),
            "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s",
            v2->pDescription,
            pGlobalTXT_LocalizationStrings[LOCSTR_NORMAL],
            v5 + 3, v5 + 10,
            v2->pBasicSkillDesc,
            pGlobalTXT_LocalizationStrings[LOCSTR_EXPERT],
            v5 + 3,  v5 + 10,
            v2->pExpertSkillDesc,
            pGlobalTXT_LocalizationStrings[LOCSTR_MASTER],
            v5 + 3, v5 + 10,
            v2->pMasterSkillDesc,
            pGlobalTXT_LocalizationStrings[LOCSTR_GRAND],
            v5 + 3,  v5 + 10,
            v2->pGrandmasterSkillDesc);
        v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2.data(), &a1, 0, 0);
        a1.uFrameHeight += v6;
        if ( (signed int)a1.uFrameHeight < 150 )
            a1.uFrameHeight = 150;
        a1.uFrameWidth = game_viewport_width;
        a1.DrawMessageBox(0);
        a1.uFrameWidth -= 12;
        a1.uFrameHeight -= 12;
        v7 = v2->pName;
        a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
        a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
        v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
        a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
        a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0);
        a1.uFrameWidth = 108;
        a1.uFrameZ = a1.uFrameX + 107;
        a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->lastOpenedSpellbookPage + 12], 3u);
        sprintf( pTmpBuf.data(),  "%s\n%d",    pGlobalTXT_LocalizationStrings[LOCSTR_SP_COST],
            pSpellDatas[spell_index + 11 * v1->lastOpenedSpellbookPage + 1].mana_per_skill[v1->pActiveSkills[v1->lastOpenedSpellbookPage + PLAYER_SKILL_FIRE]]);
        //  *(&[0].field_12 //temp_fix field_14
        // + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->lastOpenedSpellbookPage + 12]) >> 6)
        // + 10 * (int)((char *)v10 + 11 * v1->lastOpenedSpellbookPage)));
        a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf.data(), 3u);
        dword_507B00_spell_info_to_draw_in_popup = 0;
        }
    // 507B00: using guessed type int dword_507B00_spell_info_to_draw_in_popup;





//----- (00416D62) --------------------------------------------------------
void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(Vec2_int_ *_this)
{
        signed int pPlayerNum; // eax@12
        char *v2; // eax@32
        void *v3; // ecx@52
        unsigned int v4; // eax@59
        int v5; // esi@62
        signed int v6; // esi@64
        signed int v7; // esi@69
        ItemGen *v8; // ecx@70
        unsigned int v9; // eax@72
        unsigned int v10; // eax@76
        //char v11; // zf@83
        GUIButton *pButton; // esi@84
        unsigned int v13; // ecx@85
        char *pStr; // edi@85
        //signed int pControlID; // eax@92
        int v16; // eax@95
        int v17; // eax@96
        PLAYER_SKILL_TYPE v18; // eax@98
        char *pStr2; // eax@99
        unsigned int v20; // eax@108
        unsigned int pSkillId; // eax@109
        const char *pSkillInfo; // eax@111
        //char *v23; // ebx@112
        char *pHint; // edx@113
        unsigned int pColor; // eax@113
        GUIWindow pWindow; // [sp+4h] [bp-74h]@32
        double v27; // [sp+58h] [bp-20h]@33
        struct tagPOINT Point; // [sp+60h] [bp-18h]@6
        char *v29; // [sp+68h] [bp-10h]@33
        float v30; // [sp+6Ch] [bp-Ch]@33
        unsigned int pX; // [sp+70h] [bp-8h]@3
        unsigned int pY; // [sp+74h] [bp-4h]@3

        if ( pCurrentScreen == SCREEN_VIDEO )
            return;
        if ( _this )
            {
            pX = _this->x;
            pY = _this->y;
            }
        else
            {
            pMouse->GetClickPos(&pX, &pY);
            }
        if ( pRenderer->bWindowMode )
            {
            GetCursorPos(&Point);
            ScreenToClient(hWnd, &Point);
            if ( Point.x < 1 || Point.y < 1 || Point.x > 638 || Point.y > 478 )
                {
                back_to_game();
                return;
                }
            }

        if ( pParty->pPickedItem.uItemID )//нажатие на портрет перса правой кнопкой мыши с раствором
            {
            //v1 = 0;
            //do
            for ( pPlayerNum = 0; pPlayerNum < 4; ++pPlayerNum)
                {
                if ( (signed int)pX > RightClickPortraitXmin[pPlayerNum] && (signed int)pX < RightClickPortraitXmax[pPlayerNum]
                && (signed int)pY > 375 && (signed int)pY < 466 )
                    {
                    pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(pPlayerNum + 1, 1);
                    return;
                    }
                //++v1;
                }
            //while ( v1 < 4 );
            }

        pEventTimer->Pause();

        switch(pCurrentScreen)
            {
        case SCREEN_CASTING:
            {
            OnInventoryItemRightClick();
            break;
            }

        case SCREEN_CHEST:
            {
            if ( !pPlayers[uActiveCharacter]->CanAct() )
                {
                sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427],//%s не в состоянии %s
                    pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//Опознать предметы
                pWindow.Hint = pTmpBuf.data();
                pWindow.uFrameWidth = 384;
                pWindow.uFrameHeight = 180;
                pWindow.uFrameY = 40;
                if ( (signed int)pX <= 320 )
                    v10 = pX + 30;
                else
                    v10 = pX - 414;
                pWindow.uFrameX = v10;
                pWindow.DrawMessageBox(0);
                }
            else
                {
                v9 = pX + pSRZBufferLineOffsets[pY];
                if ( pRenderer->pActiveZBuffer[v9] & 0xFFFF )
                    {

                    //  __debugbreak(); // invalid indexing will result in invalid object ptr
                    //	v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime
                    //					+ (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
                    v10=pChests[pChestWindow->par1C].pInventoryIndices[(pRenderer->pActiveZBuffer[v9] & 0xFFFF)-1];
                    v8 =&pChests[pChestWindow->par1C].igChestItems[v10-1];
                    GameUI_DrawItemInfo(v8);
                    }
                }
            break;
            }
        case SCREEN_GAME:
            {
            if (GetCurrentMenuID() > 0)
                break;

            if ( (signed int)pY > (signed int)pViewport->uViewportBR_Y )
                {
                pWindow.ptr_1C = (void *)((signed int)pX / 118);
                if ( (signed int)pX / 118 < 4 )
                    {
                    pWindow.Hint = 0;
                    pWindow.uFrameWidth = 400;
                    pWindow.uFrameHeight = 200;
                    pWindow.uFrameX = 38;
                    pWindow.uFrameY = 60;
                    pAudioPlayer->StopChannels(-1, -1);
                    GameUI_CharacterQuickRecord_Draw(&pWindow, pPlayers[(int)pWindow.ptr_1C + 1]);
                    }
                }
            else if ( (signed int)pX > (signed int)pViewport->uViewportBR_X )
                {
                if ( (signed int)pY >= 130 )
                    {
                    if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )
                        {
                        pWindow.Hint = 0;
                        pWindow.uFrameWidth = 400;
                        pWindow.uFrameHeight = 200;
                        pWindow.uFrameX = 38;
                        pWindow.uFrameY = 60;
                        pAudioPlayer->StopChannels(-1, -1);
                        pWindow._41D73D_draw_buff_tooltip();
                        }
                    else if ( (signed int)pX < 485 || (signed int)pX > 548 || (signed int)pY < 156 || (signed int)pY > 229 )
                        {
                        if (!( (signed int)pX < 566 || (signed int)pX > 629 || (signed int)pY < 156 || (signed int)pY > 229 ))
                            {
                            pAudioPlayer->StopChannels(-1, -1);
                            v3 = (void *)1;
                            GameUI_DrawNPCPopup(v3);
                            }
                        }
                    else
                        {
                        pAudioPlayer->StopChannels(-1, -1);
                        v3 = 0;
                        GameUI_DrawNPCPopup(v3);
                        }
                    }
                else
                    {
                    pWindow.Hint = (char *)GameUI_GetMinimapHintText();
                    pWindow.uFrameWidth = 256;
                    pWindow.uFrameX = 130;
                    pWindow.uFrameY = 140;
                    pWindow.uFrameHeight = 64;
                    pAudioPlayer->StopChannels(-1, -1);
                    pWindow.DrawMessageBox(0);
                    }
                }
            else
                {
                pWindow.Hint = 0;
                pWindow.uFrameWidth = 320;
                pWindow.uFrameHeight = 320;
                v4 = pX - 350;
                if ( (signed int)pX <= 320 )
                    v4 = pX + 30;
                pWindow.uFrameX = v4;
                pWindow.uFrameY = 40;
                if ( pRenderer->pRenderD3D )
                    LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val();
                else
                    v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
                v6 = (unsigned __int16)v5;
                if (PID_TYPE(v6) != OBJECT_Item)
                    {
                    if (PID_TYPE(v6) == OBJECT_Actor)
                        {
                        if ( pRenderer->uNumSceneBegins )
                            {
                            pWindow.DrawMessageBox(1);
                            MonsterPopup_Draw(PID_ID(v6), &pWindow);
                            }
                        else
                            {
                            pRenderer->BeginScene();
                            pWindow.DrawMessageBox(1);
                            MonsterPopup_Draw(PID_ID(v6), &pWindow);
                            pRenderer->EndScene();
                            }
                        }
                    }
                else
                    {
                    v7 = PID_ID(v6);
                    if ( ! (pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 ) )
                        {
                        v8 = &pSpriteObjects[v7].stru_24;
                        GameUI_DrawItemInfo(v8);
                        }
                    }
                }
            break;
            }
        case SCREEN_BOOKS:
            {
            if ( !dword_506364
                || (signed int)pX < (signed int)pViewport->uViewportTL_X
                || (signed int)pX > (signed int)pViewport->uViewportBR_X
                || (signed int)pY < (signed int)pViewport->uViewportTL_Y
                || (signed int)pY > (signed int)pViewport->uViewportBR_Y
                || (v2 = (char *)sub_444564(), (pWindow.Hint = v2) == 0) )
                break;
            v30 = (double)(pFontArrus->GetLineWidth(v2) + 32);
            v27 = v30 + 6.7553994e15;
            v29 = (char *)LODWORD(v27);
            pWindow.uFrameWidth = LODWORD(v27);
            pWindow.uFrameX = pX + 5;
            pWindow.uFrameY = pY + 5;
            pWindow.uFrameHeight = 64;
            pAudioPlayer->StopChannels(-1, -1);
            pWindow.DrawMessageBox(0);
            break;
            }
        case SCREEN_CHARACTERS:
        case SCREEN_E:
        case SCREEN_CHEST_INVENTORY:
            {
            if ( (signed int)pX > 467 && pCurrentScreen != SCREEN_E )
                {
                OnInventoryItemRightClick();
                }
            else if ( (signed int)pY >= 345 )
                break;
            else if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 100 )//2DEvent - CharacerScreenStats
                {
                CharacterUI_StatsTab_ShowHint();
                }
            else if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 101 )//2DEvent - CharacerScreenSkills
                {
                CharacterUI_SkillsTab_ShowHint();
                }
            else
              {
                if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )//2DEvent - CharacerScreenInventory
                  OnInventoryItemRightClick();
              }
            break;
            }
        case SCREEN_SPELL_BOOK:
            {
            if ( dword_507B00_spell_info_to_draw_in_popup )
                DrawSpellDescriptionPopup(dword_507B00_spell_info_to_draw_in_popup - 1);
            break;
            }
        case SCREEN_HOUSE:
        {
          if ( (signed int)pY < 345 && (signed int)pX < 469 )
            ShowPopupShopItem();
          break;
        }
        case SCREEN_PARTY_CREATION:
            {
            pWindow.Hint = 0;
            pStr = 0;
            for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext)
                {
                if ( pButton->uButtonType == 1 && pButton->uButtonType != 3 && (signed int)pX > (signed int)pButton->uX && (signed int)pX < (signed int)pButton->uZ
                    && (signed int)pY > (signed int)pButton->uY && (signed int)pY < (signed int)pButton->uW )
                    {
                    switch ( pButton->msg )
                    {
                    case UIMSG_0: //stats info
                        pWindow.Hint = pAttributeDescriptions[(signed int)pButton->msg_param % 7];
                        pStr = aAttributeNames[(signed int)pButton->msg_param % 7];
                        break;
                    case UIMSG_PlayerCreationClickPlus: //Plus button info 
                        pStr = pGlobalTXT_LocalizationStrings[670];//Добавить
                        pWindow.Hint = pGlobalTXT_LocalizationStrings[671];//"Добавляет очко к выделенному навыку, забирая его из накопителя очков"
                        break;
                    case UIMSG_PlayerCreationClickMinus: //Minus button info
                        pStr = pGlobalTXT_LocalizationStrings[668];//Вычесть
                        pWindow.Hint = pGlobalTXT_LocalizationStrings[669];//"Вычитает очко из выделенного навыка, возвращая его в накопитель очков"
                        break;
                    case UIMSG_PlayerCreationSelectActiveSkill: //Available skill button info
                        v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pButton->msg_param + 4);
                        pStr = pSkillNames[v18];
                        pWindow.Hint = pSkillDesc[v18];
                        break;
                    case UIMSG_PlayerCreationSelectClass: //Available Class Info
                        pWindow.Hint = pClassDescriptions[pButton->msg_param];
                        pStr = pClassNames[pButton->msg_param];
                        break;
                    case UIMSG_PlayerCreationClickOK: //OK Info
                        pWindow.Hint = pGlobalTXT_LocalizationStrings[664];//Щелкните здесь для утверждения состава отряда и продолжения игры.
                        pStr = pGlobalTXT_LocalizationStrings[665];//Кнопка ОК
                        break;
                    case UIMSG_PlayerCreationClickReset: //Clear info
                        pWindow.Hint = pGlobalTXT_LocalizationStrings[666];//Сбрасывает все параметры и навыки отряда.
                        pStr = pGlobalTXT_LocalizationStrings[667];//Кнопка Очистить
                        break;
                    case UIMSG_PlayerCreation_SelectAttribute: // Character info
                        pStr = pParty->pPlayers[pButton->msg_param].pName;
                        pWindow.Hint = pClassDescriptions[pParty->pPlayers[pButton->msg_param].classType];
                        break;
                        }
                    if ( pButton->msg > UIMSG_44 && pButton->msg <= UIMSG_PlayerCreationRemoveDownSkill ) //Sellected skills info
                        {
                        pSkillId = pParty->pPlayers[pButton->msg_param].GetSkillIdxByOrder(pButton->msg - UIMSG_48);
                        pY = 0;
                        if ( (signed int)pSkillId < 37 )
                            {
                            pSkillInfo = CharacterUI_GetSkillDescText(pButton->msg_param, (PLAYER_SKILL_TYPE)pSkillId);
                            strcpy(pTmpBuf2.data(), pSkillInfo);
                            pWindow.Hint = pTmpBuf2.data();
                            pStr = pSkillNames[pSkillId];
                            }
                        }
                    }
                }
            if ( pWindow.Hint )
                {
                pHint = (char*)pWindow.Hint;
                pWindow.Hint = 0;
                pWindow.uFrameWidth = 384;
                pWindow.uFrameHeight = 256;
                pWindow.uFrameX = 128;
                pWindow.uFrameY = 40;
                pWindow.uFrameHeight = pFontSmallnum->CalcTextHeight(pHint, &pWindow, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
                pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
                pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
                pWindow.DrawMessageBox(0);
                pWindow.uFrameX += 12;
                pWindow.uFrameWidth -= 24;
                pWindow.uFrameY += 12;
                pWindow.uFrameHeight -= 12;
                pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
                pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
                pColor = TargetColor(0xFF, 0xFF, 0x9B);
                sprintf(pTmpBuf.data(), format_4E2D80, pColor, pStr);//"\f%05d%s\f00000\n"
                pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3);
                pWindow.DrawText(pFontSmallnum, 1, pFontLucida->uFontHeight, 0, pHint, 0, 0, 0);
                }
            break;
            }
        default:
            {
            break;
            }
            }
        dword_507BF0_is_there_popup_onscreen = 1;
        viewparams->bRedrawGameUI = 1;
        }