From 5bc939a0917e07230a3a9b7417724eb1376c419a Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Wed, 11 Jan 2012 20:31:23 -0200 Subject: [PATCH] fix viplist sort, shared exp blink --- modules/client_tibiafiles | 2 +- modules/game/creature.lua | 20 +++++++++---------- modules/game_viplist/viplist.lua | 22 +++++++++++---------- src/otclient/core/creature.cpp | 34 ++++++++++++++++++++++++++++++-- src/otclient/core/creature.h | 5 ++++- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/modules/client_tibiafiles b/modules/client_tibiafiles index 9beb17da..dd648e14 160000 --- a/modules/client_tibiafiles +++ b/modules/client_tibiafiles @@ -1 +1 @@ -Subproject commit 9beb17daaeb170c127c39c5a5e4feb9d95ebed92 +Subproject commit dd648e1431171bffe091b748744395780df7eba1 diff --git a/modules/game/creature.lua b/modules/game/creature.lua index 9df2601a..c7e357c6 100644 --- a/modules/game/creature.lua +++ b/modules/game/creature.lua @@ -41,25 +41,25 @@ end function Creature:onShieldChange(shieldId) if shieldId == ShieldWhiteYellow then - self:setShieldTexture(resolvepath('images/shield_yellow_white.png')) + self:setShieldTexture(resolvepath('images/shield_yellow_white.png'), false) elseif shieldId == ShieldWhiteBlue then - self:setShieldTexture(resolvepath('images/shield_blue_white.png')) + self:setShieldTexture(resolvepath('images/shield_blue_white.png'), false) elseif shieldId == ShieldBlue then - self:setShieldTexture(resolvepath('images/shield_blue.png')) + self:setShieldTexture(resolvepath('images/shield_blue.png'), false) elseif shieldId == ShieldYellow then - self:setShieldTexture(resolvepath('images/shield_yellow.png')) + self:setShieldTexture(resolvepath('images/shield_yellow.png'), false) elseif shieldId == ShieldBlueSharedExp then - self:setShieldTexture(resolvepath('images/shield_blue_shared.png')) + self:setShieldTexture(resolvepath('images/shield_blue_shared.png'), false) elseif shieldId == ShieldYellowSharedExp then - self:setShieldTexture(resolvepath('images/shield_yellow_shared.png')) + self:setShieldTexture(resolvepath('images/shield_yellow_shared.png'), false) elseif shieldId == ShieldBlueNoSharedExpBlink then - self:setShieldTexture(resolvepath('images/shield_blue_not_shared.png')) + self:setShieldTexture(resolvepath('images/shield_blue_not_shared.png'), true) elseif shieldId == ShieldYellowNoSharedExpBlink then - self:setShieldTexture(resolvepath('images/shield_yellow_not_shared.png')) + self:setShieldTexture(resolvepath('images/shield_yellow_not_shared.png'), true) elseif shieldId == ShieldBlueNoSharedExp then - self:setShieldTexture(resolvepath('images/shield_blue_not_shared.png')) + self:setShieldTexture(resolvepath('images/shield_blue_not_shared.png'), false) elseif shieldId == ShieldYellowNoSharedExp then - self:setShieldTexture(resolvepath('images/shield_yellow_not_shared.png')) + self:setShieldTexture(resolvepath('images/shield_yellow_not_shared.png'), false) end end diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 552c67a5..4747d1cb 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -46,23 +46,25 @@ function VipList.onAddVip(id, name, online) local nameLower = name:lower() local childrenCount = vipList:getChildCount() - for i=1,childrenCount do + for i=1,childrenCount do local child = vipList:getChildByIndex(i) if online and not child.vipOnline then vipList:insertChild(i, label) return end - - local childText = child:getText():lower() - local length = math.min(childText:len(), nameLower:len()) - for j=1,length do - if nameLower:byte(j) < childText:byte(j) then - vipList:insertChild(i, label) - return - elseif nameLower:byte(j) > childText:byte(j) then - break + if (not online and not child.vipOnline) or (online and child.vipOnline) then + local childText = child:getText():lower() + local length = math.min(childText:len(), nameLower:len()) + + for j=1,length do + if nameLower:byte(j) < childText:byte(j) then + vipList:insertChild(i, label) + return + elseif nameLower:byte(j) > childText:byte(j) then + break + end end end end diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index 9ac0ef6b..e056f266 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -49,6 +49,12 @@ Creature::Creature() : Thing() m_walking = false; m_inverseWalking = true; + m_skull = Otc::SkullNone; + m_shield = Otc::ShieldNone; + m_emblem = Otc::EmblemNone; + m_shieldBlink = false; + m_showShieldTexture = true; + m_informationFont = g_fonts.getFont("verdana-11px-rounded"); } @@ -173,7 +179,7 @@ void Creature::drawInformation(int x, int y, bool useGray, const Rect& visibleRe g_painter.setColor(Fw::white); g_painter.drawTexturedRect(Rect(x + 12, y + 5, m_skullTexture->getSize()), m_skullTexture); } - if(m_shield != Otc::ShieldNone && m_shieldTexture) { + if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture) { g_painter.setColor(Fw::white); g_painter.drawTexturedRect(Rect(x, y + 5, m_shieldTexture->getSize()), m_shieldTexture); } @@ -395,9 +401,19 @@ void Creature::setSkullTexture(const std::string& filename) m_skullTexture = g_textures.getTexture(filename); } -void Creature::setShieldTexture(const std::string& filename) +void Creature::setShieldTexture(const std::string& filename, bool blink) { m_shieldTexture = g_textures.getTexture(filename); + m_showShieldTexture = true; + + if(blink && !m_shieldBlink) { + auto self = asCreature(); + g_dispatcher.scheduleEvent([self]() { + self->updateShield(); + }, SHIELD_BLINK_TICKS); + } + + m_shieldBlink = blink; } void Creature::setEmblemTexture(const std::string& filename) @@ -436,6 +452,20 @@ void Creature::updateAnimation() } } +void Creature::updateShield() +{ + m_showShieldTexture = !m_showShieldTexture; + + if(m_shield != Otc::ShieldNone && m_shieldBlink) { + auto self = asCreature(); + g_dispatcher.scheduleEvent([self]() { + self->updateShield(); + }, SHIELD_BLINK_TICKS); + } + else if(!m_shieldBlink) + m_showShieldTexture = true; +} + ThingType *Creature::getType() { return g_thingsType.getThingType(m_outfit.getId(), m_outfit.getCategory()); diff --git a/src/otclient/core/creature.h b/src/otclient/core/creature.h index a8121e6c..cf6e958c 100644 --- a/src/otclient/core/creature.h +++ b/src/otclient/core/creature.h @@ -31,6 +31,7 @@ class Creature : public Thing { public: enum { + SHIELD_BLINK_TICKS = 500, INVISIBLE_TICKS = 500, VOLATILE_SQUARE_DURATION = 1000 }; @@ -51,7 +52,7 @@ public: void setShield(uint8 shield); void setEmblem(uint8 emblem); void setSkullTexture(const std::string& filename); - void setShieldTexture(const std::string& filename); + void setShieldTexture(const std::string& filename, bool blink); void setEmblemTexture(const std::string& filename); void setPassable(bool passable) { m_passable = passable; } @@ -73,6 +74,7 @@ public: bool getPassable() { return m_passable; } void updateAnimation(); + void updateShield(); ThingType *getType(); @@ -98,6 +100,7 @@ protected: uint16 m_speed; uint8 m_skull, m_shield, m_emblem; TexturePtr m_skullTexture, m_shieldTexture, m_emblemTexture; + bool m_showShieldTexture, m_shieldBlink; bool m_passable; Color m_volatileSquareColor, m_staticSquareColor; bool m_showVolatileSquare, m_showStaticSquare;