mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
Closes #236
This commit is contained in:
@@ -57,10 +57,14 @@ namespace Otc
|
||||
DrawStaticTexts = 512,
|
||||
DrawAnimatedTexts = 1024,
|
||||
DrawAnimations = 2048,
|
||||
DrawBars = 4096,
|
||||
DrawNames = 8192,
|
||||
DrawLights = 16384,
|
||||
DrawWalls = DrawOnBottom | DrawOnTop,
|
||||
DrawEverything = DrawGround | DrawGroundBorders | DrawWalls | DrawItems |
|
||||
DrawCreatures | DrawEffects | DrawMissiles | DrawCreaturesInformation |
|
||||
DrawStaticTexts | DrawAnimatedTexts | DrawAnimations
|
||||
DrawStaticTexts | DrawAnimatedTexts | DrawAnimations | DrawBars | DrawNames |
|
||||
DrawLights
|
||||
};
|
||||
|
||||
enum DatOpts {
|
||||
|
@@ -226,7 +226,7 @@ void Creature::drawOutfit(const Rect& destRect, bool resize)
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect)
|
||||
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
|
||||
{
|
||||
if(m_healthPercent < 1) // creature is dead
|
||||
return;
|
||||
@@ -255,17 +255,22 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
|
||||
healthRect.setWidth((m_healthPercent / 100.0) * 25);
|
||||
|
||||
// draw
|
||||
g_painter->setColor(Color::black);
|
||||
g_painter->drawFilledRect(backgroundRect);
|
||||
|
||||
if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
|
||||
g_painter->setColor(Color(0x66, 0xcc, 0xff));
|
||||
else
|
||||
fillColor = Color(0x66, 0xcc, 0xff);
|
||||
|
||||
if(drawFlags & Otc::DrawBars) {
|
||||
g_painter->setColor(Color::black);
|
||||
g_painter->drawFilledRect(backgroundRect);
|
||||
|
||||
g_painter->setColor(fillColor);
|
||||
g_painter->drawFilledRect(healthRect);
|
||||
}
|
||||
|
||||
g_painter->drawFilledRect(healthRect);
|
||||
|
||||
m_nameCache.draw(textRect);
|
||||
if(drawFlags & Otc::DrawNames) {
|
||||
if(g_painter->getColor() != fillColor)
|
||||
g_painter->setColor(fillColor);
|
||||
m_nameCache.draw(textRect);
|
||||
}
|
||||
|
||||
if(m_skull != Otc::SkullNone && m_skullTexture) {
|
||||
g_painter->setColor(Color::white);
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction, LightView *lightView = nullptr);
|
||||
void drawOutfit(const Rect& destRect, bool resize);
|
||||
void drawInformation(const Point& point, bool useGray, const Rect& parentRect);
|
||||
void drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags);
|
||||
|
||||
void setId(uint32 id) { m_id = id; }
|
||||
void setName(const std::string& name);
|
||||
|
@@ -557,6 +557,8 @@ void Client::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UIMap>("setAutoViewMode", &UIMap::setAutoViewMode);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setDrawFlags", &UIMap::setDrawFlags);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setDrawTexts", &UIMap::setDrawTexts);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setDrawNames", &UIMap::setDrawNames);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setDrawHealthBars", &UIMap::setDrawHealthBars);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setDrawLights", &UIMap::setDrawLights);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setAnimated", &UIMap::setAnimated);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setKeepAspectRatio", &UIMap::setKeepAspectRatio);
|
||||
@@ -566,6 +568,8 @@ void Client::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UIMap>("isMultifloor", &UIMap::isMultifloor);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isDrawingTexts", &UIMap::isDrawingTexts);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isDrawingNames", &UIMap::isDrawingNames);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isDrawingHealthBars", &UIMap::isDrawingHealthBars);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isDrawingLights", &UIMap::isDrawingLights);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isLimitVisibleRangeEnabled", &UIMap::isLimitVisibleRangeEnabled);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isAnimating", &UIMap::isAnimating);
|
||||
|
@@ -204,7 +204,7 @@ void MapView::draw(const Rect& rect)
|
||||
float verticalStretchFactor = rect.height() / (float)srcRect.height();
|
||||
|
||||
// avoid drawing texts on map in far zoom outs
|
||||
if(m_viewMode == NEAR_VIEW && m_drawTexts) {
|
||||
if(m_viewMode == NEAR_VIEW) {
|
||||
for(const CreaturePtr& creature : m_cachedFloorVisibleCreatures) {
|
||||
if(!creature->canBeSeen())
|
||||
continue;
|
||||
@@ -218,7 +218,10 @@ void MapView::draw(const Rect& rect)
|
||||
p.y = p.y * verticalStretchFactor;
|
||||
p += rect.topLeft();
|
||||
|
||||
creature->drawInformation(p, g_map.isCovered(pos, m_cachedFirstVisibleFloor), rect);
|
||||
int flags = 0;
|
||||
if(m_drawNames){ flags = Otc::DrawNames; }
|
||||
if(m_drawHealthBars) { flags |= Otc::DrawBars; }
|
||||
creature->drawInformation(p, g_map.isCovered(pos, m_cachedFirstVisibleFloor), rect, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -98,12 +98,18 @@ public:
|
||||
void setDrawTexts(bool enable) { m_drawTexts = enable; }
|
||||
bool isDrawingTexts() { return m_drawTexts; }
|
||||
|
||||
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
|
||||
bool isAnimating() { return m_animated; }
|
||||
void setDrawNames(bool enable) { m_drawNames = enable; }
|
||||
bool isDrawingNames() { return m_drawNames; }
|
||||
|
||||
void setDrawHealthBars(bool enable) { m_drawHealthBars = enable; }
|
||||
bool isDrawingHealthBars() { return m_drawHealthBars; }
|
||||
|
||||
void setDrawLights(bool enable);
|
||||
bool isDrawingLights() { return m_drawLights; }
|
||||
|
||||
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
|
||||
bool isAnimating() { return m_animated; }
|
||||
|
||||
void setShader(const PainterShaderProgramPtr& shader, float fadein, float fadeout);
|
||||
PainterShaderProgramPtr getShader() { return m_shader; }
|
||||
|
||||
@@ -138,8 +144,11 @@ private:
|
||||
stdext::boolean<true> m_animated;
|
||||
stdext::boolean<true> m_autoViewMode;
|
||||
stdext::boolean<true> m_drawTexts;
|
||||
stdext::boolean<true> m_smooth;
|
||||
stdext::boolean<true> m_drawNames;
|
||||
stdext::boolean<true> m_drawHealthBars;
|
||||
stdext::boolean<false> m_drawLights;
|
||||
stdext::boolean<true> m_smooth;
|
||||
|
||||
stdext::boolean<true> m_follow;
|
||||
std::vector<TilePtr> m_cachedVisibleTiles;
|
||||
std::vector<CreaturePtr> m_cachedFloorVisibleCreatures;
|
||||
|
@@ -51,6 +51,8 @@ public:
|
||||
void setAutoViewMode(bool enable) { m_mapView->setAutoViewMode(enable); }
|
||||
void setDrawFlags(Otc::DrawFlags drawFlags) { m_mapView->setDrawFlags(drawFlags); }
|
||||
void setDrawTexts(bool enable) { m_mapView->setDrawTexts(enable); }
|
||||
void setDrawNames(bool enable) { m_mapView->setDrawNames(enable); }
|
||||
void setDrawHealthBars(bool enable) { m_mapView->setDrawHealthBars(enable); }
|
||||
void setDrawLights(bool enable) { m_mapView->setDrawLights(enable); }
|
||||
void setAnimated(bool enable) { m_mapView->setAnimated(enable); }
|
||||
void setKeepAspectRatio(bool enable);
|
||||
@@ -61,6 +63,8 @@ public:
|
||||
bool isMultifloor() { return m_mapView->isMultifloor(); }
|
||||
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
|
||||
bool isDrawingTexts() { return m_mapView->isDrawingTexts(); }
|
||||
bool isDrawingNames() { return m_mapView->isDrawingNames(); }
|
||||
bool isDrawingHealthBars() { return m_mapView->isDrawingHealthBars(); }
|
||||
bool isDrawingLights() { return m_mapView->isDrawingLights(); }
|
||||
bool isAnimating() { return m_mapView->isAnimating(); }
|
||||
bool isKeepAspectRatioEnabled() { return m_keepAspectRatio; }
|
||||
|
Reference in New Issue
Block a user