mirror of
https://github.com/edubart/otclient.git
synced 2025-12-02 16:06:51 +01:00
Fix minor issues in item drawing
* Add some utilities functions
This commit is contained in:
@@ -65,6 +65,12 @@ void Item::draw(const Point& dest, float scaleFactor, bool animate, LightView *l
|
||||
|
||||
// determine animation phase
|
||||
int animationPhase = calculateAnimationPhase(animate);
|
||||
if(getAnimationPhases() > 1) {
|
||||
if(animate)
|
||||
animationPhase = (g_clock.millis() % (Otc::ITEM_TICKS_PER_FRAME * getAnimationPhases())) / Otc::ITEM_TICKS_PER_FRAME;
|
||||
else
|
||||
animationPhase = getAnimationPhases()-1;
|
||||
}
|
||||
|
||||
// determine x,y,z patterns
|
||||
int xPattern = 0, yPattern = 0, zPattern = 0;
|
||||
@@ -353,9 +359,12 @@ int Item::calculateAnimationPhase(bool animate)
|
||||
|
||||
int Item::getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
|
||||
{
|
||||
int exactSize = 0;
|
||||
calculatePatterns(xPattern, yPattern, zPattern);
|
||||
animationPhase = calculateAnimationPhase(true);
|
||||
return Thing::getExactSize(0, xPattern, yPattern, zPattern, animationPhase);
|
||||
for(layer = 0; layer < getLayers(); ++layer)
|
||||
exactSize = std::max(exactSize, Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase));
|
||||
return exactSize;
|
||||
}
|
||||
|
||||
const ThingTypePtr& Item::getThingType()
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef OTCLIENT_LUAVALUECASTS_H
|
||||
#define OTCLIENT_LUAVALUECASTS_H
|
||||
#ifndef CLIENT_LUAVALUECASTS_H
|
||||
#define CLIENT_LUAVALUECASTS_H
|
||||
|
||||
#include "global.h"
|
||||
#include <framework/luaengine/declarations.h>
|
||||
|
||||
@@ -33,7 +33,7 @@ void UICreature::drawSelf(Fw::DrawPane drawPane)
|
||||
|
||||
if(m_creature) {
|
||||
Rect drawRect = getPaddingRect();
|
||||
g_painter->setColor(Color::white);
|
||||
g_painter->setColor(m_imageColor);
|
||||
m_creature->drawOutfit(drawRect, !m_fixedCreatureSize);
|
||||
}
|
||||
}
|
||||
@@ -53,5 +53,30 @@ void UICreature::onStyleApply(const std::string& styleName, const OTMLNodePtr& s
|
||||
for(const OTMLNodePtr& node : styleNode->children()) {
|
||||
if(node->tag() == "fixed-creature-size")
|
||||
setFixedCreatureSize(node->value<bool>());
|
||||
else if(node->tag() == "outfit-id") {
|
||||
Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
|
||||
outfit.setId(node->value<int>());
|
||||
setOutfit(outfit);
|
||||
}
|
||||
else if(node->tag() == "outfit-head") {
|
||||
Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
|
||||
outfit.setHead(node->value<int>());
|
||||
setOutfit(outfit);
|
||||
}
|
||||
else if(node->tag() == "outfit-body") {
|
||||
Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
|
||||
outfit.setBody(node->value<int>());
|
||||
setOutfit(outfit);
|
||||
}
|
||||
else if(node->tag() == "outfit-legs") {
|
||||
Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
|
||||
outfit.setLegs(node->value<int>());
|
||||
setOutfit(outfit);
|
||||
}
|
||||
else if(node->tag() == "outfit-feet") {
|
||||
Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
|
||||
outfit.setFeet(node->value<int>());
|
||||
setOutfit(outfit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ void UIItem::drawSelf(Fw::DrawPane drawPane)
|
||||
|
||||
drawImage(m_rect);
|
||||
|
||||
if(m_item) {
|
||||
if(m_itemVisible && m_item) {
|
||||
Rect drawRect = getPaddingRect();
|
||||
Point dest = drawRect.bottomRight() + Point(1,1);
|
||||
|
||||
@@ -97,6 +97,8 @@ void UIItem::onStyleApply(const std::string& styleName, const OTMLNodePtr& style
|
||||
setItemId(node->value<int>());
|
||||
else if(node->tag() == "item-count")
|
||||
setItemCount(node->value<int>());
|
||||
else if(node->tag() == "item-visible")
|
||||
setItemVisible(node->value<bool>());
|
||||
else if(node->tag() == "virtual")
|
||||
setVirtual(node->value<bool>());
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
void setItemId(int id);
|
||||
void setItemCount(int count) { if(m_item) m_item->setCount(count); }
|
||||
void setItemSubType(int subType) { if(m_item) m_item->setSubType(subType); }
|
||||
void setItemVisible(bool visible) { m_itemVisible = visible; }
|
||||
void setItem(const ItemPtr& item) { m_item = item; }
|
||||
void setVirtual(bool virt) { m_virtual = virt; }
|
||||
void clearItem() { setItemId(0); }
|
||||
@@ -45,12 +46,14 @@ public:
|
||||
int getItemSubType() { return m_item ? m_item->getSubType() : 0; }
|
||||
ItemPtr getItem() { return m_item; }
|
||||
bool isVirtual() { return m_virtual; }
|
||||
bool isItemVisible() { return m_itemVisible; }
|
||||
|
||||
protected:
|
||||
void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
|
||||
|
||||
ItemPtr m_item;
|
||||
stdext::boolean<false> m_virtual;
|
||||
stdext::boolean<true> m_itemVisible;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user