Fix minor issues in item drawing

* Add some utilities functions
master
Eduardo Bart 12 years ago
parent 122577a916
commit 9d5abb0243

@ -65,6 +65,12 @@ void Item::draw(const Point& dest, float scaleFactor, bool animate, LightView *l
// determine animation phase // determine animation phase
int animationPhase = calculateAnimationPhase(animate); 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 // determine x,y,z patterns
int xPattern = 0, yPattern = 0, zPattern = 0; 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 Item::getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
{ {
int exactSize = 0;
calculatePatterns(xPattern, yPattern, zPattern); calculatePatterns(xPattern, yPattern, zPattern);
animationPhase = calculateAnimationPhase(true); 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() const ThingTypePtr& Item::getThingType()

@ -20,8 +20,8 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef OTCLIENT_LUAVALUECASTS_H #ifndef CLIENT_LUAVALUECASTS_H
#define OTCLIENT_LUAVALUECASTS_H #define CLIENT_LUAVALUECASTS_H
#include "global.h" #include "global.h"
#include <framework/luaengine/declarations.h> #include <framework/luaengine/declarations.h>

@ -33,7 +33,7 @@ void UICreature::drawSelf(Fw::DrawPane drawPane)
if(m_creature) { if(m_creature) {
Rect drawRect = getPaddingRect(); Rect drawRect = getPaddingRect();
g_painter->setColor(Color::white); g_painter->setColor(m_imageColor);
m_creature->drawOutfit(drawRect, !m_fixedCreatureSize); 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()) { for(const OTMLNodePtr& node : styleNode->children()) {
if(node->tag() == "fixed-creature-size") if(node->tag() == "fixed-creature-size")
setFixedCreatureSize(node->value<bool>()); 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); drawImage(m_rect);
if(m_item) { if(m_itemVisible && m_item) {
Rect drawRect = getPaddingRect(); Rect drawRect = getPaddingRect();
Point dest = drawRect.bottomRight() + Point(1,1); 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>()); setItemId(node->value<int>());
else if(node->tag() == "item-count") else if(node->tag() == "item-count")
setItemCount(node->value<int>()); setItemCount(node->value<int>());
else if(node->tag() == "item-visible")
setItemVisible(node->value<bool>());
else if(node->tag() == "virtual") else if(node->tag() == "virtual")
setVirtual(node->value<bool>()); setVirtual(node->value<bool>());
} }

@ -36,6 +36,7 @@ public:
void setItemId(int id); void setItemId(int id);
void setItemCount(int count) { if(m_item) m_item->setCount(count); } void setItemCount(int count) { if(m_item) m_item->setCount(count); }
void setItemSubType(int subType) { if(m_item) m_item->setSubType(subType); } 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 setItem(const ItemPtr& item) { m_item = item; }
void setVirtual(bool virt) { m_virtual = virt; } void setVirtual(bool virt) { m_virtual = virt; }
void clearItem() { setItemId(0); } void clearItem() { setItemId(0); }
@ -45,12 +46,14 @@ public:
int getItemSubType() { return m_item ? m_item->getSubType() : 0; } int getItemSubType() { return m_item ? m_item->getSubType() : 0; }
ItemPtr getItem() { return m_item; } ItemPtr getItem() { return m_item; }
bool isVirtual() { return m_virtual; } bool isVirtual() { return m_virtual; }
bool isItemVisible() { return m_itemVisible; }
protected: protected:
void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode); void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
ItemPtr m_item; ItemPtr m_item;
stdext::boolean<false> m_virtual; stdext::boolean<false> m_virtual;
stdext::boolean<true> m_itemVisible;
}; };
#endif #endif

@ -5,7 +5,7 @@
FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h) FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h)
SET(_ZLIB_STATIC_LIBS libz.a libzlib.a zlib1.a) SET(_ZLIB_STATIC_LIBS libz.a libzlib.a zlib1.a)
SET(_ZLIB_SHARED_LIBS z zlib zdll zlib1) SET(_ZLIB_SHARED_LIBS libz.dll.a zdll zlib zlib1 z)
IF(USE_STATIC_LIBS) IF(USE_STATIC_LIBS)
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${_ZLIB_STATIC_LIBS} ${_ZLIB_SHARED_LIBS}) FIND_LIBRARY(ZLIB_LIBRARY NAMES ${_ZLIB_STATIC_LIBS} ${_ZLIB_SHARED_LIBS})
ELSE() ELSE()

