SHARE
TWEET

Untitled

a guest Nov 19th, 2019 137 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
  2. {
  3.     if(m_healthPercent < 1) // creature is dead
  4.         return;
  5.  
  6.     Color fillColor = Color(96, 96, 96);
  7.  
  8.     if(!useGray)
  9.         fillColor = m_informationColor;
  10.  
  11.     // calculate main rects
  12.     const ThingTypePtr& thingType = getThingType();
  13.  
  14.     Rect backgroundRect = Rect(point.x - (13.5) + thingType->getNameDisplacement().x, point.y + thingType->getNameDisplacement().y, 27, 4);
  15.     backgroundRect.bind(parentRect);
  16.  
  17.     Size nameSize = m_nameCache.getTextSize();
  18.     Rect textRect = Rect(point.x - (nameSize.width() / 2.0) + thingType->getNameDisplacement().x, point.y - 12 + thingType->getNameDisplacement().y, nameSize);
  19.     textRect.bind(parentRect);
  20.  
  21.     // distance them
  22.     if(textRect.top() == parentRect.top())
  23.         backgroundRect.moveTop(textRect.top() + 12);
  24.     if(backgroundRect.bottom() == parentRect.bottom())
  25.         textRect.moveTop(backgroundRect.top() - 12);
  26.  
  27.     // health rect is based on background rect, so no worries
  28.     Rect healthRect = backgroundRect.expanded(-1);
  29.     healthRect.setWidth((m_healthPercent / 100.0) * 25);
  30.  
  31.     // draw
  32.     if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
  33.         fillColor = Color(0xED, 0xBB, 0x57);
  34.  
  35.     if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames)))
  36.     {
  37.         g_painter->setColor(Color::black);
  38.         g_painter->drawFilledRect(backgroundRect);
  39.  
  40.         g_painter->setColor(fillColor);
  41.         g_painter->drawFilledRect(healthRect);
  42.     }
  43.  
  44.     if(drawFlags & Otc::DrawNames)
  45.     {
  46.         //if(g_painter->getColor() != fillColor)
  47.             //g_painter->setColor(fillColor);
  48.  
  49.         Color nameColor = fillColor;
  50.  
  51.         switch(m_colorName)
  52.         {
  53.             case 0x00:
  54.                 nameColor = Color(0xFF, 0x32, 0x00);
  55.                 break;
  56.             case 0x01:
  57.                 nameColor = Color(0x00, 0xAE, 0xFF);
  58.                 break;
  59.             case 0x02:
  60.                 nameColor = Color::white;
  61.                 break;
  62.             case 0x03:
  63.                 nameColor = Color(0xED, 0xBB, 0x57);
  64.                 break;
  65.             case 0x04:
  66.                 nameColor = Color(0x50, 0xA1, 0x50);
  67.                 break;
  68.             case 0x05:
  69.                 nameColor = Color(0xFF, 0xDD, 0x00);
  70.                 break;
  71.             case 0x06:
  72.                 nameColor = Color(0x00, 0xD7, 0xFF);
  73.                 break;
  74.             case 0x07:
  75.                 nameColor = Color(0xFF, 0x7F, 0x00);
  76.                 break;
  77.             case 0x08:
  78.                 nameColor = Color(0xF6, 0x00, 0xFF);
  79.                 break;
  80.         }
  81.  
  82.         g_painter->setOpacity(0.8f);
  83.         g_painter->setColor(nameColor);
  84.  
  85.         m_nameCache.draw(textRect);
  86.         g_painter->resetOpacity();
  87.  
  88.  
  89.         CachedText shiny;
  90.         shiny.setText("Shiny");
  91.         shiny.setFont(g_fonts.getFont("verdana-11px-rounded"));
  92.         Rect shinyrect = Rect(point.x - shiny.getTextSize().width() / 2.0, point.y - 26, shiny.getTextSize());
  93.         if (m_name.find("Shiny") != std::string::npos)
  94.         {
  95.             char* shinys = "Shiny";
  96.             std::string nname = m_name;
  97.             nname.erase(0, 5);
  98.             m_nameCache.setText(nname);
  99.             m_nameCache.draw(textRect);
  100.             g_painter->setOpacity(0.5);
  101.             g_painter->setColor(Color(255, 255, 0));
  102.             shiny.draw(shinyrect);
  103.             g_painter->resetColor();
  104.             g_painter->resetOpacity();
  105.             m_nameCache.setText(m_name);
  106.         } else {
  107.             m_nameCache.draw(textRect);
  108.         }
  109.        
  110.     }
  111.  
  112.     if(m_skull != Otc::SkullNone && m_skullTexture)
  113.     {
  114.         g_painter->setColor(Color::white);
  115.         Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
  116.         g_painter->drawTexturedRect(skullRect, m_skullTexture);
  117.     }
  118.     if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture)
  119.     {
  120.         g_painter->setColor(Color::white);
  121.         Rect shieldRect = Rect(backgroundRect.x() + 13.5, backgroundRect.y() + 5, m_shieldTexture->getSize());
  122.         g_painter->drawTexturedRect(shieldRect, m_shieldTexture);
  123.     }
  124.     if(m_emblem != Otc::EmblemNone && m_emblemTexture)
  125.     {
  126.         g_painter->setColor(Color::white);
  127.         Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
  128.         g_painter->drawTexturedRect(emblemRect, m_emblemTexture);
  129.     }
  130.     if(m_icon != Otc::NpcIconNone && m_iconTexture)
  131.     {
  132.         g_painter->setColor(Color::white);
  133.         Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
  134.         g_painter->drawTexturedRect(iconRect, m_iconTexture);
  135.     }
  136. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top