view UiGame.cpp @ 924:a78f08dbeb88

CastSpellInfo
author Ritor1
date Wed, 01 May 2013 14:50:52 +0600
parents 34ed2d5e7cfb
children b462b598b97a
line wrap: on
line source

#include <assert.h>

#include "MM7.h"

#include "MapInfo.h"
#include "Game.h"
#include "GUIWindow.h"
#include "GUIFont.h"
#include "GUIProgressBar.h"
#include "Party.h"
#include "AudioPlayer.h"
#include "Outdoor.h"
#include "IndoorCamera.h"
#include "Overlays.h"
#include "Monsters.h"
#include "Arcomage.h"
#include "LOD.h"
#include "Actor.h"
#include "Allocator.h"
#include "Events.h"
#include "Viewport.h"
#include "FrameTableInc.h"
#include "Math.h"
#include "SpriteObject.h"
#include "ObjectList.h"
#include "Chest.h"
#include "PaletteManager.h"
#include "DecorationList.h"
#include "PlayerFrameTable.h"
#include "SaveLoad.h"
#include "stru123.h"
#include "Time.h"
#include "IconFrameTable.h"
#include "Awards.h"
#include "Autonotes.h"
#include "stru160.h"
#include "stru279.h"
#include "TurnEngine.h"
#include "CastSpellInfo.h"
#include "Weather.h"
#include "stru272.h"
#include "stru298.h"
#include "StorylineTextTable.h"
#include "Events2D.h"
#include "texts.h"
#include "stru351.h"
#include "UIHouses.h"

#include "mm7_data.h"




//----- (0041AD6E) --------------------------------------------------------
void __cdecl GameUI_DrawRightPanelItems()
{
  if (GameUI_RightPanel_BookFlashTimer > pParty->uTimePlayed)
    GameUI_RightPanel_BookFlashTimer = 0;

  if (pParty->uTimePlayed - GameUI_RightPanel_BookFlashTimer > 128)
  {
    GameUI_RightPanel_BookFlashTimer = pParty->uTimePlayed;
    byte_50697C = byte_50697C == 0;
    if ( byte_50697C && pCurrentScreen != SCREEN_REST )
    {
      if ( bFlashQuestBook )
        pRenderer->DrawTextureTransparent(493, 355, pIcons_LOD->GetTexture(uTextureID_ib_td1_A));
      if ( bFlashAutonotesBook )
        pRenderer->DrawTextureTransparent(527, 353, pIcons_LOD->GetTexture(uTextureID_ib_td2_A));
      if ( bFlashHistoryBook )
        pRenderer->DrawTextureTransparent(600, 361, pIcons_LOD->GetTexture(uTextureID_ib_td5_A));
    }
    else
    {
      pRenderer->DrawTextureRGB(468u, 0, pTexture_RightFrame);
      DrawHiredNPCs();
    }
  }
}

//----- (0041AEBB) --------------------------------------------------------
void __cdecl GameUI_DrawFoodAndGold()
{
  int v2; // esi@2

  if ( uGameState != GAME_STATE_FINAL_WINDOW )
  {
    v2 = sub_44100D() != 0 ? 381 : 322;
    sprintf(pTmpBuf, "\r087%lu", pParty->uNumFoodRations);
    pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf, 0, 0, uGameUIFontShadow);
    sprintf(pTmpBuf, "\r028%lu", pParty->uNumGold);
    pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf, 0, 0, uGameUIFontShadow);
  }
}

//----- (0041AF52) --------------------------------------------------------
void Actor::DrawHealthBar(Actor *a1, GUIWindow *a2)
{
  unsigned int v2; // eax@1
  GUIWindow *v3; // edi@1
  unsigned int v4; // esi@1
  signed int v5; // ebx@4
  double v6; // st7@5
  unsigned int v7; // eax@6
  unsigned int v8; // ebx@10
  unsigned int v9; // [sp+14h] [bp-Ch]@4
  unsigned int v10; // [sp+1Ch] [bp-4h]@4

  v2 = a1->pMonsterInfo.uHP;
  v3 = a2;
  v4 = 25;
  if ( (signed int)v2 > 25 )
  {
    v4 = 200;
    if ( (signed int)v2 < 200 )
      v4 = a1->pMonsterInfo.uHP;
  }
  v5 = a1->sCurrentHP;
  v10 = v4;
  v9 = uTextureID_mhp_grn;
  if ( v5 < (signed int)v2 )
  {
    v6 = (double)(signed int)v2;
    v10 = (signed __int64)((double)(signed int)v4 / (double)(signed int)v2 * (double)a1->sCurrentHP);
    if ( v5 <= (signed int)(signed __int64)(0.34 * v6) )
    {
      v7 = uTextureID_mhp_red;
      v9 = v7;
    }
    else if ( v5 <= (signed int)(signed __int64)(v6 * 0.67) )
    {
      v7 = uTextureID_mhp_yel;
      v9 = v7;
    }
  }
  v8 = a2->uFrameX + (signed int)(a2->uFrameWidth - v4) / 2;
  pRenderer->SetTextureClipRect(v8, a2->uFrameY + 32, v8 + v4, a2->uFrameY + 52);
  pRenderer->DrawTextureIndexed(
    v8,
    v3->uFrameY + 32,
    (Texture *)(uTextureID_mhp_bd != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_bd] : 0));
  pRenderer->SetTextureClipRect(v8, v3->uFrameY + 32, v8 + v10, v3->uFrameY + 52);
  pRenderer->DrawTextureIndexed(
    v8,
    v3->uFrameY + 34,
    (Texture *)(v9 != -1 ? (int)&pIcons_LOD->pTextures[v9] : 0));
  pRenderer->ResetTextureClipRect();

  pRenderer->DrawTextureIndexed(
    v8 - 5,
    v3->uFrameY + 32,
    (Texture *)(uTextureID_mhp_capl != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capl] : 0));
  pRenderer->DrawTextureIndexed(
    v8 + v4,
    v3->uFrameY + 32,
    (Texture *)(uTextureID_mhp_capr != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capr] : 0));
}

//----- (0041B0C9) --------------------------------------------------------
void __cdecl GameUI_DrawLifeManaBars()
{
  Texture *v0; // ebx@1
  Player *v1; // ecx@2
  float v2; // ST38_4@3
  double v3; // st7@3
  signed __int64 v4; // qax@6
  Player *v5; // ecx@24
  float v6; // ST30_4@25
  double v7; // st7@25
  bool v8; // ST38_4@27
  Texture *v9; // [sp-4h] [bp-30h]@10
  Texture *v10; // [sp+Ch] [bp-20h]@1
  Player *v11; // [sp+10h] [bp-1Ch]@2
  int v12; // [sp+10h] [bp-1Ch]@24
  Texture *v13; // [sp+14h] [bp-18h]@1
  Texture *v14; // [sp+18h] [bp-14h]@1
  float v15; // [sp+1Ch] [bp-10h]@1
  signed int v16; // [sp+24h] [bp-8h]@1
  signed int v17; // [sp+28h] [bp-4h]@8

  v0 = (Texture *)(uTextureID_BarGreen != -1 ? &pIcons_LOD->pTextures[uTextureID_BarGreen] : 0);
  v14 = (Texture *)(uTextureID_BarYellow != -1 ? &pIcons_LOD->pTextures[uTextureID_BarYellow] : 0);
  v13 = (Texture *)(uTextureID_BarRed != -1 ? &pIcons_LOD->pTextures[uTextureID_BarRed] : 0);
  v16 = 0;
  v10 = (Texture *)(uTextureID_BarBlue != -1 ? &pIcons_LOD->pTextures[uTextureID_BarBlue] : 0);
  v15 = (double)(uTextureID_BarGreen != -1 ? pIcons_LOD->pTextures[uTextureID_BarGreen].uTextureHeight : 26);
  do
  {
    v1 = &pParty->pPlayers[v16];
    v11 = v1;
    if ( v1->sHealth > 0 )
	{
		v11 = &pParty->pPlayers[v16];
		v2 = (double)v1->sHealth;
		v3 = v2 / (double)v1->GetMaxHealth();
		if( v3 > 0.5 )
		{
		  if ( v3 > 1.0 )
			v3 = 1.0;
		  v4 = (signed __int64)((1.0 - v3) * v15);
		  if ( v16 == 2 || v16 == 3 )
			v17 = 2;
		  else
			v17 = 0;
		  pRenderer->SetTextureClipRect(
			v17 + pHealthBarPos[v16],
			v4 + 402,
			v17 + pHealthBarPos[v16] + v0->uTextureWidth,
			v0->uTextureHeight + 402);
		  v9 = v0;
		}
		else if ( v3 > 0.25 )
		{
			if ( v16 == 2 || v16 == 3 )
			  v17 = 2;
			else
			  v17 = 0;
			pRenderer->SetTextureClipRect(
			  v17 + pHealthBarPos[v16],
			  (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
			  v17 + pHealthBarPos[v16] + v14->uTextureWidth,
			  v14->uTextureHeight + 402);
			v9 = v14;
		}
		else if ( v3 > 0.0 )
		{
			if ( v16 == 2 || v16 == 3 )
				v17 = 2;
			else
				v17 = 0;
			pRenderer->SetTextureClipRect(
				v17 + pHealthBarPos[v16],
				(unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402,
				v17 + pHealthBarPos[v16] + v13->uTextureWidth,
				v13->uTextureHeight + 402);
			v9 = v13;
		}
		if( v3 > 0.0 )
		{
		  pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[v16], 0x192u, v9);
		  pRenderer->ResetTextureClipRect();
		}
	}
    v5 = v11;
    v12 = v11->sMana;
    if ( v12 > 0 )
    {
      v6 = (double)v12;
      v7 = v6 / (double)v5->GetMaxMana();
      if ( v7 > 1.0 )
        v7 = 1.0;
      v8 = v16 == 2;
      pRenderer->SetTextureClipRect(
        (v16 == 2) + pManaBarPos[v16],
        (unsigned __int64)(signed __int64)((1.0 - v7) * v15) + 402,
        v8 + pManaBarPos[v16] + v10->uTextureWidth,
        v10->uTextureHeight + 402);
      pRenderer->DrawTextureIndexed(v8 + pManaBarPos[v16], 0x192u, v10);
      pRenderer->ResetTextureClipRect();
    }
    ++v16;
  }
  while ( v16 < 4 );
}

//----- (0041B3B6) --------------------------------------------------------
void __cdecl draw_right_panel()
{
  pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0,
    (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
}

//----- (0041B3E2) --------------------------------------------------------
void __cdecl GameUI_DrawRightPanelFrames()
{
  pRenderer->DrawTextureRGB(0, 0, pTexture_TopFrame);
  pRenderer->DrawTextureRGB(0, 8u, pTexture_LeftFrame);
  pRenderer->DrawTextureRGB(468u, 0, pTexture_RightFrame);
  pRenderer->DrawTextureRGB(0, 352u, pTexture_BottomFrame);
  GameUI_DrawFoodAndGold();
  GameUI_DrawRightPanelItems();
}

//----- (0041B438) --------------------------------------------------------
GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey)
{
  char v1; // al@1
  int v2; // esi@1
  char v3; // dl@1
  GUIWindow *v4; // ecx@2
  GUIButton *result; // eax@2
  //int v6; // edx@12

  v1 = toupper(uHotkey);
  v2 = uNumVisibleWindows;
  v3 = v1;
  if ( uNumVisibleWindows >= 0 )
  {
    while ( 2 )
    {
      v4 = &pWindowList[pVisibleWindowsIdxs[v2] - 1];
      for ( result = v4->pControlsHead; result; result = result->pNext )
      {
        if ( result->uHotkey == v3 )
        {
          pMessageQueue_50CBD0->AddMessage(result->msg, result->msg_param, 0);
          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
          {
            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)result->uControlID;
            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6;
            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
            ++pMessageQueue_50CBD0->uNumMessages;
          }*/
          return result;
        }
      }
      if ( v4->uFrameX || v4->uFrameY || !(v4->uFrameWidth == 640 & v4->uFrameHeight == 480) )
      {
        --v2;
        if ( v2 >= 0 )
          continue;
      }
      break;
    }
  }
  return 0;
}
// 5075E0: using guessed type int pVisibleWindowsIdxs[20];

//----- (0041B4E1) --------------------------------------------------------
int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall)
{
  unsigned __int8 v3; // bl@1
  int result; // eax@1
  int i; // edx@2
  GUIButton *j; // ecx@3
  int k; // edx@7
  GUIButton *l; // ecx@8
  unsigned __int8 v9; // [sp+4h] [bp-8h]@1
  char v10; // [sp+8h] [bp-4h]@1

  v3 = uNewHotkey;
  v10 = toupper(uOldHotkey);
  result = toupper(v3);
  v9 = result;
  if ( bFirstCall )
  {
    for ( i = uNumVisibleWindows; i >= 0; --i )
    {
      result = 84 * pVisibleWindowsIdxs[i];
      //for ( j = *(GUIButton **)((char *)pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_ + result); j; j = j->pNext )
      for ( j = pWindowList[pVisibleWindowsIdxs[i] - 1].pControlsHead; j; j = j->pNext )
        j->field_28 = 0;
    }
  }
  for ( k = uNumVisibleWindows; k >= 0; --k )
  {
    result = 84 * pVisibleWindowsIdxs[k];
    //for ( l = *(GUIButton **)((char *)pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_ + result); l; l = l->pNext )
    for ( l = pWindowList[pVisibleWindowsIdxs[k] - 1].pControlsHead; l; l = l->pNext )
    {
      LOBYTE(result) = v10;
      if ( l->uHotkey == v10 )
      {
        if ( !l->field_28 )
        {
          LOBYTE(result) = v9;
          l->field_28 = 1;
          l->uHotkey = v9;
        }
      }
    }
  }
  return result;
}



//----- (0041C047) --------------------------------------------------------
void __cdecl GameUI_Footer_2()
    {
    unsigned int v0; // eax@1
    char *v1; // edx@2
    unsigned int v2; // ST18_4@5
    const char *v3; // ST0C_4@5
    unsigned int v4; // ST08_4@5
    int v5; // eax@5

    pRenderer->DrawTextureRGB(0, 352u, pTexture_StatusBar);
    if ( GameUI_Footer_TimeLeft )
        {
        v1 = GameUI_Footer_TimedString;
        }
    else
        {
        if ( !pFooterString[0] )
            return;
        v1 = pFooterString;
        }
    LOWORD(v0) = uGameUIFontShadow;
    v2 = v0;
    LOWORD(v0) = uGameUIFontMain;
    v3 = v1;
    v4 = v0;
    v5 = pFontLucida->AlignText_Center(0x1C2u, v1);
    pPrimaryWindow->DrawText(pFontLucida, v5 + 11, 357, v4, v3, 0, 0, v2);
    }

//----- (0041C0B8) --------------------------------------------------------
void __thiscall sub_41C0B8_set_status_string(const char *pStr)
    {
    const char *v1; // esi@1
    int i; // eax@7
    int j; // eax@11

    v1 = pStr;
    if ( pStr && strcmp(pStr, "test") && !IsBadStringPtrA(v1, 1u) && (*v1 || GameUI_Footer_TimeLeft) )
        {
        if ( GameUI_Footer_TimeLeft )
            {
            for ( i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString);
                i > 450;
                i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString) )
                byte_5C3427[strlen(GameUI_Footer_TimedString)] = 0;
            }
        else
            {
            strcpy(pFooterString, v1);
            for ( j = pFontLucida->GetLineWidth(pFooterString);
                j > 450;
                j = pFontLucida->GetLineWidth(pFooterString) )
                GameUI_Footer_TimedString[strlen(pFooterString) + 199] = 0;
            }
        }
    }

//----- (0041C179) --------------------------------------------------------
void GameUI_Footer()
{
    unsigned int v0; // ebp@1
    char *v1; // edi@5
    int v2; // eax@5
    unsigned int v3; // esi@5
    size_t v4; // eax@6
    GUIFont *v5; // ecx@6
    int v6; // eax@9
    size_t v7; // eax@10
    GUIFont *v8; // ecx@10
    char v9; // zf@12
    unsigned int v10; // ST08_4@13
    int v11; // eax@13

    v0 = uGameUIFontShadow;
    if ( pFooterString[0] || GameUI_Footer_TimeLeft || bForceDrawFooter )
        {
        pRenderer->DrawTextureRGB(0, 352u, pTexture_StatusBar);
        if ( GameUI_Footer_TimeLeft )
            {
            v1 = GameUI_Footer_TimedString;
            v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString);
            v3 = 450;
            while ( v2 > 450 )
                {
                v4 = strlen(GameUI_Footer_TimedString);
                v5 = pFontLucida;
                byte_5C3427[v4] = 0;
                v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString);
                }
            }
        else
            {
            v1 = pFooterString;
            v6 = pFontLucida->GetLineWidth(pFooterString);
            v3 = 450;
            while ( v6 > 450 )
                {
                v7 = strlen(pFooterString);
                v8 = pFontLucida;
                GameUI_Footer_TimedString[v7 + 199] = 0;
                v6 = pFontLucida->GetLineWidth(pFooterString);
                }
            }
        v9 = *v1 == 0;
        bForceDrawFooter = 0;
        if ( !v9 )
            {
            v10 = uGameUIFontMain;
            v11 = pFontLucida->AlignText_Center(v3, v1);
            pPrimaryWindow->DrawText(pFontLucida, v11 + 11, 357, v10, v1, 0, 0, v0);
            }
        }
    }
// 5C35BC: using guessed type int bForceDrawFooter;


//----- (00420EFF) --------------------------------------------------------
void __cdecl GameUI_WritePointedObjectStatusString()
{
  int v1; // ebx@6
  GUIWindow *pWindow; // edi@7
  GUIButton *pButton; // ecx@11
  Player *pPlayer; // eax@19
  char v5; // cl@19
  unsigned int v6; // eax@19
  int v7; // ecx@19
  __int16 v8; // fps@23
  unsigned __int8 v9; // c0@23
  unsigned __int8 v10; // c3@23
  enum UIMessageType pMessageType1; // esi@24
  //int v12; // edx@25
  char *v13; // ecx@28
  int v14; // eax@41
  ItemGen *pItemGen; // ecx@44
  int v16; // ecx@46
  const char *v17; // eax@49
  signed int v18; // eax@55
  signed int v18b;
  signed int v19; // ecx@63
  BLVFace *pFace; // eax@69
  __int16 v21; // ax@70
  const char *v22; // eax@72
  LevelDecoration *v23; // ecx@75
  LevelDecoration *v24; // esi@75
  __int16 v25; // ax@75
  const char *v26; // ecx@79
  Actor *pActor; // ecx@82
  char *v28; // esi@82
  int v29; // eax@82
  signed int v30; // ecx@88
  const char *v31; // eax@91
  __int16 v32; // fps@109
  //unsigned __int8 v33; // c0@109
  //unsigned __int8 v34; // c3@109
  enum UIMessageType pMessageType2; // esi@110
  //int v36; // edx@111
  enum UIMessageType pMessageType3; // edx@117
  //int v38; // ecx@118
  const char *v39; // [sp-8h] [bp-E8h]@20
  char *v40; // [sp-8h] [bp-E8h]@83
  int v41; // [sp-4h] [bp-E4h]@20
  char Str1[200]; // [sp+Ch] [bp-D4h]@129
  unsigned int pX; // [sp+D4h] [bp-Ch]@1
  unsigned int pY; // [sp+D8h] [bp-8h]@1
  unsigned int v45; // [sp+DCh] [bp-4h]@21

  v13 = nullptr;

  pMouse->uPointingObjectID = 0;
  pMouse->GetClickPos(&pX, &pY);
  if ( pX < 0 || (signed int)pX > 639 || pY < 0 || (signed int)pY > 479 )//( (pX & 0x80000000u) != 0 || (signed int)pX > 639 || (pY & 0x80000000u) != 0 || (signed int)pY > 479 )
    return;
  if (pCurrentScreen == SCREEN_GAME)
  {
    if ( (signed int)pX > 467 || (signed int)pY > 351 )
      goto _click_on_game_ui;
    if ( pRenderer->pRenderD3D )  // inlined mm8::4C1E01
    {
      v18 = pGame->pVisInstance->get_picked_object_zbuf_val();
      if ( (signed int)pX < (signed int)pViewport->uScreen_TL_X
        || (signed int)pX > (signed int)pViewport->uScreen_BR_X
        || (signed int)pY < (signed int)pViewport->uScreen_TL_Y
        || (signed int)pY > (signed int)pViewport->uScreen_BR_Y )
        v18 = -1;
      if ( v18 == -1 )
        //goto LABEL_61;
      {
        pMouse->uPointingObjectID = 0;
        if ( pMouse->uPointingObjectID == 0 )
        {
          if ( uLastPointedObjectID != 0 )
          {
            pFooterString[0] = 0;
            bForceDrawFooter = 1;
          }
        }
        uLastPointedObjectID = pMouse->uPointingObjectID;
        return;
      }
    }
    else
    {
      v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
    }
    pMouse->uPointingObjectID = (unsigned __int16)v18;
    v19 = (signed)PID_ID(v18);
    if (PID_TYPE(v18) == OBJECT_Item)
    {
      v30 = v19;
      if ( pObjectList->pObjects[pSpriteObjects[v30].uObjectDescID].uFlags & 0x10 )
        //goto LABEL_73;
      {
        pMouse->uPointingObjectID = 0;
        //goto LABEL_50;
        uLastPointedObjectID = 1;
        if ( pMouse->uPointingObjectID == 0 )
        {
          if ( uLastPointedObjectID != 0 )
          {
            pFooterString[0] = 0;
            bForceDrawFooter = 1;
          }
        }
        uLastPointedObjectID = pMouse->uPointingObjectID;
        return;
      }
      if ( v18 >= (signed int)0x2000000u || pParty->pPickedItem.uItemID )
      {
        v22 = pSpriteObjects[v30].stru_24.GetDisplayName();
//LABEL_93:
        v26 = v22;
        //goto LABEL_87;
        sub_41C0B8_set_status_string(v26);
        if ( pMouse->uPointingObjectID == 0 )
        {
          if ( uLastPointedObjectID != 0 )
          {
            pFooterString[0] = 0;
            bForceDrawFooter = 1;
          }
        }
        uLastPointedObjectID = pMouse->uPointingObjectID;
        return;
      }
      v31 = pSpriteObjects[v30].stru_24.GetDisplayName();
      v28 = pTmpBuf;
      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s"
    }
    else
    {
      if (PID_TYPE(v18) != OBJECT_Actor)
      {
        if (PID_TYPE(v18) == OBJECT_Decoration)
        {
          v23 = &pLevelDecorations[v19];
          v24 = v23;
          v25 = v23->field_16_event_id;
          if ( !v25 )
          {
            if ( v23->IsInteractive() )
              v26 = pNPCTopics[stru_5E4C90._decor_events[v24->_idx_in_stru123 - 75] + 379].pTopic;
            else
              v26 = pDecorationList->pDecorations[v24->uDecorationDescID].field_20;
            //goto LABEL_87;
            sub_41C0B8_set_status_string(v26);
            if ( pMouse->uPointingObjectID == 0 )
            {
              if ( uLastPointedObjectID != 0 )
              {
                pFooterString[0] = 0;
                bForceDrawFooter = 1;
              }
            }
            uLastPointedObjectID = pMouse->uPointingObjectID;
            return;
          }
          v22 = GetEventHintString(v25);
          if ( !v22 )
            //goto _return;
          {
            if ( pMouse->uPointingObjectID == 0 )
            {
              if ( uLastPointedObjectID != 0 )
              {
                pFooterString[0] = 0;
                bForceDrawFooter = 1;
              }
            }
            uLastPointedObjectID = pMouse->uPointingObjectID;
            return;
          }
          //goto LABEL_93;
          v26 = v22;
          //goto LABEL_87;
          sub_41C0B8_set_status_string(v26);
          if ( pMouse->uPointingObjectID == 0 )
          {
            if ( uLastPointedObjectID != 0 )
            {
              pFooterString[0] = 0;
              bForceDrawFooter = 1;
            }
          }
          uLastPointedObjectID = pMouse->uPointingObjectID;
          return;
        }
        if (PID_TYPE(v18) == OBJECT_BModel)
        {
          if ( v18 < (signed int)0x2000000u )
          {
            if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
            {
			  v18b = (signed int)(unsigned __int16)v18 >> 9;
              v21 = pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID;
              //goto LABEL_71;
              if ( !v21 || (v22 = GetEventHintString(v21)) == 0 )
                //goto LABEL_73;
              {
                pMouse->uPointingObjectID = 0;
                //goto LABEL_50;
                uLastPointedObjectID = 1;
                if ( pMouse->uPointingObjectID == 0 )
                {
                  if ( uLastPointedObjectID != 0 )
                  {
                    pFooterString[0] = 0;
                    bForceDrawFooter = 1;
                  }
                }
                uLastPointedObjectID = pMouse->uPointingObjectID;
                return;
              }
              //goto LABEL_93;
              v26 = v22;
              //goto LABEL_87;
              sub_41C0B8_set_status_string(v26);
              if ( pMouse->uPointingObjectID == 0 )
              {
                if ( uLastPointedObjectID != 0 )
                {
                  pFooterString[0] = 0;
                  bForceDrawFooter = 1;
                }
              }
              uLastPointedObjectID = pMouse->uPointingObjectID;
              return;
            }
            pFace = &pIndoor->pFaces[v19];
            if ( BYTE3(pFace->uAttributes) & 6 )
            {
              v21 = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
//LABEL_71:
              if ( !v21 || (v22 = GetEventHintString(v21)) == 0 )
                //goto LABEL_73;
              {
                pMouse->uPointingObjectID = 0;
                //goto LABEL_50;
                uLastPointedObjectID = 1;
                if ( pMouse->uPointingObjectID == 0 )
                {
                  if ( uLastPointedObjectID != 0 )
                  {
                    pFooterString[0] = 0;
                    bForceDrawFooter = 1;
                  }
                }
                uLastPointedObjectID = pMouse->uPointingObjectID;
                return;
              }
              //goto LABEL_93;
              v26 = v22;
              //goto LABEL_87;
              sub_41C0B8_set_status_string(v26);
              if ( pMouse->uPointingObjectID == 0 )
              {
                if ( uLastPointedObjectID != 0 )
                {
                  pFooterString[0] = 0;
                  bForceDrawFooter = 1;
                }
              }
              uLastPointedObjectID = pMouse->uPointingObjectID;
              return;
            }
          }
//LABEL_73:
          pMouse->uPointingObjectID = 0;
          //goto LABEL_50;
          uLastPointedObjectID = 1;
          if ( pMouse->uPointingObjectID == 0 )
          {
            if ( uLastPointedObjectID != 0 )
            {
              pFooterString[0] = 0;
              bForceDrawFooter = 1;
            }
          }
          uLastPointedObjectID = pMouse->uPointingObjectID;
          return;
        }
//LABEL_61:
        pMouse->uPointingObjectID = 0;
        //goto _return;
        if ( pMouse->uPointingObjectID == 0 )
        {
          if ( uLastPointedObjectID != 0 )
          {
            pFooterString[0] = 0;
            bForceDrawFooter = 1;
          }
        }
        uLastPointedObjectID = pMouse->uPointingObjectID;
        return;
      }
      if ( v18 >= 335544320 )
        //goto LABEL_61;
      {
        pMouse->uPointingObjectID = 0;
        if ( pMouse->uPointingObjectID == 0 )
        {
          if ( uLastPointedObjectID != 0 )
          {
            pFooterString[0] = 0;
            bForceDrawFooter = 1;
          }
        }
        uLastPointedObjectID = pMouse->uPointingObjectID;
        return;
      }
      pActor = &pActors[v19];
      v28 = pTmpBuf;
      v29 = pActor->dword_000334_unique_name;
      if ( v29 )
        v40 = pMonsterStats->pPlaceStrings[v29];
      else
        v40 = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].pName;
      strncpy(pTmpBuf, v40, 0x7D0u);
    }
    v26 = v28;
//LABEL_87:
    sub_41C0B8_set_status_string(v26);
    //goto _return;
    if ( pMouse->uPointingObjectID == 0 )
    {
      if ( uLastPointedObjectID != 0 )
      {
        pFooterString[0] = 0;
        bForceDrawFooter = 1;
      }
    }
    uLastPointedObjectID = pMouse->uPointingObjectID;
    return;
  }
  v1 = uNumVisibleWindows;
  if ( uNumVisibleWindows > 0 )
  {
	  while ( 1 )                                   // some other fullscreen ui
	  {
		pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1];
		if ( (signed int)pX >= (signed int)pWindow->uFrameX
		  && (signed int)pX <= (signed int)pWindow->uFrameZ
		  && (signed int)pY >= (signed int)pWindow->uFrameY
		  && (signed int)pY <= (signed int)pWindow->uFrameW )
		{
		  for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext )
		  {
			if ( !pButton )
			  break;
			if ( pButton->uButtonType == 1 )
			{
			  if ( (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 )
			  {
	//LABEL_24:
				pMessageType1 = (UIMessageType)pButton->field_1C;
				if ( pMessageType1 )
				{
				  pMessageQueue_50CBD0->AddMessage(pMessageType1, pButton->msg_param, 0);
				}
	//LABEL_28:
				v13 = pButton->pButtonName;
	//_set_status_and_ret:
				sub_41C0B8_set_status_string(v13);
	//LABEL_131:
				uLastPointedObjectID = 1;
				return;
			  }
			}
			else
			{
			  if ( pButton->uButtonType == 2 )
			  {
				v45 = pX - pButton->uX;
				v45 = pY - pButton->uY;
				if ( (double)(signed int)pButton->uWidth != 0.0 )
				{
				  if ( (double)(signed int)pButton->uHeight != 0.0 )
				  {
					  pMessageType1 = (UIMessageType)pButton->field_1C;
					  if ( pMessageType1 )
					  {
						pMessageQueue_50CBD0->AddMessage(pMessageType1, pButton->msg_param, 0);
					  }
					  v13 = pButton->pButtonName;
					  sub_41C0B8_set_status_string(v13);
					  uLastPointedObjectID = 1;
					  return;
					//}
				  }
				}
			  }
			  else                                  // click on skill
			  {
				if ( 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 )
				{
	//LABEL_19:
				  pPlayer = pPlayers[uActiveCharacter];
				  v5 = LOBYTE(pPlayer->pActiveSkills[pButton->msg_param]);
				  v6 = pPlayer->uSkillPoints;
				  v7 = (v5 & 0x3F) + 1;
				  if ( v6 < v7 )
				  {
					v41 = v7 - v6;
					v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here"
				  }
				  else
				  {
					v41 = v7;
					v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points"
				  }
				  sprintf(Str1, v39, v41);
				  v13 = Str1;
				  //goto _set_status_and_ret;
				  sub_41C0B8_set_status_string(v13);
				  uLastPointedObjectID = 1;
				  return;
				}
			  }
			}
		  }
		}
		if ( pWindow->uFrameHeight == 480 )
		  break;
		--v1;
		if ( v1 <= 0 )
		{
		  break;
		}
	  }
  }
  if ( uNumVisibleWindows <= 0 || (uNumVisibleWindows > 0 && pWindow->uFrameHeight != 480 && v1 <= 0))
  {
    if ( pCurrentScreen == SCREEN_CHEST )
    {
      sub_42038D();
      //goto _return;
      if ( pMouse->uPointingObjectID == 0 )
      {
        if ( uLastPointedObjectID != 0 )
        {
          pFooterString[0] = 0;
          bForceDrawFooter = 1;
        }
      }
      uLastPointedObjectID = pMouse->uPointingObjectID;
      return;
    }
    if ( pCurrentScreen == SCREEN_HOUSE )
    {
      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD
        || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0)
        || v16 == -65536 )
        //goto _return;
      {
        if ( pMouse->uPointingObjectID == 0 )
        {
          if ( uLastPointedObjectID != 0 )
          {
            pFooterString[0] = 0;
            bForceDrawFooter = 1;
          }
        }
        uLastPointedObjectID = pMouse->uPointingObjectID;
        return;
       }
      pItemGen = (ItemGen *)((char *)&pParty->pPickedItem + 36 * (v16 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 4);
//LABEL_49:
      v17 = pItemGen->GetDisplayName();
      sub_41C0B8_set_status_string(v17);
//LABEL_50:
      uLastPointedObjectID = 1;
//_return:
      if ( pMouse->uPointingObjectID == 0 )
      {
        if ( uLastPointedObjectID != 0 )
        {
          pFooterString[0] = 0;
          bForceDrawFooter = 1;
        }
      }
      uLastPointedObjectID = pMouse->uPointingObjectID;
      return;
    }
    if ( (signed int)pY < 350 )
    {
      v14 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
      if ( v14 == 0 || v14 == -65536 || (unsigned int)v14 >= 0x1388 )
        //goto _return;
      {
        if ( pMouse->uPointingObjectID == 0 )
        {
          if ( uLastPointedObjectID != 0 )
          {
            pFooterString[0] = 0;
            bForceDrawFooter = 1;
          }
        }
        uLastPointedObjectID = pMouse->uPointingObjectID;
        return;
      }
      pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v14-1];
      //goto LABEL_49;
      v17 = pItemGen->GetDisplayName();
      sub_41C0B8_set_status_string(v17);
      uLastPointedObjectID = 1;
      if ( pMouse->uPointingObjectID == 0 )
      {
        if ( uLastPointedObjectID != 0 )
        {
          pFooterString[0] = 0;
          bForceDrawFooter = 1;
        }
      }
      uLastPointedObjectID = pMouse->uPointingObjectID;
      return;
    }
