From 487b7237a730469fc4f8a501a93f78c2bbafad51 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 13:43:46 -0700 Subject: Removed manual trimmings in exchange for using trim.h instead. Signed-off-by: Ira Rice --- src/resources/itemdb.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/resources') diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 773febd7..384efdf1 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -31,6 +31,7 @@ #include "../utils/dtor.h" #include "../utils/gettext.h" +#include "../utils/trim.h" #include "../utils/xml.h" namespace @@ -125,14 +126,7 @@ void ItemDB::load() if (itr == mNamedItemInfos.end()) { std::string temp = name; - while (temp[0] == ' ') - { - temp = temp.substr(1, temp.size()); - } - while (temp[temp.size()] == ' ') - { - temp = temp.substr(0, temp.size() - 1); - } + trim(temp); for (unsigned int i = 0; i < temp.size(); i++) { -- cgit v1.2.3-70-g09d2 From 5a3c174a53ed90224dc4fc49744c656eb9d358fa Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 23:41:36 -0700 Subject: Added coloring of item names by type. TODO: Allow this to be customizable through the color interface so that if someone is colorblind to a certain color and it doesn't show up well, they can change it (or even people who just don't like the default color). Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 35 +++++++++++++++++++++++++++++++++++ src/gui/itempopup.h | 3 +++ src/resources/itemdb.cpp | 4 ++-- src/resources/iteminfo.h | 12 +++++------- 4 files changed, 45 insertions(+), 9 deletions(-) (limited to 'src/resources') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 402f9e05..9b84b39e 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -97,6 +97,7 @@ ItemPopup::ItemPopup(): void ItemPopup::setItem(const ItemInfo &item) { mItemName->setCaption(item.getName()); + mItemName->setForegroundColor(getColor(item.getType())); mItemName->setWidth(boldFont->getWidth(item.getName())); mItemDesc->setTextWrapped(item.getDescription(), 196); mItemEffect->setTextWrapped(item.getEffect(), 196); @@ -154,6 +155,40 @@ void ItemPopup::setItem(const ItemInfo &item) (2 * getFont()->getHeight())); } +gcn::Color ItemPopup::getColor(const std::string& type) +{ + gcn::Color color; + + if (type.compare("generic") == 0) + color = 0x21a5b1; + else if (type.compare("equip-head") == 0) + color = 0x527fa4; + else if (type.compare("usable") == 0) + color = 0x268d24; + else if (type.compare("equip-torso") == 0) + color = 0xd12aa4; + else if (type.compare("equip-1hand") == 0) + color = 0xf42a2a; + else if (type.compare("equip-legs") == 0) + color = 0x718218; + else if (type.compare("equip-feet") == 0) + color = 0xf44ca5; + else if (type.compare("equip-2hand") == 0) + color = 0xf46d0e; + else if (type.compare("equip-shield") == 0) + color = 0x9c2424; + else if (type.compare("equip-ring") == 0) + color = 0xf4ea17; + else if (type.compare("equip-arms") == 0) + color = 0x9c24e8; + else if (type.compare("equip-ammo") == 0) + color = 0xbe8717; + else + color = 0x000000; + + return color; +} + unsigned int ItemPopup::getNumRows() { return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() + diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 0c729231..3c8f575d 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -27,6 +27,7 @@ #include "textbox.h" #include "window.h" +#include "../guichanfwd.h" #include "../item.h" class ItemPopup : public Window @@ -46,6 +47,8 @@ class ItemPopup : public Window ScrollArea *mItemDescScroll; ScrollArea *mItemEffectScroll; ScrollArea *mItemWeightScroll; + + gcn::Color getColor(const std::string& type); }; #endif // ITEMPOPUP_H__ diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 384efdf1..752ea38b 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -84,7 +84,7 @@ void ItemDB::load() logger->log(_("ItemDB: Redefinition of item ID %d"), id); } - int type = XML::getProperty(node, "type", 0); + std::string type = XML::getProperty(node, "type", "other"); int weight = XML::getProperty(node, "weight", 0); int view = XML::getProperty(node, "view", 0); @@ -152,7 +152,7 @@ void ItemDB::load() CHECK_PARAM(description, ""); // CHECK_PARAM(effect, ""); // CHECK_PARAM(type, 0); - CHECK_PARAM(weight, 0); + // CHECK_PARAM(weight, 0); // CHECK_PARAM(slot, 0); #undef CHECK_PARAM diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 86725ca2..c03dec28 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -47,7 +47,7 @@ class ItemInfo * Constructor. */ ItemInfo(): - mType(0), + mType(""), mWeight(0), mView(0), mAttackType(ACTION_DEFAULT) @@ -81,14 +81,12 @@ class ItemInfo void setEffect(const std::string &effect) { mEffect = effect; } - const std::string& - getEffect() const { return mEffect; } + const std::string& getEffect() const { return mEffect; } - void setType(short type) + void setType(const std::string& type) { mType = type; } - short getType() const - { return mType; } + const std::string& getType() const { return mType; } void setWeight(short weight) { mWeight = weight; } @@ -118,7 +116,7 @@ class ItemInfo std::string mName; std::string mDescription; /**< Short description. */ std::string mEffect; /**< Description of effects. */ - char mType; /**< Item type. */ + std::string mType; /**< Item type. */ short mWeight; /**< Weight in grams. */ int mView; /**< Item ID of how this item looks. */ int mId; /**< Item ID */ -- cgit v1.2.3-70-g09d2 From 7859699944d51056966c2f2415d1ade230c375a9 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 12:54:38 -0700 Subject: Some style cleanups to the image class. TODO: Find a way to fix the subimage class so that when OpenGL isn't enabled, GUI opacities can still be applied. Signed-off-by: Ira Rice --- src/resources/image.cpp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'src/resources') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index c3310849..7a7e6ac8 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -167,7 +167,8 @@ Image *Image::load(SDL_Surface *tmpImage) tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, 32, rmask, gmask, bmask, amask); - if (!tmpImage) { + if (!tmpImage) + { logger->log("Error, image convert failed: out of memory"); return NULL; } @@ -178,9 +179,8 @@ Image *Image::load(SDL_Surface *tmpImage) glGenTextures(1, &texture); glBindTexture(mTextureType, texture); - if (SDL_MUSTLOCK(tmpImage)) { + if (SDL_MUSTLOCK(tmpImage)) SDL_LockSurface(tmpImage); - } glTexImage2D( mTextureType, 0, 4, @@ -255,14 +255,13 @@ Image *Image::load(SDL_Surface *tmpImage) SDL_Surface *image; // Convert the surface to the current display format - if (hasAlpha) { + if (hasAlpha) image = SDL_DisplayFormatAlpha(tmpImage); - } - else { + else image = SDL_DisplayFormat(tmpImage); - } - if (!image) { + if (!image) + { logger->log("Error: Image convert failed."); return NULL; } @@ -274,14 +273,16 @@ void Image::unload() { mLoaded = false; - if (mImage) { + if (mImage) + { // Free the image surface. SDL_FreeSurface(mImage); mImage = NULL; } #ifdef USE_OPENGL - if (mGLImage) { + if (mGLImage) + { glDeleteTextures(1, &mGLImage); mGLImage = 0; } @@ -292,10 +293,9 @@ Image *Image::getSubImage(int x, int y, int width, int height) { // Create a new clipped sub-image #ifdef USE_OPENGL - if (mUseOpenGL) { + if (mUseOpenGL) return new SubImage(this, mGLImage, x, y, width, height, mTexWidth, mTexHeight); - } #endif return new SubImage(this, mImage, x, y, width, height); @@ -303,13 +303,13 @@ Image *Image::getSubImage(int x, int y, int width, int height) void Image::setAlpha(float a) { - if (mAlpha == a) { + if (mAlpha == a) return; - } mAlpha = a; - if (mImage) { + if (mImage) + { // Set the alpha value this image is drawn at SDL_SetAlpha(mImage, SDL_SRCALPHA, (int) (255 * mAlpha)); } @@ -321,14 +321,12 @@ float Image::getAlpha() } #ifdef USE_OPENGL -void -Image::setLoadAsOpenGL(bool useOpenGL) +void Image::setLoadAsOpenGL(bool useOpenGL) { Image::mUseOpenGL = useOpenGL; } -int -Image::powerOfTwo(int input) +int Image::powerOfTwo(int input) { int value; if (mTextureType == GL_TEXTURE_2D) @@ -353,7 +351,8 @@ Image::powerOfTwo(int input) SubImage::SubImage(Image *parent, SDL_Surface *image, int x, int y, int width, int height): - Image(image), mParent(parent) + Image(image), + mParent(parent) { mParent->incRef(); @@ -368,7 +367,8 @@ SubImage::SubImage(Image *parent, SDL_Surface *image, SubImage::SubImage(Image *parent, GLuint image, int x, int y, int width, int height, int texWidth, int texHeight): - Image(image, width, height, texWidth, texHeight), mParent(parent) + Image(image, width, height, texWidth, texHeight), + mParent(parent) { mParent->incRef(); @@ -394,3 +394,4 @@ Image *SubImage::getSubImage(int x, int y, int w, int h) { return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h); } + -- cgit v1.2.3-70-g09d2 From c6cf9a6a9c03f17362171aeed1a22244d99b7530 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 17:33:47 -0700 Subject: Disable alpha values affecting two widgets which would otherwise take alpha values under SDL. Signed-off-by: Ira Rice --- src/gui/checkbox.cpp | 14 +++++++++----- src/gui/progressbar.cpp | 5 ++++- src/resources/image.h | 14 +++++++++++++- 3 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src/resources') diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index 7fa4fa81..511ed34c 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -45,10 +45,13 @@ CheckBox::CheckBox(const std::string& caption, bool selected): checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10); checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10); checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10); - checkBoxNormal->setAlpha(mAlpha); - checkBoxChecked->setAlpha(mAlpha); - checkBoxDisabled->setAlpha(mAlpha); - checkBoxDisabledChecked->setAlpha(mAlpha); + if (config.getValue("opengl", 0)) + { + checkBoxNormal->setAlpha(mAlpha); + checkBoxChecked->setAlpha(mAlpha); + checkBoxDisabled->setAlpha(mAlpha); + checkBoxDisabledChecked->setAlpha(mAlpha); + } checkBox->decRef(); } @@ -84,7 +87,8 @@ void CheckBox::drawBox(gcn::Graphics* graphics) else box = checkBoxDisabled; - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getValue("guialpha", 0.8) != mAlpha && + config.getValue("opengl", 0)) { mAlpha = config.getValue("guialpha", 0.8); checkBoxNormal->setAlpha(mAlpha); diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 5e8e6655..a1b847c8 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -103,7 +103,10 @@ void ProgressBar::draw(gcn::Graphics *graphics) { if (config.getValue("guialpha", 0.8) != mAlpha) { - mAlpha = config.getValue("guialpha", 0.8); + if (config.getValue("opengl", 0)) + mAlpha = config.getValue("guialpha", 0.8); + else + mAlpha = 1.0f; for (int i = 0; i < 9; i++) { mBorder.grid[i]->setAlpha(mAlpha); diff --git a/src/resources/image.h b/src/resources/image.h index a4048803..5b376053 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -91,6 +91,12 @@ class Image : public Resource */ virtual void unload(); + /** + * Returns the image. + */ + virtual const Image* getImage() const + { return this; } + /** * Returns the width of the image. */ @@ -114,7 +120,7 @@ class Image : public Resource /** * Sets the alpha value of this image. */ - void setAlpha(float alpha); + virtual void setAlpha(float alpha); /** * Returns the alpha value of this image. @@ -180,6 +186,12 @@ class SubImage : public Image */ ~SubImage(); + /** + * Returns the image. + */ + virtual const Image* getImage() const + { return mParent; } + /** * Creates a new image with the desired clipping rectangle. * -- cgit v1.2.3-70-g09d2 From 450edb5900a46ada0cc6292f0079a31ea5d04573 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 21:51:35 -0700 Subject: Some more include cleanups. Signed-off-by: Ira Rice --- src/being.cpp | 6 ++++++ src/being.h | 32 +++++++++++++++++------------ src/beingmanager.cpp | 2 -- src/configlistener.h | 2 +- src/configuration.cpp | 2 -- src/configuration.h | 3 ++- src/effectmanager.cpp | 2 +- src/effectmanager.h | 5 ++--- src/engine.cpp | 10 ---------- src/engine.h | 2 -- src/equipment.cpp | 2 -- src/floor_item.cpp | 16 +++++++++++++++ src/floor_item.h | 22 ++++++++++---------- src/game.cpp | 7 +------ src/game.h | 1 - src/graphics.h | 8 ++++++-- src/gui/char_select.cpp | 2 ++ src/gui/debugwindow.cpp | 1 - src/gui/equipmentwindow.cpp | 1 - src/gui/gui.h | 1 - src/gui/inventorywindow.cpp | 1 - src/gui/itemshortcutcontainer.cpp | 1 - src/gui/setup_players.h | 2 +- src/gui/viewport.cpp | 1 - src/gui/viewport.h | 7 +++++-- src/guichanfwd.h | 3 ++- src/inventory.cpp | 42 +++++++++++++++++++-------------------- src/itemshortcut.cpp | 17 ++++++++-------- src/joystick.cpp | 2 -- src/joystick.h | 6 ++++-- src/keyboardconfig.cpp | 3 +-- src/keyboardconfig.h | 11 +++++----- src/localplayer.cpp | 8 ++++++-- src/localplayer.h | 8 ++++++-- src/log.cpp | 2 -- src/log.h | 1 - src/main.cpp | 4 ---- src/map.cpp | 5 +++++ src/map.h | 3 ++- src/monster.cpp | 3 +-- src/net/beinghandler.cpp | 1 - src/net/equipmenthandler.cpp | 1 - src/net/loginhandler.h | 1 - src/net/partyhandler.cpp | 1 - src/npc.cpp | 1 - src/openglgraphics.cpp | 5 ----- src/particle.cpp | 2 ++ src/particle.h | 2 -- src/particlecontainer.cpp | 5 +---- src/particlecontainer.h | 6 +----- src/particleemitter.cpp | 5 ++--- src/particleemitter.h | 4 ++-- src/particleemitterprop.h | 1 - src/party.cpp | 1 - src/player.cpp | 7 ++----- src/player.h | 2 +- src/player_relations.cpp | 5 +++-- src/player_relations.h | 5 ++--- src/properties.h | 3 +-- src/resources/animation.cpp | 2 -- src/resources/buddylist.h | 3 ++- src/resources/colordb.cpp | 2 -- src/resources/dye.cpp | 1 - src/resources/emotedb.cpp | 2 -- src/resources/image.h | 2 ++ src/resources/imageloader.cpp | 1 - src/resources/imagewriter.h | 2 -- src/resources/itemdb.cpp | 2 -- src/resources/itemdb.h | 2 ++ src/resources/mapreader.cpp | 1 + src/resources/mapreader.h | 2 -- src/resources/monsterdb.cpp | 2 +- src/resources/monsterdb.h | 2 +- src/resources/npcdb.cpp | 2 -- src/resources/resource.h | 3 +-- src/resources/soundeffect.h | 3 +-- src/simpleanimation.cpp | 10 +++++++++- src/simpleanimation.h | 11 +++------- src/text.cpp | 6 ++---- src/text.h | 10 +++++----- src/textmanager.cpp | 14 +++---------- src/textmanager.h | 5 +++-- src/textparticle.cpp | 2 ++ src/textparticle.h | 2 -- src/utils/tostring.h | 2 +- 85 files changed, 189 insertions(+), 222 deletions(-) (limited to 'src/resources') diff --git a/src/being.cpp b/src/being.cpp index dc843e43..2b4ba767 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -25,6 +25,7 @@ #include "animatedsprite.h" #include "being.h" #include "configuration.h" +#include "effectmanager.h" #include "game.h" #include "graphics.h" #include "localplayer.h" @@ -34,7 +35,12 @@ #include "sound.h" #include "text.h" +#include "gui/speechbubble.h" + +#include "resources/colordb.h" + #include "resources/emotedb.h" +#include "resources/image.h" #include "resources/imageset.h" #include "resources/itemdb.h" #include "resources/iteminfo.h" diff --git a/src/being.h b/src/being.h index 812ffdd3..109a44ad 100644 --- a/src/being.h +++ b/src/being.h @@ -22,37 +22,39 @@ #ifndef BEING_H #define BEING_H -#include -#include +#include + #include + #include #include #include -#include "animatedsprite.h" -#include "effectmanager.h" -#include "map.h" #include "particlecontainer.h" #include "position.h" #include "sprite.h" -#include "gui/speechbubble.h" - -#include "resources/colordb.h" +#include "resources/spritedef.h" #define FIRST_IGNORE_EMOTE 14 #define STATUS_EFFECTS 32 class AnimatedSprite; +class Image; class ItemInfo; class Item; class Map; class Graphics; class Particle; +class Position; class SpeechBubble; class Text; -enum Gender { +typedef std::list Sprites; +typedef Sprites::iterator SpriteIterator; + +enum Gender +{ GENDER_MALE = 0, GENDER_FEMALE = 1, GENDER_UNSPECIFIED = 2 @@ -61,7 +63,8 @@ enum Gender { class Being : public Sprite { public: - enum Type { + enum Type + { UNKNOWN, PLAYER, NPC, @@ -71,7 +74,8 @@ class Being : public Sprite /** * Action the being is currently performing. */ - enum Action { + enum Action + { STAND, WALK, ATTACK, @@ -80,7 +84,8 @@ class Being : public Sprite HURT }; - enum Sprite { + enum Sprite + { BASE_SPRITE = 0, SHOE_SPRITE, BOTTOMCLOTHES_SPRITE, @@ -96,7 +101,8 @@ class Being : public Sprite VECTOREND_SPRITE }; - enum TargetCursorSize { + enum TargetCursorSize + { TC_SMALL = 0, TC_MEDIUM, TC_LARGE, diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 9e620ca0..a417ee50 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "beingmanager.h" #include "localplayer.h" #include "monster.h" diff --git a/src/configlistener.h b/src/configlistener.h index 51d58144..ec7d6a2c 100644 --- a/src/configlistener.h +++ b/src/configlistener.h @@ -22,7 +22,7 @@ #ifndef CONFIGLISTENER_H #define CONFIGLISTENER_H -#include +#include /** * The listener interface for receiving notifications about changes to diff --git a/src/configuration.cpp b/src/configuration.cpp index 04cb4f36..f6c74428 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "configlistener.h" #include "configuration.h" #include "log.h" diff --git a/src/configuration.h b/src/configuration.h index 0cc4e29f..da12e1e4 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -22,8 +22,9 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H -#include #include + +#include #include #include #include diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 63796f73..0a04c33d 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - +#include "being.h" #include "effectmanager.h" #include "log.h" #include "particle.h" diff --git a/src/effectmanager.h b/src/effectmanager.h index a9efcdbc..619b8e0d 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -25,15 +25,14 @@ #include #include -#include "being.h" - class Being; class EffectManager { public: - struct EffectDescription { + struct EffectDescription + { int id; std::string GFX; std::string SFX; diff --git a/src/engine.cpp b/src/engine.cpp index 29b8921a..c91e42f9 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -19,18 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include "being.h" #include "beingmanager.h" -#include "configuration.h" #include "engine.h" #include "flooritemmanager.h" #include "game.h" -#include "graphics.h" #include "localplayer.h" #include "log.h" -#include "main.h" #include "map.h" #include "particle.h" #include "sound.h" @@ -43,14 +37,10 @@ #include "net/protocol.h" #include "resources/mapreader.h" -#include "resources/monsterdb.h" #include "resources/resourcemanager.h" -#include "utils/dtor.h" #include "utils/tostring.h" -extern Minimap *minimap; - char itemCurrenyQ[10] = "0"; Engine::Engine(Network *network): diff --git a/src/engine.h b/src/engine.h index f2852351..7ad6d894 100644 --- a/src/engine.h +++ b/src/engine.h @@ -22,7 +22,6 @@ #ifndef _ENGINE_H #define _ENGINE_H -#include #include class Map; @@ -52,7 +51,6 @@ class Engine const std::string &getCurrentMapName() { return mMapName; } - /** * Sets the currently active map. */ diff --git a/src/equipment.cpp b/src/equipment.cpp index d5e0f656..b21115a3 100644 --- a/src/equipment.cpp +++ b/src/equipment.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "equipment.h" #include "item.h" #include "inventory.h" diff --git a/src/floor_item.cpp b/src/floor_item.cpp index 0c4c1c10..fbe606b4 100644 --- a/src/floor_item.cpp +++ b/src/floor_item.cpp @@ -20,8 +20,12 @@ */ #include "floor_item.h" +#include "graphics.h" +#include "item.h" #include "map.h" +#include "resources/image.h" + FloorItem::FloorItem(unsigned int id, unsigned int itemId, unsigned short x, @@ -46,3 +50,15 @@ FloorItem::~FloorItem() delete mItem; } + +unsigned int FloorItem::getItemId() const +{ + return mItem->getId(); +} + +void FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const +{ + graphics->drawImage(mItem->getImage(), + mX * 32 + offsetX, + mY * 32 + offsetY); +} diff --git a/src/floor_item.h b/src/floor_item.h index a7299bfb..444c756a 100644 --- a/src/floor_item.h +++ b/src/floor_item.h @@ -22,11 +22,16 @@ #ifndef FLOORITEM_H #define FLOORITEM_H -#include "graphics.h" -#include "item.h" -#include "map.h" +#include + #include "sprite.h" -#include "resources/image.h" + +class Graphics; +class Image; +class Item; +class Map; + +typedef std::list Sprites; /** * An item lying on the floor. @@ -56,7 +61,7 @@ class FloorItem : public Sprite /** * Returns the item id. */ - unsigned int getItemId() const { return mItem->getId(); } + unsigned int getItemId() const; /** * Returns the x coordinate. @@ -80,12 +85,7 @@ class FloorItem : public Sprite * * @see Sprite::draw(Graphics, int, int) */ - void draw(Graphics *graphics, int offsetX, int offsetY) const - { - graphics->drawImage(mItem->getImage(), - mX * 32 + offsetX, - mY * 32 + offsetY); - } + void draw(Graphics *graphics, int offsetX, int offsetY) const; private: unsigned int mId; diff --git a/src/game.cpp b/src/game.cpp index 28c29874..e2064f58 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -25,9 +25,9 @@ #include #include -#include #include "beingmanager.h" +#include "configuration.h" #include "effectmanager.h" #include "emoteshortcut.h" #include "engine.h" @@ -55,7 +55,6 @@ #include "gui/help.h" #include "gui/inventorywindow.h" #include "gui/shortcutwindow.h" -#include "gui/shortcutcontainer.h" #include "gui/itemshortcutcontainer.h" #include "gui/menuwindow.h" #include "gui/minimap.h" @@ -73,7 +72,6 @@ #include "gui/trade.h" #include "gui/viewport.h" -#include "net/protocol.h" #include "net/beinghandler.h" #include "net/buysellhandler.h" #include "net/chathandler.h" @@ -87,14 +85,11 @@ #include "net/protocol.h" #include "net/skillhandler.h" #include "net/tradehandler.h" -#include "net/messageout.h" #include "resources/imagewriter.h" #include "utils/gettext.h" -extern Graphics *graphics; - class Map; std::string map_path; diff --git a/src/game.h b/src/game.h index 4f512d97..c9fc8d79 100644 --- a/src/game.h +++ b/src/game.h @@ -22,7 +22,6 @@ #ifndef GAME_ #define GAME_ -#include #include #include "configlistener.h" diff --git a/src/graphics.h b/src/graphics.h index 8009ceda..172032dc 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -46,14 +46,16 @@ struct SDL_Surface; * Sections 0, 2, 6 and 8 will remain as is. 1, 3, 4, 5 and 7 will be * repeated to fit the size of the widget. */ -struct ImageRect { +struct ImageRect +{ Image *grid[9]; }; /** * A central point of control for graphics. */ -class Graphics : public gcn::SDLGraphics { +class Graphics : public gcn::SDLGraphics +{ public: /** * Constructor. @@ -151,4 +153,6 @@ class Graphics : public gcn::SDLGraphics { bool mFullscreen, mHWAccel; }; +extern Graphics *graphics; + #endif diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 4433b646..6626b848 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -41,6 +41,8 @@ #include "../net/charserverhandler.h" #include "../net/messageout.h" +#include "../resources/colordb.h" + #include "../utils/gettext.h" #include "../utils/strprintf.h" #include "../utils/trim.h" diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 055d9963..5a5acfad 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -24,7 +24,6 @@ #include #include "debugwindow.h" -#include "gui.h" #include "viewport.h" #include "widgets/layout.h" diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 5ba9501d..e553fbe7 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -26,7 +26,6 @@ #include "button.h" #include "equipmentwindow.h" -#include "gui.h" #include "itempopup.h" #include "playerbox.h" #include "viewport.h" diff --git a/src/gui/gui.h b/src/gui/gui.h index 9681d44a..5c0c24f7 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -115,7 +115,6 @@ class Gui : public gcn::Gui }; extern Gui *gui; /**< The GUI system */ -extern Viewport *viewport; /**< The viewport */ extern SDLInput *guiInput; /**< GUI input */ /** diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index a3572d4f..70b3efb5 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -27,7 +27,6 @@ #include #include "button.h" -#include "gui.h" #include "inventorywindow.h" #include "item_amount.h" #include "itemcontainer.h" diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index e152b03d..d3cc2c22 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -20,7 +20,6 @@ */ #include -#include "gui.h" #include "itemshortcutcontainer.h" #include "itempopup.h" #include "viewport.h" diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 393fc6aa..2edc6983 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -53,7 +53,7 @@ private: PlayerTableModel *mPlayerTableModel; GuiTable *mPlayerTable; GuiTable *mPlayerTitleTable; - ScrollArea *mPlayerScrollArea; + gcn::ScrollArea *mPlayerScrollArea; gcn::CheckBox *mPersistIgnores; gcn::CheckBox *mDefaultTrading; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 11a0004b..25e69c43 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "gui.h" #include "popupmenu.h" #include "viewport.h" diff --git a/src/gui/viewport.h b/src/gui/viewport.h index e352f765..522ea734 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -27,13 +27,14 @@ #include "windowcontainer.h" #include "../configlistener.h" +#include "../position.h" -class Map; class FloorItem; +class Graphics; class ImageSet; class Item; +class Map; class PopupMenu; -class Graphics; /** * The viewport on the map. Displays the current map and handles mouse input @@ -137,4 +138,6 @@ class Viewport : public WindowContainer, public gcn::MouseListener, PopupMenu *mPopupMenu; /**< Popup menu. */ }; +extern Viewport *viewport; /**< The viewport */ + #endif diff --git a/src/guichanfwd.h b/src/guichanfwd.h index 2e97db68..4863421c 100644 --- a/src/guichanfwd.h +++ b/src/guichanfwd.h @@ -22,7 +22,8 @@ #ifndef GUICHANFWD_H #define GUICHANFWD_H -namespace gcn { +namespace gcn +{ class ActionListener; class AllegroGraphics; class AllegroImage; diff --git a/src/inventory.cpp b/src/inventory.cpp index 8824e1ba..3ca26e1e 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -20,7 +20,6 @@ */ #include -#include #include "inventory.h" #include "item.h" @@ -28,7 +27,8 @@ struct SlotUsed : public std::unary_function { - bool operator()(const Item *item) const { + bool operator()(const Item *item) const + { return item && item->getId() != -1 && item->getQuantity() > 0; } }; @@ -59,10 +59,9 @@ Item* Inventory::getItem(int index) const Item* Inventory::findItem(int itemId) const { for (int i = 0; i < mSize; i++) - { if (mItems[i] && mItems[i]->getId() == itemId) return mItems[i]; - } + return NULL; } @@ -73,38 +72,41 @@ void Inventory::addItem(int id, int quantity, bool equipment) void Inventory::setItem(int index, int id, int quantity, bool equipment) { - if (index < 0 || index >= mSize) { + if (index < 0 || index >= mSize) + { logger->log("Warning: invalid inventory index: %d", index); return; } - if (!mItems[index] && id > 0) { + if (!mItems[index] && id > 0) + { Item *item = new Item(id, quantity, equipment); item->setInvIndex(index); mItems[index] = item; - } else if (id > 0) { + } + else if (id > 0) + { mItems[index]->setId(id); mItems[index]->setQuantity(quantity); mItems[index]->setEquipment(equipment); - } else if (mItems[index]) { + } + else if (mItems[index]) + { removeItemAt(index); } } void Inventory::clear() { - for (int i = 0; i < mSize; i++) { + for (int i = 0; i < mSize; i++) removeItemAt(i); - } } void Inventory::removeItem(int id) { - for (int i = 0; i < mSize; i++) { - if (mItems[i] && mItems[i]->getId() == id) { + for (int i = 0; i < mSize; i++) + if (mItems[i] && mItems[i]->getId() == id) removeItemAt(i); - } - } } void Inventory::removeItemAt(int index) @@ -115,11 +117,9 @@ void Inventory::removeItemAt(int index) bool Inventory::contains(Item *item) const { - for (int i = 0; i < mSize; i++) { - if (mItems[i] && mItems[i]->getId() == item->getId()) { + for (int i = 0; i < mSize; i++) + if (mItems[i] && mItems[i]->getId() == item->getId()) return true; - } - } return false; } @@ -138,11 +138,9 @@ int Inventory::getNumberOfSlotsUsed() const int Inventory::getLastUsedSlot() const { - for (int i = mSize - 1; i >= 0; i--) { - if (SlotUsed()(mItems[i])) { + for (int i = mSize - 1; i >= 0; i--) + if (SlotUsed()(mItems[i])) return i; - } - } return -1; } diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 7bfbc88e..3404b0e3 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -33,9 +33,8 @@ ItemShortcut::ItemShortcut(): mItemSelected(-1) { for (int i = 0; i < SHORTCUT_ITEMS; i++) - { mItems[i] = -1; - } + load(); } @@ -51,9 +50,7 @@ void ItemShortcut::load() int itemId = (int) config.getValue("shortcut" + toString(i), -1); if (itemId != -1) - { mItems[i] = itemId; - } } } @@ -73,13 +70,15 @@ void ItemShortcut::useItem(int index) Item *item = player_node->getInventory()->findItem(mItems[index]); if (item && item->getQuantity()) { - if (item->isEquipment()) { - if (item->isEquipped()) { + if (item->isEquipment()) + { + if (item->isEquipped()) player_node->unequipItem(item); - } else { + else player_node->equipItem(item); - } - } else { + } + else + { player_node->useItem(item); } } diff --git a/src/joystick.cpp b/src/joystick.cpp index 1233c37f..7e9a2285 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -25,8 +25,6 @@ #include "joystick.h" #include "log.h" -#include - int Joystick::joystickCount = 0; void Joystick::init() diff --git a/src/joystick.h b/src/joystick.h index a7090293..4e5c3d23 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -30,14 +30,16 @@ class Joystick /** * Number of buttons we can handle. */ - enum { + enum + { MAX_BUTTONS = 6 }; /** * Directions, to be used as bitmask values. */ - enum { + enum + { UP = 1, DOWN = 2, LEFT = 4, diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 745a81db..ecf47573 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -19,12 +19,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "configuration.h" #include "keyboardconfig.h" #include "log.h" +#include "gui/sdlinput.h" #include "gui/setup_keyboard.h" #include "utils/gettext.h" diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index ba8039bf..bfcde31c 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -22,13 +22,9 @@ #ifndef KEYBOARDCONFIG_H #define KEYBOARDCONFIG_H +#include #include -#include - -#include "gui/sdlinput.h" -#include "gui/setup_keyboard.h" - /** * Each key represents a key function. Such as 'Move up', 'Attack' etc. */ @@ -40,6 +36,8 @@ struct KeyFunction int value; /** The actual value that is used. */ }; +class Setup_Keyboard; + class KeyboardConfig { public: @@ -148,7 +146,8 @@ class KeyboardConfig * The key assignment view gets arranged according to the order of * these values. */ - enum KeyAction { + enum KeyAction + { KEY_NO_VALUE = -1, KEY_MOVE_UP, KEY_MOVE_DOWN, diff --git a/src/localplayer.cpp b/src/localplayer.cpp index bc0b2b81..01de3b41 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -24,20 +24,24 @@ #include "equipment.h" #include "floor_item.h" #include "game.h" +#include "graphics.h" #include "inventory.h" #include "item.h" #include "localplayer.h" -#include "main.h" +#include "map.h" #include "monster.h" #include "particle.h" +#include "simpleanimation.h" #include "sound.h" -#include "monster.h" +#include "text.h" #include "gui/gui.h" #include "net/messageout.h" #include "net/protocol.h" +#include "resources/animation.h" +#include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" diff --git a/src/localplayer.h b/src/localplayer.h index 7f5596e4..d6d5ad2e 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -22,8 +22,9 @@ #ifndef LOCALPLAYER_H #define LOCALPLAYER_H +#include + #include "player.h" -#include "simpleanimation.h" // TODO move into some sane place... #define MAX_SLOT 2 @@ -36,7 +37,9 @@ class FloorItem; class ImageSet; class Inventory; class Item; +class Map; class Network; +class SimpleAnimation; /** * The local player character. @@ -44,7 +47,8 @@ class Network; class LocalPlayer : public Player { public: - enum Attribute { + enum Attribute + { STR = 0, AGI, VIT, INT, DEX, LUK }; diff --git a/src/log.cpp b/src/log.cpp index e50edeb2..b0024f80 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include #include #include diff --git a/src/log.h b/src/log.h index fcd48757..b06bdc89 100644 --- a/src/log.h +++ b/src/log.h @@ -22,7 +22,6 @@ #ifndef _LOG_H #define _LOG_H -#include #include class ChatWindow; diff --git a/src/main.cpp b/src/main.cpp index 65b61de2..73e0b0fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,8 +28,6 @@ #include -#include - #include #include @@ -65,7 +63,6 @@ #include "gui/register.h" #include "gui/sdlinput.h" #include "gui/setup.h" -#include "gui/textfield.h" #include "gui/updatewindow.h" #include "net/charserverhandler.h" @@ -82,7 +79,6 @@ #include "resources/npcdb.h" #include "resources/resourcemanager.h" -#include "utils/dtor.h" #include "utils/gettext.h" #include "utils/tostring.h" diff --git a/src/map.cpp b/src/map.cpp index 57b79ef4..716e9aee 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -68,6 +68,11 @@ TileAnimation::TileAnimation(Animation *ani): { } +TileAnimation::~TileAnimation() +{ + delete mLastImage; +} + void TileAnimation::update() { //update animation diff --git a/src/map.h b/src/map.h index bd4cb122..1423565f 100644 --- a/src/map.h +++ b/src/map.h @@ -27,9 +27,9 @@ #include "position.h" #include "properties.h" - #include "simpleanimation.h" +class Animation; class AmbientOverlay; class Graphics; class Image; @@ -72,6 +72,7 @@ class TileAnimation { public: TileAnimation(Animation *ani); + ~TileAnimation(); void update(); void addAffectedTile(MapLayer *layer, int index) { mAffected.push_back(std::make_pair(layer, index)); } diff --git a/src/monster.cpp b/src/monster.cpp index 4f2c97e7..33703817 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -28,8 +28,7 @@ #include "text.h" #include "resources/monsterdb.h" - -#include "utils/tostring.h" +#include "resources/monsterinfo.h" static const int NAME_X_OFFSET = 16; static const int NAME_Y_OFFSET = 16; diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 69bc462c..69f462ec 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -32,7 +32,6 @@ #include "../game.h" #include "../localplayer.h" #include "../log.h" -#include "../main.h" #include "../npc.h" #include "../particle.h" #include "../player_relations.h" diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 319d1205..9a3c396a 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -23,7 +23,6 @@ #include "messagein.h" #include "protocol.h" -#include "../beingmanager.h" #include "../equipment.h" #include "../inventory.h" #include "../item.h" diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index c847b4c1..df86b634 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -25,7 +25,6 @@ #include #include "messagehandler.h" -#include struct LoginData; diff --git a/src/net/partyhandler.cpp b/src/net/partyhandler.cpp index d4b7455b..2437d0a0 100644 --- a/src/net/partyhandler.cpp +++ b/src/net/partyhandler.cpp @@ -29,7 +29,6 @@ #include "../gui/confirm_dialog.h" #include "../beingmanager.h" -#include "../game.h" #include "../party.h" PartyHandler::PartyHandler(Party *party) : mParty(party) diff --git a/src/npc.cpp b/src/npc.cpp index cef98e45..7b7db125 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -20,7 +20,6 @@ */ #include "animatedsprite.h" -#include "graphics.h" #include "localplayer.h" #include "npc.h" #include "particle.h" diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index d3278c1a..e7e7b204 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -19,14 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include -#include -#include - #include "log.h" -#include "main.h" #include "openglgraphics.h" #include "resources/image.h" diff --git a/src/particle.cpp b/src/particle.cpp index 4de9fe29..d89d0a3e 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include "animationparticle.h" #include "configuration.h" #include "imageparticle.h" diff --git a/src/particle.h b/src/particle.h index 87e4d69d..881bbb74 100644 --- a/src/particle.h +++ b/src/particle.h @@ -25,8 +25,6 @@ #include #include -#include - #include "guichanfwd.h" #include "sprite.h" #include "vector.h" diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index d100ba27..1ed51053 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -21,9 +21,9 @@ #include +#include "particle.h" #include "particlecontainer.h" - ParticleContainer::ParticleContainer(ParticleContainer *parent, bool delParent) : mDelParent(delParent), mNext(parent) @@ -103,9 +103,6 @@ void ParticleList::moveTo(float x, float y) } } - - - // -- particle vector ---------------------------------------- ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent) : diff --git a/src/particlecontainer.h b/src/particlecontainer.h index 0181f6e1..4fb00027 100644 --- a/src/particlecontainer.h +++ b/src/particlecontainer.h @@ -25,8 +25,7 @@ #include #include -#include "particle.h" - +class Particle; /** * Set of particle effects. May be stacked with other ParticleContainers. All @@ -65,8 +64,6 @@ protected: ParticleContainer *mNext; /**< Contained container, if any */ }; - - /** * Linked list of particle effects. */ @@ -94,7 +91,6 @@ protected: std::list mElements; /**< Contained particle effects */ }; - /** * Particle container with indexing facilities */ diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index ca9f7bf5..fa5dcde4 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -19,19 +19,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "animationparticle.h" #include "imageparticle.h" #include "log.h" #include "particle.h" #include "particleemitter.h" -#include "resources/animation.h" #include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" -#include - #define SIN45 0.707106781f #define DEG_RAD_FACTOR 0.017453293f diff --git a/src/particleemitter.h b/src/particleemitter.h index cc77f215..67b35ae2 100644 --- a/src/particleemitter.h +++ b/src/particleemitter.h @@ -26,10 +26,10 @@ #include "utils/xml.h" -#include "resources/animation.h" - #include "particleemitterprop.h" +#include "resources/animation.h" + class Image; class Map; class Particle; diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h index fde78f8f..e68ac222 100644 --- a/src/particleemitterprop.h +++ b/src/particleemitterprop.h @@ -20,7 +20,6 @@ */ #include -#include /** * Returns a random numeric value that is larger than or equal min and smaller diff --git a/src/party.cpp b/src/party.cpp index 67262176..e9304ada 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "beingmanager.h" #include "game.h" #include "localplayer.h" #include "party.h" diff --git a/src/player.cpp b/src/player.cpp index ca8c9f14..610dfeb1 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -19,16 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "animatedsprite.h" #include "game.h" -#include "graphics.h" -#include "log.h" #include "player.h" +#include "text.h" +#include "resources/colordb.h" #include "resources/itemdb.h" -#include "resources/iteminfo.h" #include "utils/strprintf.h" diff --git a/src/player.h b/src/player.h index 5fe9963a..f9911bb8 100644 --- a/src/player.h +++ b/src/player.h @@ -23,8 +23,8 @@ #define PLAYER_H #include "being.h" -#include "text.h" +class FlashText; class Graphics; class Map; diff --git a/src/player_relations.cpp b/src/player_relations.cpp index 057eea94..6386c246 100644 --- a/src/player_relations.cpp +++ b/src/player_relations.cpp @@ -21,12 +21,13 @@ #include +#include "being.h" #include "beingmanager.h" +#include "configuration.h" #include "graphics.h" +#include "player.h" #include "player_relations.h" -#include "gui/gui.h" - #define PLAYER_IGNORE_STRATEGY_NOP "nop" #define PLAYER_IGNORE_STRATEGY_EMOTE0 "emote0" #define DEFAULT_IGNORE_STRATEGY PLAYER_IGNORE_STRATEGY_EMOTE0 diff --git a/src/player_relations.h b/src/player_relations.h index 0f8bb4e3..1eb4ede6 100644 --- a/src/player_relations.h +++ b/src/player_relations.h @@ -27,9 +27,8 @@ #include #include -#include "being.h" -#include "configuration.h" -#include "player.h" +class Being; +class Player; struct PlayerRelation { diff --git a/src/properties.h b/src/properties.h index 91367552..4bad8e59 100644 --- a/src/properties.h +++ b/src/properties.h @@ -35,8 +35,7 @@ class Properties /** * Destructor. */ - virtual - ~Properties() {} + virtual ~Properties() {} /** * Get a map property. diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 8d7156a9..54c319de 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "animation.h" #include "../utils/dtor.h" diff --git a/src/resources/buddylist.h b/src/resources/buddylist.h index d769b2b8..f0758c25 100644 --- a/src/resources/buddylist.h +++ b/src/resources/buddylist.h @@ -27,7 +27,8 @@ #include -class BuddyList : public gcn::ListModel { +class BuddyList : public gcn::ListModel +{ public: /** * Constructor diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index f80ca6b3..7456f0e4 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -19,14 +19,12 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include "colordb.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index fd760c3f..63d85501 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include "dye.h" diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 2f43822d..adc1635c 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -20,11 +20,9 @@ */ #include "emotedb.h" -#include "resourcemanager.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/image.h b/src/resources/image.h index 5b376053..9af10fda 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -40,6 +40,8 @@ #include "resource.h" class Dye; +class SDL_Rect; +class SDL_Surface; /** * Defines a class for loading and storing images. diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index 8ad6c5d4..c182b44c 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -20,7 +20,6 @@ */ #include -#include #include #include diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h index a9133846..039d3afb 100644 --- a/src/resources/imagewriter.h +++ b/src/resources/imagewriter.h @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - struct SDL_Surface; class ImageWriter diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 752ea38b..9976f0d4 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -24,8 +24,6 @@ #include #include "itemdb.h" -#include "iteminfo.h" -#include "resourcemanager.h" #include "../log.h" diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index e7c23ca2..08a7acd0 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -26,6 +26,8 @@ #include "iteminfo.h" +class ItemInfo; + /** * The namespace that holds the item information. */ diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index a4ec3b69..2278dc67 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -23,6 +23,7 @@ #include #include +#include "animation.h" #include "image.h" #include "mapreader.h" #include "resourcemanager.h" diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index ef945c3f..0ed553c3 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -22,8 +22,6 @@ #ifndef MAPREADER_H #define MAPREADER_H -#include - #include class Map; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index c7926260..c7824a5d 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -20,7 +20,7 @@ */ #include "monsterdb.h" -#include "resourcemanager.h" +#include "monsterinfo.h" #include "../log.h" diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h index 6fbde55f..0a218661 100644 --- a/src/resources/monsterdb.h +++ b/src/resources/monsterdb.h @@ -24,7 +24,7 @@ #include -#include "monsterinfo.h" +class MonsterInfo; /** * Monster information database. diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 88572481..73c3939d 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -20,11 +20,9 @@ */ #include "npcdb.h" -#include "resourcemanager.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/resource.h b/src/resources/resource.h index 303b82c8..7c5f989e 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -62,8 +62,7 @@ class Resource /** * Destructor. */ - virtual - ~Resource(); + virtual ~Resource(); private: std::string mIdPath; /**< Path identifying this resource. */ diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 05ec9e54..116df930 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -35,8 +35,7 @@ class SoundEffect : public Resource /** * Destructor. */ - virtual - ~SoundEffect(); + virtual ~SoundEffect(); /** * Loads a sample from a buffer in memory. diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 17d9ce60..9066ed7f 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -19,14 +19,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "graphics.h" #include "log.h" #include "simpleanimation.h" +#include "resources/animation.h" #include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" +SimpleAnimation::SimpleAnimation(Animation *animation): + mAnimation(animation), + mAnimationTime(0), + mAnimationPhase(0), + mCurrentFrame(mAnimation->getFrame(0)) +{ +}; + SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode): mAnimationTime(0), mAnimationPhase(0) diff --git a/src/simpleanimation.h b/src/simpleanimation.h index a7178145..16ac2906 100644 --- a/src/simpleanimation.h +++ b/src/simpleanimation.h @@ -22,12 +22,12 @@ #ifndef SIMPLEANIMAION_H #define SIMPLEANIMAION_H -#include "resources/animation.h" - #include "utils/xml.h" +class Animation; class Frame; class Graphics; +class Image; /** * This class is a leightweight alternative to the AnimatedSprite class. @@ -39,12 +39,7 @@ class SimpleAnimation /** * Creates a simple animation with an already created animation. */ - SimpleAnimation(Animation *animation): - mAnimation(animation), - mAnimationTime(0), - mAnimationPhase(0), - mCurrentFrame(mAnimation->getFrame(0)) - {}; + SimpleAnimation(Animation *animation); /** * Creates a simple animation that creates its animation from XML Data. diff --git a/src/text.cpp b/src/text.cpp index 14ee3919..8f93f157 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -18,8 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include - #include #include "text.h" @@ -72,7 +70,7 @@ Text::~Text() } } -void Text::draw(Graphics *graphics, int xOff, int yOff) +void Text::draw(gcn::Graphics *graphics, int xOff, int yOff) { graphics->setFont(boldFont); @@ -102,7 +100,7 @@ FlashText::FlashText(const std::string &text, int x, int y, { } -void FlashText::draw(Graphics *graphics, int xOff, int yOff) +void FlashText::draw(gcn::Graphics *graphics, int xOff, int yOff) { if (mTime) { diff --git a/src/text.h b/src/text.h index 43d6b5ea..c898bbe3 100644 --- a/src/text.h +++ b/src/text.h @@ -21,10 +21,10 @@ #ifndef TEXT_H #define TEXT_H -#include "graphics.h" -#include "guichanfwd.h" +#include +#include -#include +#include "guichanfwd.h" class TextManager; @@ -52,7 +52,7 @@ class Text /** * Draws the text. */ - virtual void draw(Graphics *graphics, int xOff, int yOff); + virtual void draw(gcn::Graphics *graphics, int xOff, int yOff); private: int mX; /**< Actual x-value of left of text written. */ @@ -84,7 +84,7 @@ class FlashText : public Text /** * Draws the text */ - virtual void draw(Graphics *graphics, int xOff, int yOff); + virtual void draw(gcn::Graphics *graphics, int xOff, int yOff); private: int mTime; /**< Time left for flashing */ diff --git a/src/textmanager.cpp b/src/textmanager.cpp index 7c5d2713..d40ba4d2 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -59,7 +59,7 @@ TextManager::~TextManager() { } -void TextManager::draw(Graphics *graphics, int xOff, int yOff) +void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff) { for (TextList::iterator bPtr = mTextList.begin(), ePtr = mTextList.end(); bPtr != ePtr; ++bPtr) @@ -89,21 +89,13 @@ void TextManager::place(const Text *textObj, const Text *omit, int from = (*ptr)->mY - occupiedTop; int to = from + (*ptr)->mHeight - 1; if (to < 0 || from >= TEST) // out of range considered - { continue; - } if (from < 0) - { from = 0; - } if (to >= TEST) - { to = TEST - 1; - } for (int i = from; i <= to; ++i) - { occupied[i] = true; - } } } bool ok = true; @@ -111,10 +103,10 @@ void TextManager::place(const Text *textObj, const Text *omit, { ok = ok && !occupied[i]; } + if (ok) - { return; - } + // Have to move it up or down, so find nearest spaces either side int consec = 0; int upSlot = -1; // means not found diff --git a/src/textmanager.h b/src/textmanager.h index a08660d5..b1e10f08 100644 --- a/src/textmanager.h +++ b/src/textmanager.h @@ -23,8 +23,9 @@ #include +#include "guichanfwd.h" + class Text; -class Graphics; class TextManager { @@ -57,7 +58,7 @@ class TextManager /** * Draw the text */ - void draw(Graphics *graphics, int xOff, int yOff); + void draw(gcn::Graphics *graphics, int xOff, int yOff); private: /** diff --git a/src/textparticle.cpp b/src/textparticle.cpp index 7e329b4e..f38c32ce 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "graphics.h" #include "textparticle.h" diff --git a/src/textparticle.h b/src/textparticle.h index bc7cd88c..cdf99d8f 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -22,8 +22,6 @@ #ifndef _TEXTPARTICLE_H #define _TEXTPARTICLE_H -#include - #include "guichanfwd.h" #include "particle.h" diff --git a/src/utils/tostring.h b/src/utils/tostring.h index eb86f99e..62eb44e4 100644 --- a/src/utils/tostring.h +++ b/src/utils/tostring.h @@ -34,7 +34,7 @@ std::string toString(const T &arg) // TODO: Is there a good way to suppress warnings from classes which don't use // this function? -static char *iptostring(int address) +inline char *iptostring(int address) { static char asciiIP[16]; -- cgit v1.2.3-70-g09d2