From 72b42a7da7580e0eb52170f3d6c7d49dc0925e98 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 3 Dec 2008 12:38:29 -0700 Subject: Added in the effects manager, which was accidently missing from the last commit. Signed-off-by: Ira Rice --- src/effectmanager.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/effectmanager.cpp (limited to 'src/effectmanager.cpp') diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp new file mode 100644 index 00000000..4b835355 --- /dev/null +++ b/src/effectmanager.cpp @@ -0,0 +1,85 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World 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. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "effectmanager.h" + +#include "particle.h" +#include "log.h" +#include "sound.h" + +#include "utils/xml.h" + + +EffectManager::EffectManager() +{ + XML::Document doc("effects.xml"); + xmlNodePtr root = doc.rootNode(); + + if (!root || !xmlStrEqual(root->name, BAD_CAST "being-effects")) + { + logger->log("Error loading being effects file: effects.xml"); + return; + } + else + { + logger->log("Effects are now loading"); + } + + for_each_xml_child_node(node, root) + { + int id; + + if (xmlStrEqual(node->name, BAD_CAST "effect")) + { + EffectDescription ed; + ed.id = XML::getProperty(node, "id", -1); + ed.GFX = XML::getProperty(node, "particle", ""); + ed.SFX = XML::getProperty(node, "audio", ""); + mEffects.push_back(ed); + } + } +} + +EffectManager::~EffectManager() +{ + +} + +bool EffectManager::trigger(int id, int x, int y) +{ + 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 != "") + particleEngine->addEffect((*i).GFX, x, y); + if((*i).SFX != "") + sound.playSfx((*i).SFX); + break; + } + } + return rValue; +} + -- cgit v1.2.3-70-g09d2 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(-) (limited to 'src/effectmanager.cpp') 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 From c38a213e2a70c00b338d9e3fe284a3e7ed336b44 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 6 Jan 2009 00:20:40 -0700 Subject: Fixed the windows cbp file, deleted some files which we don't use, and fixed a few compiler warnings noticed from building in windows. Signed-off-by: Ira Rice --- aethyra.cbp | 377 +++++---------------------------- src/effectmanager.cpp | 2 +- src/gui/buddywindow.cpp | 83 -------- src/gui/minimap.cpp | 4 +- src/gui/newskill.cpp | 193 ----------------- src/gui/smileycontainer.h | 2 +- src/gui/smileyshortcutcontainer.h | 3 +- src/gui/viewport.cpp | 2 +- src/gui/widgets/adjustingcontainer.cpp | 279 ------------------------ src/gui/widgets/adjustingcontainer.hpp | 235 -------------------- 10 files changed, 64 insertions(+), 1116 deletions(-) delete mode 100644 src/gui/buddywindow.cpp delete mode 100644 src/gui/newskill.cpp delete mode 100644 src/gui/widgets/adjustingcontainer.cpp delete mode 100644 src/gui/widgets/adjustingcontainer.hpp (limited to 'src/effectmanager.cpp') diff --git a/aethyra.cbp b/aethyra.cbp index efc735c9..f24a28a6 100644 --- a/aethyra.cbp +++ b/aethyra.cbp @@ -24,6 +24,7 @@ + @@ -66,315 +67,25 @@ - + + + + + + + + + -<<<<<<< HEAD:aethyra.cbp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - -