summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/graphics/gui/CMakeLists.txt2
-rw-r--r--data/graphics/gui/bg.xml (renamed from data/graphics/images/bg.xml)0
-rw-r--r--data/graphics/gui/scrolls.png (renamed from data/graphics/images/scrolls.png)bin2230 -> 2230 bytes
-rw-r--r--data/graphics/images/CMakeLists.txt3
-rw-r--r--data/graphics/images/login_wallpaper.pngbin10948 -> 0 bytes
-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
11 files changed, 65 insertions, 6 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index 51782750..ab114449 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -1,4 +1,5 @@
SET (FILES
+ bg.xml
bubble.png
button.png
button-icon-confirm.png
@@ -37,6 +38,7 @@ SET (FILES
radioout.png
radioout_highlight.png
resize.png
+ scrolls.png
selection.png
slider.png
slider_hilight.png
diff --git a/data/graphics/images/bg.xml b/data/graphics/gui/bg.xml
index c4fd11f6..c4fd11f6 100644
--- a/data/graphics/images/bg.xml
+++ b/data/graphics/gui/bg.xml
diff --git a/data/graphics/images/scrolls.png b/data/graphics/gui/scrolls.png
index 79f534e3..79f534e3 100644
--- a/data/graphics/images/scrolls.png
+++ b/data/graphics/gui/scrolls.png
Binary files differ
diff --git a/data/graphics/images/CMakeLists.txt b/data/graphics/images/CMakeLists.txt
index 6694f254..f3fa7180 100644
--- a/data/graphics/images/CMakeLists.txt
+++ b/data/graphics/images/CMakeLists.txt
@@ -1,5 +1,6 @@
SET(FILES
- login_wallpaper.png
+ bg_image.png
+ bg_overlay.png
)
INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/graphics/images)
diff --git a/data/graphics/images/login_wallpaper.png b/data/graphics/images/login_wallpaper.png
deleted file mode 100644
index 109acccd..00000000
--- a/data/graphics/images/login_wallpaper.png
+++ /dev/null
Binary files differ
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: