fix viplist sort, shared exp blink

master
Henrique Santiago 12 years ago
parent a7865e26e3
commit 5bc939a091

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

@ -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

@ -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

@ -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());

@ -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;

Loading…
Cancel
Save