Hopefully fixed <origin> tag. In particular, it's now a float instead of an int (as it should've been!).

This commit is contained in:
Aloshi 2012-08-15 01:18:06 -05:00
parent e42568bc55
commit 7b97a464c3
3 changed files with 8 additions and 8 deletions

View file

@ -15,8 +15,8 @@ GuiImage::GuiImage(int offsetX, int offsetY, std::string path, unsigned int maxW
mOffsetY = offsetY;
//default origin (center of image)
mOriginX = 0;
mOriginY = 0;
mOriginX = 0.5;
mOriginY = 0.5;
mTiled = false;
@ -141,7 +141,7 @@ void GuiImage::setImage(std::string path)
void GuiImage::updateRect()
{
mRect.x = mOffsetX /*- mSurface->w*/ - (mSurface->w * mOriginX);
mRect.y = mOffsetY + (mSurface->h * mOriginY);
mRect.y = mOffsetY - (mSurface->h * mOriginY);
mRect.w = mSurface->w;
mRect.h = mSurface->h;
}

View file

@ -135,8 +135,8 @@ GuiComponent* GuiTheme::createElement(pugi::xml_node data, GuiComponent* parent)
int w = resolveExp(dimW) * Renderer::getScreenWidth();
int h = resolveExp(dimH) * Renderer::getScreenHeight();
int ox = strToInt(originX);
int oy = strToInt(originY);
float ox = strToFloat(originX);
float oy = strToFloat(originY);
std::cout << "w: " << w << "px, h: " << h << "px\n";
@ -201,12 +201,12 @@ void GuiTheme::splitString(std::string str, char delim, std::string* before, std
*after = str.substr(split + 1, str.length() - split - 1);
}
int GuiTheme::strToInt(std::string str)
float GuiTheme::strToFloat(std::string str)
{
if(str.empty())
return 0;
int ret;
float ret;
std::stringstream ss;
ss << str;
ss >> ret;

View file

@ -29,7 +29,7 @@ private:
float resolveExp(std::string str);
int resolveColor(std::string str, int defaultColor = 0x000000);
void splitString(std::string str, char delim, std::string* before, std::string* after);
int strToInt(std::string str);
float strToFloat(std::string str);
std::vector<GuiComponent*> mComponentVector;
std::string mPath;