From 4854bc433cd74bb072d02e25aa416f06ff6257b4 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 26 Dec 2008 22:45:24 -0700 Subject: Fixed a potential leak in setup, changed the default border color to white for wallpapers (matches our wallpapers better), and fixed the effect manager. Signed-off-by: Ira Rice --- src/CMakeLists.txt | 4 ++-- src/being.cpp | 4 ---- src/effectmanager.cpp | 27 ++++++++++++++++++++++++--- src/effectmanager.h | 18 ++++++++++++++---- src/graphics.cpp | 3 ++- src/gui/setup_video.cpp | 3 +++ src/main.cpp | 2 +- src/net/beinghandler.cpp | 3 +-- 8 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2403b8f..fea11c55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -284,6 +284,8 @@ SET(SRCS configlistener.h configuration.cpp configuration.h + effectmanager.cpp + effectmanager.h engine.cpp engine.h equipment.cpp @@ -348,8 +350,6 @@ SET(SRCS textparticle.h tileset.h vector.h - effectmanager.cpp - effectmanager.h ) ADD_EXECUTABLE(aethyra ${SRCS}) diff --git a/src/being.cpp b/src/being.cpp index 3f4c5d9c..edacbc26 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -47,10 +47,6 @@ #include "utils/tostring.h" #include "utils/xml.h" -#define BEING_EFFECTS_FILE "effects.xml" - -#include "utils/xml.h" - #define BEING_EFFECTS_FILE "effects.xml" #define HAIR_FILE "hair.xml" diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 4b835355..89bbf8f5 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -21,14 +21,12 @@ */ #include "effectmanager.h" - -#include "particle.h" #include "log.h" +#include "particle.h" #include "sound.h" #include "utils/xml.h" - EffectManager::EffectManager() { XML::Document doc("effects.xml"); @@ -64,6 +62,29 @@ EffectManager::~EffectManager() } +bool EffectManager::trigger(int id, Being* being) +{ + bool rValue = false; + for (std::list::iterator i = mEffects.begin(); i != mEffects.end(); ++i) + { + if ((*i).id == id) + { + printf("Found effect, playing it"); + rValue = true; + if((*i).GFX != "") + { + Particle *selfFX; + selfFX = particleEngine->addEffect((*i).GFX, 0, 0); + being->controlParticle(selfFX); + } + if((*i).SFX != "") + sound.playSfx((*i).SFX); + break; + } + } + return rValue; +} + bool EffectManager::trigger(int id, int x, int y) { bool rValue = false; diff --git a/src/effectmanager.h b/src/effectmanager.h index b5451f27..e6671498 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -23,8 +23,12 @@ #ifndef _EFFECT_MANAGER_H #define _EFFECT_MANAGER_H -#include #include +#include + +#include "being.h" + +class Being; class EffectManager { @@ -42,10 +46,16 @@ class EffectManager ~EffectManager(); /** - * Triggers a effect with the id, at x,y - * returns true if ID exists + * Triggers a effect with the id, at + * the specified being. + */ + bool trigger(int id, Being* being); + + /** + * Triggers a effect with the id, at + * the specified x and y coordinate. */ - bool trigger(int id, int x = 0, int y = 0); + bool trigger(int id, int x, int y); private: std::list mEffects; diff --git a/src/graphics.cpp b/src/graphics.cpp index 82404bce..4854d5fa 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -59,6 +59,7 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel) displayFlags |= SDL_SWSURFACE; } + delete mScreen; mScreen = SDL_SetVideoMode(w, h, bpp, displayFlags); if (!mScreen) { @@ -71,7 +72,7 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel) logger->log("Using video driver: %s", videoDriverName); } else { - logger->log("Using video driver: unkown"); + logger->log("Using video driver: unknown"); } const SDL_VideoInfo *vi = SDL_GetVideoInfo(); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 262c17e1..2e620095 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -401,6 +401,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) const int bpp = 0; const bool fullscreen = ((int) config.getValue("screen", 0) == 1); const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1); + // Try to set the desired video mode if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { @@ -411,7 +412,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) } // Initialize for drawing + graphics->_endDraw(); graphics->_beginDraw(); + graphics->updateScreen(); // TODO: Find out why the drawing area doesn't resize without a restart. new OkDialog("Screen resolution changed", diff --git a/src/main.cpp b/src/main.cpp index 378e913e..818a4e32 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -822,7 +822,7 @@ int main(int argc, char *argv[]) if (graphics->getWidth() > login_wallpaper->getWidth() || graphics->getHeight() > login_wallpaper->getHeight()) { - graphics->setColor(gcn::Color(64, 64, 64)); + graphics->setColor(gcn::Color(255, 255, 255)); graphics->fillRectangle(gcn::Rectangle( 0, 0, graphics->getWidth(), graphics->getHeight())); } diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 3c022af6..4f525e8d 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -265,8 +265,7 @@ void BeingHandler::handleMessage(MessageIn *msg) int effectType = msg->readInt32(); Being* being = beingManager->findBeing(id); - effectManager->trigger(effectType, (int) being->getPixelX(), - (int) being->getPixelY()); + effectManager->trigger(effectType, being); break; } -- cgit v1.2.3-70-g09d2