diff --git a/modules/outfit/outfit.lua b/modules/outfit/outfit.lua index da65e3cb..4328e064 100644 --- a/modules/outfit/outfit.lua +++ b/modules/outfit/outfit.lua @@ -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 diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index 2e08c7ae..789800f2 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -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 diff --git a/src/otclient/core/outfit.h b/src/otclient/core/outfit.h index 2dfb79e1..9e829851 100644 --- a/src/otclient/core/outfit.h +++ b/src/otclient/core/outfit.h @@ -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 diff --git a/src/otclient/net/protocolgame.h b/src/otclient/net/protocolgame.h index 27d67614..ab44ff79 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/net/protocolgame.h @@ -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); diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index 55e14a7e..3df83f04 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -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; diff --git a/src/otclient/ui/uiitem.cpp b/src/otclient/ui/uiitem.cpp index 278f6b01..c97dbc1c 100644 --- a/src/otclient/ui/uiitem.cpp +++ b/src/otclient/ui/uiitem.cpp @@ -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();