_click_on_game_ui:
    if ( (signed int)pX >= (signed int)pWindowList[0].uFrameX
      && (signed int)pX <= (signed int)pWindowList[0].uFrameZ
      && (signed int)pY >= (signed int)pWindowList[0].uFrameY
      && (signed int)pY <= (signed int)pWindowList[0].uFrameW )
    {
      for ( pButton = pWindowList[0].pControlsHead; pButton != (GUIButton *)0; pButton = pButton->pNext )
      {
        if ( pButton->uButtonType == 1 )
        {
          if ( (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 )
          {
            pMessageType3 = (UIMessageType)pButton->field_1C;
            if ( pMessageType3 == 0 ) // For books
              //goto LABEL_28;
            {
              v13 = pButton->pButtonName;
              sub_41C0B8_set_status_string(v13);
              uLastPointedObjectID = 1;
              return;
            }

            pMessageQueue_50CBD0->AddMessage(pMessageType3, pButton->msg_param, 0);
            //goto LABEL_131;
            uLastPointedObjectID = 1;
            return;
          }
        }
        else
        {
          if ( pButton->uButtonType == 2 )
          {
            v45 = pX - pButton->uX;
            v45 = pY - pButton->uY;

            if (pX >= pButton->uX && pX <= pButton->uZ &&
                pY >= pButton->uY && pY <= pButton->uW)
            if ( (double)(signed int)pButton->uWidth != 0.0 )
            {
              if ( (double)(signed int)pButton->uHeight != 0.0 )
              {
                 //UNDEF(v32);
                //if ( v33 | v34 )
                //{
                  pMessageType2 = (UIMessageType)pButton->field_1C;
                  if ( pMessageType2 != 0 )
                      pMessageQueue_50CBD0->AddMessage(pMessageType2, pButton->msg_param, 0);

                  //goto LABEL_28;
                  v13 = pButton->pButtonName;
                  sub_41C0B8_set_status_string(v13);
                  uLastPointedObjectID = 1;
                  return;
                //}
              }
            }
          }
          else
          {
            if ( 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 )
              //goto LABEL_19;
            {
              pPlayer = pPlayers[uActiveCharacter];
              v5 = LOBYTE(pPlayer->pActiveSkills[pButton->msg_param]);
              v6 = pPlayer->uSkillPoints;
              v7 = (v5 & 0x3F) + 1;
              if ( v6 < v7 )
              {
                v41 = v7 - v6;
                v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here"
              }
              else
              {
                v41 = v7;
                v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points"
              }
              sprintf(Str1, v39, v41);
              v13 = Str1;
              //goto _set_status_and_ret;
              sub_41C0B8_set_status_string(v13);
              uLastPointedObjectID = 1;
              return;
            }
          }
        }
      }
    }
    pMouse->uPointingObjectID = sub_46A99B();
    //goto _return;
    if ( pMouse->uPointingObjectID == 0 )
    {
      if ( uLastPointedObjectID != 0 )
      {
        pFooterString[0] = 0;
        bForceDrawFooter = 1;
      }
    }
    uLastPointedObjectID = pMouse->uPointingObjectID;
    return;
  }
}


//----- (0044158F) --------------------------------------------------------
void __cdecl GameUI_DrawCharacterSelectionFrame()
{
  if ( uActiveCharacter )
    pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[uActiveCharacter - 1] - 9,
        380, &pIcons_LOD->pTextures[dword_50C98C]);
}

//----- (004415C5) --------------------------------------------------------
void LoadPartyBuffIcons()
    {
    for (uint i = 0; i < 14; ++i)
        {
        char filename[200];
        sprintf(filename, "isn-%02d", i + 1);
        pTextureIDs_PartyBuffIcons[i] = pIcons_LOD->LoadTexture(filename, TEXTURE_16BIT_PALETTE);
        }

    uIconIdx_FlySpell = pIconsFrameTable->FindIcon("spell21");
    uIconIdx_WaterWalk = pIconsFrameTable->FindIcon("spell27");
    }

//----- (0044162D) --------------------------------------------------------
void __cdecl GameUI_DrawPartySpells()
    {
    unsigned int v0; // ebp@1
    //signed int v1; // edi@1
    //int v2; // eax@2
    //int v3; // ecx@5
    //__int16 *v4; // ebx@25
    //Player *v5; // edi@26
    //unsigned int v6; // [sp-4h] [bp-1Ch]@11
    Texture *v7; // [sp-4h] [bp-1Ch]@12
    //unsigned int v8; // [sp-4h] [bp-1Ch]@20
    Texture *v9; // [sp-4h] [bp-1Ch]@21
    //Player **v10; // [sp+10h] [bp-8h]@25

    v0 = (signed __int64)((double)GetTickCount() * 0.050000001);
    //v1 = 0;
    for (uint i = 0; i < 14; ++i)
        {
        //v2 =  byte_4E5DD8[v1];
        if (pParty->pPartyBuffs[byte_4E5DD8[i]].uExpireTime)
            {
            auto tex = pIcons_LOD->GetTexture(pTextureIDs_PartyBuffIcons[i]);
            //v3 = pTextureIDs_PartyBuffIcons[i];
            if (tex)
                pRenderer->_4A65CC(pPartySpellbuffsUI_XYs[i][0],
                pPartySpellbuffsUI_XYs[i][1], tex, tex,
                v0 + 20 * pPartySpellbuffsUI_smthns[i], 0, 63);
            }
        //++v1;
        }
    //while ( v1 < 14 );

    if (pCurrentScreen == SCREEN_GAME || pCurrentScreen == SCREEN_NPC_DIALOGUE)
        {
        if (pParty->FlyActive())
            {
            if ( pParty->bFlying )
                v7 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_FlySpell, v0)->uTextureID];
            else
                v7 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_FlySpell, 0)->uTextureID];
            if ( pRenderer->pRenderD3D )
                pRenderer->DrawTextureIndexed(8u, 8u, v7);
            else
                pRenderer->DrawTextureTransparent(8u, 8u, v7);
            }
        if (pParty->WaterWalkActive())
            {
            if ( pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER)
                v9 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, v0)->uTextureID];
            else
                v9 = &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, 0)->uTextureID];
            if ( pRenderer->pRenderD3D )
                pRenderer->DrawTextureIndexed(396u, 8u, v9);
            else
                pRenderer->DrawTextureTransparent(396u, 8u, v9);
            }
        }

    for (uint i = 0; i < 4; ++i)
        {
        auto player = pParty->pPlayers + i;

        if (player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime)
            pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 427, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Hammerhands));
        if (player->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime)
            pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 393, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Bless));
        if (player->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime)
            pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 410, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Preservation));
        if (player->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime)
            pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 444, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_PainReflection));
        }
    }


//----- (00421626) --------------------------------------------------------
GUIWindow *GameUI_InitializeCharacterWindow(unsigned int _this)
{
  unsigned int v1; // edi@1
  GUIWindow *pWindow; // edi@3

  ++pIcons_LOD->uTexturePacksCount;
  v1 = _this;
  if ( !pIcons_LOD->uNumPrevLoadedFiles )
    pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
  pEventTimer->Pause();
  pAudioPlayer->StopChannels(-1, -1);
  bRingsShownInCharScreen = 0;
  CharacterUI_LoadPaperdollTextures();
  pCurrentScreen = v1;
  pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
  pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308,
                                (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureWidth : 24),
                                (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureHeight : 26),
                                1, 0, UIMSG_73, 0, 0x53u, pGlobalTXT_LocalizationStrings[216],// Stats
                                (Texture *)(papredoll_dbrds[10] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[10]] : 0),
                                papredoll_dbrds[9] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[9]] : 0, 0);
  pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308,
                                 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureWidth : 24),
                                 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureHeight : 26),
                                 1, 0, UIMSG_72, 0, 0x4Bu, pGlobalTXT_LocalizationStrings[205],//Skills
                                 (Texture *)(papredoll_dbrds[8] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[8]] : 0),
                                 papredoll_dbrds[7] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[7]] : 0, 0);
  pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308,
                                    (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureWidth : 24),
                                    (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureHeight : 26),
                                    1, 0, UIMSG_74, 0, 0x49u, pGlobalTXT_LocalizationStrings[120], //Inventory
                                    (Texture *)(papredoll_dbrds[6] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[6]] : 0),
                                    papredoll_dbrds[5] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[5]] : 0, 0);
  pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308,
                                 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureWidth : 24),
                                 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureHeight : 26),
                                 1, 0, UIMSG_75, 0, 0x41u, pGlobalTXT_LocalizationStrings[22], //Awards
                                 (Texture *)(papredoll_dbrds[4] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[4]] : 0),
                                 papredoll_dbrds[3] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[3]] : 0, 0);
  pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308,
                 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureWidth : 24),
                 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureHeight : 26),
                 1, 0, UIMSG_A8, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
                 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0, 0);
  pWindow->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
  pCharacterScreen_DetalizBtn = pWindow->CreateButton(0x258u, 0x12Cu, 0x1Eu, 0x1Eu, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0);
  pCharacterScreen_DollBtn = pWindow->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
  pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
  pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
  pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
  pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
  pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
  FillAwardsData();
  return pWindow;
}


