uiitem and outfit class fixes

master
Henrique 13 years ago
parent a95d0bcc1f
commit 591f8c2c7c

@ -16,10 +16,7 @@ function Outfit.test()
end
function Outfit.create(creature, outfitList)
if window ~= nil then
Outfit.destroy()
end
Outfit.destroy()
window = loadUI("/outfit/outfit.otui", UI.root)
local creatureWidget = window:getChildById('creature')
@ -27,8 +24,10 @@ function Outfit.create(creature, outfitList)
end
function Outfit.destroy()
window:destroy()
window = nil
if window ~= nil then
window:destroy()
window = nil
end
end
-- private functions

@ -70,19 +70,19 @@ void Creature::draw(const Point& p)
g_graphics.bindBlendFunc(Fw::BlendColorzing);
// head
g_graphics.bindColor(m_outfit.getHead());
g_graphics.bindColor(m_outfit.getHeadColor());
internalDraw(p + m_walkOffset, 1, Otc::SpriteYellowMask);
// body
g_graphics.bindColor(m_outfit.getBody());
g_graphics.bindColor(m_outfit.getBodyColor());
internalDraw(p + m_walkOffset, 1, Otc::SpriteRedMask);
// legs
g_graphics.bindColor(m_outfit.getLegs());
g_graphics.bindColor(m_outfit.getLegsColor());
internalDraw(p + m_walkOffset, 1, Otc::SpriteGreenMask);
// feet
g_graphics.bindColor(m_outfit.getFeet());
g_graphics.bindColor(m_outfit.getFeetColor());
internalDraw(p + m_walkOffset, 1, Otc::SpriteBlueMask);
// restore default blend func

@ -36,22 +36,27 @@ public:
static Color getColor(int color);
void setType(int type) { m_type = type; }
void setHead(int head) { m_head = getColor(head); }
void setBody(int body) { m_body = getColor(body); }
void setLegs(int legs) { m_legs = getColor(legs); }
void setFeet(int feet) { m_feet = getColor(feet); }
void setHead(int head) { m_head = head; m_headColor = getColor(head); }
void setBody(int body) { m_body = body; m_bodyColor = getColor(body); }
void setLegs(int legs) { m_legs = legs; m_legsColor = getColor(legs); }
void setFeet(int feet) { m_feet = feet; m_feetColor = getColor(feet); }
void setAddons(int addons) { m_addons = addons; }
int getType() { return m_type; }
Color getHead() { return m_head; }
Color getBody() { return m_body; }
Color getLegs() { return m_legs; }
Color getFeet() { return m_feet; }
int getAddons() { return m_addons; }
int getType() const { return m_type; }
int getHead() const { return m_head; }
int getBody() const { return m_body; }
int getLegs() const { return m_legs; }
int getFeet() const { return m_feet; }
int getAddons() const { return m_addons; }
Color getHeadColor() { return m_headColor; }
Color getBodyColor() { return m_bodyColor; }
Color getLegsColor() { return m_legsColor; }
Color getFeetColor() { return m_feetColor; }
private:
int m_type, m_addons;
Color m_head, m_body, m_legs, m_feet;
int m_type, m_head, m_body, m_legs, m_feet, m_addons;
Color m_headColor, m_bodyColor, m_legsColor, m_feetColor;
};
#endif

@ -57,6 +57,7 @@ public:
void sendUseItem(const Position& position, int itemId, int stackpos, int index);
void sendTalk(int channelType, int channelId, const std::string& receiver, const std::string& message);
void sendGetOutfit();
void sendSetOutfit(const Outfit& outfit);
void sendAddVip(const std::string& name);
void sendRemoveVip(int id);

@ -202,6 +202,21 @@ void ProtocolGame::sendGetOutfit()
send(oMsg);
}
void ProtocolGame::sendSetOutfit(const Outfit& outfit)
{
OutputMessage oMsg;
oMsg.addU8(Otc::ClientSetOutfit);
oMsg.addU16(outfit.getType());
oMsg.addU8(outfit.getHead());
oMsg.addU8(outfit.getBody());
oMsg.addU8(outfit.getLegs());
oMsg.addU8(outfit.getFeet());
oMsg.addU8(outfit.getAddons());
send(oMsg);
}
void ProtocolGame::sendAddVip(const std::string& name)
{
OutputMessage oMsg;

@ -35,7 +35,7 @@ void UIItem::render()
if(m_item) {
g_graphics.bindColor(Fw::white);
m_item->draw(m_rect.topLeft() + m_itemMargin);
m_item->draw(m_rect.bottomRight() - Point(32, 32) + m_itemMargin);
}
renderChildren();

Loading…
Cancel
Save