summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/animatedsprite.cpp4
-rw-r--r--src/graphics.cpp12
-rw-r--r--src/gui/minimap.cpp26
-rw-r--r--src/gui/outfitwindow.cpp4
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/icon.cpp10
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/resizegrip.cpp4
-rw-r--r--src/imageparticle.cpp8
-rw-r--r--src/opengl1graphics.cpp4
-rw-r--r--src/openglgraphics.cpp8
-rw-r--r--src/resources/ambientlayer.cpp12
-rw-r--r--src/resources/image.cpp6
-rw-r--r--src/resources/image.h3
-rw-r--r--src/resources/imageloader.cpp4
15 files changed, 58 insertions, 55 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 215fd9ad6..8ccdd61e5 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -274,7 +274,7 @@ unsigned int AnimatedSprite::getFrameCount() const
int AnimatedSprite::getWidth() const
{
if (mFrame && mFrame->image)
- return mFrame->image->getWidth();
+ return mFrame->image->mBounds.w;
else
return 0;
}
@@ -282,7 +282,7 @@ int AnimatedSprite::getWidth() const
int AnimatedSprite::getHeight() const
{
if (mFrame && mFrame->image)
- return mFrame->image->getHeight();
+ return mFrame->image->mBounds.h;
else
return 0;
}
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 076f9c8e2..ff8bda066 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -243,8 +243,8 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
if (!image->mSDLSurface)
return;
- const int iw = image->getWidth();
- const int ih = image->getHeight();
+ const int iw = image->mBounds.w;
+ const int ih = image->mBounds.h;
if (iw == 0 || ih == 0) return;
@@ -291,8 +291,8 @@ void Graphics::drawRescaledImagePattern(Image *image, int x, int y,
if (!tmpImage)
return;
- const int iw = tmpImage->getWidth();
- const int ih = tmpImage->getHeight();
+ const int iw = tmpImage->mBounds.w;
+ const int ih = tmpImage->mBounds.h;
if (iw == 0 || ih == 0)
return;
@@ -516,8 +516,8 @@ void Graphics::calcImagePattern(GraphicsVertexes* vert,
}
vert->clearSDL();
- const int iw = image->getWidth();
- const int ih = image->getHeight();
+ const int iw = image->mBounds.w;
+ const int ih = image->mBounds.h;
if (iw == 0 || ih == 0)
{
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index dd0edc0ba..5022f9210 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -165,22 +165,22 @@ void Minimap::setMap(Map *map)
const int offsetX = 2 * getPadding();
const int offsetY = getTitleBarHeight() + getPadding();
const int titleWidth = getFont()->getWidth(getCaption()) + 15;
- const int mapWidth = mMapImage->getWidth() < 100 ?
- mMapImage->getWidth() + offsetX : 100;
- const int mapHeight = mMapImage->getHeight() < 100 ?
- mMapImage->getHeight() + offsetY : 100;
+ const int mapWidth = mMapImage->mBounds.w < 100 ?
+ mMapImage->mBounds.w + offsetX : 100;
+ const int mapHeight = mMapImage->mBounds.h < 100 ?
+ mMapImage->mBounds.h + offsetY : 100;
setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
setMinHeight(mapHeight);
mWidthProportion = static_cast<float>(
- mMapImage->getWidth()) / static_cast<float>(map->getWidth());
+ mMapImage->mBounds.w) / static_cast<float>(map->getWidth());
mHeightProportion = static_cast<float>(
- mMapImage->getHeight()) / static_cast<float>(map->getHeight());
+ mMapImage->mBounds.h) / static_cast<float>(map->getHeight());
- setMaxWidth(mMapImage->getWidth() > titleWidth ?
- mMapImage->getWidth() + offsetX : titleWidth);
- setMaxHeight(mMapImage->getHeight() + offsetY);
+ setMaxWidth(mMapImage->mBounds.w > titleWidth ?
+ mMapImage->mBounds.w + offsetX : titleWidth);
+ setMaxHeight(mMapImage->mBounds.h + offsetY);
setDefaultSize(getX(), getY(), getWidth(), getHeight());
resetToDefaultSize();
@@ -219,8 +219,8 @@ void Minimap::draw(gcn::Graphics *graphics)
if (mMapImage)
{
- if (mMapImage->getWidth() > a.width ||
- mMapImage->getHeight() > a.height)
+ if (mMapImage->mBounds.w > a.width ||
+ mMapImage->mBounds.h > a.height)
{
const Vector &p = player_node->getPosition();
mapOriginX = ((a.width) / 2) - static_cast<int>((p.x
@@ -231,8 +231,8 @@ void Minimap::draw(gcn::Graphics *graphics)
+ viewport->getCameraRelativeX()) * static_cast<int>(
mHeightProportion)) / 32;
- const int minOriginX = a.width - mMapImage->getWidth();
- const int minOriginY = a.height - mMapImage->getHeight();
+ const int minOriginX = a.width - mMapImage->mBounds.w;
+ const int minOriginY = a.height - mMapImage->mBounds.h;
if (mapOriginX < minOriginX)
mapOriginX = minOriginX;
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 8e7fbd1d1..93dbd77a9 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -342,8 +342,8 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
Image* image = mItemMoved->getImage();
if (image)
{
- const int tPosX = mCursorPosX - (image->getWidth() / 2);
- const int tPosY = mCursorPosY - (image->getHeight() / 2);
+ const int tPosX = mCursorPosX - (image->mBounds.w / 2);
+ const int tPosY = mCursorPosY - (image->mBounds.h / 2);
g->drawImage(image, tPosX, tPosY);
}
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index fd920ffa4..7fec6bf44 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -156,8 +156,8 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
Image* image = mItemMoved->getImage();
if (image)
{
- const int tPosX = mCursorPosX - (image->getWidth() / 2);
- const int tPosY = mCursorPosY - (image->getHeight() / 2);
+ const int tPosX = mCursorPosX - (image->mBounds.w / 2);
+ const int tPosY = mCursorPosY - (image->mBounds.h / 2);
g->drawImage(image, tPosX, tPosY);
g->drawText(toString(mItemMoved->getQuantity()),
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 2799080b6..3e9c7dd24 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -34,21 +34,21 @@ Icon::Icon(const std::string &file)
{
mImage = ResourceManager::getInstance()->getImage(file);
if (mImage)
- setSize(mImage->getWidth(), mImage->getHeight());
+ setSize(mImage->mBounds.w, mImage->mBounds.h);
}
Icon::Icon(Image *image)
: mImage(image)
{
if (mImage)
- setSize(mImage->getWidth(), mImage->getHeight());
+ setSize(mImage->mBounds.w, mImage->mBounds.h);
}
void Icon::setImage(Image *image)
{
mImage = image;
if (mImage)
- setSize(mImage->getWidth(), mImage->getHeight());
+ setSize(mImage->mBounds.w, mImage->mBounds.h);
}
void Icon::draw(gcn::Graphics *g)
@@ -56,8 +56,8 @@ void Icon::draw(gcn::Graphics *g)
if (mImage)
{
Graphics *graphics = static_cast<Graphics*>(g);
- const int x = (getWidth() - mImage->getWidth()) / 2;
- const int y = (getHeight() - mImage->getHeight()) / 2;
+ const int x = (getWidth() - mImage->mBounds.w) / 2;
+ const int y = (getHeight() - mImage->mBounds.h) / 2;
graphics->drawImage(mImage, x, y);
}
}
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index b33c7ee26..ab089ca45 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -196,8 +196,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
Image* image = mItemMoved->getImage();
if (image)
{
- const int tPosX = mCursorPosX - (image->getWidth() / 2);
- const int tPosY = mCursorPosY - (image->getHeight() / 2);
+ const int tPosX = mCursorPosX - (image->mBounds.w / 2);
+ const int tPosY = mCursorPosY - (image->mBounds.h / 2);
g->drawImage(image, tPosX, tPosY);
g->drawText(toString(mItemMoved->getQuantity()),
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index f477e51a8..861dde29e 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -52,8 +52,8 @@ ResizeGrip::ResizeGrip(const std::string &image)
if (gripImage)
{
- setWidth(gripImage->getWidth() + 2);
- setHeight(gripImage->getHeight() + 2);
+ setWidth(gripImage->mBounds.w + 2);
+ setHeight(gripImage->mBounds.h + 2);
}
else
{
diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp
index ca220bcc4..e38dc8cb5 100644
--- a/src/imageparticle.cpp
+++ b/src/imageparticle.cpp
@@ -70,14 +70,14 @@ bool ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
if (!isAlive() || !mImage)
return false;
- int screenX = static_cast<int>(mPos.x) + offsetX - mImage->getWidth() / 2;
+ int screenX = static_cast<int>(mPos.x) + offsetX - mImage->mBounds.w / 2;
int screenY = static_cast<int>(mPos.y) - static_cast<int>(mPos.z)
- + offsetY - mImage->getHeight() / 2;
+ + offsetY - mImage->mBounds.h / 2;
// Check if on screen
- if (screenX + mImage->getWidth() < 0 ||
+ if (screenX + mImage->mBounds.w < 0 ||
screenX > graphics->getWidth() ||
- screenY + mImage->getHeight() < 0 ||
+ screenY + mImage->mBounds.h < 0 ||
screenY > graphics->getHeight())
{
return false;
diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp
index 5f22171d0..78396c8c8 100644
--- a/src/opengl1graphics.cpp
+++ b/src/opengl1graphics.cpp
@@ -316,8 +316,8 @@ void OpenGL1Graphics::drawImagePattern(Image *image, int x, int y,
const int srcX = image->mBounds.x;
const int srcY = image->mBounds.y;
- const int iw = image->getWidth();
- const int ih = image->getHeight();
+ const int iw = image->mBounds.w;
+ const int ih = image->mBounds.h;
if (iw == 0 || ih == 0)
return;
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index ea5d11c27..b2e4d8931 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -363,8 +363,8 @@ void OpenGLGraphics::drawImagePattern(Image *image, int x, int y, int w, int h)
const int srcX = image->mBounds.x;
const int srcY = image->mBounds.y;
- const int iw = image->getWidth();
- const int ih = image->getHeight();
+ const int iw = image->mBounds.w;
+ const int ih = image->mBounds.h;
if (iw == 0 || ih == 0)
return;
@@ -684,8 +684,8 @@ void OpenGLGraphics::calcImagePattern(GraphicsVertexes* vert, Image *image,
const int srcX = image->mBounds.x;
const int srcY = image->mBounds.y;
- const int iw = image->getWidth();
- const int ih = image->getHeight();
+ const int iw = image->mBounds.w;
+ const int ih = image->mBounds.h;
if (iw == 0 || ih == 0)
{
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index caa4d46bf..09a235e59 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -47,9 +47,9 @@ AmbientLayer::AmbientLayer(Image *img, float parallax,
// Rescale the overlay to keep the ratio as if we were on
// the default resolution...
Image *rescaledOverlay = ResourceManager::getInstance()->
- getRescaled(mImage, static_cast<int>(mImage->getWidth())
+ getRescaled(mImage, static_cast<int>(mImage->mBounds.w)
/ defaultScreenWidth * graphics->getWidth(),
- static_cast<int>(mImage->getHeight())
+ static_cast<int>(mImage->mBounds.h)
/ defaultScreenHeight * graphics->getHeight());
if (rescaledOverlay)
@@ -85,8 +85,8 @@ void AmbientLayer::update(int timePassed, float dx, float dy)
mPosX += dx * mParallax;
mPosY += dy * mParallax;
- int imgW = mImage->getWidth();
- int imgH = mImage->getHeight();
+ int imgW = mImage->mBounds.w;
+ int imgH = mImage->mBounds.h;
// Wrap values
while (mPosX > imgW)
@@ -116,9 +116,9 @@ void AmbientLayer::draw(Graphics *graphics, int x, int y)
graphics->drawRescaledImagePattern(mImage, static_cast<int>(-mPosX),
static_cast<int>(-mPosY), x + static_cast<int>(mPosX),
y + static_cast<int>(mPosY),
- static_cast<int>(mImage->getWidth())
+ static_cast<int>(mImage->mBounds.w)
/ defaultScreenWidth * graphics->getWidth(),
- static_cast<int>(mImage->getHeight()) / defaultScreenHeight
+ static_cast<int>(mImage->mBounds.h) / defaultScreenHeight
* graphics->getHeight());
}
}
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index ec74630ff..2d3676304 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -386,8 +386,10 @@ Image* Image::SDLmerge(Image *image, int x, int y)
SDL_LockSurface(mSDLSurface);
const int x0 = (y * getWidth()) + x;
- const int maxX = std::min(image->getWidth(), getWidth() - x);
- const int maxY = std::min(image->getHeight(), getHeight() - y);
+ const int maxX = std::min(image->mBounds.w,
+ static_cast<Uint16>(mBounds.w - x));
+ const int maxY = std::min(image->mBounds.w,
+ static_cast<Uint16>(mBounds.h - y));
// for each pixel lines of a source image
for (offset_x = (x > 0 ? 0 : -x); offset_x < maxX; offset_x++)
diff --git a/src/resources/image.h b/src/resources/image.h
index 4f59ba1ae..72b85cc1e 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -214,13 +214,14 @@ class Image : public Resource
static int mTextureType;
#endif
+ SDL_Rect mBounds;
+
protected:
// -----------------------
// Generic protected members
// -----------------------
- SDL_Rect mBounds;
bool mLoaded;
float mAlpha;
bool mHasAlphaChannel;
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index fa5d0eea1..c63d33c00 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -66,7 +66,7 @@ int ProxyImage::getWidth() const
if (mSDLImage)
return mSDLImage->w;
else if (mImage)
- return mImage->getWidth();
+ return mImage->mBounds.w;
else
return 0;
}
@@ -76,7 +76,7 @@ int ProxyImage::getHeight() const
if (mSDLImage)
return mSDLImage->h;
else if (mImage)
- return mImage->getHeight();
+ return mImage->mBounds.h;
else
return 0;
// return mSDLImage ? mSDLImage->h : mImage->getHeight();