//----- (004921C1) --------------------------------------------------------
void GameUI_DrawPortraits(unsigned int _this)
{
    Texture *pFace; // eax@10
    unsigned int v7; // eax@17
    PlayerFrame *pFrame; // eax@21
    unsigned int v9; // eax@27
    bool v10; // eax@33
    bool v11; // edi@40
    bool v12; // edx@43
    bool v13; // ecx@46
    int v16; // eax@57
    int v19; // eax@62
    Texture *pPortrait; // [sp-4h] [bp-1Ch]@27
    unsigned int v22; // [sp+14h] [bp-4h]@1

    v22 = _this;
    if ( qword_A750D8 )
        {
        qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed;
        if ( qword_A750D8 <= 0 )
            {
            if ( pPlayers[word_A750E2]->CanAct() )
                pPlayers[word_A750E2]->PlaySound((PlayerSpeech)word_A750E0, 0);
            qword_A750D8 = 0i64;
            }
        }

    for (uint i = 0; i < 4; ++i)
        {
        auto pPlayer = pParty->pPlayers + i;

        if (pPlayer->Eradicated())
            {
            pFace = pTexture_PlayerFaceEradicated;
            pPortrait = pFace;
            v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
            if ( pParty->pPartyBuffs[11].uExpireTime )
                pRenderer->_4A6E7E(v9, 0x183u, pPortrait);
            else
                pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait);
            auto _v1 = 0;
            v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
            if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
                _v1 = 1;
            v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
            v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
            v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
            if ( v13 | v12 | v11 | _v1 | v10 )
                sub_441A4E(i);
            continue;
            }
        if (pPlayer->Dead())
            {
            pFace = pTexture_PlayerFaceDead;
            pPortrait = pFace;
            v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
            if ( pParty->pPartyBuffs[11].uExpireTime )
                pRenderer->_4A6E7E(v9, 0x183u, pPortrait);
            else
                pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait);
            auto _v1 = 0;
            v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
            if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
                _v1 = 1;
            v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
            v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
            v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
            if ( v13 | v12 | v11 | _v1 | v10 )
                sub_441A4E(i);
            continue;
            }
        v7 = 0;
        for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
            if (pPlayerFrameTable->pFrames[j].expression == pPlayer->expression)
                {
                v7 = j;
                break;
                }
            if ( v7 == 0 )
                v7 = 1;
            if (pPlayer->expression == CHARACTER_EXPRESSION_21)
                pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed);
            else
                pFrame = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed);
            if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || v22 )
                {
                pPlayer->field_1AA2 = pFrame->uTextureID - 1;
                pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID];
                pPortrait = pFace;
                v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
                if ( pParty->pPartyBuffs[11].uExpireTime )
                    pRenderer->_4A6E7E(v9, 0x183u, pPortrait);
                else
                    pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait);
                auto _v1 = 0;
                v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
                if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
                    _v1 = 1;
                v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
                v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
                v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
                if ( v13 | v12 | v11 | _v1 | v10 )
                    sub_441A4E(i);
                continue;
                }
        }
    if ( pParty->bTurnBasedModeOn == 1 )
        {
        if ( pTurnEngine->field_4 != 1 )
            {
            if (PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player)
                {
                //v14 = 0;
                if ( pTurnEngine->uActorQueueSize > 0 )
                    {
                    //v15 = (char *)pTurnEngine->pQueue;
                    for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i)
                        {
                        auto pElem = pTurnEngine->pQueue + i;

                        if (PID_TYPE(pElem->uPackedID) != OBJECT_Player)
                            break;
                        v16 = dword_5079D0;
                        if ( pParty->uFlags & 0x10 )
                            {
                            v16 = dword_5079CC;
                            }
                        else
                            {
                            if ( pParty->uFlags & 0x20 )
                                v16 = dword_5079C8;
                            }
                        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4,
                            0x181u, (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
                        }
                    }
                }
            }
        }
    else
        {
        for (uint i = 0; i < 4; ++i)
            {
            auto pPlayer = pParty->pPlayers + i;
            if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery)
                {
                v19 = dword_5079D0;
                if ( pParty->uFlags & 0x10 )
                    {
                    v19 = dword_5079CC;
                    }
                else
                    {
                    if ( pParty->uFlags & 0x20 )
                        v19 = dword_5079C8;
                    }
                pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
                    0x181u, (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
                }
            }
        }
    }

//----- (00441D38) --------------------------------------------------------
void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap)
{
  int uHeight; // ebx@6
  __int16 v11; // cx@11
  unsigned int v14; // ebx@23
  int v15; // eax@23
  __int16 v17; // di@30
  double v18; // st7@30
  float v19; // ST38_4@30
  double v20; // st7@30
  double v21; // st6@30
  double v22; // st5@33
  signed int v27; // eax@37
  unsigned __int16 *v28; // ecx@37
  signed int v29; // edi@40
  //signed int v33; // ebx@50
  //unsigned int v34; // eax@50
  //signed int v35; // ecx@50
  //unsigned __int16 v36; // di@66
  int v37; // edi@72
  int v38; // ebx@72
  __int16 v39; // ax@87
  int v40; // edi@91
  int v41; // ebx@91
  unsigned int v42; // eax@101
  unsigned int v43; // ebx@101
  unsigned int v44; // ST30_4@101
  char *v45; // ebx@106
  int v46; // edi@108
  int v47; // eax@108
  unsigned int v48; // ebx@114
  unsigned int v49; // ST64_4@114
  //unsigned int v51; // [sp-10h] [bp-64h]@79
  unsigned int v52; // [sp-10h] [bp-64h]@100
  //unsigned int v53; // [sp-Ch] [bp-60h]@79
  unsigned int v54; // [sp-Ch] [bp-60h]@100
  //unsigned int v55; // [sp-8h] [bp-5Ch]@77
  unsigned int v56; // [sp-8h] [bp-5Ch]@100
  //signed int v57; // [sp-4h] [bp-58h]@54
  //unsigned __int16 v58; // [sp-4h] [bp-58h]@77
  unsigned __int16 v59; // [sp-4h] [bp-58h]@100
  unsigned __int16 v60; // [sp+10h] [bp-44h]@66
  unsigned int v61; // [sp+10h] [bp-44h]@85
  unsigned int v63; // [sp+14h] [bp-40h]@85
  unsigned int v65; // [sp+18h] [bp-3Ch]@85
  unsigned int lPitch; // [sp+20h] [bp-34h]@1
  unsigned int lPitcha; // [sp+20h] [bp-34h]@23
  char *lPitchb; // [sp+20h] [bp-34h]@106
  unsigned int v69; // [sp+24h] [bp-30h]@23
  signed int v70; // [sp+24h] [bp-30h]@37
  unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1
  signed int uBluea; // [sp+28h] [bp-2Ch]@37
  int v73; // [sp+2Ch] [bp-28h]@30
  int v76; // [sp+34h] [bp-20h]@91
  int v77; // [sp+34h] [bp-20h]@108
  //int v79; // [sp+38h] [bp-1Ch]@72
  //char *a2c; // [sp+40h] [bp-14h]@68
  signed int uCenterY; // [sp+48h] [bp-Ch]@1
  signed int uCenterX; // [sp+4Ch] [bp-8h]@1
  signed int uWidth; // [sp+5Ch] [bp+8h]@30
  //signed int uZe; // [sp+5Ch] [bp+8h]@67
  signed int uZf; // [sp+5Ch] [bp+8h]@85
  signed int uZg; // [sp+5Ch] [bp+8h]@105
  unsigned int uWa; // [sp+60h] [bp+Ch]@23
  float uWb; // [sp+60h] [bp+Ch]@30
  unsigned int uWd; // [sp+60h] [bp+Ch]@95
  float uZooma; // [sp+64h] [bp+10h]@117
  unsigned int flagsb; // [sp+68h] [bp+14h]@66
  Actor *flagsc; // [sp+68h] [bp+14h]@86
  unsigned int flagsd; // [sp+68h] [bp+14h]@105

  uCenterX = (uX + uZ) / 2;
  uCenterY = (uY + uW) / 2;
  lPitch = pRenderer->uTargetSurfacePitch;
  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
  uBlue = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
  auto bWizardEyeActive = pParty->WizardEyeActive();
  auto uWizardEyeSkillLevel = pParty->WizardEyeSkillLevel();
  if (CheckHiredNPCSpeciality(Cartographer))
  {
    bWizardEyeActive = true;
    uWizardEyeSkillLevel = 2;
  }
    bWizardEyeActive = true;
    uWizardEyeSkillLevel = 3;
  pRenderer->SetRasterClipRect(uX, uY, uZ - 1, uW - 1);
  uHeight = uW - uY;
  uWidth = uZ - uX;

  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
  {
    v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
    auto pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
    auto pPal = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
    v73 = (1 << (v17 + 16)) / (signed int)uZoom;
    v18 = (double)(1 << (16 - v17));
    v19 = v18;
    v20 = (double)(pParty->vPosition.x + 32768) / v18;
    v21 = (double)(32768 - pParty->vPosition.y) / v19;
    uWb = v21;
    switch (uZoom)
    {
      case 512:
      {
        v20 = v20 - (double)(uWidth / 2);
        v22 = (double)(uHeight / 2);
        uWb = v21 - v22;
      }
      break;

      case 1024:
      {
        v20 = v20 - (double)(uWidth / 4);
        v22 = (double)(uHeight / 4);
        uWb = v21 - v22;
      }
      break;

      case 2048:
      {
        v20 = v20 - (double)(uWidth / 8);
        v22 = (double)(uHeight / 8);
        uWb = v21 - v22;
      }
      break;

      default: assert(false);
    }
    assert(sizeof(pOdmMinimap) == 137 * 117 * sizeof(short));

    v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24);
    uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25);
    v27 = uBluea >> 16;
    v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
    if (pMapLod0 && bRedrawOdmMinimap)
    {
      assert(uWidth == 137 && uHeight == 117);
      //auto pMinimap = (unsigned __int16 *)pOdmMinimap;

        auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;

          v29 = v70 >> 16;

          for (int y = 0; y < uHeight; ++y)
          {
              auto pMapLod0Line = &pMapLod0[v27 * mapWidth];
              for (int x = 0; x < uWidth; ++x)
              {
                //*pMinimap++ = pPal[pMapLod0Line[v29]];
                pOdmMinimap[y][x] = pPal[pMapLod0Line[v29]];
                v29 = (v70 + x * v73) >> 16;
              }

            v29 = v70 >> 16;
            v28 += 137 - uWidth;
            uBluea += v73;
            v27 = uBluea >> 16;
          }
    }

    for (int y = 0; y < 117; ++y)
    {
      for (int x = 0; x < 137; ++x)
      {
        *v28++ = pOdmMinimap[y][x];
      }
      v28 += lPitch - 137;
    }
    uNumBlueFacesInBLVMinimap = 0;
  }
  else
  {
    pRenderer->FillRectFast(uX, uY, uZ - uX, uHeight, 0xF);
    uNumBlueFacesInBLVMinimap = 0;

    for (uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i)
    {
      auto pOutline = &pIndoor->pMapOutlines->pOutlines[i];

      auto pFace1 = pIndoor->pFaces + pOutline->uFace1ID;
      auto pFace2 = pIndoor->pFaces + pOutline->uFace2ID;
      //v9 = pIndoor->pFaces[pMapVertex->uFace1ID].uAttributes;
        //v10 = pIndoor->pFaces[pMapVertex->uFace2ID].uAttributes;
      if (pFace1->Visible() && pFace2->Visible())
      {
        v11 = pOutline->uFlags;
        if ( v11 & 1 )
          goto LABEL_15;
        if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80u != 0 )
          goto LABEL_ABC;

      }
      continue;

LABEL_ABC:
    pOutline->uFlags = v11 | 1;
    pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8);

LABEL_15:
    //v12 = &pIndoor->pFaces[pOutline->uFace1ID];
    if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 &&
        (pFace1->uAttributes & 0x2000000 || pFace2->uAttributes & 0x2000000) &&
        (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID))
    {
      if (uNumBlueFacesInBLVMinimap < 49)
        pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap++] = i;
    }
    else
    {
      auto _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x);
      auto _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16);
      auto _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16);
      v69 =     uCenterX + _c;
      v69 =     uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
      lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
      uWa =     uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
      v14 =     uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
      v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8;
      if ( v15 > 100 )
        v15 = 100;
      pRenderer->RasterLine2D(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
    }
  }


  for (uint i = 0; i < uNumBlueFacesInBLVMinimap; ++i)
  {
    //v16 = (uint *)&pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]];
    auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[i]];
    pRenderer->RasterLine2D(uCenterX + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16)
                  - uZoom * pParty->vPosition.x) >> 16),
      uCenterY
    - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16)
                  - uZoom * pParty->vPosition.y) >> 16),
      uCenterX
    + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16)
                  - uZoom * pParty->vPosition.x) >> 16),
      uCenterY
    - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16)
                  - uZoom * pParty->vPosition.y) >> 16),
      uBlue);
  }
  }


  assert(pParty->sRotationY >= 0);
  float angle = (pParty->sRotationY % 2048) / 2048.0f;
  const float two_pi = 2.0f * 3.14159f;

  uint arrow_idx = floorf(0.5f + 7 * angle);
  pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx]));

  flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 255);
  v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 0, 0);
  if (bWizardEyeActive)
  {
    //uZe = 0;
    if (uWizardEyeSkillLevel >= 2)
      for (uint i = 0; i < uNumSpriteObjects; ++i)
    //if (uNumSpriteObjects > 0)
      {
        auto object = pSpriteObjects + i;

      //a2c = (char *)&pSpriteObjects[0].uObjectDescID;
      //while ( 1 )
      //{
      if (!object->uType || !object->uObjectDescID)
        continue;
      //if (uWizardEyeSkillLevel == 1
      v37 = uCenterX + ((unsigned __int64)((object->vPosition.x - pParty->vPosition.x) * (signed __int64)uZoom) >> 16);
      //v79 = (unsigned __int64)((object->vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16;
      //v38 = uCenterY - v79;
      v38 = uCenterY - ((signed __int64)((object->vPosition.y - pParty->vPosition.y) * (signed __int64)uZoom) >> 16);
      if (v37 < pRenderer->raster_clip_x || v37 > pRenderer->raster_clip_z ||
          v38 < pRenderer->raster_clip_y || v38 > pRenderer->raster_clip_w)
        continue;

      assert(uZoom >= 512);
      if (pObjectList->pObjects[object->uObjectDescID].uFlags & OBJECT_DESC_UNPICKABLE)
      {
        pRenderer->RasterLine2D(v37, v38,
                                v37, v38, v60);
      }
      else if (uZoom > 512)
      {
        pRenderer->RasterLine2D(v37 - 1, v38 - 1, v37 - 1, v38 + 1, flagsb);
        pRenderer->RasterLine2D(v37, v38 - 2, v37, v38 + 1, flagsb);
        pRenderer->RasterLine2D(v37 + 1, v38 - 1, v37 + 1, v38 + 1, flagsb);
        pRenderer->RasterLine2D(v37 - 2, v38, v37 - 2, v38 + 1, flagsb);
        pRenderer->RasterLine2D(v37 + 2, v38,
                                v37 + 2, v38 + 1, flagsb);
      }
      else
      {
        pRenderer->RasterLine2D(v37 - 1, v38 - 1,
                                v37 - 1, v38, flagsb);
        pRenderer->RasterLine2D(v37, v38 - 1,
                                v37, v38, flagsb);
      }
//LABEL_82:
//LABEL_83:
        //++uZe;
        //a2c += 112;
        //if ( uZe >= (signed int)uNumSpriteObjects )
        //{
          //goto LABEL_85;
        //}
      //}
    }


LABEL_85:
    v63 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 0, 0);
    v61 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 255, 0);
    v65 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 0);
    uZf = 0;
    if ( (signed int)uNumActors > 0 )
    {
      flagsc = pActors;//[0].uAIState;
      do
      {
		v39 = flagsc->uAIState;
		if ( flagsc->uAIState != 11 && v39 != 19 && (v39 == 5 || BYTE1(flagsc->uAttributes) & 0x80) )
        {
		  v40 = ((unsigned __int64)(( flagsc->vPosition.x - pParty->vPosition.x)
                                  * (signed __int64)(signed int)uZoom) >> 16)
              + uCenterX;
          v76 = (unsigned __int64)(( flagsc->vPosition.y - pParty->vPosition.y)
                                 * (signed __int64)(signed int)uZoom) >> 16;
          v41 = uCenterY - v76;
          if ( v40 >= pRenderer->raster_clip_x )
          {
            if ( v40 <= pRenderer->raster_clip_z && v41 >= pRenderer->raster_clip_y && v41 <= pRenderer->raster_clip_w )
            {
              uWd = v61;
			  if ( BYTE3(flagsc->uAttributes) & 1 )
                uWd = v63;
              if ( flagsc->uAIState == 5 )
                uWd = v65;
              if ( (signed int)uZoom > 1024 )
              {
                pRenderer->RasterLine2D(v40 - 1, v41 - 2, v40 - 1, v41 + 2, uWd);
                pRenderer->RasterLine2D(v40, v41 - 2, v40, v41 + 2, uWd);
                pRenderer->RasterLine2D(v40 + 1, v41 - 2, v40 + 1, v41 + 2, uWd);
                v42 = v41 + 1;
                v43 = v41 - 1;
                v44 = v42;
                pRenderer->RasterLine2D(v40 - 2, v43, v40 - 2, v42, uWd);
                v40 += 2;
                v59 = uWd;
                v56 = v44;
                v54 = v40;
                v52 = v43;
              }
              else
              {
                pRenderer->RasterLine2D(v40 - 1, v41 - 1, v40 - 1, uCenterY - v76, uWd);
                v59 = uWd;
                v56 = uCenterY - v76;
                v54 = v40;
                v52 = v41 - 1;
              }
              pRenderer->RasterLine2D(v40, v52, v54, v56, v59);
            }
          }
        }
        ++uZf;
        ++flagsc;
      }
      while ( uZf < (signed int)uNumActors );
    }
  }


  flagsd = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
  uZg = 0;
  if ( (signed int)uNumLevelDecorations > 0 )
  {
    v45 = (char *)&pLevelDecorations[0].vPosition;
    lPitchb = (char *)&pLevelDecorations[0].vPosition;
    do
    {
      if ( *(v45 - 2) & 8 )
      {
        v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
            + uCenterX;
        v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16;
        v47 = uCenterY - v77;
        if ( v46 >= pRenderer->raster_clip_x )
        {
          if ( v46 <= pRenderer->raster_clip_z && v47 >= pRenderer->raster_clip_y && v47 <= pRenderer->raster_clip_w )
          {
            if ( (signed int)uZoom > 512 )
            {
              v48 = v47 + 1;
              v49 = v47 - 1;
              pRenderer->RasterLine2D(v46 - 1, v47 - 1, v46 - 1, v47 + 1, flagsd);
              pRenderer->RasterLine2D(v46, v49, v46, v48, flagsd);
              pRenderer->RasterLine2D(v46 + 1, v49, v46 + 1, v48, flagsd);
              v45 = lPitchb;
            }
            else
            {
              pRenderer->RasterLine2D(v46, uCenterY - v77, v46, uCenterY - v77, flagsd);
            }
          }
        }
      }
      ++uZg;
      v45 += 32;
      lPitchb = v45;
    }
    while ( uZg < (signed int)uNumLevelDecorations );
  }
  pRenderer->DrawTextureTransparent(0x1D4u, 0, (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
  uZooma = (double)pParty->sRotationY * 0.1171875;
  //v50 = uZooma + 6.7553994e15;
  pRenderer->SetTextureClipRect(541, 0, 567, 480);
  pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 136, (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
  pRenderer->ResetTextureClipRect();
}

//----- (00441498) --------------------------------------------------------
void __cdecl GameUI_DrawTorchlightAndWizardEye()
    {
    if (pCurrentScreen == SCREEN_GAME
        || pCurrentScreen == SCREEN_MENU
        || pCurrentScreen == SCREEN_OPTIONS
        || pCurrentScreen == SCREEN_REST
        || pCurrentScreen == SCREEN_SPELL_BOOK
        || pCurrentScreen == SCREEN_CHEST
        || pCurrentScreen == SCREEN_SAVEGAME
        || pCurrentScreen == SCREEN_LOADGAME
        || pCurrentScreen == SCREEN_F
        || pCurrentScreen == SCREEN_BOOKS
        || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG )
        {
        if (pParty->TorchlightActive())
            {
            auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnum_Torchlight->uIconID, pEventTimer->Time());
            pRenderer->DrawTextureTransparent(pUIAnum_Torchlight->x, pUIAnum_Torchlight->y, pIcons_LOD->GetTexture(icon->uTextureID));
            }
        if (pParty->WizardEyeActive())
            {
            auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnim_WizardEye->uIconID, pEventTimer->Time());
            pRenderer->DrawTextureTransparent(pUIAnim_WizardEye->x, pUIAnim_WizardEye->y, pIcons_LOD->GetTexture(icon->uTextureID));
            }
        }
    }
// 4E28F8: using guessed type int pCurrentScreen;


//----- (00491F87) --------------------------------------------------------
void __cdecl DrawHiredNPCs()
{
  //int v6; // eax@15
  char v7; // al@17
  unsigned int v8; // eax@18
  int v9; // esi@18
  int v10; // eax@18
  unsigned int v11; // eax@19
  unsigned int v12; // esi@19
  unsigned int v13; // eax@23
  IconFrame *v14; // eax@24
  unsigned int v15; // eax@26
  char pContainer[20]; // [sp+Ch] [bp-30h]@18
  unsigned int v17; // [sp+20h] [bp-1Ch]@19
  signed int uFrameID; // [sp+24h] [bp-18h]@19
  //int i; // [sp+28h] [bp-14h]@15
  unsigned int v20; // [sp+2Ch] [bp-10h]@20
  unsigned int v21; // [sp+30h] [bp-Ch]@19
  int v22; // [sp+34h] [bp-8h]@2
  unsigned __int8 v23; // [sp+3Bh] [bp-1h]@2

  if ( bNoNPCHiring != 1 )
  {
    v23 = 0;
    v22 = 0;
    /*for (uint i = 0; i < 2; ++i)
    { 
      if (pParty->pHirelings[i].pName)
        pTmpBuf[v22++] = i;
    }*/
    if (pParty->pHirelings[0].pName)
      pTmpBuf[v22++] = 0;
    if (pParty->pHirelings[1].pName)
      pTmpBuf[v22++] = 1;

    for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
    {
      if (pNPCStats->pNewNPCData[i].uFlags & 128)
      {
        if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
        {
          if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName))
            pTmpBuf[v22++] = i + 2;
        }
      }
    }

    //v6 = (unsigned __int8)pParty->field_709;
	for ( int i = (unsigned __int8)pParty->field_709; i < v22 && v23 < 2; i++ )
    {
      v7 = pTmpBuf[i];
      if ( (unsigned __int8)v7 >= 2 )
      {
        sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
        v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
      }
      else
      {
        sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
        v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
        v9 = v23;
        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
        v10 = (unsigned __int8)pTmpBuf[i];
        if ( pParty->pHirelings[v10].evt_A == 1 )
        {
          uFrameID = pParty->pHirelings[v10].evt_B;
          v11 = pHiredNPCsIconsOffsetsX[v9];
          v12 = pHiredNPCsIconsOffsetsY[v9];
          v17 = v11;
          v21 = 0;
          if ( (signed int)pIconsFrameTable->uNumIcons <= 0 )
          {
LABEL_23:
            v13 = 0;
          }
          else
          {
            v20 = 0;
            while ( _strcmpi("spell96", pIconsFrameTable->pIcons[v20 / 0x20].pAnimationName) )
            {
              ++v21;
              v20 += 32;
              if ( (signed int)v21 >= (signed int)pIconsFrameTable->uNumIcons )
                goto LABEL_23;
            }
            v13 = v21;
          }
          v14 = pIconsFrameTable->GetFrame(v13, uFrameID);
          pRenderer->DrawTextureTransparent(v17, v12, &pIcons_LOD->pTextures[v14->uTextureID]);
        }
      }
      ++v23;
    }
  }
}
// 6BE3C5: using guessed type char bNoNPCHiring;