uiitem and outfit class fixes

This commit is contained in:
Henrique 2011-11-14 20:47:36 -02:00
parent a95d0bcc1f
commit 591f8c2c7c
6 changed files with 43 additions and 23 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -202,6 +202,21 @@ void ProtocolGame::sendGetOutfit()
send(oMsg); 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) void ProtocolGame::sendAddVip(const std::string& name)
{ {
OutputMessage oMsg; OutputMessage oMsg;

View File

@ -35,7 +35,7 @@ void UIItem::render()
if(m_item) { if(m_item) {
g_graphics.bindColor(Fw::white); 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(); renderChildren();