diff options
-rw-r--r-- | src/gui/widgets/desktop.cpp | 19 | ||||
-rw-r--r-- | src/gui/widgets/desktop.h | 3 | ||||
-rw-r--r-- | src/net/tmwserv/beinghandler.cpp | 2 | ||||
-rw-r--r-- | src/resources/image.cpp | 47 | ||||
-rw-r--r-- | src/resources/image.h | 6 |
5 files changed, 62 insertions, 15 deletions
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 6633d2ce..4583ef13 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -32,6 +32,9 @@ #include "log.h" #include "main.h" +#define VERSION_LABEL_X 25 +#define VERSION_LABEL_Y 2 + Desktop::Desktop() : mWallpaper(0) { @@ -40,7 +43,16 @@ Desktop::Desktop() Wallpaper::loadWallpapers(); gcn::Label *versionLabel = new Label(FULL_VERSION); - add(versionLabel, 25, 2); + add(versionLabel, VERSION_LABEL_X, VERSION_LABEL_Y); + + mVersionRectangle.x = VERSION_LABEL_X; + mVersionRectangle.y = VERSION_LABEL_Y; + mVersionRectangle.width = versionLabel->getWidth(); + mVersionRectangle.height = versionLabel->getHeight(); + + // Loads a white pattern and make it translucent... + mVersionBorder = Image::getColoredPattern(0xFF, 0xFF, 0xFF); + mVersionBorder->setAlpha(0.5f); } Desktop::~Desktop() @@ -84,6 +96,11 @@ void Desktop::draw(gcn::Graphics *graphics) getWidth(), getHeight(), false); } + // Draw a thin border under the application version... + g->drawImagePattern(mVersionBorder, mVersionRectangle.x, mVersionRectangle.y, + mVersionRectangle.width, + mVersionRectangle.height); + Container::draw(graphics); } diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index ad04ee96..267acead 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -59,7 +59,8 @@ class Desktop : public Container, gcn::WidgetListener private: void setBestFittingWallpaper(); - Image *mWallpaper; + Image *mWallpaper, *mVersionBorder; + gcn::Rectangle mVersionRectangle; }; #endif // DESKTOP_H diff --git a/src/net/tmwserv/beinghandler.cpp b/src/net/tmwserv/beinghandler.cpp index fc24a0ae..2eed1dc3 100644 --- a/src/net/tmwserv/beinghandler.cpp +++ b/src/net/tmwserv/beinghandler.cpp @@ -321,7 +321,7 @@ void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg) }; std::string message(deadMsg[rand()%13]); - message.append(" " + _("Press OK to respawn.")); + message.append(std::string(" ") + _("Press OK to respawn.")); OkDialog *dlg = new OkDialog(_("You Died"), message); dlg->addActionListener(&(Net::GameServer::Player::respawnListener)); } diff --git a/src/resources/image.cpp b/src/resources/image.cpp index dafc3e87..3f9f645a 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -299,18 +299,6 @@ bool Image::isAnOpenGLOne() const #endif } -Image *Image::getSubImage(int x, int y, int width, int height) -{ - // Create a new clipped sub-image -#ifdef USE_OPENGL - if (mUseOpenGL) - return new SubImage(this, mGLImage, x, y, width, height, - mTexWidth, mTexHeight); -#endif - - return new SubImage(this, mImage, x, y, width, height); -} - void Image::setAlpha(float a) { if (mAlpha == a) @@ -405,6 +393,29 @@ float Image::getAlpha() const return mAlpha; } +Image* Image::getColoredPattern(Uint8 red, Uint8 green, Uint8 blue) +{ + // A simple pattern used for pattern operations... + SDL_Surface* tmpSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, + 2, 2, 32, 0, 0, 0, 0); + + Image* patternImage = NULL; + + if(tmpSurface) + { + //Fill the surface white + SDL_FillRect(tmpSurface, + &tmpSurface->clip_rect, + SDL_MapRGB(tmpSurface->format, red, green, blue)); + + + patternImage = Image::load(tmpSurface); + } + SDL_FreeSurface(tmpSurface); + + return patternImage; +} + Image* Image::SDLgetScaledImage(int width, int height) { // No scaling on incorrect new values. @@ -458,6 +469,18 @@ int Image::powerOfTwo(int input) } #endif +Image *Image::getSubImage(int x, int y, int width, int height) +{ + // Create a new clipped sub-image +#ifdef USE_OPENGL + if (mUseOpenGL) + return new SubImage(this, mGLImage, x, y, width, height, + mTexWidth, mTexHeight); +#endif + + return new SubImage(this, mImage, x, y, width, height); +} + //============================================================================ // SubImage Class //============================================================================ diff --git a/src/resources/image.h b/src/resources/image.h index 25339e68..c67686e6 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -138,6 +138,12 @@ class Image : public Resource */ float getAlpha() const; + /** + * Returns a 2x2 image filled with the desired color. + * Useful for pattern operations. + */ + static Image* getColoredPattern(Uint8 red, Uint8 green, Uint8 blue); + #ifdef USE_OPENGL /** * Sets the target image format. Use <code>false</code> for SDL and |