@ -1,30 +0,0 @@
--- src/framework/core/resourcemanager.cpp
+++ src/framework/core/resourcemanager.cpp
@@ -34,19 +35,21 @@
void ResourceManager::discoverWorkDir(const std::string& existentFile)
{
// search for modules directory
- std::string sep = PHYSFS_getDirSeparator();
- std::string possiblePaths[] = { boost::filesystem::current_path().generic_string() + sep,
- g_resources.getBaseDir() + ".." + sep};
+ std::string possiblePaths[] = { g_resources.getCurrentDir(),
+ g_resources.getBaseDir(),
+ g_resources.getBaseDir() + "../" };
bool found = false;
for(const std::string& dir : possiblePaths) {
- // try to directory to modules path to see if it exists
- std::ifstream fin(dir + existentFile);
- if(fin) {
+ if(!PHYSFS_addToSearchPath(dir.c_str(), 0))
+ continue;
+
+ if(PHYSFS_exists(existentFile.c_str())) {
g_logger.debug(stdext::format("Found work dir at '%s'", dir.c_str()));
m_workDir = dir;
found = true;
break;
}
+ PHYSFS_removeFromSearchPath(dir.c_str());
}
if(!found)

@ -58,10 +58,10 @@ public:
const_iterator cend() const { return m_data + m_size; } const_iterator cend() const { return m_data + m_size; }
reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); } reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
size_type size() const { return m_size; } size_type size() const { return m_size; }
@ -140,7 +140,7 @@ public:
return tmp + i; return tmp + i;
} }
void swap(packed_vector<T,U>& other) { std::swap(m_size, other.m_size); std::swap(m_data, other.m_data); return *this; } void swap(packed_vector<T,U>& other) { std::swap(m_size, other.m_size); std::swap(m_data, other.m_data); }
operator std::vector<T>() const { return std::vector<T>(begin(), end()); } operator std::vector<T>() const { return std::vector<T>(begin(), end()); }

@ -63,6 +63,12 @@ public:
void setRGBA(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) { m_r = r/255.0f; m_g = g/255.0f; m_b = b/255.0f; m_a = a/255.0f; } void setRGBA(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) { m_r = r/255.0f; m_g = g/255.0f; m_b = b/255.0f; m_a = a/255.0f; }
void setRGBA(uint32 rgba) { setRGBA((rgba >> 0) & 0xff, (rgba >> 8) & 0xff, (rgba >> 16) & 0xff, (rgba >> 24) & 0xff); } void setRGBA(uint32 rgba) { setRGBA((rgba >> 0) & 0xff, (rgba >> 8) & 0xff, (rgba >> 16) & 0xff, (rgba >> 24) & 0xff); }
Color operator+(const Color& other) const { return Color(m_r + other.m_r, m_g + other.m_g, m_b + other.m_b, m_a + other.m_a); }
Color operator-(const Color& other) const { return Color(m_r - other.m_r, m_g - other.m_g, m_b - other.m_b, m_a - other.m_a); }
Color operator*(float v) const { return Color(m_r*v, m_g*v, m_b*v, m_a*v); }
Color operator/(float v) const { return Color(m_r/v, m_g/v, m_b/v, m_a/v); }
Color& operator=(uint32_t rgba) { setRGBA(rgba); return *this; } Color& operator=(uint32_t rgba) { setRGBA(rgba); return *this; }
bool operator==(uint32_t rgba) const { return this->rgba() == rgba; } bool operator==(uint32_t rgba) const { return this->rgba() == rgba; }

@ -24,6 +24,7 @@
#define RECT_H #define RECT_H
#include "../stdext/types.h" #include "../stdext/types.h"
#include "../const.h"
#include <sstream> #include <sstream>
template<class T> template<class T>
@ -108,6 +109,10 @@ public:
void moveBottomRight(const TPoint<T> &p) { moveRight(p.x); moveBottom(p.y); } void moveBottomRight(const TPoint<T> &p) { moveRight(p.x); moveBottom(p.y); }
void moveTopRight(const TPoint<T> &p) { moveRight(p.x); moveTop(p.y); } void moveTopRight(const TPoint<T> &p) { moveRight(p.x); moveTop(p.y); }
void moveBottomLeft(const TPoint<T> &p) { moveLeft(p.x); moveBottom(p.y); } void moveBottomLeft(const TPoint<T> &p) { moveLeft(p.x); moveBottom(p.y); }
void moveTopCenter(const TPoint<T> &p) { moveHorizontalCenter(p.x); moveTop(p.y); }
void moveBottomCenter(const TPoint<T> &p) { moveHorizontalCenter(p.x); moveBottom(p.y); }
void moveCenterLeft(const TPoint<T> &p) { moveLeft(p.x); moveVerticalCenter(p.y); }
void moveCenterRight(const TPoint<T> &p) { moveRight(p.x); moveVerticalCenter(p.y); }
TRect<T> translated(int x, int y) const { return TRect<T>(TPoint<T>(x1 + x, y1 + y), TPoint<T>(x2 + x, y2 + y)); } TRect<T> translated(int x, int y) const { return TRect<T>(TPoint<T>(x1 + x, y1 + y), TPoint<T>(x2 + x, y2 + y)); }
TRect<T> translated(const TPoint<T> &p) const { return TRect<T>(TPoint<T>(x1 + p.x, y1 + p.y), TPoint<T>(x2 + p.x, y2 + p.y)); } TRect<T> translated(const TPoint<T> &p) const { return TRect<T>(TPoint<T>(x1 + p.x, y1 + p.y), TPoint<T>(x2 + p.x, y2 + p.y)); }

Loading…
Cancel
Save