summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphics.cpp4
-rw-r--r--src/graphics.h4
-rw-r--r--src/gui/widgets/desktop.cpp43
-rw-r--r--src/gui/widgets/desktop.h4
-rw-r--r--src/resources/theme.cpp6
-rw-r--r--src/resources/theme.h5
6 files changed, 61 insertions, 5 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 61cc78ba..08b1b298 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -188,8 +188,8 @@ bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY,
SDL_Rect srcRect;
dstRect.x = dstX; dstRect.y = dstY;
srcRect.x = srcX; srcRect.y = srcY;
- srcRect.w = width;
- srcRect.h = height;
+ srcRect.w = tmpImage->getWidth();
+ srcRect.h = tmpImage->getHeight();
returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect,
mTarget, &dstRect) < 0);
diff --git a/src/graphics.h b/src/graphics.h
index 4c1b2561..36a9adb9 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -102,7 +102,7 @@ class Graphics : public gcn::SDLGraphics
bool drawImage(Image *image, int x, int y);
/**
- * Draws a resclaled version of the image
+ * Draws a rescaled version of the image.
*/
bool drawRescaledImage(Image *image, int srcX, int srcY,
int dstX, int dstY,
@@ -115,7 +115,7 @@ class Graphics : public gcn::SDLGraphics
false); }
/**
- * Draws a resclaled version of the image
+ * Draws a rescaled version of the image.
*/
virtual bool drawRescaledImage(Image *image, int srcX, int srcY,
int dstX, int dstY,
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index ce609891..ec76f861 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -32,12 +32,16 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include "resources/wallpaper.h"
#include "utils/stringutils.h"
Desktop::Desktop()
: mWallpaper(0)
+ , mBackground(ResourceManager::getInstance()->getImage("graphics/images/bg_image.png"))
+ , mOverlay(ResourceManager::getInstance()->getImage("graphics/images/bg_overlay.png"))
+ , mBgSkin(Theme::instance()->load("bg.xml"))
{
addWidgetListener(this);
@@ -59,6 +63,10 @@ Desktop::~Desktop()
{
if (mWallpaper)
mWallpaper->decRef();
+
+ mBgSkin->instances--;
+ mBackground->decRef();
+ mOverlay->decRef();
}
void Desktop::reloadWallpaper()
@@ -96,6 +104,41 @@ void Desktop::draw(gcn::Graphics *graphics)
getWidth(), getHeight(), false);
}
+ mBgSkin->setAlpha(1.0f);
+ g->drawImageRect(gcn::Rectangle(5, 5, getWidth() - 10, getHeight() - 10),
+ mBgSkin->getBorder());
+
+ gcn::Rectangle innerArea(5 + 64,
+ 5 + 64,
+ getWidth() - 10 - 64 * 2,
+ getHeight() - 10 - 64 * 2);
+
+ if (innerArea.width > 0 && innerArea.height > 0)
+ {
+ g->pushClipArea(innerArea);
+
+ float scale = std::max((float) innerArea.width / mBackground->getWidth(),
+ (float) innerArea.height / mBackground->getHeight());
+
+ int width = scale * mBackground->getWidth();
+ int height = scale * mBackground->getHeight();
+
+ g->drawRescaledImage(mBackground, 0, 0,
+ (innerArea.width - width) / 2,
+ (innerArea.height - height) / 2,
+ mBackground->getWidth(),
+ mBackground->getHeight(),
+ width, height, false);
+
+ g->drawRescaledImage(mOverlay, 0, 0, -1, -1,
+ mOverlay->getWidth(),
+ mOverlay->getHeight(),
+ innerArea.width + 2,
+ innerArea.height + 2, false);
+
+ g->popClipArea();
+ }
+
// Draw a thin border under the application version...
g->setColor(gcn::Color(255, 255, 255, 128));
g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension()));
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index 8ecb7e03..e2ff207c 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -29,6 +29,7 @@
#include <guichan/widgetlistener.hpp>
class Image;
+class Skin;
/**
* Desktop widget, for drawing a background image and color.
@@ -62,6 +63,9 @@ class Desktop : public Container, gcn::WidgetListener
void setBestFittingWallpaper();
Image *mWallpaper;
+ Image *mBackground;
+ Image *mOverlay;
+ Skin *mBgSkin;
gcn::Label *mVersionLabel;
};
diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp
index dde7bb3c..036cd4a3 100644
--- a/src/resources/theme.cpp
+++ b/src/resources/theme.cpp
@@ -82,8 +82,12 @@ Skin::~Skin()
void Skin::updateAlpha(float minimumOpacityAllowed)
{
const float alpha = std::max(minimumOpacityAllowed,
- config.getFloatValue("guialpha"));
+ config.getFloatValue("guialpha"));
+ setAlpha(alpha);
+}
+void Skin::setAlpha(float alpha)
+{
for_each(mBorder.grid, mBorder.grid + 9,
std::bind2nd(std::mem_fun(&Image::setAlpha), alpha));
diff --git a/src/resources/theme.h b/src/resources/theme.h
index 98904518..426f1a7e 100644
--- a/src/resources/theme.h
+++ b/src/resources/theme.h
@@ -89,6 +89,11 @@ class Skin
*/
void updateAlpha(float minimumOpacityAllowed = 0.0f);
+ /**
+ * Sets the alpha, overriding GUI opacity level.
+ */
+ void setAlpha(float alpha);
+
int instances;
private: