summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/graphics.cpp15
-rw-r--r--src/graphics.h6
-rw-r--r--src/gui/gui.cpp5
-rw-r--r--src/guichan/graphics.cpp5
-rw-r--r--src/guichan/sdl/sdlgraphics.cpp90
-rw-r--r--src/guichanfwd.h1
-rw-r--r--src/resources/imageloader.cpp117
-rw-r--r--src/resources/imageloader.h70
10 files changed, 11 insertions, 302 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 68a0966a9..604484dde 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -411,8 +411,6 @@ SET(SRCS
resources/emotedb.h
resources/image.cpp
resources/image.h
- resources/imageloader.cpp
- resources/imageloader.h
resources/imageset.h
resources/imageset.cpp
resources/imagewriter.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f6ebd60f..295391096 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -427,8 +427,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
resources/emotedb.h \
resources/image.cpp \
resources/image.h \
- resources/imageloader.cpp \
- resources/imageloader.h \
resources/imageset.h \
resources/imageset.cpp \
resources/imagewriter.cpp \
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 677172420..f72e495c6 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -30,8 +30,6 @@
#include "logger.h"
#include "resources/image.h"
-#include "resources/imageloader.h"
-
#include "utils/stringutils.h"
#include <guichan/sdl/sdlpixel.hpp>
@@ -358,7 +356,7 @@ bool Graphics::drawImage(Image *image, int x, int y)
if (image)
{
return drawImage(image, 0, 0, x, y,
- image->mBounds.w, image->mBounds.h);
+ image->mBounds.w, image->mBounds.h, false);
}
else
{
@@ -444,17 +442,6 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
}
}
-void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY,
- int dstX, int dstY, int width, int height)
-{
- ProxyImage const *srcImage =
- dynamic_cast< ProxyImage const * >(image);
- if (!srcImage)
- return;
- drawImage(srcImage->getImage(), srcX, srcY, dstX, dstY,
- width, height, true);
-}
-
void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
{
// Check that preconditions for blitting are met.
diff --git a/src/graphics.h b/src/graphics.h
index 9b69f2f60..805b3a02f 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -118,12 +118,6 @@ class Graphics : public gcn::SDLGraphics
bool drawImage(Image *image, int x, int y);
/**
- * Overrides with our own drawing method.
- */
- void drawImage(gcn::Image const *image, int srcX, int srcY,
- int dstX, int dstY, int width, int height);
-
- /**
* Draws a resclaled version of the image
*/
bool drawRescaledImage(Image *image, int srcX, int srcY,
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 1536feb68..ea6112262 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -42,7 +42,6 @@
#include "resources/image.h"
#include "resources/imageset.h"
-#include "resources/imageloader.h"
#include "resources/resourcemanager.h"
#include "utils/langs.h"
@@ -89,10 +88,6 @@ Gui::Gui(Graphics *graphics):
// Set graphics
setGraphics(graphics);
- // Set image loader
- static ImageLoader imageLoader;
- gcn::Image::setImageLoader(&imageLoader);
-
// Set input
guiInput = new SDLInput;
setInput(guiInput);
diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp
index 0e414827c..1c99d899e 100644
--- a/src/guichan/graphics.cpp
+++ b/src/guichan/graphics.cpp
@@ -142,10 +142,9 @@ namespace gcn
return mClipStack.top();
}
- void Graphics::drawImage(const Image* image, int dstX, int dstY)
+ void Graphics::drawImage(const Image* image A_UNUSED,
+ int dstX A_UNUSED, int dstY A_UNUSED)
{
- drawImage(image, 0, 0, dstX, dstY,
- image->getWidth(), image->getHeight());
}
void Graphics::setFont(Font* font)
diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp
index ae61a0432..63ed8bbc2 100644
--- a/src/guichan/sdl/sdlgraphics.cpp
+++ b/src/guichan/sdl/sdlgraphics.cpp
@@ -129,92 +129,18 @@ namespace gcn
return mTarget;
}
- void SDLGraphics::drawImage(const Image* image,
- int srcX,
- int srcY,
- int dstX,
- int dstY,
- int width,
- int height)
+ void SDLGraphics::drawImage(const Image* image A_UNUSED,
+ int srcX A_UNUSED,
+ int srcY A_UNUSED,
+ int dstX A_UNUSED,
+ int dstY A_UNUSED,
+ int width A_UNUSED,
+ int height A_UNUSED)
{
- if (mClipStack.empty())
- {
- throw GCN_EXCEPTION("Clip stack is empty, perhaps you called a "
- "draw funtion outside of _beginDraw() and _endDraw()?");
- }
-
- const ClipRectangle& top = mClipStack.top();
-
- SDL_Rect src;
- SDL_Rect dst;
- src.x = srcX;
- src.y = srcY;
- src.w = width;
- src.h = height;
- dst.x = dstX + top.xOffset;
- dst.y = dstY + top.yOffset;
-
- const SDLImage* srcImage = dynamic_cast<const SDLImage*>(image);
-
- if (!srcImage)
- {
- throw GCN_EXCEPTION("Trying to draw an image of unknown format,"
- " must be an SDLImage.");
- }
-
- SDL_BlitSurface(srcImage->getSurface(), &src, mTarget, &dst);
}
- void SDLGraphics::fillRectangle(const Rectangle& rectangle)
+ void SDLGraphics::fillRectangle(const Rectangle& rectangle A_UNUSED)
{
- if (mClipStack.empty())
- {
- throw GCN_EXCEPTION("Clip stack is empty, perhaps you called a "
- "draw funtion outside of _beginDraw() and _endDraw()?");
- }
-
- const ClipRectangle& top = mClipStack.top();
-
- Rectangle area = rectangle;
- area.x += top.xOffset;
- area.y += top.yOffset;
-
- if (!area.isIntersecting(top))
- return;
-
- if (mAlpha)
- {
- int x1 = area.x > top.x ? area.x : top.x;
- int y1 = area.y > top.y ? area.y : top.y;
- int x2 = area.x + area.width < top.x + top.width ?
- area.x + area.width : top.x + top.width;
- int y2 = area.y + area.height < top.y + top.height ?
- area.y + area.height : top.y + top.height;
- int x, y;
-
- SDL_LockSurface(mTarget);
- for (y = y1; y < y2; y++)
- {
- for (x = x1; x < x2; x++)
- SDLputPixelAlpha(mTarget, x, y, mColor);
- }
- SDL_UnlockSurface(mTarget);
- }
- else
- {
- SDL_Rect rect;
- rect.x = area.x;
- rect.y = area.y;
- rect.w = area.width;
- rect.h = area.height;
-
- Uint32 color = SDL_MapRGBA(mTarget->format,
- mColor.r,
- mColor.g,
- mColor.b,
- mColor.a);
- SDL_FillRect(mTarget, &rect, color);
- }
}
void SDLGraphics::drawPoint(int x, int y)
diff --git a/src/guichanfwd.h b/src/guichanfwd.h
index 7ccc221b4..85a9c5cfa 100644
--- a/src/guichanfwd.h
+++ b/src/guichanfwd.h
@@ -53,7 +53,6 @@ namespace gcn
class ImageButton;
class InputEvent;
class ImageFont;
- class ImageLoader;
class Input;
class Key;
class KeyEvent;
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
deleted file mode 100644
index decf17189..000000000
--- a/src/resources/imageloader.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2012 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/imageloader.h"
-
-#include "resources/image.h"
-#include "resources/resourcemanager.h"
-
-#include <guichan/color.hpp>
-
-#include <guichan/sdl/sdlpixel.hpp>
-
-#include "debug.h"
-
-#ifdef free
-#undef free
-#endif
-
-ProxyImage::ProxyImage(SDL_Surface *s):
- mImage(nullptr),
- mSDLImage(s)
-{
-}
-
-ProxyImage::~ProxyImage()
-{
- free();
-}
-
-void ProxyImage::free()
-{
- if (mSDLImage)
- {
- SDL_FreeSurface(mSDLImage);
- mSDLImage = nullptr;
- }
- else
- {
- delete mImage;
- mImage = nullptr;
- }
-}
-
-int ProxyImage::getWidth() const
-{
- if (mSDLImage)
- return mSDLImage->w;
- else if (mImage)
- return mImage->mBounds.w;
- else
- return 0;
-}
-
-int ProxyImage::getHeight() const
-{
- if (mSDLImage)
- return mSDLImage->h;
- else if (mImage)
- return mImage->mBounds.h;
- else
- return 0;
-}
-
-gcn::Color ProxyImage::getPixel(int x, int y)
-{
- return gcn::SDLgetPixel(mSDLImage, x, y);
-}
-
-void ProxyImage::putPixel(int x, int y, gcn::Color const &color)
-{
- if (!mSDLImage)
- return;
- gcn::SDLputPixel(mSDLImage, x, y, color);
-}
-
-void ProxyImage::convertToDisplayFormat()
-{
- if (!mSDLImage)
- return;
-
- /* The picture is most probably full of the pink pixels Guichan uses for
- transparency, as this function will only be called when setting an image
- font. Get rid of them. */
- SDL_SetColorKey(mSDLImage, SDL_SRCCOLORKEY,
- SDL_MapRGB(mSDLImage->format, 255, 0, 255));
- mImage = ::Image::load(mSDLImage);
- SDL_FreeSurface(mSDLImage);
- mSDLImage = nullptr;
-}
-
-gcn::Image *ImageLoader::load(const std::string &filename, bool convert)
-{
- ResourceManager *resman = ResourceManager::getInstance();
- ProxyImage *i = new ProxyImage(resman->loadSDLSurface(filename));
- if (convert)
- i->convertToDisplayFormat();
- return i;
-}
diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h
deleted file mode 100644
index 1dcd046ca..000000000
--- a/src/resources/imageloader.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2012 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef IMAGELOADER_H
-#define IMAGELOADER_H
-
-#include <guichan/image.hpp>
-#include <guichan/imageloader.hpp>
-
-#include <string>
-
-class Image;
-struct SDL_Surface;
-
-class ProxyImage : public gcn::Image
-{
- public:
- ProxyImage(SDL_Surface *);
- ~ProxyImage();
-
- void free();
- int getWidth() const;
- int getHeight() const;
- gcn::Color getPixel(int x, int y);
- void putPixel(int x, int y, gcn::Color const &color);
- void convertToDisplayFormat();
-
- /**
- * Gets the image handled by this proxy.
- */
- ::Image *getImage() const
- { return mImage; }
-
- private:
- ::Image *mImage; /**< The real image. */
-
- /**
- * An SDL surface kept around until Guichan is done reading pixels from
- * an OpenGL texture.
- */
- SDL_Surface *mSDLImage;
-};
-
-class ImageLoader : public gcn::ImageLoader
-{
- public:
- gcn::Image *load(const std::string &filename,
- bool convertToDisplayFormat);
-};
-
-#endif