diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-01 00:07:47 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-01 00:07:47 +0000 |
commit | 17de81fb71b4f91d2e0897f802a36df5630f1eaa (patch) | |
tree | a8d6444c8f4da24918228eb7566204aa5dded4a9 /src/gui/chat.cpp | |
parent | e9a413d772c608f4ceba2953fabea643a02e0266 (diff) | |
download | mana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.tar.gz mana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.tar.bz2 mana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.tar.xz mana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.zip |
Changed around recent additions to Image class a bit and fixed OpenGL compile.
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 278f36c3..34b49571 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -31,10 +31,11 @@ ChatBox::ChatBox(const char *logfile, int item_num) items = 0; items_keep = item_num; - chatBoxBackground = new Image(); - chatBoxBackground->create(200, 200); - chatBoxBackground->fillWithColor(255, 255, 255); - chatBoxBackground->setAlpha(0.7f); + chatBoxBackground = Image::create(200, 200); + if (chatBoxBackground) { + chatBoxBackground->fillWithColor(255, 255, 255); + chatBoxBackground->setAlpha(0.7f); + } } ChatBox::~ChatBox() @@ -128,16 +129,25 @@ void ChatBox::draw(gcn::Graphics *graphics) graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); getAbsolutePosition(x, y); - - if ( (chatBoxBackground->getWidth() != getWidth()) || (chatBoxBackground->getHeight() != getHeight()) ) - { - chatBoxBackground->unload(); - chatBoxBackground->create(getWidth(), getHeight()); - chatBoxBackground->fillWithColor(255, 255, 255); - chatBoxBackground->setAlpha(0.7f); + + // Potentially recreate background with new size + if (chatBoxBackground) { + if ((chatBoxBackground->getWidth() != getWidth()) || + (chatBoxBackground->getHeight() != getHeight())) + { + delete chatBoxBackground; + chatBoxBackground = Image::create(getWidth(), getHeight()); + if (chatBoxBackground) { + chatBoxBackground->fillWithColor(255, 255, 255); + chatBoxBackground->setAlpha(0.7f); + } + } + } + + // Draw background image + if (chatBoxBackground) { + chatBoxBackground->draw(screen, x, y); } - - chatBoxBackground->draw(screen, x, y); for (iter = chatlog.begin(); iter != chatlog.end(); iter++) { line = *iter; |