summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-02-27 01:54:10 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-02-27 01:54:10 +0000
commitd0aedbeaa22104f625483417bcb632a94e552a52 (patch)
tree70d0c152d516c331dc09fed1606c39d81402627a
parent5410d1613e6f0c8a8b91fffea18387c39bd5f9f5 (diff)
downloadmana-client-d0aedbeaa22104f625483417bcb632a94e552a52.tar.gz
mana-client-d0aedbeaa22104f625483417bcb632a94e552a52.tar.bz2
mana-client-d0aedbeaa22104f625483417bcb632a94e552a52.tar.xz
mana-client-d0aedbeaa22104f625483417bcb632a94e552a52.zip
No more SDL_Surface in the chat box.
-rw-r--r--src/gui/chat.cpp45
-rw-r--r--src/gui/chat.h3
2 files changed, 12 insertions, 36 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index ac611012..ed1f74d6 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -31,26 +31,16 @@ ChatBox::ChatBox(const char *logfile, int item_num)
items = 0;
items_keep = item_num;
- chatBoxBackground = SDL_AllocSurface(SDL_SWSURFACE, 200, 200, (screen->format->BytesPerPixel*8), 0, 0, 0, 0);
- Uint32 boxColor = SDL_MapRGB(screen->format, 255, 255, 255);
- SDL_Rect sourceRect;
- sourceRect.x = sourceRect.y = 0;
- sourceRect.w = 200;
- sourceRect.h = 200;
- if ( chatBoxBackground )
- {
- SDL_FillRect(chatBoxBackground, &sourceRect, boxColor);
- SDL_SetAlpha(chatBoxBackground, SDL_SRCALPHA, 120);
- }
-
+ chatBoxBackground = new Image();
+ chatBoxBackground->create(200, 200);
+ chatBoxBackground->fillWithColor(255, 255, 255);
+ chatBoxBackground->setAlpha(0.7f);
}
ChatBox::~ChatBox()
{
chatlog_file.flush();
chatlog_file.close();
-
- SDL_FreeSurface(chatBoxBackground);
}
void ChatBox::chat_log(std::string line, int own)
@@ -111,30 +101,15 @@ void ChatBox::draw(gcn::Graphics *graphics)
getAbsolutePosition(x, y);
- if ( (chatBoxBackground->w != getWidth()) || (chatBoxBackground->h != getHeight()) )
+ if ( (chatBoxBackground->getWidth() != getWidth()) || (chatBoxBackground->getHeight() != getHeight()) )
{
- SDL_FreeSurface(chatBoxBackground);
- chatBoxBackground = SDL_AllocSurface(SDL_SWSURFACE, getWidth(), getHeight(),
- (screen->format->BytesPerPixel*8), 0, 0, 0, 0);
- Uint32 boxColor = SDL_MapRGB(screen->format, 255, 255, 255);
- SDL_Rect sourceRect;
- sourceRect.x = sourceRect.y = 0;
- sourceRect.w = getWidth();
- sourceRect.h = getHeight();
- if ( chatBoxBackground )
- {
- SDL_FillRect(chatBoxBackground, &sourceRect, boxColor);
- SDL_SetAlpha(chatBoxBackground, SDL_SRCALPHA, 120);
- }
-
+ chatBoxBackground->unload();
+ chatBoxBackground->create(getWidth(), getHeight());
+ chatBoxBackground->fillWithColor(255, 255, 255);
+ chatBoxBackground->setAlpha(0.7f);
}
- SDL_Rect screenRect;
- screenRect.w = getWidth();
- screenRect.h = getHeight();
- screenRect.x = x;
- screenRect.y = y;
- if ( chatBoxBackground ) SDL_BlitSurface(chatBoxBackground, NULL, screen, &screenRect);
+ chatBoxBackground->draw(screen, x, y);
for (iter = chatlog.begin(); iter != chatlog.end(); iter++) {
line = *iter;
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 8c9376d9..39f9ab1c 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -25,6 +25,7 @@
#define _TMW_CHAT_H
#include <guichan.hpp>
+#include "../resources/image.h"
#include <SDL.h>
#include <list>
#include <string>
@@ -170,7 +171,7 @@ class ChatBox : public gcn::Widget {
std::string const_msg(CHATSKILL);
// The Alpha-Blended Surface for the background transluency effect.
- SDL_Surface *chatBoxBackground;
+ Image *chatBoxBackground;
};
#endif