Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
- {
- if(m_healthPercent < 1) // creature is dead
- return;
- Color fillColor = Color(96, 96, 96);
- if(!useGray)
- fillColor = m_informationColor;
- // calculate main rects
- const ThingTypePtr& thingType = getThingType();
- Rect backgroundRect = Rect(point.x - (13.5) + thingType->getNameDisplacement().x, point.y + thingType->getNameDisplacement().y, 27, 4);
- backgroundRect.bind(parentRect);
- Size nameSize = m_nameCache.getTextSize();
- Rect textRect = Rect(point.x - (nameSize.width() / 2.0) + thingType->getNameDisplacement().x, point.y - 12 + thingType->getNameDisplacement().y, nameSize);
- textRect.bind(parentRect);
- // distance them
- if(textRect.top() == parentRect.top())
- backgroundRect.moveTop(textRect.top() + 12);
- if(backgroundRect.bottom() == parentRect.bottom())
- textRect.moveTop(backgroundRect.top() - 12);
- // health rect is based on background rect, so no worries
- Rect healthRect = backgroundRect.expanded(-1);
- healthRect.setWidth((m_healthPercent / 100.0) * 25);
- // draw
- if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
- fillColor = Color(0xED, 0xBB, 0x57);
- if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames)))
- {
- g_painter->setColor(Color::black);
- g_painter->drawFilledRect(backgroundRect);
- g_painter->setColor(fillColor);
- g_painter->drawFilledRect(healthRect);
- }
- if(drawFlags & Otc::DrawNames)
- {
- //if(g_painter->getColor() != fillColor)
- //g_painter->setColor(fillColor);
- Color nameColor = fillColor;
- switch(m_colorName)
- {
- case 0x00:
- nameColor = Color(0xFF, 0x32, 0x00);
- break;
- case 0x01:
- nameColor = Color(0x00, 0xAE, 0xFF);
- break;
- case 0x02:
- nameColor = Color::white;
- break;
- case 0x03:
- nameColor = Color(0xED, 0xBB, 0x57);
- break;
- case 0x04:
- nameColor = Color(0x50, 0xA1, 0x50);
- break;
- case 0x05:
- nameColor = Color(0xFF, 0xDD, 0x00);
- break;
- case 0x06:
- nameColor = Color(0x00, 0xD7, 0xFF);
- break;
- case 0x07:
- nameColor = Color(0xFF, 0x7F, 0x00);
- break;
- case 0x08:
- nameColor = Color(0xF6, 0x00, 0xFF);
- break;
- }
- g_painter->setOpacity(0.8f);
- g_painter->setColor(nameColor);
- m_nameCache.draw(textRect);
- g_painter->resetOpacity();
- CachedText shiny;
- shiny.setText("Shiny");
- shiny.setFont(g_fonts.getFont("verdana-11px-rounded"));
- Rect shinyrect = Rect(point.x - shiny.getTextSize().width() / 2.0, point.y - 26, shiny.getTextSize());
- if (m_name.find("Shiny") != std::string::npos)
- {
- char* shinys = "Shiny";
- std::string nname = m_name;
- nname.erase(0, 5);
- m_nameCache.setText(nname);
- m_nameCache.draw(textRect);
- g_painter->setOpacity(0.5);
- g_painter->setColor(Color(255, 255, 0));
- shiny.draw(shinyrect);
- g_painter->resetColor();
- g_painter->resetOpacity();
- m_nameCache.setText(m_name);
- } else {
- m_nameCache.draw(textRect);
- }
- }
- if(m_skull != Otc::SkullNone && m_skullTexture)
- {
- g_painter->setColor(Color::white);
- Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
- g_painter->drawTexturedRect(skullRect, m_skullTexture);
- }
- if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture)
- {
- g_painter->setColor(Color::white);
- Rect shieldRect = Rect(backgroundRect.x() + 13.5, backgroundRect.y() + 5, m_shieldTexture->getSize());
- g_painter->drawTexturedRect(shieldRect, m_shieldTexture);
- }
- if(m_emblem != Otc::EmblemNone && m_emblemTexture)
- {
- g_painter->setColor(Color::white);
- Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
- g_painter->drawTexturedRect(emblemRect, m_emblemTexture);
- }
- if(m_icon != Otc::NpcIconNone && m_iconTexture)
- {
- g_painter->setColor(Color::white);
- Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
- g_painter->drawTexturedRect(iconRect, m_iconTexture);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement