Fix minor issues in item drawing

* Add some utilities functions
This commit is contained in:
Eduardo Bart
2013-01-08 17:40:25 -02:00
parent 122577a916
commit 9d5abb0243
10 changed files with 59 additions and 39 deletions

View File

@@ -5,7 +5,7 @@
FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h)
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)
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${_ZLIB_STATIC_LIBS} ${_ZLIB_SHARED_LIBS})
ELSE()

View File

@@ -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)

View File

@@ -58,10 +58,10 @@ public:
const_iterator cend() const { return m_data + m_size; }
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()); }
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()); }
size_type size() const { return m_size; }
@@ -140,7 +140,7 @@ public:
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()); }

View File

@@ -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(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; }
bool operator==(uint32_t rgba) const { return this->rgba() == rgba; }

View File

@@ -24,6 +24,7 @@
#define RECT_H
#include "../stdext/types.h"
#include "../const.h"
#include <sstream>
template<class T>
@@ -108,6 +109,10 @@ public:
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 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(const TPoint<T> &p) const { return TRect<T>(TPoint<T>(x1 + p.x, y1 + p.y), TPoint<T>(x2 + p.x, y2 + p.y)); }