fix viplist sort, shared exp blink

This commit is contained in:
Henrique Santiago 2012-01-11 20:31:23 -02:00
parent a7865e26e3
commit 5bc939a091
5 changed files with 59 additions and 24 deletions

@ -1 +1 @@
Subproject commit 9beb17daaeb170c127c39c5a5e4feb9d95ebed92 Subproject commit dd648e1431171bffe091b748744395780df7eba1

View File

@ -41,25 +41,25 @@ end
function Creature:onShieldChange(shieldId) function Creature:onShieldChange(shieldId)
if shieldId == ShieldWhiteYellow then 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 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 elseif shieldId == ShieldBlue then
self:setShieldTexture(resolvepath('images/shield_blue.png')) self:setShieldTexture(resolvepath('images/shield_blue.png'), false)
elseif shieldId == ShieldYellow then elseif shieldId == ShieldYellow then
self:setShieldTexture(resolvepath('images/shield_yellow.png')) self:setShieldTexture(resolvepath('images/shield_yellow.png'), false)
elseif shieldId == ShieldBlueSharedExp then 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 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 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 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 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 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
end end

View File

@ -46,23 +46,25 @@ function VipList.onAddVip(id, name, online)
local nameLower = name:lower() local nameLower = name:lower()
local childrenCount = vipList:getChildCount() local childrenCount = vipList:getChildCount()
for i=1,childrenCount do
for i=1,childrenCount do
local child = vipList:getChildByIndex(i) local child = vipList:getChildByIndex(i)
if online and not child.vipOnline then if online and not child.vipOnline then
vipList:insertChild(i, label) vipList:insertChild(i, label)
return return
end end
local childText = child:getText():lower() if (not online and not child.vipOnline) or (online and child.vipOnline) then
local length = math.min(childText:len(), nameLower:len()) local childText = child:getText():lower()
local length = math.min(childText:len(), nameLower:len())
for j=1,length do for j=1,length do
if nameLower:byte(j) < childText:byte(j) then if nameLower:byte(j) < childText:byte(j) then
vipList:insertChild(i, label) vipList:insertChild(i, label)
return return
elseif nameLower:byte(j) > childText:byte(j) then elseif nameLower:byte(j) > childText:byte(j) then
break break
end
end end
end end
end end

View File

@ -49,6 +49,12 @@ Creature::Creature() : Thing()
m_walking = false; m_walking = false;
m_inverseWalking = true; 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"); 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.setColor(Fw::white);
g_painter.drawTexturedRect(Rect(x + 12, y + 5, m_skullTexture->getSize()), m_skullTexture); 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.setColor(Fw::white);
g_painter.drawTexturedRect(Rect(x, y + 5, m_shieldTexture->getSize()), m_shieldTexture); 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); 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_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) 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() ThingType *Creature::getType()
{ {
return g_thingsType.getThingType(m_outfit.getId(), m_outfit.getCategory()); return g_thingsType.getThingType(m_outfit.getId(), m_outfit.getCategory());

View File

@ -31,6 +31,7 @@ class Creature : public Thing
{ {
public: public:
enum { enum {
SHIELD_BLINK_TICKS = 500,
INVISIBLE_TICKS = 500, INVISIBLE_TICKS = 500,
VOLATILE_SQUARE_DURATION = 1000 VOLATILE_SQUARE_DURATION = 1000
}; };
@ -51,7 +52,7 @@ public:
void setShield(uint8 shield); void setShield(uint8 shield);
void setEmblem(uint8 emblem); void setEmblem(uint8 emblem);
void setSkullTexture(const std::string& filename); 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 setEmblemTexture(const std::string& filename);
void setPassable(bool passable) { m_passable = passable; } void setPassable(bool passable) { m_passable = passable; }
@ -73,6 +74,7 @@ public:
bool getPassable() { return m_passable; } bool getPassable() { return m_passable; }
void updateAnimation(); void updateAnimation();
void updateShield();
ThingType *getType(); ThingType *getType();
@ -98,6 +100,7 @@ protected:
uint16 m_speed; uint16 m_speed;
uint8 m_skull, m_shield, m_emblem; uint8 m_skull, m_shield, m_emblem;
TexturePtr m_skullTexture, m_shieldTexture, m_emblemTexture; TexturePtr m_skullTexture, m_shieldTexture, m_emblemTexture;
bool m_showShieldTexture, m_shieldBlink;
bool m_passable; bool m_passable;
Color m_volatileSquareColor, m_staticSquareColor; Color m_volatileSquareColor, m_staticSquareColor;
bool m_showVolatileSquare, m_showStaticSquare; bool m_showVolatileSquare, m_showStaticSquare;