diff options
Diffstat (limited to 'src')
123 files changed, 2031 insertions, 1171 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86deec0c..513456aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ FIND_PACKAGE(PhysFS REQUIRED) FIND_PACKAGE(PNG REQUIRED) SET(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"") -SET(FLAGS "${FLAGS} -DAETHYRA_DATADIR=\\\"${PKG_DATADIR}/\\\"") +SET(FLAGS "${FLAGS} -DTMW_DATADIR=\\\"${PKG_DATADIR}/\\\"") SET(GUICHAN_COMPONENTS "SDL") IF (WITH_OPENGL) @@ -395,9 +395,9 @@ SET(SRCS vector.h ) -ADD_EXECUTABLE(aethyra ${SRCS}) +ADD_EXECUTABLE(tmw ${SRCS}) -TARGET_LINK_LIBRARIES(aethyra +TARGET_LINK_LIBRARIES(tmw ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} @@ -410,6 +410,6 @@ TARGET_LINK_LIBRARIES(aethyra ${OPENGL_LIBRARIES} ) -INSTALL(TARGETS aethyra RUNTIME DESTINATION ${PKG_BINDIR}) +INSTALL(TARGETS tmw RUNTIME DESTINATION ${PKG_BINDIR}) -SET_TARGET_PROPERTIES(aethyra PROPERTIES COMPILE_FLAGS "${FLAGS}") +SET_TARGET_PROPERTIES(tmw PROPERTIES COMPILE_FLAGS "${FLAGS}") diff --git a/src/Makefile.am b/src/Makefile.am index c6a9a9c4..ecf45945 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,8 @@ -bin_PROGRAMS = aethyra -aethyra_SOURCES = gui/widgets/dropdown.cpp \ - gui/widgets/dropdown.h \ +AUTOMAKE_OPTIONS = subdir-objects + +bin_PROGRAMS = tmw +tmw_SOURCES = gui/widgets/dropdown.cpp \ + gui/widgets/dropdown.h \ gui/widgets/layout.cpp \ gui/widgets/layout.h \ gui/widgets/layouthelper.cpp \ @@ -98,8 +100,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ gui/progressbar.h \ gui/radiobutton.cpp \ gui/radiobutton.h \ - gui/recorder.cpp \ - gui/recorder.h \ + gui/recorder.cpp \ + gui/recorder.h \ gui/register.cpp \ gui/register.h \ gui/scrollarea.cpp \ @@ -187,8 +189,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ net/network.h \ net/npchandler.cpp \ net/npchandler.h \ - net/partyhandler.cpp \ - net/partyhandler.h \ + net/partyhandler.cpp \ + net/partyhandler.h \ net/playerhandler.cpp \ net/playerhandler.h \ net/protocol.cpp \ @@ -316,8 +318,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ particleemitter.cpp \ particleemitter.h \ particleemitterprop.h \ - party.cpp \ - party.h \ + party.cpp \ + party.h \ player.cpp \ player.h \ player_relations.cpp \ @@ -333,6 +335,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ sound.cpp \ sound.h \ sprite.h \ + statuseffect.cpp \ + statuseffect.h \ text.cpp \ text.h \ textmanager.cpp \ @@ -345,12 +349,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ # set the include path found by configure INCLUDES = \ - $(all_includes) \ - -DAETHYRA_DATADIR=\""$(pkgdatadir)/"\" \ - -DLOCALEDIR=\""$(localedir)/"\" - -# the library search path. -aethyra_LDFLAGS = $(all_libraries) $(LIBSDL_RPATH) `pkg-config --libs libxml-2.0` -aethyra_CXXFLAGS = -Wall $(LIBSDL_CFLAGS) `pkg-config --cflags libxml-2.0` $(CURL_CFLAGS) -aethyra_LDADD = $(LIBSDL_LIBS) -lguichan_sdl $(CURL_LIBS) -aethyra_TARGET = aethyra + $(all_includes) \ + -DTMW_DATADIR=\""$(pkgdatadir)/"\" \ + -DLOCALEDIR=\""$(localedir)"\" diff --git a/src/SDLMain.h b/src/SDLMain.h index 4683df57..4683df57 100755..100644 --- a/src/SDLMain.h +++ b/src/SDLMain.h diff --git a/src/SDLMain.m b/src/SDLMain.m index 3d02719c..3d02719c 100755..100644 --- a/src/SDLMain.m +++ b/src/SDLMain.m diff --git a/src/animatedsprite.h b/src/animatedsprite.h index b196b990..43248731 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -50,7 +50,8 @@ class AnimatedSprite * @param filename the file of the sprite to animate * @param variant the sprite variant */ - static AnimatedSprite *load(std::string const &filename, int variant = 0); + static AnimatedSprite *load(const std::string &filename, + int variant = 0); /** * Destructor. diff --git a/src/being.cpp b/src/being.cpp index 9b8ede27..e1ff5591 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -19,11 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <cassert> -#include <cmath> +#include "being.h" #include "animatedsprite.h" -#include "being.h" #include "configuration.h" #include "effectmanager.h" #include "game.h" @@ -34,6 +32,7 @@ #include "particle.h" #include "sound.h" #include "text.h" +#include "statuseffect.h" #include "gui/speechbubble.h" @@ -55,6 +54,12 @@ #include "utils/trim.h" #include "utils/xml.h" +#include <cassert> +#include <cmath> + +#define BEING_EFFECTS_FILE "effects.xml" +#define HAIR_FILE "hair.xml" + int Being::instances = 0; int Being::mNumberOfHairstyles = 1; std::vector<AnimatedSprite*> Being::emotionSet; @@ -84,11 +89,13 @@ Being::Being(int id, int job, Map *map): mGender(GENDER_UNSPECIFIED), mSpeechTime(0), mPx(0), mPy(0), + mStunMode(0), mSprites(VECTOREND_SPRITE, NULL), mSpriteIDs(VECTOREND_SPRITE, 0), mSpriteColors(VECTOREND_SPRITE, ""), mStatusParticleEffects(&mStunParticleEffects, false), - mChildParticleEffects(&mStatusParticleEffects, false) + mChildParticleEffects(&mStatusParticleEffects, false), + mMustResetParticles(false) { setMap(map); @@ -190,7 +197,7 @@ void Being::setSpeech(const std::string &text, Uint32 time) while (start != std::string::npos && end != std::string::npos) { // Catch multiple embeds and ignore them so it doesn't crash the client. - while ((mSpeech.find('[', start + 1) != std::string::npos) && + while ((mSpeech.find('[', start + 1) != std::string::npos) && (mSpeech.find('[', start + 1) < end)) { start = mSpeech.find('[', start + 1); @@ -290,6 +297,7 @@ void Being::setMap(Map *map) // Clear particle effect list because child particles became invalid mChildParticleEffects.clear(); + mMustResetParticles = true; // Reset status particles on next redraw } void Being::controlParticle(Particle *particle) @@ -314,7 +322,7 @@ void Being::setAction(Action action) { currentAction = mEquippedWeapon->getAttackType(); } - else + else { currentAction = ACTION_ATTACK; } @@ -383,11 +391,11 @@ SpriteDirection Being::getSpriteDirection() const { dir = DIRECTION_RIGHT; } - else + else { dir = DIRECTION_LEFT; } - + return dir; } @@ -468,6 +476,17 @@ void Being::logic() } } + // Restart status/particle effects, if needed + if (mMustResetParticles) { + mMustResetParticles = false; + for (std::set<int>::iterator it = mStatusEffects.begin(); + it != mStatusEffects.end(); it++) { + const StatusEffect *effect = StatusEffect::getStatusEffect(*it, true); + if (effect && effect->particleEffectIsPersistent()) + updateStatusEffect(*it, true); + } + } + // Update particle effects mChildParticleEffects.moveTo((float) mPx + 16.0f, (float) mPy + 32.0f); @@ -517,10 +536,10 @@ void Being::drawSpeech(int offsetX, int offsetY) mSpeechBubble->setCaption(mName, mNameColor); - // Not quite centered, but close enough. However, it's not too important to get - // it right right now, as it doesn't take bubble collision into account yet. + // Not quite centered, but close enough. However, it's not too important to get + // it right right now, as it doesn't take bubble collision into account yet. mSpeechBubble->setText(mSpeech); - mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() * 4 / 11), py - 70 - + mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() * 4 / 11), py - 70 - (mSpeechBubble->getNumRows()*14)); mSpeechBubble->setVisible(true); } @@ -545,10 +564,66 @@ Being::Type Being::getType() const return UNKNOWN; } +void Being::setStatusEffectBlock(int offset, Uint16 newEffects) +{ + for (int i = 0; i < STATUS_EFFECTS; i++) { + int index = StatusEffect::blockEffectIndexToEffectIndex(offset + i); + + if (index != -1) + setStatusEffect(index, (newEffects & (1 << i)) > 0); + } +} + +void Being::handleStatusEffect(StatusEffect *effect, int effectId) +{ + if (!effect) + return; + + // TODO: Find out how this is meant to be used + // (SpriteAction != Being::Action) + //SpriteAction action = effect->getAction(); + //if (action != ACTION_INVALID) + // setAction(action); + + Particle *particle = effect->getParticle(); + + if (effectId >= 0) + mStatusParticleEffects.setLocally(effectId, particle); + else { + mStunParticleEffects.clearLocally(); + if (particle) + mStunParticleEffects.addLocally(particle); + } +} + +void Being::updateStunMode(int oldMode, int newMode) +{ + handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1); + handleStatusEffect(StatusEffect::getStatusEffect(newMode, true), -1); +} + +void Being::updateStatusEffect(int index, bool newStatus) +{ + handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index); +} + +void Being::setStatusEffect(int index, bool active) +{ + const bool wasActive = mStatusEffects.find(index) != mStatusEffects.end(); + + if (active != wasActive) { + updateStatusEffect(index, active); + if (active) + mStatusEffects.insert(index); + else + mStatusEffects.erase(index); + } +} + int Being::getOffset(char pos, char neg) const { // Check whether we're walking in the requested direction - if (mAction != WALK || !(mDirection & (pos | neg))) + if (mAction != WALK || !(mDirection & (pos | neg))) { return 0; } @@ -557,13 +632,13 @@ int Being::getOffset(char pos, char neg) const // We calculate the offset _from_ the _target_ location offset -= 32; - if (offset > 0) + if (offset > 0) { offset = 0; } // Going into negative direction? Invert the offset. - if (mDirection & pos) + if (mDirection & pos) { offset = -offset; } @@ -576,11 +651,11 @@ int Being::getWidth() const if (mSprites[BASE_SPRITE]) { const int width = mSprites[BASE_SPRITE]->getWidth() > DEFAULT_WIDTH ? - mSprites[BASE_SPRITE]->getWidth() : + mSprites[BASE_SPRITE]->getWidth() : DEFAULT_WIDTH; return width; } - else + else { return DEFAULT_WIDTH; } @@ -592,13 +667,185 @@ int Being::getHeight() const if (mSprites[BASE_SPRITE]) { const int height = mSprites[BASE_SPRITE]->getHeight() > DEFAULT_HEIGHT ? - mSprites[BASE_SPRITE]->getHeight() : + mSprites[BASE_SPRITE]->getHeight() : DEFAULT_HEIGHT; return height; } - else + else { return DEFAULT_HEIGHT; } } + +struct EffectDescription { + std::string mGFXEffect; + std::string mSFXEffect; +}; + +static EffectDescription *default_effect = NULL; +static std::map<int, EffectDescription *> effects; +static bool effects_initialized = false; + +static EffectDescription *getEffectDescription(xmlNodePtr node, int *id) +{ + EffectDescription *ed = new EffectDescription; + + *id = atoi(XML::getProperty(node, "id", "-1").c_str()); + ed->mSFXEffect = XML::getProperty(node, "audio", ""); + ed->mGFXEffect = XML::getProperty(node, "particle", ""); + + return ed; +} + +static EffectDescription *getEffectDescription(int effectId) +{ + if (!effects_initialized) + { + XML::Document doc(BEING_EFFECTS_FILE); + xmlNodePtr root = doc.rootNode(); + + if (!root || !xmlStrEqual(root->name, BAD_CAST "being-effects")) + { + logger->log("Error loading being effects file: " + BEING_EFFECTS_FILE); + return NULL; + } + + for_each_xml_child_node(node, root) + { + int id; + + if (xmlStrEqual(node->name, BAD_CAST "effect")) + { + EffectDescription *EffectDescription = + getEffectDescription(node, &id); + effects[id] = EffectDescription; + } else if (xmlStrEqual(node->name, BAD_CAST "default")) + { + EffectDescription *EffectDescription = + getEffectDescription(node, &id); + + if (default_effect) + delete default_effect; + + default_effect = EffectDescription; + } + } + + effects_initialized = true; + } // done initializing + + EffectDescription *ed = effects[effectId]; + + if (!ed) + return default_effect; + else + return ed; +} + +void Being::internalTriggerEffect(int effectId, bool sfx, bool gfx) +{ + logger->log("Special effect #%d on %s", effectId, + getId() == player_node->getId() ? "self" : "other"); + + EffectDescription *ed = getEffectDescription(effectId); + + if (!ed) { + logger->log("Unknown special effect and no default recorded"); + return; + } + + if (gfx && ed->mGFXEffect != "") { + Particle *selfFX; + + selfFX = particleEngine->addEffect(ed->mGFXEffect, 0, 0); + controlParticle(selfFX); + } + + if (sfx && ed->mSFXEffect != "") { + sound.playSfx(ed->mSFXEffect); + } +} + + + + +static int hairStylesNr; +static int hairColorsNr; +static std::vector<std::string> hairColors; + +static void initializeHair(); + +int Being::getHairStylesNr() +{ + initializeHair(); + return hairStylesNr; +} + +int Being::getHairColorsNr() +{ + initializeHair(); + return hairColorsNr; +} + +std::string Being::getHairColor(int index) +{ + initializeHair(); + if (index < 0 || index >= hairColorsNr) + return "#000000"; + + return hairColors[index]; +} + +static bool hairInitialized = false; + +static void initializeHair() +{ + if (hairInitialized) + return; + + // Hairstyles are encoded as negative numbers. Count how far negative we + // can go. + int hairstylesCtr = -1; + while (ItemDB::get(hairstylesCtr).getSprite(GENDER_MALE) != "error.xml") + --hairstylesCtr; + + hairStylesNr = -hairstylesCtr; // done. + if (hairStylesNr == 0) + hairStylesNr = 1; // No hair style -> no hair + + hairColorsNr = 0; + + XML::Document doc(HAIR_FILE); + xmlNodePtr root = doc.rootNode(); + + if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) + { + logger->log("Error loading being hair configuration file"); + } else { + for_each_xml_child_node(node, root) + { + if (xmlStrEqual(node->name, BAD_CAST "color")) + { + int index = atoi(XML::getProperty(node, "id", "-1").c_str()); + std::string value = XML::getProperty(node, "value", ""); + + if (index >= 0 && value != "") { + if (index >= hairColorsNr) { + hairColorsNr = index + 1; + hairColors.resize(hairColorsNr, "#000000"); + } + hairColors[index] = value; + } + } + } + } // done initializing + + if (hairColorsNr == 0) { // No colours -> black only + hairColorsNr = 1; + hairColors.resize(hairColorsNr, "#000000"); + } + + hairInitialized = 1; +} diff --git a/src/being.h b/src/being.h index d722092e..3c3a9b73 100644 --- a/src/being.h +++ b/src/being.h @@ -26,9 +26,9 @@ #include <SDL_types.h> +#include <set> #include <string> #include <vector> -#include <bitset> #include "particlecontainer.h" #include "position.h" @@ -53,6 +53,8 @@ class Position; class SpeechBubble; class Text; +class StatusEffect; + typedef std::list<Sprite*> Sprites; typedef Sprites::iterator SpriteIterator; @@ -112,7 +114,6 @@ class Being : public Sprite NUM_TC }; - /** * Directions, to be used as bitmask values */ @@ -121,7 +122,7 @@ class Being : public Sprite Uint16 mJob; /**< Job (player job, npc, monster, ) */ Uint16 mX, mY; /**< Tile coordinates */ Action mAction; /**< Action the being is performing */ - Uint16 mFrame; + Uint16 mFrame; Uint16 mWalkTime; Uint8 mEmotion; /**< Currently showing emotion */ Uint8 mEmotionTime; /**< Time until emotion disappears */ @@ -180,14 +181,16 @@ class Being : public Sprite /** * Returns the name of the being. */ - const std::string& getName() const { return mName; } + const std::string &getName() const + { return mName; } /** * Sets the name for the being. * * @param name The name that should appear. */ - virtual void setName(const std::string &name) { mName = name; } + virtual void setName(const std::string &name) + { mName = name; } /** * Gets the hair color for this being. @@ -331,12 +334,14 @@ class Being : public Sprite /** * Get the current X pixel offset. */ - int getXOffset() const { return getOffset(LEFT, RIGHT); } + int getXOffset() const + { return getOffset(LEFT, RIGHT); } /** * Get the current Y pixel offset. */ - int getYOffset() const { return getOffset(UP, DOWN); } + int getYOffset() const + { return getOffset(UP, DOWN); } /** * Returns the horizontal size of the current base sprite of the being @@ -367,12 +372,45 @@ class Being : public Sprite mEmotionTime = emote_time; } + /** + * Sets the being's stun mode. If zero, the being is `normal', + * otherwise it is `stunned' in some fashion. + */ + void setStunMode(int stunMode) + { + if (mStunMode != stunMode) + updateStunMode(mStunMode, stunMode); + mStunMode = stunMode; + }; + + void setStatusEffect(int index, bool active); + + /** + * A status effect block is a 16 bit mask of status effects. + * We assign each such flag a block ID of offset + bitnr. + * + * These are NOT the same as the status effect indices. + */ + void setStatusEffectBlock(int offset, Uint16 flags); + + /** + * Triggers a visual effect, such as `level up' + * + * Only draws the visual effect, does not play sound effects + * + * \param effectId ID of the effect to trigger + */ + virtual void triggerEffect(int effectId) + { + internalTriggerEffect(effectId, false, true); + } + // Target cursor being used by the being Image *mTargetCursor; - static int getHairColorsNr(void); + static int getHairColorsNr(); - static int getHairStylesNr(void); + static int getHairStylesNr(); static std::string getHairColor(int index); @@ -399,6 +437,26 @@ class Being : public Sprite */ void internalTriggerEffect(int effectId, bool sfx, bool gfx); + /** + * Notify self that the stun mode has been updated. Invoked by + * setStunMode if something changed. + */ + virtual void updateStunMode(int oldMode, int newMode); + + /** + * Notify self that a status effect has flipped. + * The new flag is passed. + */ + virtual void updateStatusEffect(int index, bool newStatus); + + /** + * Handle an update to a status or stun effect + * + * \param The StatusEffect to effect + * \param effectId -1 for stun, otherwise the effect index + */ + virtual void handleStatusEffect(StatusEffect *effect, int effectId); + Uint32 mId; /**< Unique sprite id */ Uint16 mWalkSpeed; /**< Walking speed */ Uint8 mDirection; /**< Facing direction */ @@ -408,8 +466,6 @@ class Being : public Sprite bool mIsGM; bool mParticleEffects; /**< Whether to display particles or not */ - typedef std::bitset<STATUS_EFFECTS> StatusEffects; - /** Engine-related infos about weapon. */ const ItemInfo* mEquippedWeapon; @@ -422,8 +478,8 @@ class Being : public Sprite Gender mGender; Uint32 mSpeechTime; Sint32 mPx, mPy; /**< Pixel coordinates */ - Uint16 mStunMode; /**< Stun mode; zero if not stunned */ - StatusEffects mStatusEffects; /**< Bitset of active status effects */ + Uint16 mStunMode; /**< Stun mode; zero if not stunned */ + std::set<int> mStatusEffects; /**< set of active status effects */ gcn::Color mNameColor; @@ -441,6 +497,9 @@ class Being : public Sprite */ int getOffset(char pos, char neg) const; + /** Reset particle status effects on next redraw? */ + bool mMustResetParticles; + // Speech Bubble components SpeechBubble *mSpeechBubble; diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index a417ee50..3c8edf86 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -20,6 +20,7 @@ */ #include "beingmanager.h" + #include "localplayer.h" #include "monster.h" #include "npc.h" @@ -30,6 +31,8 @@ #include "utils/dtor.h" +#include <cassert> + class FindBeingFunctor { public: @@ -70,15 +73,15 @@ Being* BeingManager::createBeing(Uint32 id, Uint16 job) if (job < 10) being = new Player(id, job, mMap); - else if (job >= 100 && job < 200) + else if (job >= 50 && job < 1002) being = new NPC(id, job, mMap, mNetwork); - else if (job >= 1000 && job < 1200) + else if (job >= 1002 && job < 1500) being = new Monster(id, job, mMap); else being = new Being(id, job, mMap); // Player or NPC - if (job < 200) + if (job < 1002) { MessageOut outMsg(mNetwork); outMsg.writeInt16(0x0094); diff --git a/src/configuration.cpp b/src/configuration.cpp index f6c74428..6815ea03 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -56,7 +56,8 @@ void Configuration::setValue(const std::string &key, std::string value) } } -std::string ConfigurationObject::getValue(const std::string &key, std::string deflt) +std::string ConfigurationObject::getValue(const std::string &key, + std::string deflt) { OptionIterator iter = mOptions.find(key); return ((iter != mOptions.end()) ? iter->second : deflt); @@ -77,7 +78,7 @@ void ConfigurationObject::deleteList(const std::string &name) mContainerOptions[name].clear(); } -void ConfigurationObject::clear(void) +void ConfigurationObject::clear() { for (std::map<std::string, ConfigurationList>::const_iterator it = mContainerOptions.begin(); it != mContainerOptions.end(); it++) @@ -85,7 +86,7 @@ void ConfigurationObject::clear(void) mOptions.clear(); } -ConfigurationObject::~ConfigurationObject(void) +ConfigurationObject::~ConfigurationObject() { clear(); } diff --git a/src/configuration.h b/src/configuration.h index da12e1e4..4d28008d 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -72,7 +72,7 @@ class ConfigurationObject friend class Configuration; public: - virtual ~ConfigurationObject(void); + virtual ~ConfigurationObject(); /** * Sets an option using a string value. @@ -109,7 +109,7 @@ class ConfigurationObject /** * Re-sets all data in the configuration */ - virtual void clear(void); + virtual void clear(); /** * Serialises a container into a list of configuration options @@ -159,7 +159,7 @@ class ConfigurationObject { ConfigurationList *list = &(mContainerOptions[name]); CONT container = empty; - + for (ConfigurationList::const_iterator it = list->begin(); it != list->end(); it++) container = manager->readConfigItem(*it, container); @@ -188,7 +188,7 @@ class ConfigurationObject class Configuration : public ConfigurationObject { public: - virtual ~Configuration(void) {} + virtual ~Configuration() {} /** * Reads config file and parse all options into memory. @@ -215,6 +215,7 @@ class Configuration : public ConfigurationObject virtual void setValue(const std::string &key, std::string value); virtual void setValue(const std::string &key, float value); + private: typedef std::list<ConfigListener*> Listeners; typedef Listeners::iterator ListenerIterator; diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 0a04c33d..f004a450 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -1,8 +1,9 @@ /* - * The Mana World - * Copyright 2008 The Mana World Development Team + * An effects manager + * Copyright (C) 2008 Fate <fate.tmw@googlemail.com> + * Copyright (C) 2008 Chuck Miller <shadowmil@gmail.com> * - * This file is part of Aethyra. + * This file is part of The Mana World. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,7 +41,7 @@ EffectManager::EffectManager() else { logger->log("Effects are now loading"); - } + } for_each_xml_child_node(node, root) { @@ -70,15 +71,15 @@ bool EffectManager::trigger(int id, Being* being) if ((*i).id == id) { rValue = true; - if((*i).GFX != "") + if (!(*i).GFX.empty()) { Particle *selfFX; selfFX = particleEngine->addEffect((*i).GFX, 0, 0); being->controlParticle(selfFX); } - if((*i).SFX != "") + if (!(*i).SFX.empty()) sound.playSfx((*i).SFX); - break; + break; } } return rValue; @@ -92,13 +93,12 @@ bool EffectManager::trigger(int id, int x, int y) if ((*i).id == id) { rValue = true; - if((*i).GFX != "") + if (!(*i).GFX.empty()) particleEngine->addEffect((*i).GFX, x, y); - if((*i).SFX != "") + if (!(*i).SFX.empty()) sound.playSfx((*i).SFX); - break; + break; } } return rValue; } - diff --git a/src/effectmanager.h b/src/effectmanager.h index 619b8e0d..12fe3133 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -1,8 +1,9 @@ /* - * The Mana World - * Copyright 2008 The Mana World Development Team + * An effects manager + * Copyright (C) 2008 Fate <fate.tmw@googlemail.com> + * Copyright (C) 2008 Chuck Miller <shadowmil@gmail.com> * - * This file is part of Aethyra. + * This file is part of The Mana World. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +20,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _EFFECT_MANAGER_H -#define _EFFECT_MANAGER_H +#ifndef EFFECT_MANAGER_H +#define EFFECT_MANAGER_H #include <list> #include <string> @@ -38,28 +39,25 @@ class EffectManager std::string SFX; }; - EffectManager(); - ~EffectManager(); /** * Triggers a effect with the id, at * the specified being. */ - bool trigger(int id, Being* 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, int y); + bool trigger(int id, int x, int y); private: std::list<EffectDescription> mEffects; - }; extern EffectManager *effectManager; -#endif // _EFFECT_MANAGER_H +#endif // EFFECT_MANAGER_H diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp index 66989d44..807fa3a2 100644 --- a/src/emoteshortcut.cpp +++ b/src/emoteshortcut.cpp @@ -1,22 +1,22 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "emoteshortcut.h" diff --git a/src/emoteshortcut.h b/src/emoteshortcut.h index 3f907e1b..ceb51a9b 100644 --- a/src/emoteshortcut.h +++ b/src/emoteshortcut.h @@ -1,26 +1,26 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef EMOTESHORTCUT_H__ -#define EMOTESHORTCUT_H__ +#ifndef EMOTESHORTCUT_H +#define EMOTESHORTCUT_H #define SHORTCUT_EMOTES 12 diff --git a/src/engine.cpp b/src/engine.cpp index c91e42f9..39b9b3ec 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -98,7 +98,7 @@ void Engine::changeMap(const std::string &mapPath) map_path.c_str()); } - // How many pixels equal one tile. .5 (which is the TMW default) is + // How many pixels equal one tile. .5 (which is the TMW default) is // 2 tiles to a pixel, while 1 is 1 tile to 1 pixel if (newMap->hasProperty("minimapproportion")) minimap->setProportion(atof( diff --git a/src/equipment.cpp b/src/equipment.cpp index b21115a3..cb7acd44 100644 --- a/src/equipment.cpp +++ b/src/equipment.cpp @@ -35,6 +35,5 @@ void Equipment::setEquipment(int index, int inventoryIndex) mEquipment[index] = inventoryIndex; Item* item = player_node->getInventory()->getItem(inventoryIndex); if (item) - item->setEquipped(true); + item->setEquipped(true); } - diff --git a/src/game.cpp b/src/game.cpp index e2064f58..48ca1c73 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -176,11 +176,11 @@ Uint32 nextSecond(Uint32 interval, void *param) int get_elapsed_time(int start_time) { - if (start_time <= tick_time) + if (start_time <= tick_time) { return (tick_time - start_time) * 10; } - else + else { return (tick_time + (MAX_TIME - start_time)) * 10; } @@ -222,6 +222,8 @@ void createGuiWindows(Network *network) miniStatusWindow->getWindowName() + "Visible", true)); buyDialog->setVisible(false); sellDialog->setVisible(false); + minimap->setVisible((bool) config.getValue( + minimap->getWindowName() + "Visible", true)); tradeWindow->setVisible(false); menuWindow->setVisible((bool) config.getValue( menuWindow->getWindowName() + "Visible", true)); @@ -366,11 +368,11 @@ static bool saveScreenshot() filenameSuffix.str(""); filename << PHYSFS_getUserDir(); #if (defined __USE_UNIX98 || defined __FreeBSD__) - filenameSuffix << ".aethyra/"; + filenameSuffix << ".tmw/"; #elif defined __APPLE__ filenameSuffix << "Desktop/"; #endif - filenameSuffix << "Ae_Screenshot_" << screenshotCount << ".png"; + filenameSuffix << "TMW_Screenshot_" << screenshotCount << ".png"; filename << filenameSuffix.str(); testExists.open(filename.str().c_str(), std::ios::in); found = !testExists.is_open(); @@ -464,7 +466,8 @@ void Game::logic() if (!disconnectedDialog) { disconnectedDialog = new OkDialog(_("Network Error"), - _("The connection to the server was lost, the program will now quit")); + _("The connection to the server was lost, " + "the program will now quit")); disconnectedDialog->addActionListener(&exitListener); disconnectedDialog->requestMoveToTop(); } @@ -488,7 +491,7 @@ void Game::handleInput() { gcn::Window *requestedWindow = NULL; - if (setupWindow->isVisible() && + if (setupWindow->isVisible() && keyboard.getNewKeyIndex() > keyboard.KEY_NO_VALUE) { keyboard.setNewKey((int) event.key.keysym.sym); @@ -594,7 +597,7 @@ void Game::handleInput() case KeyboardConfig::KEY_QUIT: if (!exitConfirm) { - exitConfirm = new ConfirmDialog( _("Quit"), + exitConfirm = new ConfirmDialog( _("Quit"), _("Are you sure you " "want to quit?")); exitConfirm->addActionListener(&exitListener); @@ -621,7 +624,7 @@ void Game::handleInput() i <= KeyboardConfig::KEY_SHORTCUT_12; i++) { - if (tKey == i && !used) + if (tKey == i && !used) { itemShortcut->useItem( i - KeyboardConfig::KEY_SHORTCUT_1); @@ -634,9 +637,9 @@ void Game::handleInput() { case KeyboardConfig::KEY_PICKUP: { - FloorItem *item = floorItemManager->findByCoordinates( - player_node->mX, - player_node->mY); + FloorItem *item = + floorItemManager->findByCoordinates( + player_node->mX, player_node->mY); // If none below the player, try the tile in front // of the player @@ -652,7 +655,9 @@ void Game::handleInput() x--; if (player_node->getDirection() & Being::RIGHT) x++; - item = floorItemManager->findByCoordinates(x, y); + + item = floorItemManager->findByCoordinates( + x, y); } if (item) @@ -822,7 +827,7 @@ void Game::handleInput() if (keyboard.isKeyActive(keyboard.KEY_ATTACK) || (joystick && joystick->buttonPressed(0))) { - Being *target = beingManager->findNearestLivingBeing(x, y, 20, + Being *target = beingManager->findNearestLivingBeing(x, y, 20, Being::MONSTER); bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET); @@ -850,7 +855,7 @@ void Game::handleInput() } // Target the nearest player if 'q' is pressed - if ( keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER) && + if ( keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER) && !keyboard.isKeyActive(keyboard.KEY_TARGET) ) { Being *target = beingManager->findNearestLivingBeing(player_node, 20, Being::PLAYER); @@ -859,8 +864,8 @@ void Game::handleInput() } // Target the nearest monster if 'a' pressed - if ((keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) || - (joystick && joystick->buttonPressed(3))) && + if ((keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) || + (joystick && joystick->buttonPressed(3))) && !keyboard.isKeyActive(keyboard.KEY_TARGET)) { Being *target = beingManager->findNearestLivingBeing( @@ -870,7 +875,7 @@ void Game::handleInput() } // Target the nearest npc if 'n' pressed - if ( keyboard.isKeyActive(keyboard.KEY_TARGET_NPC) && + if ( keyboard.isKeyActive(keyboard.KEY_TARGET_NPC) && !keyboard.isKeyActive(keyboard.KEY_TARGET) ) { Being *target = beingManager->findNearestLivingBeing( @@ -19,8 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef GAME_ -#define GAME_ +#ifndef GAME_H +#define GAME_H #include <memory> @@ -36,35 +36,35 @@ extern volatile int tick_time; class Game : public ConfigListener { public: - Game(Network *network); - ~Game(); + Game(Network *network); + ~Game(); - void logic(); + void logic(); - void handleInput(); + void handleInput(); - void optionChanged(const std::string &name); + void optionChanged(const std::string &name); private: - Network *mNetwork; + Network *mNetwork; - /** Used to determine whether to draw the next frame. */ - int mDrawTime; + /** Used to determine whether to draw the next frame. */ + int mDrawTime; - /** The minimum frame time (used for frame limiting). */ - int mMinFrameTime; + /** The minimum frame time (used for frame limiting). */ + int mMinFrameTime; - typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr; - MessageHandlerPtr mBeingHandler; - MessageHandlerPtr mBuySellHandler; - MessageHandlerPtr mChatHandler; - MessageHandlerPtr mEquipmentHandler; - MessageHandlerPtr mInventoryHandler; - MessageHandlerPtr mItemHandler; - MessageHandlerPtr mNpcHandler; - MessageHandlerPtr mPlayerHandler; - MessageHandlerPtr mSkillHandler; - MessageHandlerPtr mTradeHandler; + typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr; + MessageHandlerPtr mBeingHandler; + MessageHandlerPtr mBuySellHandler; + MessageHandlerPtr mChatHandler; + MessageHandlerPtr mEquipmentHandler; + MessageHandlerPtr mInventoryHandler; + MessageHandlerPtr mItemHandler; + MessageHandlerPtr mNpcHandler; + MessageHandlerPtr mPlayerHandler; + MessageHandlerPtr mSkillHandler; + MessageHandlerPtr mTradeHandler; }; /** diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 5895d557..65659df6 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -103,7 +103,7 @@ void BrowserBox::addRow(const std::string &row) newRow += "##<" + bLink.caption; tmp.erase(0, idx3 + 2); - if(tmp != "") + if (tmp != "") { newRow += "##>"; } diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 6626b848..8de4f5a7 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -94,8 +94,8 @@ CharSelectDialog::CharSelectDialog(Network *network, mJobLevelLabel = new gcn::Label(strprintf(_("Job Level: %d"), 0)); mMoneyLabel = new gcn::Label(strprintf(_("Money: %d"), 0)); - const std::string tempString = getFont()->getWidth(_("New")) < - getFont()->getWidth(_("Delete")) ? + const std::string tempString = getFont()->getWidth(_("New")) < + getFont()->getWidth(_("Delete")) ? _("Delete") : _("New"); mPreviousButton = new Button(_("Previous"), "previous", this); @@ -231,7 +231,7 @@ bool CharSelectDialog::selectByName(const std::string &name) unsigned int oldPos = mCharInfo->getPos(); mCharInfo->select(0); - do + do { LocalPlayer *player = mCharInfo->getEntry(); @@ -309,15 +309,15 @@ CharCreateDialog::~CharCreateDialog() void CharCreateDialog::action(const gcn::ActionEvent &event) { int numberOfColors = ColorDB::size(); - if (event.getId() == "create") + if (event.getId() == "create") { - if (getName().length() >= 4) + if (getName().length() >= 4) { // Attempt to create the character mCreateButton->setEnabled(false); attemptCharCreate(); } - else + else { new OkDialog("Error", "Your name needs to be at least 4 characters.", this); @@ -326,18 +326,18 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) else if (event.getId() == "cancel") scheduleDelete(); else if (event.getId() == "nextcolor") - mPlayer->setHairStyle(mPlayer->getHairStyle(), + mPlayer->setHairStyle(mPlayer->getHairStyle(), (mPlayer->getHairColor() + 1) % numberOfColors); else if (event.getId() == "prevcolor") - mPlayer->setHairStyle(mPlayer->getHairStyle(), - (mPlayer->getHairColor() + numberOfColors - 1) % + mPlayer->setHairStyle(mPlayer->getHairStyle(), + (mPlayer->getHairColor() + numberOfColors - 1) % numberOfColors); else if (event.getId() == "nextstyle") - mPlayer->setHairStyle(mPlayer->getHairStyle() + 1, + mPlayer->setHairStyle(mPlayer->getHairStyle() + 1, mPlayer->getHairColor()); else if (event.getId() == "prevstyle") - mPlayer->setHairStyle(mPlayer->getHairStyle() + - mPlayer->getNumOfHairstyles() - 1, + mPlayer->setHairStyle(mPlayer->getHairStyle() + + mPlayer->getNumOfHairstyles() - 1, mPlayer->getHairColor()); } diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 2363fc50..1c0cea13 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -138,18 +138,20 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) } std::string lineColor = "##C"; - switch (own) + switch (own) { case BY_GM: if (tmp.nick.empty()) { - tmp.nick = std::string(_("Global announcement: ")); + tmp.nick = std::string(_("Global announcement:")); + tmp.nick += " "; lineColor = "##G"; } else { - tmp.nick = strprintf(_("Global announcement from %s: "), + tmp.nick = strprintf(_("Global announcement from %s:"), tmp.nick.c_str()); + tmp.nick += " "; lineColor = "##1"; // Equiv. to BrowserBox::RED } break; @@ -172,7 +174,8 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) lineColor = "##P"; break; case ACT_WHISPER: - tmp.nick += CAT_WHISPER; + tmp.nick = strprintf(_("%s whispers:"), tmp.nick.c_str()); + tmp.nick += " "; lineColor = "##W"; break; case ACT_IS: @@ -215,7 +218,7 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) // adding a row, otherwise the max will always be a row higher // at comparison. if (mScrollArea->getVerticalScrollAmount() == - mScrollArea->getVerticalMaxScroll()) + mScrollArea->getVerticalMaxScroll()) { mTextOutput->addRow(line); mScrollArea->setVerticalScrollAmount(mScrollArea-> @@ -234,7 +237,7 @@ void ChatWindow::chatLog(CHATSKILL act) chatLog(const_msg(act), BY_SERVER); } -void ChatWindow::action(const gcn::ActionEvent & event) +void ChatWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "chatinput") { @@ -341,7 +344,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) return; // Send party message - if (msg.at(0) == mPartyPrefix) + if (msg.at(0) == mPartyPrefix) { msg.erase(0, 1); std::size_t length = msg.length() + 1; @@ -367,7 +370,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) if (end != std::string::npos) { // Catch multiple embeds and ignore them so it doesn't crash the client. - while ((msg.find('[', start + 1) != std::string::npos) && + while ((msg.find('[', start + 1) != std::string::npos) && (msg.find('[', start + 1) < end)) { start = msg.find('[', start + 1); @@ -395,7 +398,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) } // Prepare ordinary message - if (msg.substr(0, 1) != "/") + if (msg.substr(0, 1) != "/") { msg = nick + " : " + msg; @@ -423,14 +426,14 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) trim(msg); } - if (command == "announce") + if (command == "announce") { MessageOut outMsg(mNetwork); outMsg.writeInt16(0x0099); outMsg.writeInt16(msg.length() + 4); outMsg.writeString(msg, msg.length()); } - else if (command == "help") + else if (command == "help") { trim(msg); std::size_t space = msg.find(" "); @@ -483,16 +486,16 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) msg = msg.substr(0, 1); - if (msg == "1" || - msg == "y" || msg == "Y" || + if (msg == "1" || + msg == "y" || msg == "Y" || msg == "t" || msg == "T") { chatLog(_("Return now toggles chat."), BY_SERVER); mReturnToggles = true; return; } - else if (msg == "0" || - msg == "n" || msg == "N" || + else if (msg == "0" || + msg == "n" || msg == "N" || msg == "f" || msg == "F") { chatLog(_("Message now closes chat."), BY_SERVER); @@ -697,9 +700,8 @@ void ChatWindow::scroll(int amount) mTextOutput->showPart(scr); } -void ChatWindow::keyPressed(gcn::KeyEvent & event) +void ChatWindow::keyPressed(gcn::KeyEvent &event) { - if (event.getKey().getValue() == Key::DOWN && mCurHist != mHistory.end()) { @@ -787,7 +789,7 @@ void ChatWindow::party(const std::string & command, const std::string & rest) void ChatWindow::help(const std::string & msg1, const std::string & msg2) { chatLog(_("-- Help --"), BY_SERVER); - if (msg1 == "") + if (msg1 == "") { chatLog(_("/announce: Global announcement (GM only)"), BY_SERVER); chatLog(_("/clear: Clears this window"), BY_SERVER); @@ -827,18 +829,18 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) chatLog(_("Command: /help <command>"), BY_SERVER); chatLog(_("This command displays help on <command>."), BY_SERVER); } - else if (msg1 == "party") + else if (msg1 == "party") { mParty->help(msg2); } - else if (msg1 == "present") + else if (msg1 == "present") { chatLog(_("Command: /present"), BY_SERVER); chatLog(_("This command gets a list of players within hearing and " "sends it to either the record log if recording, or the chat " "log otherwise."), BY_SERVER); } - else if (msg1 == "record") + else if (msg1 == "record") { chatLog(_("Command: /record <filename>"), BY_SERVER); chatLog(_("This command starts recording the chat log to the file " @@ -846,10 +848,10 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) chatLog(_("Command: /record"), BY_SERVER); chatLog(_("This command finishes a recording session."), BY_SERVER); } - else if (msg1 == "toggle") + else if (msg1 == "toggle") { chatLog(_("Command: /toggle <state>"), BY_SERVER); - chatLog(_("This command sets whether the return key should toggle the" + chatLog(_("This command sets whether the return key should toggle the" "chat log, or whether the chat log turns off automatically."), BY_SERVER); chatLog(_("<state> can be one of \"1\", \"yes\", \"true\" to " diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index c4505c2f..cdb5a3fd 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -1,23 +1,23 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program is distributed with The Mana Experiment * - * 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +/* + * Configurable text colors + * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "colour.h" diff --git a/src/gui/colour.h b/src/gui/colour.h index d0349b7d..6ea02840 100644 --- a/src/gui/colour.h +++ b/src/gui/colour.h @@ -1,26 +1,26 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program is distributed with The Mana Experiment * - * 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef _COLOUR_H -#define _COLOUR_H +/* + * Configurable text colors + * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef COLOUR_H +#define COLOUR_H #include <string> #include <vector> diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 8bb9c578..38697f3a 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -55,7 +55,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, // 15 == height of each line of text (based on font heights) // 14 == row top + bottom graphic pixel heights setContentSize(mTextBox->getMinWidth() + 15, 15 + (numRows * 15) + noButton->getHeight()); - mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, + mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, 3 + (numRows * 14))); } else diff --git a/src/gui/emotecontainer.cpp b/src/gui/emotecontainer.cpp index fa63d4bb..94ce9736 100644 --- a/src/gui/emotecontainer.cpp +++ b/src/gui/emotecontainer.cpp @@ -1,22 +1,22 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <guichan/mouseinput.hpp> @@ -90,7 +90,7 @@ void EmoteContainer::draw(gcn::Graphics *graphics) { int emoteX = ((i) % columns) * gridWidth; int emoteY = ((i) / columns) * gridHeight; - + // Draw emote icon mEmoteImg[i]->draw(static_cast<Graphics*>(graphics), emoteX, emoteY); @@ -121,7 +121,7 @@ void EmoteContainer::recalculateHeight() setHeight(height); } -int EmoteContainer::getSelectedEmote() +int EmoteContainer::getSelectedEmote() { if (mSelectedEmoteIndex == NO_EMOTE) return 0; diff --git a/src/gui/emotecontainer.h b/src/gui/emotecontainer.h index 5a2b8c2e..fefce793 100644 --- a/src/gui/emotecontainer.h +++ b/src/gui/emotecontainer.h @@ -1,26 +1,26 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef EMOTECONTAINER_H__ -#define EMOTECONTAINER_H__ +#ifndef EMOTECONTAINER_H +#define EMOTECONTAINER_H #include <list> #include <vector> @@ -41,7 +41,7 @@ namespace gcn { * * \ingroup GUI */ -class EmoteContainer : public gcn::Widget, +class EmoteContainer : public gcn::Widget, public gcn::MouseListener, public gcn::WidgetListener { @@ -101,8 +101,8 @@ class EmoteContainer : public gcn::Widget, private: /** - - * Sets the currently selected emote. Invalid (e.g., negative) indices set `no emotr'. + * Sets the currently selected emote. Invalid (e.g., negative) indices + * set `no emotr'. */ void setSelectedEmoteIndex(int index); diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp index e35d037f..b66592c1 100644 --- a/src/gui/emoteshortcutcontainer.cpp +++ b/src/gui/emoteshortcutcontainer.cpp @@ -1,22 +1,22 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "emoteshortcutcontainer.h" @@ -121,14 +121,14 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event) { - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == gcn::MouseEvent::LEFT) { - if (!mEmoteMoved && mEmoteClicked) + if (!mEmoteMoved && mEmoteClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); const int emoteId = emoteShortcut->getEmote(index); - if (index == -1) + if (index == -1) { return; } @@ -139,7 +139,7 @@ void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event) emoteShortcut->removeEmote(index); } } - if (mEmoteMoved) + if (mEmoteMoved) { mCursorPosX = event.getX(); mCursorPosY = event.getY(); @@ -151,18 +151,18 @@ void EmoteShortcutContainer::mousePressed(gcn::MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); - if (index == -1) + if (index == -1) { return; } // Stores the selected emote if there is one. - if (emoteShortcut->isEmoteSelected()) + if (emoteShortcut->isEmoteSelected()) { emoteShortcut->setEmote(index); emoteShortcut->setEmoteSelected(0); } - else if (emoteShortcut->getEmote(index)) + else if (emoteShortcut->getEmote(index)) { mEmoteClicked = true; } @@ -179,13 +179,13 @@ void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event) emoteShortcut->setEmoteSelected(0); } - if (index == -1) + if (index == -1) { mEmoteMoved = 0; return; } - if (mEmoteMoved) + if (mEmoteMoved) { emoteShortcut->setEmotes(index, mEmoteMoved); mEmoteMoved = 0; @@ -195,7 +195,7 @@ void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event) emoteShortcut->useEmote(index + 1); } - if (mEmoteClicked) + if (mEmoteClicked) { mEmoteClicked = false; } diff --git a/src/gui/emoteshortcutcontainer.h b/src/gui/emoteshortcutcontainer.h index e8d87b60..d32a9f79 100644 --- a/src/gui/emoteshortcutcontainer.h +++ b/src/gui/emoteshortcutcontainer.h @@ -1,26 +1,26 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef EMOTESHORTCUTCONTAINER_H__ -#define EMOTESHORTCUTCONTAINER_H__ +#ifndef EMOTESHORTCUTCONTAINER_H +#define EMOTESHORTCUTCONTAINER_H #include <vector> diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp index 3fa96a6d..f4a8999a 100644 --- a/src/gui/emotewindow.cpp +++ b/src/gui/emotewindow.cpp @@ -1,22 +1,22 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "button.h" @@ -29,7 +29,7 @@ #include "../localplayer.h" -#include "../utils/gettext.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" EmoteWindow::EmoteWindow(): diff --git a/src/gui/emotewindow.h b/src/gui/emotewindow.h index c642ff6f..8af24a7b 100644 --- a/src/gui/emotewindow.h +++ b/src/gui/emotewindow.h @@ -1,22 +1,22 @@ /* - * Aethyra - * Copyright 2009 Aethyra Development Team + * Extended support for activating emotes + * Copyright (C) 2009 Aethyra Development Team * - * This file is part of Aethyra. + * This file is part of The Mana World. * - * Aethyra is free software; you can redistribute it and/or modify + * This program 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. * - * Aethyra is distributed in the hope that it will be useful, + * This program 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 Aethyra; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef EMOTEWINDOW_H diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index e553fbe7..a2be6b00 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -125,7 +125,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) graphics->drawText(toString(item->getQuantity()), mEquipBox[i].posX + (BOX_WIDTH / 2), mEquipBox[i].posY - getFont()->getHeight(), - gcn::Graphics::CENTER); + gcn::Graphics::CENTER); } } diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 4ae3300f..c491062a 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -1,26 +1,26 @@ /* * The Mana World - * Copyright 2004 The Mana World Development Team + * Copyright (C) 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 + * This program 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, + * This program 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 + * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef EQUIPMENT_WINDOW_H -#define EQUIPMENT_WINDOW_H +#ifndef EQUIPMENTWINDOW_H +#define EQUIPMENTWINDOW_H #include <guichan/actionlistener.hpp> diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 70b3efb5..b9fe1c90 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -57,11 +57,11 @@ InventoryWindow::InventoryWindow(int invSize): // If you adjust these defaults, don't forget to adjust the trade window's. setDefaultSize(115, 25, 375, 300); - std::string longestUseString = getFont()->getWidth(_("Equip")) > + std::string longestUseString = getFont()->getWidth(_("Equip")) > getFont()->getWidth(_("Use")) ? _("Equip") : _("Use"); - if (getFont()->getWidth(longestUseString) < + if (getFont()->getWidth(longestUseString) < getFont()->getWidth(_("Unequip"))) { longestUseString = _("Unequip"); @@ -150,7 +150,7 @@ void InventoryWindow::logic() // Adjust progress bars mSlotsBar->setProgress((float) player_node->getInventory()->getNumberOfSlotsUsed() / mMaxSlots); - mWeightBar->setProgress((float) player_node->mTotalWeight / + mWeightBar->setProgress((float) player_node->mTotalWeight / player_node->mMaxWeight); mSlotsBar->setText(strprintf("%s/%d", mUsedSlots.c_str(), mMaxSlots)); diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 5693d001..0beb5cfb 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <SDL_mouse.h> +#include "itemcontainer.h" + +#include "itempopup.h" #include <guichan/mouseinput.hpp> #include <guichan/selectionlistener.hpp> -#include "itemcontainer.h" -#include "itempopup.h" +#include <SDL_mouse.h> #include "../graphics.h" #include "../inventory.h" @@ -124,7 +125,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) // Draw item caption graphics->setFont(getFont()); - graphics->setColor(0x000000); + graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawText( (item->isEquipped() ? "Eq." : toString(item->getQuantity())), itemX + gridWidth / 2, @@ -171,7 +172,6 @@ void ItemContainer::refindSelectedItem() { if (mSelectedItemIndex != NO_ITEM) { - if (mInventory->getItem(mSelectedItemIndex) && mInventory->getItem(mSelectedItemIndex)->getId() == mLastSelectedItemId) return; // we're already fine @@ -204,6 +204,7 @@ void ItemContainer::setSelectedItemIndex(int index) newSelectedItemIndex = NO_ITEM; else newSelectedItemIndex = index; + if (mSelectedItemIndex != newSelectedItemIndex) { mSelectedItemIndex = newSelectedItemIndex; diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index f027de19..71fcc5d0 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -42,7 +42,7 @@ namespace gcn { * * \ingroup GUI */ -class ItemContainer : public gcn::Widget, +class ItemContainer : public gcn::Widget, public gcn::MouseListener, public gcn::WidgetListener { @@ -118,17 +118,17 @@ class ItemContainer : public gcn::Widget, /** * Find the current item index by the most recently used item ID */ - void refindSelectedItem(void); + void refindSelectedItem(); /** * Determine and set the height of the container. */ - void recalculateHeight(void); + void recalculateHeight(); /** * Sends out selection events to the list of selection listeners. */ - void distributeValueChangedEvent(void); + void distributeValueChangedEvent(); /** * Gets the slot index based on the cursor position. diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index b7e015a4..df7afa48 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -136,12 +136,12 @@ void ItemPopup::setItem(const ItemInfo &item) mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsWeight * getFont()->getHeight())); - if(item.getEffect() == "") + if (item.getEffect() == "") { setContentSize(minWidth, (numRowsDesc * getFont()->getHeight() + (3 * getFont()->getHeight()))); - mItemWeightScroll->setPosition(2, + mItemWeightScroll->setPosition(2, (numRowsDesc * getFont()->getHeight()) + (2 * getFont()->getHeight())); } @@ -151,7 +151,7 @@ void ItemPopup::setItem(const ItemInfo &item) (numRowsEffect * getFont()->getHeight()) + (3 * getFont()->getHeight())); - mItemWeightScroll->setPosition(2, + mItemWeightScroll->setPosition(2, (numRowsDesc * getFont()->getHeight()) + (numRowsEffect * getFont()->getHeight()) + (2 * getFont()->getHeight())); @@ -205,9 +205,9 @@ unsigned int ItemPopup::getNumRows() void ItemPopup::view(int x, int y) { if (windowContainer->getWidth() < (x + getWidth() + 5)) - x = windowContainer->getWidth() - getWidth(); + x = windowContainer->getWidth() - getWidth(); if ((y - getHeight() - 10) < 0) - y = 0; + y = 0; else y = y - getHeight() - 10; setPosition(x, y); diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 95ab6ffa..c820e3a0 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -5,23 +5,23 @@ * * This file is part of The Mana World. * - * The Mana World is free software; you can redistribute it and/or modify + * This program 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, + * This program 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 + * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef ITEMPOPUP_H__ -#define ITEMPOPUP_H__ +#ifndef ITEMPOPUP_H +#define ITEMPOPUP_H #include "window.h" @@ -51,4 +51,4 @@ class ItemPopup : public Window gcn::Color getColor(const std::string& type); }; -#endif // ITEMPOPUP_H__ +#endif // ITEMPOPUP_H diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index d3cc2c22..42e3b853 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -81,6 +81,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) { Graphics *g = static_cast<Graphics*>(graphics); + graphics->setColor(gcn::Color(0, 0, 0)); graphics->setFont(getFont()); for (int i = 0; i < mMaxItems; i++) diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 3c8e7cb3..e22ee2ad 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -54,9 +54,8 @@ LoginDialog::LoginDialog(LoginData *loginData): gcn::Label *portLabel = new gcn::Label(_("Port:")); gcn::Label *dropdownLabel = new gcn::Label(_("Recent:")); std::vector<std::string> dfltServer; - dfltServer.push_back("www.aethyra.org"); - dfltServer.push_back("www.aethyra.org"); - dfltServer.push_back("209.168.213.109"); + dfltServer.push_back("server.themanaworld.org"); + dfltServer.push_back("server.themanaworld.org"); std::vector<std::string> dfltPort; dfltPort.push_back("21001"); dfltPort.push_back("22001"); @@ -75,7 +74,7 @@ LoginDialog::LoginDialog(LoginData *loginData): mServerListBox); mServerDropDown->setOpaque(false); - mKeepCheck = new CheckBox(_("Keep"), mLoginData->remember); + mKeepCheck = new CheckBox(_("Remember Username"), mLoginData->remember); mOkButton = new Button(_("OK"), "ok", this); mCancelButton = new Button(_("Cancel"), "cancel", this); mRegisterButton = new Button(_("Register"), "register", this); diff --git a/src/gui/login.h b/src/gui/login.h index 023d60aa..c0d6e755 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -73,29 +73,29 @@ class LoginDialog : public Window, public gcn::ActionListener, */ bool canSubmit(); - /** - * Function to decide whether string is an unsigned short or not - * - * @param str the string to parse - * - * @return true is str is an unsigned short, false otherwise - */ - static bool isUShort(const std::string &str); - - /** - * Converts string to an unsigned short (undefined if invalid) - * - * @param str the string to parse - * - * @return the value str represents - */ - static unsigned short getUShort(const std::string &str); + /** + * Function to decide whether string is an unsigned short or not + * + * @param str the string to parse + * + * @return true is str is an unsigned short, false otherwise + */ + static bool isUShort(const std::string &str); + + /** + * Converts string to an unsigned short (undefined if invalid) + * + * @param str the string to parse + * + * @return the value str represents + */ + static unsigned short getUShort(const std::string &str); DropDown *mServerDropDown; gcn::TextField *mUserField; gcn::TextField *mPassField; gcn::TextField *mServerField; - gcn::TextField *mPortField; + gcn::TextField *mPortField; gcn::CheckBox *mKeepCheck; gcn::Button *mOkButton; gcn::Button *mCancelButton; @@ -111,26 +111,25 @@ class LoginDialog : public Window, public gcn::ActionListener, { private: std::vector<std::string> mServers; - std::vector<std::string> mPorts; + std::vector<std::string> mPorts; std::string mConfigPrefix; int mMaxEntries; void saveEntry(const std::string &server, - const std::string &port, int &saved); + const std::string &port, int &saved); public: DropDownList(std::string prefix, std::vector<std::string> dfltServer, - std::vector<std::string> dfltPort, + std::vector<std::string> dfltPort, int maxEntries); void save(const std::string &server, const std::string &port); int getNumberOfElements(); std::string getElementAt(int i); - std::string getServerAt(int i); - std::string getPortAt(int i); + std::string getServerAt(int i); + std::string getPortAt(int i); }; DropDownList *mServerList; gcn::ListBox *mServerListBox; gcn::ScrollArea *mServerScrollArea; - }; #endif diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 37505305..55cd8b5d 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -68,9 +68,9 @@ void Minimap::setMapImage(Image *img) const int offsetX = 2 * getPadding(); const int offsetY = getTitleBarHeight() + getPadding(); const int titleWidth = getFont()->getWidth(getCaption()) + 15; - const int mapWidth = mMapImage->getWidth() < 100 ? + const int mapWidth = mMapImage->getWidth() < 100 ? mMapImage->getWidth() + offsetX : 100; - const int mapHeight = mMapImage->getHeight() < 100 ? + const int mapHeight = mMapImage->getHeight() < 100 ? mMapImage->getHeight() + offsetY : 100; setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth); diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 4c22e63d..7058d572 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -23,6 +23,7 @@ #include "ministatus.h" #include "progressbar.h" +#include "../animatedsprite.h" #include "../configuration.h" #include "../graphics.h" #include "../localplayer.h" @@ -55,6 +56,24 @@ MiniStatusWindow::MiniStatusWindow(): loadWindowState(); } +void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) +{ + if (index >= (int) mIcons.size()) + mIcons.resize(index + 1, NULL); + + if (mIcons[index]) + delete mIcons[index]; + + mIcons[index] = sprite; +} + +void MiniStatusWindow::eraseIcon(int index) +{ + mIcons.erase(mIcons.begin() + index); +} + +extern volatile int tick_time; + void MiniStatusWindow::update() { // HP Bar coloration @@ -91,7 +110,7 @@ void MiniStatusWindow::update() // Displays the number of monsters to next lvl // (disabled for now but interesting idea) /* - if(config.getValue("xpBarMonsterCounterExp", 0)!=0) + if (config.getValue("xpBarMonsterCounterExp", 0)!=0) { updatedText << " | " << (int)(((float)player_node->mXpForNextLevel - (float)player_node->mXp) @@ -102,6 +121,11 @@ void MiniStatusWindow::update() */ mXpBar->setText(updatedText.str()); + + for (unsigned int i = 0; i < mIcons.size(); i++) + if (mIcons[i]) + mIcons[i]->update(tick_time * 10); + } void MiniStatusWindow::draw(gcn::Graphics *graphics) @@ -109,3 +133,15 @@ void MiniStatusWindow::draw(gcn::Graphics *graphics) update(); drawChildren(graphics); } + +void MiniStatusWindow::drawIcons(Graphics *graphics) +{ + // Draw icons + int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4; + for (unsigned int i = 0; i < mIcons.size(); i++) { + if (mIcons[i]) { + mIcons[i]->draw(graphics, icon_x, 3); + icon_x += 2 + mIcons[i]->getWidth(); + } + } +} diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index 832475f1..f262a2a0 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -24,6 +24,9 @@ #include "window.h" +#include <vector> + +class AnimatedSprite; class ProgressBar; /** @@ -44,6 +47,15 @@ class MiniStatusWindow : public Window */ void draw(gcn::Graphics *graphics); + /** + * Sets one of the icons. + */ + void setIcon(int index, AnimatedSprite *sprite); + + void eraseIcon(int index); + + void drawIcons(Graphics *graphics); + private: /** * Updates this dialog with values from player_node. @@ -56,6 +68,8 @@ class MiniStatusWindow : public Window ProgressBar *mHpBar; ProgressBar *mMpBar; ProgressBar *mXpBar; + + std::vector<AnimatedSprite *> mIcons; }; #endif diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index 0d1f658f..2c67e71f 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -52,7 +52,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, // 15 == height of each line of text (based on font heights) // 14 == row top + bottom graphic pixel heights setContentSize(mTextBox->getMinWidth() + 15, 15 + (numRows * 15) + okButton->getHeight()); - mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, + mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, 3 + (numRows * 14))); } else diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h index 89293b05..42f8d187 100644 --- a/src/gui/passwordfield.h +++ b/src/gui/passwordfield.h @@ -31,7 +31,7 @@ * * \ingroup GUI */ -class PasswordField : public TextField +class PasswordField : public TextField { public: /** diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 6c0e6ad6..be5252f7 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -29,6 +29,7 @@ #include "windowcontainer.h" #include "../being.h" +#include "../beingmanager.h" #include "../floor_item.h" #include "../item.h" #include "../localplayer.h" @@ -47,7 +48,7 @@ extern std::string tradePartnerName; PopupMenu::PopupMenu(): Window(), - mBeing(NULL), + mBeingId(0), mFloorItem(NULL), mItem(NULL) { @@ -65,57 +66,57 @@ PopupMenu::PopupMenu(): void PopupMenu::showPopup(int x, int y, Being *being) { - mBeing = being; + mBeingId = being->getId(); mBrowserBox->clearRows(); - switch (mBeing->getType()) + switch (being->getType()) { - case Being::PLAYER: - { - // Players can be traded with. Later also attack, follow and - // add as buddy will be options in this menu. - const std::string &name = mBeing->getName(); - mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); - mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); - - mBrowserBox->addRow("##3---"); - - switch (player_relations.getRelation(name)) { - case PlayerRelation::NEUTRAL: - mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str())); - - case PlayerRelation::FRIEND: - mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str())); - mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str())); - break; - - case PlayerRelation::DISREGARDED: - mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); - mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str())); - break; - - case PlayerRelation::IGNORED: - mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); - break; - } - - //mBrowserBox->addRow(_("@@follow|Follow ") + name + "@@"); - //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@"); - - mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf(_("@@party-invite|Invite %s to party@@"), name.c_str())); - } - break; - - case Being::NPC: - // NPCs can be talked to (single option, candidate for removal - // unless more options would be added) - mBrowserBox->addRow(_("@@talk|Talk To NPC@@")); - break; - - default: - /* Other beings aren't interesting... */ - break; + case Being::PLAYER: + { + // Players can be traded with. Later also attack, follow and + // add as buddy will be options in this menu. + const std::string &name = being->getName(); + mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); + + mBrowserBox->addRow("##3---"); + + switch (player_relations.getRelation(name)) { + case PlayerRelation::NEUTRAL: + mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str())); + + case PlayerRelation::FRIEND: + mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str())); + break; + + case PlayerRelation::DISREGARDED: + mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str())); + break; + + case PlayerRelation::IGNORED: + mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); + break; + } + + //mBrowserBox->addRow(_("@@follow|Follow ") + name + "@@"); + //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@"); + + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow(strprintf(_("@@party-invite|Invite %s to party@@"), name.c_str())); + } + break; + + case Being::NPC: + // NPCs can be talked to (single option, candidate for removal + // unless more options would be added) + mBrowserBox->addRow(_("@@talk|Talk To NPC@@")); + break; + + default: + /* Other beings aren't interesting... */ + break; } //browserBox->addRow("@@look|Look To@@"); @@ -143,58 +144,60 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) void PopupMenu::handleLink(const std::string& link) { + Being *being = beingManager->findBeing(mBeingId); + // Talk To action if (link == "talk" && - mBeing != NULL && - mBeing->getType() == Being::NPC && - current_npc == 0) + being != NULL && + being->getType() == Being::NPC && + current_npc == 0) { - dynamic_cast<NPC*>(mBeing)->talk(); + dynamic_cast<NPC*>(being)->talk(); } // Trade action else if (link == "trade" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_node->trade(mBeing); - tradePartnerName = mBeing->getName(); + player_node->trade(being); + tradePartnerName = being->getName(); } // Attack action else if (link == "attack" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_node->attack(mBeing, true); + player_node->attack(being, true); } else if (link == "unignore" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::NEUTRAL); + player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL); } else if (link == "ignore" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::IGNORED); + player_relations.setRelation(being->getName(), PlayerRelation::IGNORED); } else if (link == "disregard" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::DISREGARDED); + player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED); } else if (link == "friend" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::FRIEND); + player_relations.setRelation(being->getName(), PlayerRelation::FRIEND); } /* @@ -205,18 +208,18 @@ void PopupMenu::handleLink(const std::string& link) /* // Add Buddy action - else if ((link == "buddy") && mBeing != NULL && mBeing->isPlayer()) + else if ((link == "buddy") && being != NULL && being->isPlayer()) { - if (!buddyWindow->isVisible()) - buddyWindow->setVisible(true); + if (!buddyWindow->isVisible()) + buddyWindow->setVisible(true); - buddyWindow->addBuddy(mBeing->getName()); + buddyWindow->addBuddy(being->getName()); }*/ // Pick Up Floor Item action else if ((link == "pickup") && mFloorItem != NULL) { - player_node->pickUp(mFloorItem); + player_node->pickUp(mFloorItem); } // Look To action @@ -226,51 +229,51 @@ void PopupMenu::handleLink(const std::string& link) else if (link == "use") { - assert(mItem); - if (mItem->isEquipment()) - { - if (mItem->isEquipped()) - { - player_node->unequipItem(mItem); - } - else - { - player_node->equipItem(mItem); - } - } - else - { - player_node->useItem(mItem); - } + assert(mItem); + if (mItem->isEquipment()) + { + if (mItem->isEquipped()) + { + player_node->unequipItem(mItem); + } + else + { + player_node->equipItem(mItem); + } + } + else + { + player_node->useItem(mItem); + } } else if (link == "chat") { - chatWindow->addItemText(mItem->getInfo().getName()); + chatWindow->addItemText(mItem->getInfo().getName()); } else if (link == "drop") { - new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem); + new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem); } else if (link == "party-invite" && - mBeing != NULL && - mBeing->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - MessageOut outMsg(player_node->getNetwork()); - outMsg.writeInt16(CMSG_PARTY_INVITE); - outMsg.writeInt32(mBeing->getId()); + MessageOut outMsg(player_node->getNetwork()); + outMsg.writeInt16(CMSG_PARTY_INVITE); + outMsg.writeInt32(being->getId()); } // Unknown actions else { - std::cout << link << std::endl; + std::cout << link << std::endl; } setVisible(false); - mBeing = NULL; + mBeingId = 0; mFloorItem = NULL; mItem = NULL; } @@ -303,9 +306,9 @@ void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); if (windowContainer->getWidth() < (x + getWidth() + 5)) - x = windowContainer->getWidth() - getWidth(); + x = windowContainer->getWidth() - getWidth(); if (windowContainer->getHeight() < (y + getHeight() + 5)) - y = windowContainer->getHeight() - getHeight(); + y = windowContainer->getHeight() - getHeight(); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 715a9bb5..2694abd8 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -22,6 +22,8 @@ #ifndef POPUP_MENU_H #define POPUP_MENU_H +#include <SDL.h> // for Uint32 + #include "linkhandler.h" #include "window.h" @@ -66,7 +68,7 @@ class PopupMenu : public Window, public LinkHandler private: BrowserBox* mBrowserBox; - Being* mBeing; + Uint32 mBeingId; FloorItem* mFloorItem; Item *mItem; diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 707f08ab..0bbab012 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -1,8 +1,8 @@ /* - * Aethyra - * Copyright (C) 2008 Aethyra Development Team + * A chat recorder + * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net> * - * This file is part of Aethyra. + * This file is part of The Mana World. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,4 +72,5 @@ class Recorder : public Window, public gcn::ActionListener std::ofstream mStream; }; + #endif diff --git a/src/gui/register.cpp b/src/gui/register.cpp index cbf87e5b..cf12375c 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -251,21 +251,21 @@ bool RegisterDialog::isUShort(const std::string &str) { if (str == "") { - return false; + return false; } unsigned long l = 0; for (std::string::const_iterator strPtr = str.begin(), strEnd = str.end(); - strPtr != strEnd; ++strPtr) + strPtr != strEnd; ++strPtr) { - if (*strPtr < '0' || *strPtr > '9') + if (*strPtr < '0' || *strPtr > '9') { - return false; - } - l = l * 10 + (*strPtr - '0'); // *strPtr - '0' will never be negative - if (l > 65535) - { - return false; - } + return false; + } + l = l * 10 + (*strPtr - '0'); // *strPtr - '0' will never be negative + if (l > 65535) + { + return false; + } } return true; } @@ -274,9 +274,9 @@ unsigned short RegisterDialog::getUShort(const std::string &str) { unsigned long l = 0; for (std::string::const_iterator strPtr = str.begin(), strEnd = str.end(); - strPtr != strEnd; ++strPtr) + strPtr != strEnd; ++strPtr) { - l = l * 10 + (*strPtr - '0'); + l = l * 10 + (*strPtr - '0'); } return static_cast<unsigned short>(l); } diff --git a/src/gui/register.h b/src/gui/register.h index e58ac9db..9588e07e 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -72,29 +72,29 @@ class RegisterDialog : public Window, public gcn::ActionListener, */ bool canSubmit() const; - /** - * Function to decide whether string is an unsigned short or not - * - * @param str the string to parse - * - * @return true if str is an unsigned short, false otherwise - */ - static bool isUShort(const std::string &str); - - /** - * Converts string to an unsigned short (undefined if invalid) - * - * @param str the string to parse - * - * @return the value str represents - */ - static unsigned short getUShort(const std::string &str); + /** + * Function to decide whether string is an unsigned short or not + * + * @param str the string to parse + * + * @return true if str is an unsigned short, false otherwise + */ + static bool isUShort(const std::string &str); + + /** + * Converts string to an unsigned short (undefined if invalid) + * + * @param str the string to parse + * + * @return the value str represents + */ + static unsigned short getUShort(const std::string &str); gcn::TextField *mUserField; gcn::TextField *mPasswordField; gcn::TextField *mConfirmField; gcn::TextField *mServerField; - gcn::TextField *mPortField; + gcn::TextField *mPortField; gcn::Button *mRegisterButton; gcn::Button *mCancelButton; diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 09f7c5e7..eacc4714 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -110,9 +110,9 @@ void ScrollArea::init() int vsgridy[4] = {0, 4, 15, 19}; a = 0; - for (y = 0; y < 3; y++) + for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (x = 0; x < 3; x++) { vMarker.grid[a] = vscroll->getSubImage( vsgridx[x], vsgridy[y], @@ -214,7 +214,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics) int w = getWidth() + bs * 2; int h = getHeight() + bs * 2; - if (mOpaque) + if (mOpaque) { static_cast<Graphics*>(graphics)-> drawImageRect(0, 0, w, h, background); @@ -225,11 +225,11 @@ void ScrollArea::setOpaque(bool opaque) { mOpaque = opaque; - if (mOpaque) + if (mOpaque) { setFrameSize(2); } - else + else { setFrameSize(0); } @@ -240,7 +240,7 @@ void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir) int state = 0; gcn::Rectangle dim; - switch(dir) + switch (dir) { case UP: state = mUpButtonPressed ? 1 : 0; diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index f68dc9c8..51442798 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -228,7 +228,7 @@ int SDLInput::convertMouseButton(int button) int SDLInput::convertKeyCharacter(SDL_Event event) { SDL_keysym keysym = event.key.keysym; - + int value = keysym.unicode; switch (keysym.sym) diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index acc28b1f..49e08aeb 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -1,23 +1,23 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program is distributed with The Mana Experiment * - * 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +/* + * Configurable text colors + * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include <string> diff --git a/src/gui/setup_colours.h b/src/gui/setup_colours.h index f56daa60..57d9e304 100644 --- a/src/gui/setup_colours.h +++ b/src/gui/setup_colours.h @@ -1,26 +1,26 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program is distributed with The Mana Experiment * - * 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +/* + * Configurable text colors + * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef _SETUP_COLOURS_H -#define _SETUP_COLOURS_H +#ifndef SETUP_COLOURS_H +#define SETUP_COLOURS_H #include <string> diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index 06a5a520..5d7519ef 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -1,6 +1,7 @@ /* - * The Mana World - * Copyright (C) 2007 The Mana World Development Team + * Custom keyboard shortcuts configuration + * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au> + * Copyright (C) 2009 The Mana World Development Team * * This file is part of The Mana World. * diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h index 082fa84d..dee12135 100644 --- a/src/gui/setup_keyboard.h +++ b/src/gui/setup_keyboard.h @@ -1,6 +1,6 @@ /* - * The Mana World - * Copyright (C) 2007 The Mana World Development Team + * Custom keyboard shortcuts configuration + * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au> * * This file is part of The Mana World. * diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 7e76055a..5c19bd2b 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -67,9 +67,9 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = { class PlayerRelationListModel : public gcn::ListModel { public: - virtual ~PlayerRelationListModel(void) { } + virtual ~PlayerRelationListModel() { } - virtual int getNumberOfElements(void) + virtual int getNumberOfElements() { return PlayerRelation::RELATIONS_NR; } @@ -85,30 +85,30 @@ public: class PlayerTableModel : public TableModel { public: - PlayerTableModel(void) : + PlayerTableModel() : mPlayers(NULL) { playerRelationsUpdated(); } - virtual ~PlayerTableModel(void) + virtual ~PlayerTableModel() { freeWidgets(); if (mPlayers) delete mPlayers; } - virtual int getRows(void) + virtual int getRows() { return mPlayers->size(); } - virtual int getColumns(void) + virtual int getColumns() { return COLUMNS_NR; } - virtual int getRowHeight(void) + virtual int getRowHeight() { return ROW_HEIGHT; } @@ -121,7 +121,7 @@ public: return RELATION_CHOICE_COLUMN_WIDTH; } - virtual void playerRelationsUpdated(void) + virtual void playerRelationsUpdated() { signalBeforeUpdate(); @@ -164,7 +164,7 @@ public: return mWidgets[WIDGET_AT(row, column)]; } - virtual void freeWidgets(void) + virtual void freeWidgets() { if (mPlayers) delete mPlayers; @@ -193,9 +193,9 @@ protected: class IgnoreChoicesListModel : public gcn::ListModel { public: - virtual ~IgnoreChoicesListModel(void) { } + virtual ~IgnoreChoicesListModel() { } - virtual int getNumberOfElements(void) + virtual int getNumberOfElements() { return player_relations.getPlayerIgnoreStrategies()->size(); } @@ -292,7 +292,7 @@ Setup_Players::Setup_Players(): setDimension(gcn::Rectangle(0, 0, 290, 250)); } -Setup_Players::~Setup_Players(void) +Setup_Players::~Setup_Players() { player_relations.removeListener(this); } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 1775665f..b1d33b09 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -289,7 +289,7 @@ void Setup_Video::apply() * See http://libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode */ -#ifdef WIN32 +#if defined(WIN32) || defined(__APPLE__) // checks for opengl usage if (!(config.getValue("opengl", false) == 1)) { @@ -307,7 +307,7 @@ void Setup_Video::apply() logger->error(error.str()); } } -#ifdef WIN32 +#if defined(WIN32) || defined(__APPLE__) } else { new OkDialog(_("Switching to full screen"), _("Restart needed for changes to take effect.")); diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp index eae24785..4472818e 100644 --- a/src/gui/shortcutcontainer.cpp +++ b/src/gui/shortcutcontainer.cpp @@ -38,7 +38,7 @@ ShortcutContainer::ShortcutContainer(): void ShortcutContainer::widgetResized(const gcn::Event &event) { mGridWidth = getWidth() / mBoxWidth; - if (mGridWidth < 1) + if (mGridWidth < 1) { mGridWidth = 1; } @@ -47,7 +47,7 @@ void ShortcutContainer::widgetResized(const gcn::Event &event) (mMaxItems % mGridWidth > 0 ? 1 : 0)) * mBoxHeight); mGridHeight = getHeight() / mBoxHeight; - if (mGridHeight < 1) + if (mGridHeight < 1) { mGridHeight = 1; } @@ -57,7 +57,7 @@ int ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const { const gcn::Rectangle tRect = gcn::Rectangle( 0, 0, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); - if (!tRect.isPointInRect(pointX, pointY)) + if (!tRect.isPointInRect(pointX, pointY)) { return -1; } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index dd7c3a4e..c4f8737b 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -47,7 +47,7 @@ struct SkillInfo { std::vector<SkillInfo> skill_db; -static void initSkillinfo(void); +static void initSkillinfo(); class SkillGuiTableModel : public StaticTableModel { @@ -73,14 +73,17 @@ public: return 35; } - virtual int getRowHeight(void) + virtual int getRowHeight() { return 12; } - virtual void update(void) + virtual void update() { - static const SkillInfo fakeSkillInfo = { _("???"), false }; + static const SkillInfo fakeSkillInfo = { + _("Mystery Skill"), + false + }; mEntriesNr = mDialog->getSkills().size(); resize(); @@ -112,7 +115,6 @@ public: } } - private: SkillDialog *mDialog; int mEntriesNr; @@ -246,11 +248,11 @@ void SkillDialog::setSkill(int id, int lvl, int mp) void SkillDialog::cleanList() { - for_each(mSkillList.begin(), mSkillList.end(), make_dtor(mSkillList)); + delete_all(mSkillList); mSkillList.clear(); } -static void initSkillinfo(void) +static void initSkillinfo() { SkillInfo emptySkillInfo = { "", false }; diff --git a/src/gui/skill.h b/src/gui/skill.h index 91c2b640..0600d106 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -65,7 +65,7 @@ class SkillDialog : public Window, public gcn::ActionListener void setSkill(int id, int lv, int sp); void cleanList(); - const std::vector<SKILL*>& getSkills(void) const { return mSkillList; } + const std::vector<SKILL*>& getSkills() const { return mSkillList; } private: GuiTable *mTable; diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index f8c69e87..c76558e4 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -1,22 +1,21 @@ /* - * The Legend of Mazzeroth - * Copyright (C) 2008, The Legend of Mazzeroth Development Team + * Speech bubbles + * Copyright (C) 2008 The Legend of Mazzeroth Development Team * - * This file is part of The Legend of Mazzeroth based on original code - * from The Mana World. + * This file is part of The Mana World. * - * The Legend of Mazzeroth is free software; you can redistribute it and/or modify + * This program 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 Legend of Mazzeroth is distributed in the hope that it will be useful, + * This program 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 Legend of Mazzeroth; if not, write to the Free Software + * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 7f5818af..d2d81332 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -1,27 +1,26 @@ /* - * The Legend of Mazzeroth - * Copyright (C) 2008, The Legend of Mazzeroth Development Team + * Speech bubbles + * Copyright (C) 2008 The Legend of Mazzeroth Development Team * - * This file is part of The Legend of Mazzeroth based on original code - * from The Mana World. + * This file is part of The Mana World. * - * The Legend of Mazzeroth is free software; you can redistribute it and/or modify + * This program 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 Legend of Mazzeroth is distributed in the hope that it will be useful, + * This program 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 Legend of Mazzeroth; if not, write to the Free Software + * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SPEECHBUBBLE_H__ -#define SPEECHBUBBLE_H__ +#ifndef SPEECHBUBBLE_H +#define SPEECHBUBBLE_H #include "window.h" @@ -31,20 +30,19 @@ class TextBox; class SpeechBubble : public Window { public: - - SpeechBubble(); - ~SpeechBubble(); + SpeechBubble(); + ~SpeechBubble(); void setCaption(const std::string &name, const gcn::Color &color = 0x000000); - void setText(std::string mText); - void setLocation(int x, int y); - unsigned int getNumRows(); + void setText(std::string mText); + void setLocation(int x, int y); + unsigned int getNumRows(); private: gcn::Label *mCaption; - TextBox *mSpeechBox; - ScrollArea *mSpeechArea; + TextBox *mSpeechBox; + ScrollArea *mSpeechArea; }; #endif diff --git a/src/gui/status.cpp b/src/gui/status.cpp index e0e43b36..21087fad 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -78,8 +78,11 @@ StatusWindow::StatusWindow(LocalPlayer *player): mStatsDefenseLabel= new gcn::Label(_("Defense:")); mStatsMagicAttackLabel = new gcn::Label(_("M.Attack:")); mStatsMagicDefenseLabel = new gcn::Label(_("M.Defense:")); + // Gettext flag for next line: xgettext:no-c-format mStatsAccuracyLabel = new gcn::Label(_("% Accuracy:")); + // Gettext flag for next line: xgettext:no-c-format mStatsEvadeLabel = new gcn::Label(_("% Evade:")); + // Gettext flag for next line: xgettext:no-c-format mStatsReflexLabel = new gcn::Label(_("% Reflex:")); mStatsAttackPoints = new gcn::Label; @@ -307,3 +310,4 @@ void StatusWindow::action(const gcn::ActionEvent &event) } } } + diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 674f3891..19039b2d 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -37,7 +37,7 @@ class GuiTableActionListener : public gcn::ActionListener public: GuiTableActionListener(GuiTable *_table, gcn::Widget *_widget, int _row, int _column); - virtual ~GuiTableActionListener(void); + virtual ~GuiTableActionListener(); virtual void action(const gcn::ActionEvent& actionEvent); @@ -62,7 +62,7 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid } } -GuiTableActionListener::~GuiTableActionListener(void) +GuiTableActionListener::~GuiTableActionListener() { if (mWidget) { @@ -96,12 +96,12 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, addKeyListener(this); } -GuiTable::~GuiTable(void) +GuiTable::~GuiTable() { delete mModel; } -TableModel* GuiTable::getModel(void) const +TableModel *GuiTable::getModel() const { return mModel; } @@ -124,7 +124,7 @@ void GuiTable::setModel(TableModel *new_model) } } -void GuiTable::recomputeDimensions(void) +void GuiTable::recomputeDimensions() { int rows_nr = mModel->getRows(); int columns_nr = mModel->getColumns(); @@ -152,12 +152,12 @@ void GuiTable::setSelected(int row, int column) mSelectedRow = row; } -int GuiTable::getSelectedRow(void) +int GuiTable::getSelectedRow() { return mSelectedRow; } -int GuiTable::getSelectedColumn(void) +int GuiTable::getSelectedColumn() { return mSelectedColumn; } @@ -167,7 +167,7 @@ void GuiTable::setLinewiseSelection(bool linewise) mLinewiseMode = linewise; } -int GuiTable::getRowHeight(void) +int GuiTable::getRowHeight() { if (mModel) return mModel->getRowHeight() + 1; // border @@ -242,7 +242,7 @@ void GuiTable::uninstallActionListeners(void) action_listeners.clear(); } -void GuiTable::installActionListeners(void) +void GuiTable::installActionListeners() { if (!mModel) return; @@ -291,7 +291,7 @@ void GuiTable::draw(gcn::Graphics* graphics) int max_rows_nr = mModel->getRows() - first_row; // clip if neccessary: if (max_rows_nr < rows_nr) rows_nr = max_rows_nr; - + // Now determine the first and last column // Take the easy way out; these are usually bounded and all visible. int first_column = 0; @@ -383,7 +383,7 @@ void GuiTable::moveToBottom(gcn::Widget *widget) mTopWidget = NULL; } -gcn::Rectangle GuiTable::getChildrenArea(void) +gcn::Rectangle GuiTable::getChildrenArea() { return gcn::Rectangle(0, 0, getWidth(), getHeight()); } @@ -477,7 +477,7 @@ void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) mouseEvent.consume(); } } - + void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent) { } @@ -497,7 +497,7 @@ void GuiTable::modelUpdated(bool completed) } } -gcn::Widget* GuiTable::getWidgetAt(int x, int y) +gcn::Widget *GuiTable::getWidgetAt(int x, int y) { int row = getRowForY(y); int column = getColumnForX(x); @@ -549,12 +549,13 @@ void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler) { gcn::Widget::_setFocusHandler(focusHandler); - if (mModel) - for (int r = 0; r < mModel->getRows(); ++r) - for (int c = 0; c < mModel->getColumns(); ++c) - { + if (mModel) { + for (int r = 0; r < mModel->getRows(); ++r) { + for (int c = 0; c < mModel->getColumns(); ++c) { gcn::Widget *w = mModel->getElementAt(r, c); if (w) w->_setFocusHandler(focusHandler); } + } + } } diff --git a/src/gui/table.h b/src/gui/table.h index 912eb284..841f6ef2 100644 --- a/src/gui/table.h +++ b/src/gui/table.h @@ -46,17 +46,19 @@ class GuiTable : public gcn::Widget, public gcn::KeyListener, public TableModelListener { - friend class GuiTableActionListener; // so that the action listener can call distributeActionEvent + // so that the action listener can call distributeActionEvent + friend class GuiTableActionListener; + public: GuiTable(TableModel * initial_model = NULL, gcn::Color background = 0xffffff, bool opacity = true); - virtual ~GuiTable(void); + virtual ~GuiTable(); /** * Retrieves the active table model */ - TableModel *getModel(void) const; + TableModel *getModel() const; /** * Sets the table model @@ -72,9 +74,9 @@ public: void setSelected(int row, int column); - int getSelectedRow(void); + int getSelectedRow(); - int getSelectedColumn(void); + int getSelectedColumn(); void setSelectedRow(int selected); @@ -136,25 +138,25 @@ public: virtual void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); virtual void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); - + virtual void mouseDragged(gcn::MouseEvent& mouseEvent); // Constraints inherited from TableModelListener virtual void modelUpdated(bool); protected: + /** Frees all action listeners on inner widgets. */ + virtual void uninstallActionListeners(); + /** Installs all action listeners on inner widgets. */ + virtual void installActionListeners(); - virtual void uninstallActionListeners(void); // frees all action listeners on inner widgets - virtual void installActionListeners(void); // installs all action listeners on inner widgets - - virtual int getRowHeight(void); + virtual int getRowHeight(); virtual int getColumnWidth(int i); - -private: +private: int getRowForY(int y); // -1 on error int getColumnForX(int x); // -1 on error - void recomputeDimensions(void); + void recomputeDimensions(); bool mLinewiseMode; bool mWrappingEnabled; bool mOpaque; @@ -171,11 +173,14 @@ private: int mSelectedRow; int mSelectedColumn; - int mPopFramesNr; // Number of frames to skip upwards when drawing the selected widget + /** Number of frames to skip upwards when drawing the selected widget. */ + int mPopFramesNr; - gcn::Widget *mTopWidget; // If someone moves a fresh widget to the top, we must display it + /** If someone moves a fresh widget to the top, we must display it. */ + gcn::Widget *mTopWidget; - std::vector<GuiTableActionListener *> action_listeners; // Vector for compactness; used as a list in practice. + /** Vector for compactness; used as a list in practice. */ + std::vector<GuiTableActionListener *> action_listeners; }; diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp index 19e780f3..4fa13bae 100644 --- a/src/gui/table_model.cpp +++ b/src/gui/table_model.cpp @@ -35,13 +35,13 @@ void TableModel::removeListener(TableModelListener *listener) listeners.erase(listener); } -void TableModel::signalBeforeUpdate(void) +void TableModel::signalBeforeUpdate() { for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++) (*it)->modelUpdated(false); } -void TableModel::signalAfterUpdate(void) +void TableModel::signalAfterUpdate() { for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++) (*it)->modelUpdated(true); @@ -60,12 +60,12 @@ StaticTableModel::StaticTableModel(int row, int column) : mWidths.resize(column, 1); } -StaticTableModel::~StaticTableModel(void) +StaticTableModel::~StaticTableModel() { delete_all(mTableModel); } -void StaticTableModel::resize(void) +void StaticTableModel::resize() { mRows = getRows(); mColumns = getColumns(); @@ -97,7 +97,7 @@ void StaticTableModel::set(int row, int column, gcn::Widget *widget) signalAfterUpdate(); } -gcn::Widget* StaticTableModel::getElementAt(int row, int column) +gcn::Widget *StaticTableModel::getElementAt(int row, int column) { return mTableModel[WIDGET_AT(row, column)]; } @@ -119,7 +119,7 @@ void StaticTableModel::fixRowHeight(int height) mHeight = -height; } -int StaticTableModel::getRowHeight(void) +int StaticTableModel::getRowHeight() { return abs(mHeight); } @@ -132,12 +132,12 @@ int StaticTableModel::getColumnWidth(int column) return abs(mWidths[column]); } -int StaticTableModel::getRows(void) +int StaticTableModel::getRows() { return mRows; } -int StaticTableModel::getColumns(void) +int StaticTableModel::getColumns() { return mColumns; } diff --git a/src/gui/table_model.h b/src/gui/table_model.h index 1d966e8b..9ca36120 100644 --- a/src/gui/table_model.h +++ b/src/gui/table_model.h @@ -29,8 +29,9 @@ class TableModelListener { public: /** - * Must be invoked by the TableModel whenever a global change is about to occur or - * has occurred (e.g., when a row or column is being removed or added). + * Must be invoked by the TableModel whenever a global change is about to + * occur or has occurred (e.g., when a row or column is being removed or + * added). * * This method is triggered twice, once before and once after the update. * @@ -45,22 +46,22 @@ public: class TableModel { public: - virtual ~TableModel(void) { } + virtual ~TableModel() { } /** * Determines the number of rows (lines) in the table */ - virtual int getRows(void) = 0; + virtual int getRows() = 0; /** * Determines the number of columns in each row */ - virtual int getColumns(void) = 0; + virtual int getColumns() = 0; /** * Determines the height for each row */ - virtual int getRowHeight(void) = 0; + virtual int getRowHeight() = 0; /** * Determines the width of each individual column @@ -80,12 +81,12 @@ protected: /** * Tells all listeners that the table is about to see an update */ - virtual void signalBeforeUpdate(void); + virtual void signalBeforeUpdate(); /** * Tells all listeners that the table has seen an update */ - virtual void signalAfterUpdate(void); + virtual void signalAfterUpdate(); private: std::set<TableModelListener *> listeners; @@ -96,7 +97,7 @@ class StaticTableModel : public TableModel { public: StaticTableModel(int width, int height); - virtual ~StaticTableModel(void); + virtual ~StaticTableModel(); /** * Inserts a widget into the table model. @@ -106,7 +107,8 @@ public: virtual void set(int row, int column, gcn::Widget *widget); /** - * Fixes the column width for a given column; this overrides dynamic width inference. + * Fixes the column width for a given column; this overrides dynamic width + * inference. * * Semantics are undefined for width 0. */ @@ -122,17 +124,16 @@ public: /** * Resizes the table model */ - virtual void resize(void); + virtual void resize(); - virtual int getRows(void); - virtual int getColumns(void); - virtual int getRowHeight(void); - virtual int getWidth(void); - virtual int getHeight(void); + virtual int getRows(); + virtual int getColumns(); + virtual int getRowHeight(); + virtual int getWidth(); + virtual int getHeight(); virtual int getColumnWidth(int index); virtual gcn::Widget *getElementAt(int row, int column); - protected: int mRows, mColumns; int mHeight; diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index f901be5e..af30d1fe 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -125,7 +125,7 @@ void TradeWindow::addMoney(int amount) void TradeWindow::addItem(int id, bool own, int quantity, bool equipment) { - if (own) + if (own) { mMyItemContainer->setWidth(mMyScroll->getWidth()); mMyInventory->addItem(id, quantity, equipment); @@ -139,7 +139,7 @@ void TradeWindow::addItem(int id, bool own, int quantity, bool equipment) void TradeWindow::removeItem(int id, bool own) { - if (own) + if (own) mMyInventory->removeItem(id); else mPartnerInventory->removeItem(id); diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp index 6e8efeff..66855b77 100644 --- a/src/gui/truetypefont.cpp +++ b/src/gui/truetypefont.cpp @@ -45,8 +45,7 @@ class TextChunk bool operator==(const TextChunk &chunk) const { - return ( - chunk.text == text && chunk.color == color); + return (chunk.text == text && chunk.color == color); } void generate(TTF_Font *font) @@ -81,7 +80,7 @@ typedef std::list<TextChunk>::iterator CacheIterator; static int fontCounter; -TrueTypeFont::TrueTypeFont(const std::string& filename, int size) +TrueTypeFont::TrueTypeFont(const std::string &filename, int size) { if (fontCounter == 0 && TTF_Init() == -1) { @@ -162,7 +161,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, g->drawImage(cache.front().img, x, y); } -int TrueTypeFont::getWidth(const std::string& text) const +int TrueTypeFont::getWidth(const std::string &text) const { int w, h; TTF_SizeUTF8(mFont, text.c_str(), &w, &h); diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h index bd338d84..cd68a94e 100644 --- a/src/gui/truetypefont.h +++ b/src/gui/truetypefont.h @@ -45,7 +45,7 @@ class TrueTypeFont : public gcn::Font * @param filename Font filename. * @param size Font size. */ - TrueTypeFont(const std::string& filename, int size); + TrueTypeFont(const std::string &filename, int size); /** * Destructor. @@ -59,7 +59,9 @@ class TrueTypeFont : public gcn::Font /** * @see Font::drawString */ - void drawString(gcn::Graphics* graphics, const std::string& text, int x, int y); + void drawString(gcn::Graphics *graphics, + const std::string &text, + int x, int y); private: TTF_Font *mFont; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 19e9a4fb..f5a6edb4 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "ministatus.h" #include "popupmenu.h" #include "viewport.h" @@ -74,6 +75,8 @@ void Viewport::setMap(Map *map) mMap = map; } +extern MiniStatusWindow *miniStatusWindow; + void Viewport::draw(gcn::Graphics *gcnGraphics) { static int lastTick = tick_time; @@ -167,7 +170,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) // Find a path from the player to the mouse, and draw it. This is for debug // purposes. - if (mShowDebugPath) + if (mShowDebugPath) { // Get the current mouse position int mouseX, mouseY; @@ -211,6 +214,9 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) (*i)->drawEmotion(graphics, -(int) mPixelViewX, -(int) mPixelViewY); } + if (miniStatusWindow) + miniStatusWindow->drawIcons(graphics); + // Draw contained widgets WindowContainer::draw(gcnGraphics); } @@ -263,7 +269,8 @@ void Viewport::mousePressed(gcn::MouseEvent &event) mPopupMenu->showPopup(event.getX(), event.getY(), being); return; } - else if((floorItem = floorItemManager->findByCoordinates(tilex, tiley))) + else if ((floorItem = floorItemManager->findByCoordinates(tilex, + tiley))) { mPopupMenu->showPopup(event.getX(), event.getY(), floorItem); return; @@ -282,7 +289,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { Being *being; FloorItem *item; - + // Interact with some being // if ((being = beingManager->findBeing(tilex, tiley))) if ((being = beingManager->findBeingByPixel(x, y))) @@ -330,7 +337,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { // Find the being nearest to the clicked position Being *target = beingManager->findBeingByPixel(x, y); - + if (target) { player_node->setTarget(target); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 934bd9b3..797b4be9 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -75,7 +75,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std { logger->log("Window::Window(\"%s\")", caption.c_str()); - if (!windowContainer) + if (!windowContainer) { throw GCN_EXCEPTION("Window::Window(): no windowContainer set"); } @@ -126,7 +126,7 @@ Window::~Window() config.setValue(name + "WinY", getY()); config.setValue(name + "Visible", isVisible()); - if (mGrip) + if (mGrip) { config.setValue(name + "WinWidth", getWidth()); config.setValue(name + "WinHeight", getHeight()); @@ -145,7 +145,7 @@ Window::~Window() instances--; // Clean up static resources - for( int i = 0; i < 9; i++ ) + for (int i = 0; i < 9; i++) { delete border.grid[i]; border.grid[i] = NULL; @@ -525,7 +525,7 @@ int Window::getResizeHandles(gcn::MouseEvent &event) void Window::setGuiAlpha() { //logger->log("Window::setGuiAlpha: Alpha Value %f", config.getValue("guialpha", 0.8)); - for(int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { //logger->log("Window::setGuiAlpha: Border Image (%i)", i); border.grid[i]->setAlpha(config.getValue("guialpha", 0.8)); @@ -534,7 +534,7 @@ void Window::setGuiAlpha() mAlphaChanged = false; } -void Window::loadSkin(const std::string filename) +void Window::loadSkin(const std::string &filename) { const std::string windowId = Window::getId(); @@ -544,7 +544,7 @@ void Window::loadSkin(const std::string filename) logger->log("Loading Window ID '%s'.", windowId.c_str()); - if(filename == "") + if (filename.empty()) logger->error("Window::loadSkin(): Invalid File Name."); // TODO: @@ -562,7 +562,7 @@ void Window::loadSkin(const std::string filename) std::string skinSetImage; skinSetImage = XML::getProperty(rootNode, "image", ""); Image *dBorders = NULL; - if(skinSetImage != "") + if (!skinSetImage.empty()) { logger->log("Window::loadSkin(): <skinset> defines '%s' as a skin image.", skinSetImage.c_str()); dBorders = resman->getImage("graphics/gui/" + skinSetImage);//"graphics/gui/speech_bubble.png"); @@ -596,7 +596,7 @@ void Window::loadSkin(const std::string filename) std::string partType; partType = XML::getProperty(partNode, "type", "unknown"); // TOP ROW - if(partType == "top-left-corner") + if (partType == "top-left-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -605,7 +605,7 @@ void Window::loadSkin(const std::string filename) border.grid[0] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "top-edge") + else if (partType == "top-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -614,7 +614,7 @@ void Window::loadSkin(const std::string filename) border.grid[1] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "top-right-corner") + else if (partType == "top-right-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -625,7 +625,7 @@ void Window::loadSkin(const std::string filename) } // MIDDLE ROW - else if(partType == "left-edge") + else if (partType == "left-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -634,7 +634,7 @@ void Window::loadSkin(const std::string filename) border.grid[3] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "bg-quad") + else if (partType == "bg-quad") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -643,7 +643,7 @@ void Window::loadSkin(const std::string filename) border.grid[4] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "right-edge") + else if (partType == "right-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -654,7 +654,7 @@ void Window::loadSkin(const std::string filename) } // BOTTOM ROW - else if(partType == "bottom-left-corner") + else if (partType == "bottom-left-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -663,7 +663,7 @@ void Window::loadSkin(const std::string filename) border.grid[6] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "bottom-edge") + else if (partType == "bottom-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -672,7 +672,7 @@ void Window::loadSkin(const std::string filename) border.grid[7] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "bottom-right-corner") + else if (partType == "bottom-right-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -728,4 +728,3 @@ void Window::reflowLayout(int w, int h) mLayout = NULL; setContentSize(w, h); } - diff --git a/src/gui/window.h b/src/gui/window.h index 501ad160..518de6e9 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -30,7 +30,6 @@ #include "../guichanfwd.h" class ConfigListener; -class GCContainer; class ContainerPlacer; class Image; class ImageRect; @@ -177,7 +176,7 @@ class Window : public gcn::Window, gcn::WidgetListener * * @return The parent window or <code>NULL</code> if there is none. */ - Window* getParentWindow() { return mParent; } + Window *getParentWindow() { return mParent; } /** * Schedule this window for deletion. It will be deleted at the start @@ -222,7 +221,7 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Returns the name of the window. This is not the window title. */ - const std::string& getWindowName() { return mWindowName; } + const std::string &getWindowName() { return mWindowName; } /** * Reads the position (and the size for resizable windows) in the @@ -264,7 +263,7 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Loads a window skin */ - void loadSkin(const std::string filename); + void loadSkin(const std::string &filename); /** * Adds a widget to the window and sets it at given cell. @@ -300,7 +299,6 @@ class Window : public gcn::Window, gcn::WidgetListener void setGuiAlpha(); - GCContainer *mChrome; /**< Contained container */ ResizeGrip *mGrip; /**< Resize grip */ Window *mParent; /**< The parent window */ Layout *mLayout; /**< Layout handler */ diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index ecf47573..413a8036 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -1,6 +1,6 @@ /* - * The Mana World - * Copyright (C) 2007 The Mana World Development Team + * Custom keyboard shortcuts configuration + * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au> * * This file is part of The Mana World. * @@ -141,10 +141,10 @@ void KeyboardConfig::makeDefault() bool KeyboardConfig::hasConflicts() { int i, j; -/** - * No need to parse the square matrix: only check one triangle - * that's enough to detect conflicts - */ + /** + * No need to parse the square matrix: only check one triangle + * that's enough to detect conflicts + */ for (i = 0; i < KEY_TOTAL; i++) { for (j = i, j++; j < KEY_TOTAL; j++) @@ -172,7 +172,7 @@ int KeyboardConfig::getKeyIndex(int keyValue) const { for (int i = 0; i < KEY_TOTAL; i++) { - if(keyValue == mKey[i].value) + if (keyValue == mKey[i].value) { return i; } @@ -185,7 +185,7 @@ int KeyboardConfig::getKeyEmoteOffset(int keyValue) const { for (int i = KEY_EMOTE_1; i <= KEY_EMOTE_12; i++) { - if(keyValue == mKey[i].value) + if (keyValue == mKey[i].value) { return 1 + i - KEY_EMOTE_1; } diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index bfcde31c..8949a48e 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -1,6 +1,6 @@ /* - * The Mana World - * Copyright (C) 2007 The Mana World Development Team + * Custom keyboard shortcuts configuration + * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au> * * This file is part of The Mana World. * diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 01de3b41..b450c0ba 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -33,9 +33,11 @@ #include "particle.h" #include "simpleanimation.h" #include "sound.h" +#include "statuseffect.h" #include "text.h" #include "gui/gui.h" +#include "gui/ministatus.h" #include "net/messageout.h" #include "net/protocol.h" @@ -72,7 +74,7 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map): mTarget(NULL), mPickUpTarget(NULL), mTrading(false), mGoingToTarget(false), mTargetTime(-1), mLastAction(-1), - mLastTarget(-1), mWalkingDir(0), + mLastTarget(-1), mWalkingDir(0), mDestX(0), mDestY(0), mInventory(new Inventory(INVENTORY_SIZE)), mStorage(new Inventory(STORAGE_SIZE)) @@ -176,7 +178,7 @@ void LocalPlayer::logic() } void LocalPlayer::setGM() -{ +{ mIsGM = !mIsGM; mNameColor = mIsGM ? 0x009000: 0x202020; setName(getName()); @@ -383,10 +385,7 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) void LocalPlayer::setWalkingDir(int dir) { - if (mWalkingDir != dir) - { - mWalkingDir = dir; - } + mWalkingDir = dir; // If we're not already walking, start walking. if (mAction != WALK && dir) @@ -509,7 +508,7 @@ void LocalPlayer::attack(Being *target, bool keep) int dist_y = target->mY - mY; // Must be standing and be within attack range to continue - if ((mAction != STAND) || (mAttackRange < abs(dist_x)) || + if ((mAction != STAND) || (mAttackRange < abs(dist_x)) || (mAttackRange < abs(dist_y))) return; @@ -613,6 +612,48 @@ void LocalPlayer::setGotoTarget(Being *target) setDestination(target->mX, target->mY); } + +extern MiniStatusWindow *miniStatusWindow; + +void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId) +{ + Being::handleStatusEffect(effect, effectId); + + + + if (effect) { + effect->deliverMessage(); + effect->playSFX(); + + AnimatedSprite *sprite = effect->getIcon(); + + if (!sprite) { + // delete sprite, if necessary + for (unsigned int i = 0; i < mStatusEffectIcons.size();) + if (mStatusEffectIcons[i] == effectId) { + mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i); + miniStatusWindow->eraseIcon(i); + } else i++; + } else { + // replace sprite or append + bool found = false; + + for (unsigned int i = 0; i < mStatusEffectIcons.size(); i++) + if (mStatusEffectIcons[i] == effectId) { + miniStatusWindow->setIcon(i, sprite); + found = true; + break; + } + + if (!found) { // add new + int offset = mStatusEffectIcons.size(); + miniStatusWindow->setIcon(offset, sprite); + mStatusEffectIcons.push_back(effectId); + } + } + } +} + void LocalPlayer::initTargetCursor() { // Load target cursors @@ -654,7 +695,7 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, mOutRangeImages[size] = currentImageSet; mTargetCursorOutRange[size] = currentCursor; } - else + else { mInRangeImages[size] = currentImageSet; mTargetCursorInRange[size] = currentCursor; @@ -681,7 +722,7 @@ void LocalPlayer::drawTargetCursor(Graphics *graphics, int scrollX, int scrollY) { mTarget->mTargetCursor = mTargetCursorOutRange[cursorSize]->getCurrentImage(); } - else + else { mTarget->mTargetCursor = mTargetCursorInRange[cursorSize]->getCurrentImage(); } diff --git a/src/localplayer.h b/src/localplayer.h index d6d5ad2e..c128f4a4 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -23,6 +23,7 @@ #define LOCALPLAYER_H #include <memory> +#include <vector> #include "player.h" @@ -242,6 +243,9 @@ class LocalPlayer : public Player const std::auto_ptr<Equipment> mEquipment; protected: + virtual void + handleStatusEffect(StatusEffect *effect, int effectId); + void walk(unsigned char dir); int mXp; /**< Experience points. */ @@ -261,6 +265,8 @@ class LocalPlayer : public Player int mDestX; /**< X coordinate of destination. */ int mDestY; /**< Y coordinate of destination. */ + std::vector<int> mStatusEffectIcons; + Inventory *mInventory; Inventory *mStorage; diff --git a/src/main.cpp b/src/main.cpp index 73e0b0fe..a9206505 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -187,7 +187,7 @@ void setUpdatesDir() if (updateHost.empty()) { updateHost = - config.getValue("updatehost", "http://www.aethyra.org/updates"); + config.getValue("updatehost", "http://updates.themanaworld.org/"); } // Remove any trailing slash at the end of the update host @@ -201,7 +201,7 @@ void setUpdatesDir() { if (pos + 3 < updateHost.length()) { - updates << "updates/" << updateHost.substr(pos + 3) + updates << "updates/" << updateHost.substr(pos + 3) << "/" << loginData.port; updatesDir = updates.str(); } @@ -259,18 +259,18 @@ void setUpdatesDir() */ void init_engine(const Options &options) { - homeDir = std::string(PHYSFS_getUserDir()) + "/.aethyra"; + homeDir = std::string(PHYSFS_getUserDir()) + "/.tmw"; #if defined WIN32 if (!CreateDirectory(homeDir.c_str(), 0) && GetLastError() != ERROR_ALREADY_EXISTS) #elif defined __APPLE__ - // Use Application Directory instead of .aethyra + // Use Application Directory instead of .tmw homeDir = std::string(PHYSFS_getUserDir()) + - "/Library/Application Support/Aethyra"; + "/Library/Application Support/The Mana World"; if ((mkdir(homeDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) && (errno != EEXIST)) #else - // Checking if /home/user/.Aethyra folder exists. + // Checking if /home/user/.tmw folder exists. if ((mkdir(homeDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) && (errno != EEXIST)) #endif @@ -282,12 +282,12 @@ void init_engine(const Options &options) } // Set log file - logger->setLogFile(homeDir + std::string("/aethyra.log")); + logger->setLogFile(homeDir + std::string("/tmw.log")); #ifdef PACKAGE_VERSION - logger->log(_("Starting Aethyra Version %s"), PACKAGE_VERSION); + logger->log(_("Starting The Mana World Version %s"), PACKAGE_VERSION); #else - logger->log(_("Starting Aethyra - Version not defined")); + logger->log(_("Starting The Mana World - Version not defined")); #endif // Initialize SDL @@ -332,12 +332,12 @@ void init_engine(const Options &options) strncat(path, "/data", PATH_MAX - 1); resman->addToSearchPath(path, true); #else - resman->addToSearchPath(AETHYRA_DATADIR "data", true); + resman->addToSearchPath(TMW_DATADIR "data", true); #endif // Fill configuration with defaults logger->log(_("Initializing configuration...")); - config.setValue("host", "www.aethyra.org"); + config.setValue("host", "www.themanaworld.org"); config.setValue("port", 21001); config.setValue("hwaccel", 0); #if (defined __APPLE__ || defined WIN32) && defined USE_OPENGL @@ -352,34 +352,34 @@ void init_engine(const Options &options) config.setValue("sfxVolume", 100); config.setValue("musicVolume", 60); config.setValue("fpslimit", 0); - config.setValue("updatehost", "http://www.aethyra.org/updates"); + config.setValue("updatehost", "http://updates.themanaworld.org"); config.setValue("customcursor", 1); config.setValue("ChatLogLength", 128); // Checking if the configuration file exists... otherwise creates it with // default options ! - FILE *aethyraFile = 0; + FILE *configFile = 0; std::string configPath = options.configPath; if (configPath.empty()) configPath = homeDir + "/config.xml"; - aethyraFile = fopen(configPath.c_str(), "r"); + configFile = fopen(configPath.c_str(), "r"); // If we can't read it, it doesn't exist ! - if (aethyraFile == NULL) { + if (configFile == NULL) { // We reopen the file in write mode and we create it - aethyraFile = fopen(configPath.c_str(), "wt"); + configFile = fopen(configPath.c_str(), "wt"); } - if (aethyraFile == NULL) { + if (configFile == NULL) { std::cout << "Can't create " << configPath << ". " "Using Defaults." << std::endl; } else { - fclose(aethyraFile); + fclose(configFile); config.init(configPath); } - SDL_WM_SetCaption("Aethyra", NULL); + SDL_WM_SetCaption("The Mana World", NULL); #ifdef WIN32 static SDL_SysWMinfo pInfo; SDL_GetWMInfo(&pInfo); @@ -389,7 +389,7 @@ void init_engine(const Options &options) SetClassLong(pInfo.window, GCL_HICON, (LONG) icon); } #else - SDL_Surface *icon = IMG_Load(AETHYRA_DATADIR "data/icons/aethyra.png"); + SDL_Surface *icon = IMG_Load(TMW_DATADIR "data/icons/tmw.png"); if (icon) { SDL_SetAlpha(icon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); @@ -492,7 +492,7 @@ void exit_engine() void printHelp() { std::cout - << _("aethyra") << std::endl << std::endl + << _("tmw") << std::endl << std::endl << _("Options: ") << std::endl << _(" -C --configfile : Configuration file to use") << std::endl << _(" -d --data : Directory to load game data from") << std::endl @@ -509,11 +509,10 @@ void printHelp() void printVersion() { #ifdef PACKAGE_VERSION - std::cout << _("Aethyra version ") << PACKAGE_VERSION << - std::endl; + std::cout << _("The Mana World version ") << PACKAGE_VERSION << std::endl; #else - std::cout << _("Aethyra version ") << - _("(local build?, PACKAGE_VERSION is not defined)") << std::endl; + std::cout << _("The Mana World version ") << + _"(local build?, PACKAGE_VERSION is not defined)") << std::endl; #endif } @@ -737,11 +736,14 @@ int main(int argc, char *argv[]) #if ENABLE_NLS #ifdef WIN32 putenv(("LANG=" + std::string(_nl_locale_name_default())).c_str()); + // mingw doesn't like LOCALEDIR to be defined for some reason + bindtextdomain("tmw", "translations/"); +#else + bindtextdomain("tmw", LOCALEDIR); #endif setlocale(LC_MESSAGES, ""); - bindtextdomain("aethyra", LOCALEDIR); - bind_textdomain_codeset("aethyra", "UTF-8"); - textdomain("aethyra"); + bind_textdomain_codeset("tmw", "UTF-8"); + textdomain("tmw"); #endif // Initialize libxml2 and check for potential ABI mismatches between @@ -796,8 +798,8 @@ int main(int argc, char *argv[]) if (!options.password.empty()) { loginData.password = options.password; } - loginData.hostname = config.getValue("host", "www.aethyra.org"); - loginData.port = (short)config.getValue("port", 21001); + loginData.hostname = config.getValue("host", "server.themanaworld.org"); + loginData.port = (short)config.getValue("port", 6901); loginData.remember = config.getValue("remember", 0); loginData.registerLogin = false; @@ -870,7 +872,7 @@ int main(int argc, char *argv[]) if (graphics->getWidth() > login_wallpaper->getWidth() || graphics->getHeight() > login_wallpaper->getHeight()) { - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(gcn::Color(64, 64, 64)); graphics->fillRectangle(gcn::Rectangle( 0, 0, graphics->getWidth(), graphics->getHeight())); } @@ -958,15 +960,15 @@ int main(int argc, char *argv[]) case CHAR_SERVER_STATE: logger->log("State: CHAR_SERVER"); - if (n_server == 1) + if (n_server == 1) { SERVER_INFO *si = *server_info; loginData.hostname = iptostring(si->address); loginData.port = si->port; loginData.updateHost = si->updateHost; state = UPDATE_STATE; - } - else + } + else { int nextState = (options.skipUpdate) ? LOADDATA_STATE : UPDATE_STATE; @@ -974,7 +976,7 @@ int main(int argc, char *argv[]) nextState); positionDialog(currentDialog, screenWidth, screenHeight); - if (options.chooseDefault || options.playername != "") + if (options.chooseDefault || options.playername != "") { ((ServerSelectDialog*) currentDialog)->action( gcn::ActionEvent(NULL, "ok")); @@ -984,8 +986,8 @@ int main(int argc, char *argv[]) case CHAR_SELECT_STATE: logger->log("State: CHAR_SELECT"); currentDialog = new CharSelectDialog(network, &charInfo, - (loginData.sex == 0) ? - GENDER_FEMALE : GENDER_MALE); + (loginData.sex == 0) ? + GENDER_FEMALE : GENDER_MALE); positionDialog(currentDialog, screenWidth, screenHeight); if (((CharSelectDialog*) currentDialog)-> diff --git a/src/map.cpp b/src/map.cpp index 716e9aee..b6ccad3b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -330,7 +330,7 @@ Tileset* Map::getTilesetWithGid(int gid) const containsGid.gid = gid; Tilesets::const_iterator i = find_if(mTilesets.begin(), mTilesets.end(), - containsGid); + containsGid); return (i == mTilesets.end()) ? NULL : *i; } @@ -339,7 +339,7 @@ void Map::setWalk(int x, int y, bool walkable) { mMetaTiles[x + y * mWidth].walkable = walkable; } - + bool Map::occupied(int x, int y) const { Beings &beings = beingManager->getAll(); @@ -357,7 +357,7 @@ bool Map::occupied(int x, int y) const bool Map::tileCollides(int x, int y) const { - return !(contains(x, y) && mMetaTiles[x + y * mWidth].walkable); + return !(contains(x, y) && mMetaTiles[x + y * mWidth].walkable); } bool Map::contains(int x, int y) const @@ -459,6 +459,13 @@ Path Map::findPath(int startX, int startY, int destX, int destY) // 14 for moving diagonal (sqrt(200) = 14.1421...) int Gcost = curr.tile->Gcost + ((dx == 0 || dy == 0) ? 10 : 14); + // It costs extra to walk through a being (needs to be enough + // to make it more attractive to walk around). + if (occupied(x, y)) + { + Gcost += 30; + } + // Skip if Gcost becomes too much // Warning: probably not entirely accurate if (Gcost > 200) diff --git a/src/monster.cpp b/src/monster.cpp index 33703817..3b1e4c80 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -74,7 +74,7 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): mNameColor = 0xff2020; } -Monster::~Monster() +Monster::~Monster() { if (mText) { @@ -199,7 +199,7 @@ void Monster::showName(bool show) { mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET - getHeight(), - gcn::Graphics::CENTER, gcn::Color(255, 32, 32)); + gcn::Graphics::CENTER, gcn::Color(255, 64, 64)); } else { diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 69f462ec..0db8fcbf 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -59,6 +59,7 @@ BeingHandler::BeingHandler(bool enableSync): SMSG_PLAYER_STOP, SMSG_PLAYER_MOVE_TO_ATTACK, 0x0119, + 0x0196, 0 }; handledMessages = _messages; @@ -69,13 +70,16 @@ void BeingHandler::handleMessage(MessageIn *msg) Uint32 id; Uint16 job, speed; Uint16 headTop, headMid, headBottom; - Uint16 shoes, gloves, cape, misc1, misc2; + Uint16 shoes, gloves; Uint16 weapon, shield; Uint16 gmstatus; Sint16 param1; + int stunMode; + Uint32 statusEffects; Sint8 type; + Uint16 status; Being *srcBeing, *dstBeing; - int hairStyle, hairColor; + int hairStyle, hairColor, flag; switch (msg->getId()) { @@ -84,9 +88,9 @@ void BeingHandler::handleMessage(MessageIn *msg) // Information about a being in range id = msg->readInt32(); speed = msg->readInt16(); - msg->readInt16(); // opt1 - msg->readInt16(); // opt2 - msg->readInt16(); // option + stunMode = msg->readInt16(); // opt1 + statusEffects = msg->readInt16(); // opt2 + statusEffects |= ((Uint32)msg->readInt16()) << 16; // option job = msg->readInt16(); // class dstBeing = beingManager->findBeing(id); @@ -110,6 +114,7 @@ void BeingHandler::handleMessage(MessageIn *msg) dstBeing->setAction(Being::STAND); } + // Prevent division by 0 when calculating frame if (speed == 0) { speed = 150; } @@ -128,14 +133,14 @@ void BeingHandler::handleMessage(MessageIn *msg) headTop = msg->readInt16(); headMid = msg->readInt16(); hairColor = msg->readInt16(); - shoes = msg->readInt16(); - gloves = msg->readInt16(); + shoes = msg->readInt16(); // clothes color - "abused" as shoes + gloves = msg->readInt16(); // head dir - "abused" as gloves msg->readInt16(); // guild msg->readInt16(); // unknown msg->readInt16(); // unknown msg->readInt16(); // manner - msg->readInt16(); // karma - msg->readInt8(); // unknown + dstBeing->setStatusEffectBlock(32, msg->readInt16()); // opt3 + msg->readInt8(); // karma dstBeing->setGender( (msg->readInt8() == 0) ? GENDER_FEMALE : GENDER_MALE); @@ -166,6 +171,10 @@ void BeingHandler::handleMessage(MessageIn *msg) msg->readInt8(); // unknown msg->readInt8(); // unknown msg->readInt8(); // unknown / sit + + dstBeing->setStunMode(stunMode); + dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); + dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); break; case SMSG_BEING_MOVE2: @@ -230,7 +239,7 @@ void BeingHandler::handleMessage(MessageIn *msg) switch (type) { case 0x0a: // Critical Damage - if (dstBeing) + if (dstBeing) dstBeing->showCrit(); case 0x00: // Damage if (dstBeing) @@ -240,7 +249,7 @@ void BeingHandler::handleMessage(MessageIn *msg) break; case 0x02: // Sit - if (srcBeing) + if (srcBeing) { srcBeing->mFrame = 0; srcBeing->setAction(Being::SIT); @@ -248,7 +257,7 @@ void BeingHandler::handleMessage(MessageIn *msg) break; case 0x03: // Stand up - if (srcBeing) + if (srcBeing) { srcBeing->mFrame = 0; srcBeing->setAction(Being::STAND); @@ -371,9 +380,10 @@ void BeingHandler::handleMessage(MessageIn *msg) // An update about a player, potentially including movement. id = msg->readInt32(); speed = msg->readInt16(); - cape = msg->readInt16(); - misc1 = msg->readInt16(); - misc2 = msg->readInt16(); + stunMode = msg->readInt16(); // opt1; Aethyra use this as cape + statusEffects = msg->readInt16(); // opt2; Aethyra use this as misc1 + statusEffects |= ((Uint32) msg->readInt16()) + << 16; // status.options; Aethyra uses this as misc2 job = msg->readInt16(); dstBeing = beingManager->findBeing(id); @@ -398,11 +408,12 @@ void BeingHandler::handleMessage(MessageIn *msg) headTop = msg->readInt16(); headMid = msg->readInt16(); hairColor = msg->readInt16(); - shoes = msg->readInt16(); - gloves = msg->readInt16(); + msg->readInt16(); // clothes color - Aethyra-"abused" as shoes, we ignore it + msg->readInt16(); // head dir - Aethyra-"abused" as gloves, we ignore it msg->readInt32(); // guild - msg->readInt32(); // emblem + msg->readInt16(); // emblem msg->readInt16(); // manner + dstBeing->setStatusEffectBlock(32, msg->readInt16()); // opt3 msg->readInt8(); // karma dstBeing->setGender( (msg->readInt8() == 0) ? GENDER_FEMALE : GENDER_MALE); @@ -413,13 +424,9 @@ void BeingHandler::handleMessage(MessageIn *msg) dstBeing->setSprite(Being::BOTTOMCLOTHES_SPRITE, headBottom); dstBeing->setSprite(Being::TOPCLOTHES_SPRITE, headMid); dstBeing->setSprite(Being::HAT_SPRITE, headTop); - dstBeing->setSprite(Being::SHOE_SPRITE, shoes); - // Compensation for the unpatched TMW server - if (gloves > 10) - dstBeing->setSprite(Being::GLOVES_SPRITE, gloves); - dstBeing->setSprite(Being::CAPE_SPRITE, cape); - dstBeing->setSprite(Being::MISC1_SPRITE, misc1); - dstBeing->setSprite(Being::MISC2_SPRITE, misc2); + //dstBeing->setSprite(Being::CAPE_SPRITE, cape); + //dstBeing->setSprite(Being::MISC1_SPRITE, misc1); + //dstBeing->setSprite(Being::MISC2_SPRITE, misc2); dstBeing->setHairStyle(hairStyle, hairColor); if (msg->getId() == SMSG_PLAYER_MOVE) @@ -446,7 +453,7 @@ void BeingHandler::handleMessage(MessageIn *msg) switch (msg->readInt8()) { case 1: - if (dstBeing->getType() != Being::NPC) + if (dstBeing->getType() != Being::NPC) dstBeing->setAction(Being::DEAD); break; @@ -465,6 +472,10 @@ void BeingHandler::handleMessage(MessageIn *msg) dstBeing->mWalkTime = tick_time; dstBeing->mFrame = 0; + + dstBeing->setStunMode(stunMode); + dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); + dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); break; case SMSG_PLAYER_STOP: @@ -504,11 +515,30 @@ void BeingHandler::handleMessage(MessageIn *msg) break; case 0x0119: - // Change in players look - logger->log("0x0119 %i %i %i %x %i", msg->readInt32(), - msg->readInt16(), msg->readInt16(), msg->readInt16(), - msg->readInt8()); + // Change in players' flags + id = msg->readInt32(); + dstBeing = beingManager->findBeing(id); + stunMode = msg->readInt16(); + statusEffects = msg->readInt16(); + statusEffects |= ((Uint32) msg->readInt16()) << 16; + msg->readInt8(); + + if (dstBeing) { + dstBeing->setStunMode(stunMode); + dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); + dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); + } + break; + + case 0x0196: + // Status change + status = msg->readInt16(); + id = msg->readInt32(); + flag = msg->readInt8(); // 0: stop, 1: start + + dstBeing = beingManager->findBeing(id); + if (dstBeing) + dstBeing->setStatusEffect(status, flag); break; } } - diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index 4f5f2acc..41314d16 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -113,7 +113,7 @@ void LoginHandler::handleMessage(MessageIn *msg) iptostring(server_info[i]->address), server_info[i]->port); } - state = CHAR_SERVER_STATE; + state = CHAR_SERVER_STATE; break; case 0x006a: diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp index 4e17a27e..ea03537f 100644 --- a/src/net/npchandler.cpp +++ b/src/net/npchandler.cpp @@ -79,7 +79,7 @@ void NPCHandler::handleMessage(MessageIn *msg) case SMSG_NPC_CLOSE: id = msg->readInt32(); if (current_npc == dynamic_cast<NPC*>(beingManager->findBeing(id))) - current_npc = NULL; + current_npc = NULL; break; case SMSG_NPC_NEXT: diff --git a/src/net/partyhandler.cpp b/src/net/partyhandler.cpp index 2437d0a0..03aca66d 100644 --- a/src/net/partyhandler.cpp +++ b/src/net/partyhandler.cpp @@ -34,17 +34,17 @@ PartyHandler::PartyHandler(Party *party) : mParty(party) { static const Uint16 _messages[] = { - SMSG_PARTY_CREATE, - SMSG_PARTY_INFO, - SMSG_PARTY_INVITE, - SMSG_PARTY_INVITED, - SMSG_PARTY_SETTINGS, - SMSG_PARTY_MEMBER_INFO, - SMSG_PARTY_LEAVE, - SMSG_PARTY_UPDATE_HP, - SMSG_PARTY_UPDATE_COORDS, - SMSG_PARTY_MESSAGE, - 0 + SMSG_PARTY_CREATE, + SMSG_PARTY_INFO, + SMSG_PARTY_INVITE, + SMSG_PARTY_INVITED, + SMSG_PARTY_SETTINGS, + SMSG_PARTY_MEMBER_INFO, + SMSG_PARTY_LEAVE, + SMSG_PARTY_UPDATE_HP, + SMSG_PARTY_UPDATE_COORDS, + SMSG_PARTY_MESSAGE, + 0 }; handledMessages = _messages; } @@ -53,70 +53,70 @@ void PartyHandler::handleMessage(MessageIn *msg) { switch (msg->getId()) { - case SMSG_PARTY_CREATE: - mParty->createResponse(msg->readInt8()); - break; - case SMSG_PARTY_INFO: - break; - case SMSG_PARTY_INVITE: - { - std::string nick = msg->readString(24); - int status = msg->readInt8(); - mParty->inviteResponse(nick, status); - break; - } - case SMSG_PARTY_INVITED: - { - int id = msg->readInt32(); - Being *being = beingManager->findBeing(id); - if (being == NULL) - { - break; - } - std::string nick; + case SMSG_PARTY_CREATE: + mParty->createResponse(msg->readInt8()); + break; + case SMSG_PARTY_INFO: + break; + case SMSG_PARTY_INVITE: + { + std::string nick = msg->readString(24); + int status = msg->readInt8(); + mParty->inviteResponse(nick, status); + break; + } + case SMSG_PARTY_INVITED: + { + int id = msg->readInt32(); + Being *being = beingManager->findBeing(id); + if (being == NULL) + { + break; + } + std::string nick; int gender = 0; - std::string partyName = ""; - if (being->getType() != Being::PLAYER) - { - nick = ""; - } - else - { - nick = being->getName(); - gender = being->getGender(); - partyName = msg->readString(24); - } - mParty->invitedAsk(nick, gender, partyName); - break; - } - case SMSG_PARTY_SETTINGS: - break; - case SMSG_PARTY_MEMBER_INFO: - break; - case SMSG_PARTY_LEAVE: - { - /*int id = */msg->readInt32(); - std::string nick = msg->readString(24); - /*int fail = */msg->readInt8(); - mParty->leftResponse(nick); - break; - } - case SMSG_PARTY_UPDATE_HP: - break; - case SMSG_PARTY_UPDATE_COORDS: - break; - case SMSG_PARTY_MESSAGE: - { // new block to enable local variables - int msgLength = msg->readInt16() - 8; - if (msgLength <= 0) - { - return; - } - int id = msg->readInt32(); - Being *being = beingManager->findBeing(id); - std::string chatMsg = msg->readString(msgLength); - mParty->receiveChat(being, chatMsg); - } - break; + std::string partyName = ""; + if (being->getType() != Being::PLAYER) + { + nick = ""; + } + else + { + nick = being->getName(); + gender = being->getGender(); + partyName = msg->readString(24); + } + mParty->invitedAsk(nick, gender, partyName); + break; + } + case SMSG_PARTY_SETTINGS: + break; + case SMSG_PARTY_MEMBER_INFO: + break; + case SMSG_PARTY_LEAVE: + { + /*int id = */msg->readInt32(); + std::string nick = msg->readString(24); + /*int fail = */msg->readInt8(); + mParty->leftResponse(nick); + break; + } + case SMSG_PARTY_UPDATE_HP: + break; + case SMSG_PARTY_UPDATE_COORDS: + break; + case SMSG_PARTY_MESSAGE: + { // new block to enable local variables + int msgLength = msg->readInt16() - 8; + if (msgLength <= 0) + { + return; + } + int id = msg->readInt32(); + Being *being = beingManager->findBeing(id); + std::string chatMsg = msg->readString(msgLength); + mParty->receiveChat(being, chatMsg); + } + break; } } diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h index 08d85ad0..048da9b1 100644 --- a/src/net/partyhandler.h +++ b/src/net/partyhandler.h @@ -29,11 +29,11 @@ class Party; class PartyHandler : public MessageHandler { public: - PartyHandler(Party *party); + PartyHandler(Party *party); - void handleMessage(MessageIn *msg); + void handleMessage(MessageIn *msg); private: - Party *mParty; + Party *mParty; }; #endif diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index d06f1108..46ded32e 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -146,7 +146,7 @@ void PlayerHandler::handleMessage(MessageIn *msg) /* Scroll if neccessary */ if (!nearby || (abs(x - player_node->mX) > MAP_TELEPORT_SCROLL_DISTANCE) - || (abs(y - player_node->mY) > MAP_TELEPORT_SCROLL_DISTANCE)) + || (abs(y - player_node->mY) > MAP_TELEPORT_SCROLL_DISTANCE)) { scrollOffsetX = (x - player_node->mX) * 32; scrollOffsetY = (y - player_node->mY) * 32; diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp index 0c7c9205..c5465835 100644 --- a/src/net/tradehandler.cpp +++ b/src/net/tradehandler.cpp @@ -112,7 +112,7 @@ void TradeHandler::handleMessage(MessageIn *msg) BY_SERVER); break; case 2: // Invite request check failed... - chatWindow->chatLog(_("Trade cancelled due to an unknown reason."), + chatWindow->chatLog(_("Trade cancelled due to an unknown reason."), BY_SERVER); break; case 3: // Trade accepted @@ -191,7 +191,7 @@ void TradeHandler::handleMessage(MessageIn *msg) BY_SERVER); break; default: - chatWindow->chatLog(_("Failed adding item for unknown reason."), + chatWindow->chatLog(_("Failed adding item for unknown reason."), BY_SERVER); break; } diff --git a/src/npc.cpp b/src/npc.cpp index 7b7db125..dfbc7d16 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -144,10 +144,10 @@ void NPC::stringInput(const std::string &value) { MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_NPC_STR_RESPONSE); - outMsg.writeInt16(value.length() + 15); + outMsg.writeInt16(value.length() + 8); outMsg.writeInt32(mId); - outMsg.writeString(value, value.length() + 6); - outMsg.writeInt8(0); + outMsg.writeString(value, value.length()); + outMsg.writeInt8(0); // Just to be safe } /* diff --git a/src/particle.cpp b/src/particle.cpp index d89d0a3e..45cbb4c9 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -251,7 +251,7 @@ void Particle::moveTo(float x, float y) moveTo(Vector(x, y, mPos.z)); } -Particle* Particle::addEffect(const std::string &particleEffectFile, +Particle *Particle::addEffect(const std::string &particleEffectFile, int pixelX, int pixelY, int rotation) { Particle *newParticle = NULL; diff --git a/src/particle.h b/src/particle.h index 881bbb74..e79a46dd 100644 --- a/src/particle.h +++ b/src/particle.h @@ -284,7 +284,7 @@ class Particle : public Sprite // follow-point particles Particle *mTarget; /**< The particle that attracts this particle*/ - float mAcceleration; /**< Acceleration towards the target particle in pixels per game-tick²*/ + float mAcceleration; /**< Acceleration towards the target particle in pixels per game-tick²*/ float mInvDieDistance; /**< Distance in pixels from the target particle that causes the destruction of the particle*/ float mMomentum; /**< How much speed the particle retains after each game tick*/ }; diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 1ed51053..63f89079 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -24,15 +24,17 @@ #include "particle.h" #include "particlecontainer.h" -ParticleContainer::ParticleContainer(ParticleContainer *parent, bool delParent) : + +ParticleContainer::ParticleContainer(ParticleContainer *parent, + bool delParent): mDelParent(delParent), mNext(parent) -{}; +{} ParticleContainer::~ParticleContainer() { clearLocally(); - if (mNext && mDelParent) + if (mDelParent) delete mNext; } @@ -51,10 +53,12 @@ void ParticleContainer::moveTo(float x, float y) // -- particle list ---------------------------------------- -ParticleList::ParticleList(ParticleContainer *parent, bool delParent) : - ParticleContainer(parent, delParent) {}; +ParticleList::ParticleList(ParticleContainer *parent, bool delParent): + ParticleContainer(parent, delParent) +{} -ParticleList::~ParticleList() {} +ParticleList::~ParticleList() +{} void ParticleList::addLocally(Particle *particle) { @@ -70,10 +74,12 @@ void ParticleList::removeLocally(Particle *particle) { for (std::list<Particle *>::iterator it = mElements.begin(); it != mElements.end(); it++) + { if (*it == particle) { (*it)->kill(); mElements.erase(it); } + } } void ParticleList::clearLocally() @@ -81,7 +87,7 @@ void ParticleList::clearLocally() for (std::list<Particle *>::iterator it = mElements.begin(); it != mElements.end(); it++) (*it)->kill(); - + mElements.clear(); } @@ -105,10 +111,12 @@ void ParticleList::moveTo(float x, float y) // -- particle vector ---------------------------------------- -ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent) : - ParticleContainer(parent, delParent) {}; +ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent): + ParticleContainer(parent, delParent) +{} -ParticleVector::~ParticleVector() {}; +ParticleVector::~ParticleVector() +{} void ParticleVector::setLocally(int index, Particle *particle) { @@ -119,6 +127,8 @@ void ParticleVector::setLocally(int index, Particle *particle) if (mIndexedElements.size() <= (unsigned) index) mIndexedElements.resize(index + 1, NULL); + if (particle) + particle->disableAutoDelete(); mIndexedElements[index] = particle; } @@ -148,7 +158,7 @@ void ParticleVector::moveTo(float x, float y) ParticleContainer::moveTo(x, y); for (std::vector<Particle *>::iterator it = mIndexedElements.begin(); - it != mIndexedElements.end(); it++) + it != mIndexedElements.end(); it++) { if (*it) { (*it)->moveTo(x, y); @@ -159,5 +169,6 @@ void ParticleVector::moveTo(float x, float y) *it = NULL; } } + } } diff --git a/src/particlecontainer.h b/src/particlecontainer.h index 4fb00027..26539dd7 100644 --- a/src/particlecontainer.h +++ b/src/particlecontainer.h @@ -60,8 +60,8 @@ public: virtual void moveTo(float x, float y); protected: - bool mDelParent; /**< Delete mNext in destructor */ - ParticleContainer *mNext; /**< Contained container, if any */ + bool mDelParent; /**< Delete mNext in destructor */ + ParticleContainer *mNext; /**< Contained container, if any */ }; /** @@ -88,7 +88,7 @@ public: virtual void moveTo(float x, float y); protected: - std::list<Particle *> mElements; /**< Contained particle effects */ + std::list<Particle *> mElements; /**< Contained particle effects */ }; /** diff --git a/src/party.cpp b/src/party.cpp index 70e0d3c2..fe575a37 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -33,7 +33,9 @@ #include "utils/strprintf.h" Party::Party(ChatWindow *chat, Network *network) : - mChat(chat), mNetwork(network), mInviteListener(network, &mInParty) + mChat(chat), + mNetwork(network), + mInviteListener(network, &mInParty) { } @@ -41,24 +43,24 @@ void Party::respond(const std::string &command, const std::string &args) { if (command == "new" || command == "create") { - create(args); - return; + create(args); + return; } if (command == "leave") { - leave(args); - return; + leave(args); + return; } if (command == "settings") { - mChat->chatLog(_("Not yet implemented!"), BY_SERVER); - return; - /* - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_PARTY_SETTINGS); - outMsg.writeInt16(0); // Experience - outMsg.writeInt16(0); // Item - */ + mChat->chatLog(_("Not yet implemented!"), BY_SERVER); + return; + /* + MessageOut outMsg(mNetwork); + outMsg.writeInt16(CMSG_PARTY_SETTINGS); + outMsg.writeInt16(0); // Experience + outMsg.writeInt16(0); // Item + */ } mChat->chatLog(_("Party command not known."), BY_SERVER); } @@ -67,8 +69,8 @@ void Party::create(const std::string &party) { if (party == "") { - mChat->chatLog(_("Party name is missing."), BY_SERVER); - return; + mChat->chatLog(_("Party name is missing."), BY_SERVER); + return; } MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_PARTY_CREATE); @@ -88,12 +90,12 @@ void Party::createResponse(bool ok) { if (ok) { - mChat->chatLog(_("Party successfully created."), BY_SERVER); - mInParty = true; + mChat->chatLog(_("Party successfully created."), BY_SERVER); + mInParty = true; } else { - mChat->chatLog(_("Could not create party."), BY_SERVER); + mChat->chatLog(_("Could not create party."), BY_SERVER); } } @@ -102,34 +104,34 @@ void Party::inviteResponse(const std::string &nick, int status) switch (status) { case 0: - mChat->chatLog(strprintf(_("%s is already a member of a party."), - nick.c_str()), BY_SERVER); - break; + mChat->chatLog(strprintf(_("%s is already a member of a party."), + nick.c_str()), BY_SERVER); + break; case 1: - mChat->chatLog(strprintf(_("%s refused your invitation."), - nick.c_str()), BY_SERVER); - break; + mChat->chatLog(strprintf(_("%s refused your invitation."), + nick.c_str()), BY_SERVER); + break; case 2: - mChat->chatLog(strprintf(_("%s is now a member of your party."), - nick.c_str()), BY_SERVER); - break; + mChat->chatLog(strprintf(_("%s is now a member of your party."), + nick.c_str()), BY_SERVER); + break; } } void Party::invitedAsk(const std::string &nick, int gender, - const std::string &partyName) + const std::string &partyName) { mPartyName = partyName; /* Quick and nasty - needs redoing */ if (nick == "") { mChat->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); - return; + return; } mCreating = false; ConfirmDialog *dlg = new ConfirmDialog(_("Invite to party"), - strprintf(_("%s invites you to join" - " the %s party, do you accept?"), - nick.c_str(), partyName.c_str())); + strprintf(_("%s invites you to join" + " the %s party, do you accept?"), + nick.c_str(), partyName.c_str())); dlg->addActionListener(&mInviteListener); } @@ -145,7 +147,7 @@ void Party::InviteListener::action(const gcn::ActionEvent &event) void Party::leftResponse(const std::string &nick) { - mChat->chatLog(strprintf(_("%s has left your party."), nick.c_str()), + mChat->chatLog(strprintf(_("%s has left your party."), nick.c_str()), BY_SERVER); } @@ -153,13 +155,13 @@ void Party::receiveChat(Being *being, const std::string &msg) { if (being == NULL) { - return; + return; } if (being->getType() != Being::PLAYER) { - mChat->chatLog(_("Party chat received, but being is not a player"), + mChat->chatLog(_("Party chat received, but being is not a player"), BY_SERVER); - return; + return; } being->setSpeech(msg, SPEECH_TIME); mChat->chatLog(being->getName() + " : " + msg, BY_PARTY); @@ -169,46 +171,46 @@ void Party::help(const std::string &msg) { if (msg == "") { - mChat->chatLog(_("Command: /party <command> <args>"), BY_SERVER); - mChat->chatLog(_("where <command> can be one of:"), BY_SERVER); - mChat->chatLog(_(" /new"), BY_SERVER); - mChat->chatLog(_(" /create"), BY_SERVER); - mChat->chatLog(_(" /prefix"), BY_SERVER); - mChat->chatLog(_(" /leave"), BY_SERVER); - mChat->chatLog(_("This command implements the partying function."), - BY_SERVER); - mChat->chatLog(_("Type /help party <command> for further help."), - BY_SERVER); - return; + mChat->chatLog(_("Command: /party <command> <args>"), BY_SERVER); + mChat->chatLog(_("where <command> can be one of:"), BY_SERVER); + mChat->chatLog(_(" /new"), BY_SERVER); + mChat->chatLog(_(" /create"), BY_SERVER); + mChat->chatLog(_(" /prefix"), BY_SERVER); + mChat->chatLog(_(" /leave"), BY_SERVER); + mChat->chatLog(_("This command implements the partying function."), + BY_SERVER); + mChat->chatLog(_("Type /help party <command> for further help."), + BY_SERVER); + return; } if (msg == "new" || msg == "create") { - mChat->chatLog(_("Command: /party new <party-name>"), BY_SERVER); - mChat->chatLog(_("Command: /party create <party-name>"), BY_SERVER); - mChat->chatLog(_("These commands create a new party <party-name."), - BY_SERVER); - return; + mChat->chatLog(_("Command: /party new <party-name>"), BY_SERVER); + mChat->chatLog(_("Command: /party create <party-name>"), BY_SERVER); + mChat->chatLog(_("These commands create a new party <party-name."), + BY_SERVER); + return; } if (msg == "prefix") { - mChat->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER); - mChat->chatLog(_("This command sets the party prefix character."), - BY_SERVER); - mChat->chatLog(_("Any message preceded by <prefix-char> is sent to " - "the party instead of everyone."), BY_SERVER); - mChat->chatLog(_("Command: /party prefix"), BY_SERVER); - mChat->chatLog(_("This command reports the current party prefix " - "character."), BY_SERVER); - return; + mChat->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER); + mChat->chatLog(_("This command sets the party prefix character."), + BY_SERVER); + mChat->chatLog(_("Any message preceded by <prefix-char> is sent to " + "the party instead of everyone."), BY_SERVER); + mChat->chatLog(_("Command: /party prefix"), BY_SERVER); + mChat->chatLog(_("This command reports the current party prefix " + "character."), BY_SERVER); + return; } //if (msg == "settings") //if (msg == "info") if (msg == "leave") { - mChat->chatLog(_("Command: /party leave"), BY_SERVER); - mChat->chatLog(_("This command causes the player to leave the party."), - BY_SERVER); - return; + mChat->chatLog(_("Command: /party leave"), BY_SERVER); + mChat->chatLog(_("This command causes the player to leave the party."), + BY_SERVER); + return; } mChat->chatLog(_("Unknown /party command."), BY_SERVER); mChat->chatLog(_("Type /help party for a list of options."), BY_SERVER); diff --git a/src/party.h b/src/party.h index 5643f894..98252c37 100644 --- a/src/party.h +++ b/src/party.h @@ -33,40 +33,44 @@ class Network; class Party { - public: - Party(ChatWindow *chat, Network *network); - void respond(const std::string &command, const std::string &args); + public: + Party(ChatWindow *chat, Network *network); + void respond(const std::string &command, const std::string &args); - void create(const std::string &party); - void leave(const std::string &args); + void create(const std::string &party); + void leave(const std::string &args); - void createResponse(bool ok); - void inviteResponse(const std::string &nick, int status); - void invitedAsk(const std::string &nick, int gender, - const std::string &partyName); - void leftResponse(const std::string &nick); - void receiveChat(Being *being, const std::string &msg); + void createResponse(bool ok); + void inviteResponse(const std::string &nick, int status); + void invitedAsk(const std::string &nick, int gender, + const std::string &partyName); + void leftResponse(const std::string &nick); + void receiveChat(Being *being, const std::string &msg); - void help(const std::string &msg); - private: - ChatWindow *mChat; - std::string mPartyName; - Network *mNetwork; - bool mInParty; - bool mCreating; /**< Used to give an appropriate response to - failure */ - PartyHandler *handler; + void help(const std::string &msg); - class InviteListener : public gcn::ActionListener - { - public: - InviteListener(Network *network, bool *inParty) : - mNetwork(network), mInParty(inParty) {}; - void action(const gcn::ActionEvent &event); - Network *mNetwork; - private: - bool *mInParty; - }; - InviteListener mInviteListener; + private: + ChatWindow *mChat; + std::string mPartyName; + Network *mNetwork; + bool mInParty; + bool mCreating; /**< Used to give an appropriate response to + failure */ + PartyHandler *handler; + + class InviteListener : public gcn::ActionListener + { + public: + InviteListener(Network *network, bool *inParty) : + mNetwork(network), + mInParty(inParty) + {} + void action(const gcn::ActionEvent &event); + Network *mNetwork; + private: + bool *mInParty; + }; + InviteListener mInviteListener; }; + #endif diff --git a/src/properties.h b/src/properties.h index 4bad8e59..a2ce5b88 100644 --- a/src/properties.h +++ b/src/properties.h @@ -45,7 +45,8 @@ class Properties * @return the value of the given property or the given default when it * doesn't exist. */ - const std::string& getProperty(const std::string &name, const std::string &def = "") const + const std::string &getProperty(const std::string &name, + const std::string &def = "") const { PropertyMap::const_iterator i = mProperties.find(name); return (i != mProperties.end()) ? i->second : def; @@ -59,7 +60,7 @@ class Properties * @return the value of the given property, or 0.0f when it doesn't * exist. */ - float getFloatProperty(std::string const &name, float def = 0.0f) const + float getFloatProperty(const std::string &name, float def = 0.0f) const { PropertyMap::const_iterator i = mProperties.find(name); float ret = def; diff --git a/src/resources/buddylist.cpp b/src/resources/buddylist.cpp index 541acabe..719ecab1 100644 --- a/src/resources/buddylist.cpp +++ b/src/resources/buddylist.cpp @@ -55,9 +55,9 @@ void BuddyList::loadFile() char *buddy = new char[LEN_MAX_USERNAME]; inputStream.getline(buddy, LEN_MAX_USERNAME); // Ugly ? - if(strcmp(buddy,"")) mBuddylist.push_back(buddy); + if (strcmp(buddy, "")) mBuddylist.push_back(buddy); delete [] buddy; - } while(!inputStream.eof()); + } while (!inputStream.eof()); // Read buddy and close file inputStream.close(); diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 7456f0e4..61ea4bc0 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Aethyra; if not, write to the Free Software Foundation, + * along with Aethyra; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -101,7 +101,7 @@ void ColorDB::unload() std::string& ColorDB::get(int id) { - if(!mLoaded) + if (!mLoaded) load(); ColorIterator i = mColors.find(id); diff --git a/src/resources/colordb.h b/src/resources/colordb.h index da36048a..892411f8 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Aethyra; if not, write to the Free Software Foundation, + * along with Aethyra; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -47,6 +47,6 @@ namespace ColorDB // Color DB typedef std::map<int, std::string> Colors; typedef Colors::iterator ColorIterator; -}; +} #endif diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 63d85501..22bd2411 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -25,7 +25,7 @@ #include "../log.h" -Palette::Palette(std::string const &description) +Palette::Palette(const std::string &description) { int size = description.length(); if (size == 0) return; @@ -108,7 +108,7 @@ void Palette::getColor(int intensity, int color[3]) const color[2] = ((255 - t) * b1 + t * b2) / 255; } -Dye::Dye(std::string const &description) +Dye::Dye(const std::string &description) { for (int i = 0; i < 7; ++i) mPalettes[i] = 0; @@ -174,7 +174,7 @@ void Dye::update(int color[3]) const mPalettes[i - 1]->getColor(cmax, color); } -void Dye::instantiate(std::string &target, std::string const &palettes) +void Dye::instantiate(std::string &target, const std::string &palettes) { std::string::size_type next_pos = target.find('|'); if (next_pos == std::string::npos || palettes.empty()) return; diff --git a/src/resources/dye.h b/src/resources/dye.h index 1db16c6a..3cef334a 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -37,7 +37,7 @@ class Palette * The string is either a file name or a sequence of hexadecimal RGB * values separated by ',' and starting with '#'. */ - Palette(std::string const &pallete); + Palette(const std::string &pallete); /** * Gets a pixel color depending on its intensity. @@ -64,7 +64,7 @@ class Dye * The parts of string are separated by semi-colons. Each part starts * by an uppercase letter, followed by a colon and then a palette name. */ - Dye(std::string const &dye); + Dye(const std::string &dye); /** * Destroys the associated palettes. @@ -80,7 +80,7 @@ class Dye * Fills the blank in a dye placeholder with some palette names. */ static void instantiate(std::string &target, - std::string const &palettes); + const std::string &palettes); private: diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index adc1635c..ac41b59c 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Aethyra; if not, write to the Free Software Foundation, + * along with Aethyra; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h index 0962edad..2b9dbbc2 100644 --- a/src/resources/emotedb.h +++ b/src/resources/emotedb.h @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Aethyra; if not, write to the Free Software Foundation, + * along with Aethyra; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index c182b44c..40d62797 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -87,7 +87,7 @@ void ProxyImage::convertToDisplayFormat() mSDLImage = NULL; } -gcn::Image *ImageLoader::load(std::string const &filename, bool convert) +gcn::Image *ImageLoader::load(const std::string &filename, bool convert) { ResourceManager *resman = ResourceManager::getInstance(); ProxyImage *i = new ProxyImage(resman->loadSDLSurface(filename)); diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h index 0ac7c899..1d6c9ae4 100644 --- a/src/resources/imageloader.h +++ b/src/resources/imageloader.h @@ -61,7 +61,8 @@ class ProxyImage : public gcn::Image class ImageLoader : public gcn::ImageLoader { public: - gcn::Image *load(std::string const &filename, bool convertToDisplayFormat); + gcn::Image *load(const std::string &filename, + bool convertToDisplayFormat); }; #endif diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 2278dc67..3270c665 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -359,12 +359,12 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) xmlNodePtr dataChild = childNode->xmlChildrenNode; if (!dataChild) continue; - + int len = strlen((const char*)dataChild->content) + 1; unsigned char *charData = new unsigned char[len + 1]; const char *charStart = (const char*)dataChild->content; unsigned char *charIndex = charData; - + while (*charStart) { if (*charStart != ' ' && *charStart != '\t' && *charStart != '\n') @@ -426,10 +426,10 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) } } else { - // Read plain XML map file - for_each_xml_child_node(childNode2, childNode) - { - if (!xmlStrEqual(childNode2->name, BAD_CAST "tile")) + // Read plain XML map file + for_each_xml_child_node(childNode2, childNode) + { + if (!xmlStrEqual(childNode2->name, BAD_CAST "tile")) continue; const int gid = XML::getProperty(childNode2, "gid", -1); @@ -443,12 +443,12 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) } } } - + if (y < h) std::cerr << "TOO SMALL!\n"; if (x) std::cerr << "TOO SMALL!\n"; - + // There can be only one data element break; } diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index 75464035..359791fd 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -67,13 +67,13 @@ class MonsterInfo void addParticleEffect(std::string filename); - const std::string& getName() const + const std::string& getName() const { return mName; } - const std::list<std::string>& getSprites() const + const std::list<std::string>& getSprites() const { return mSprites; } - Being::TargetCursorSize getTargetCursorSize() const + Being::TargetCursorSize getTargetCursorSize() const { return mTargetCursorSize; } std::string getSound(MonsterSoundEvent event) const; @@ -83,7 +83,7 @@ class MonsterInfo void addAttackParticleEffect(const std::string &particleEffect) { mAttackParticle = particleEffect; } - const std::list<std::string>& getParticleEffects() const + const std::list<std::string>& getParticleEffects() const { return mParticleEffects; } private: diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index f193d55d..3f58076e 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -207,13 +207,13 @@ std::string ResourceManager::getPath(const std::string &file) else { // if not found in search path return the default path - path = std::string(AETHYRA_DATADIR) + std::string("data") + "/" + file; + path = std::string(TMW_DATADIR) + std::string("data") + "/" + file; } return path; } -Resource *ResourceManager::get(std::string const &idPath, generator fun, +Resource *ResourceManager::get(const std::string &idPath, generator fun, void *data) { // Check if the id exists, and return the value if it does. @@ -265,7 +265,7 @@ struct ResourceLoader } }; -Resource *ResourceManager::load(std::string const &path, loader fun) +Resource *ResourceManager::load(const std::string &path, loader fun) { ResourceLoader l = { this, path, fun }; return get(path, ResourceLoader::load, &l); @@ -307,7 +307,7 @@ struct DyedImageLoader } }; -Image *ResourceManager::getImage(std::string const &idPath) +Image *ResourceManager::getImage(const std::string &idPath) { DyedImageLoader l = { this, idPath }; return static_cast<Image*>(get(idPath, DyedImageLoader::load, &l)); @@ -349,8 +349,7 @@ struct SpriteDefLoader } }; -SpriteDef *ResourceManager::getSprite - (std::string const &path, int variant) +SpriteDef *ResourceManager::getSprite(const std::string &path, int variant) { SpriteDefLoader l = { path, variant }; std::stringstream ss; @@ -379,7 +378,8 @@ void ResourceManager::release(Resource *res) ResourceManager *ResourceManager::getInstance() { // Create a new instance if necessary. - if (instance == NULL) instance = new ResourceManager(); + if (!instance) + instance = new ResourceManager(); return instance; } diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 7996e816..c3c68d88 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -98,8 +98,9 @@ class ResourceManager bool isDirectory(const std::string &path); /** - * Returns the real path to a file - * + * Returns the real path to a file. Note that this method will always + * return a path, it does not check whether the file exists. + * * @param file The file to get the real path to. * @return The real path. */ @@ -114,7 +115,7 @@ class ResourceManager * @return A valid resource or <code>NULL</code> if the resource could * not be generated. */ - Resource *get(std::string const &idPath, generator fun, void *data); + Resource *get(const std::string &idPath, generator fun, void *data); /** * Loads a resource from a file and adds it to the resource map. @@ -124,7 +125,7 @@ class ResourceManager * @return A valid resource or <code>NULL</code> if the resource could * not be loaded. */ - Resource *load(std::string const &path, loader fun); + Resource *load(const std::string &path, loader fun); /** * Convenience wrapper around ResourceManager::get for loading @@ -154,7 +155,7 @@ class ResourceManager * Creates a sprite definition based on a given path and the supplied * variant. */ - SpriteDef *getSprite(std::string const &path, int variant = 0); + SpriteDef *getSprite(const std::string &path, int variant = 0); /** * Releases a resource, placing it in the set of orphaned resources. diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index e8d064d4..af3281be 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -32,7 +32,7 @@ #include "../log.h" #include "../utils/xml.h" -Action* SpriteDef::getAction(SpriteAction action) const +Action *SpriteDef::getAction(SpriteAction action) const { Actions::const_iterator i = mActions.find(action); @@ -45,7 +45,7 @@ Action* SpriteDef::getAction(SpriteAction action) const return i->second; } -SpriteDef *SpriteDef::load(std::string const &animationFile, int variant) +SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) { std::string::size_type pos = animationFile.find('|'); std::string palettes; @@ -120,7 +120,7 @@ void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant, } } -void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes) +void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes) { const std::string name = XML::getProperty(node, "name", ""); @@ -319,7 +319,7 @@ SpriteDef::~SpriteDef() } } -SpriteAction SpriteDef::makeSpriteAction(const std::string& action) +SpriteAction SpriteDef::makeSpriteAction(const std::string &action) { if (action == "" || action == "default") { return ACTION_DEFAULT; @@ -390,5 +390,5 @@ SpriteDirection SpriteDef::makeSpriteDirection(const std::string& direction) } else { return DIRECTION_INVALID; - }; + } } diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 99d570f1..b9d7b85d 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -71,13 +71,24 @@ class SpriteDef : public Resource /** * Loads a sprite definition file. */ - static SpriteDef *load(std::string const &file, int variant); + static SpriteDef *load(const std::string &file, int variant); /** * Returns the specified action. */ Action *getAction(SpriteAction action) const; + /** + * Converts a string into a SpriteAction enum. + */ + static SpriteAction makeSpriteAction(const std::string &action); + + /** + * Converts a string into a SpriteDirection enum. + */ + static SpriteDirection + makeSpriteDirection(const std::string &direction); + private: /** * Constructor. @@ -98,7 +109,7 @@ class SpriteDef : public Resource /** * Loads an imageset element. */ - void loadImageSet(xmlNodePtr node, std::string const &palettes); + void loadImageSet(xmlNodePtr node, const std::string &palettes); /** * Loads an action element. @@ -128,16 +139,6 @@ class SpriteDef : public Resource */ void substituteAction(SpriteAction complete, SpriteAction with); - /** - * Converts a string into a SpriteAction enum. - */ - static SpriteAction makeSpriteAction(const std::string &action); - - /** - * Converts a string into a SpriteDirection enum. - */ - static SpriteDirection makeSpriteDirection(const std::string &direction); - typedef std::map<std::string, ImageSet*> ImageSets; typedef ImageSets::iterator ImageSetIterator; diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 9066ed7f..d90602a6 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -33,7 +33,7 @@ SimpleAnimation::SimpleAnimation(Animation *animation): mAnimationPhase(0), mCurrentFrame(mAnimation->getFrame(0)) { -}; +} SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode): mAnimationTime(0), diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp new file mode 100644 index 00000000..8872fd7b --- /dev/null +++ b/src/statuseffect.cpp @@ -0,0 +1,170 @@ +/* + * The Mana World + * Copyright (C) 2008 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <map> + +#include "gui/chat.h" +#include "statuseffect.h" + +#include "log.h" +#include "utils/xml.h" + + +#define STATUS_EFFECTS_FILE "status-effects.xml" + +StatusEffect::StatusEffect() : + mPersistentParticleEffect(false) +{} + +StatusEffect::~StatusEffect() +{} + +void StatusEffect::playSFX() +{ + if (mSFXEffect != "") + sound.playSfx(mSFXEffect); +} + +void StatusEffect::deliverMessage() +{ + if (mMessage != "") + chatWindow->chatLog(mMessage, BY_SERVER); +} + +Particle *StatusEffect::getParticle() +{ + if (mParticleEffect == "") + return NULL; + else + return particleEngine->addEffect(mParticleEffect, 0, 0); +} + +AnimatedSprite *StatusEffect::getIcon() +{ + if (mIcon == "") + return NULL; + else { + AnimatedSprite *sprite = AnimatedSprite::load( + "graphics/sprites/" + mIcon); + if (false && sprite) { + sprite->play(ACTION_DEFAULT); + sprite->reset(); + } + return sprite; + } +} + +SpriteAction StatusEffect::getAction() +{ + if (mAction == "") + return ACTION_INVALID; + else + return SpriteDef::makeSpriteAction(mAction); +} + + +// -- initialisation and static parts -- + + +typedef std::map<int, StatusEffect *> status_effect_map[2]; + +static status_effect_map statusEffects; +static status_effect_map stunEffects; +static std::map<int, int> blockEffectIndexMap; + +int StatusEffect::blockEffectIndexToEffectIndex(int blockIndex) +{ + load(); + if (blockEffectIndexMap.find(blockIndex) == blockEffectIndexMap.end()) + return -1; + return blockEffectIndexMap[blockIndex]; +} + +StatusEffect *StatusEffect::getStatusEffect(int index, bool enabling) +{ + load(); + return statusEffects[enabling][index]; +} + +StatusEffect *StatusEffect::getStunEffect(int index, bool enabling) +{ + load(); + return stunEffects[enabling][index]; +} + +static bool status_effects_loaded = false; + + + +void StatusEffect::load() +{ + if (status_effects_loaded) + return; + + status_effects_loaded = true; + + XML::Document doc(STATUS_EFFECTS_FILE); + xmlNodePtr rootNode = doc.rootNode(); + + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "status-effects")) + { + logger->log("Error loading status effects file: " + STATUS_EFFECTS_FILE); + return; + } + + for_each_xml_child_node(node, rootNode) + { + status_effect_map *the_map = NULL; + + int index = atoi(XML::getProperty(node, "id", "-1").c_str()); + + if (xmlStrEqual(node->name, BAD_CAST "status-effect")) + { + the_map = &statusEffects; + int block_index = atoi(XML::getProperty(node, "block-id", "-1").c_str()); + + if (index >= 0 && block_index >= 0) + blockEffectIndexMap[block_index] = index; + + } else if (xmlStrEqual(node->name, BAD_CAST "stun-effect")) + the_map = &stunEffects; + + if (the_map) { + StatusEffect *startEffect = new StatusEffect(); + StatusEffect *endEffect = new StatusEffect(); + + startEffect->mMessage = XML::getProperty(node, "start-message", ""); + startEffect->mSFXEffect = XML::getProperty(node, "start-audio", ""); + startEffect->mParticleEffect = XML::getProperty(node, "start-particle", ""); + startEffect->mIcon = XML::getProperty(node, "icon", ""); + startEffect->mAction = XML::getProperty(node, "action", ""); + startEffect->mPersistentParticleEffect = (XML::getProperty(node, "persistent-particle-effect", "no")) != "no"; + + endEffect->mMessage = XML::getProperty(node, "end-message", ""); + endEffect->mSFXEffect = XML::getProperty(node, "end-audio", ""); + endEffect->mParticleEffect = XML::getProperty(node, "end-particle", ""); + + (*the_map)[1][index] = startEffect; + (*the_map)[0][index] = endEffect; + } + } +} diff --git a/src/statuseffect.h b/src/statuseffect.h new file mode 100644 index 00000000..16fed69a --- /dev/null +++ b/src/statuseffect.h @@ -0,0 +1,108 @@ +/* + * The Mana World + * Copyright (C) 2008 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef STATUS_EFFECT_H +#define STATUS_EFFECT_H + +#include "resources/animation.h" +#include "particle.h" +#include "animatedsprite.h" +#include "sound.h" + +class StatusEffect +{ +public: + StatusEffect(); + ~StatusEffect(); + + /** + * Plays the sound effect associated with this status effect, if possible. + */ + void playSFX(); + + /** + * Delivers the chat message associated with this status effect, if + * possible. + */ + void deliverMessage(); + + /** + * Creates the particle effect associated with this status effect, if + * possible. + */ + Particle *getParticle(); + + /** + * Retrieves the status icon for this effect, if applicable + */ + AnimatedSprite *getIcon(); + + /** + * Retrieves an action to perform, or ACTION_INVALID + */ + SpriteAction getAction(); + + /** + * Determines whether the particle effect should be restarted when the + * being changes maps + */ + bool particleEffectIsPersistent() const { return mPersistentParticleEffect; } + + + /** + * Retrieves a status effect. + * + * \param index Index of the status effect. + * \param enabling Whether to retrieve the activating effect (true) or + * the deactivating effect (false). + */ + static StatusEffect *getStatusEffect(int index, bool enabling); + + /** + * Retrieves a stun effect. + * + * \param index Index of the stun effect. + * \param enabling Whether to retrieve the activating effect (true) or + * the deactivating effect (false). + */ + static StatusEffect *getStunEffect(int index, bool enabling); + + /** + * Maps a block effect index to its corresponding effect index. Block + * effect indices are used for opt2/opt3/status.option blocks; their + * mapping to regular effect indices is handled in the config file. + * + * Returns -1 on failure. + */ + static int blockEffectIndexToEffectIndex(int blocKIndex); + +private: + static void load(); + + std::string mMessage; + std::string mSFXEffect; + std::string mParticleEffect; + std::string mIcon; + std::string mAction; + bool mPersistentParticleEffect; +}; + +#endif // !defined(STATUS_EFFECT_H) diff --git a/src/text.cpp b/src/text.cpp index 8f93f157..e4f1d409 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -1,43 +1,75 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +/* + * Support for non-overlapping floating text + * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> + * Copyright (C) 2008 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "text.h" #include <guichan/font.hpp> -#include "text.h" +#include "configuration.h" #include "textmanager.h" +#include "resources/resourcemanager.h" +#include "resources/image.h" #include "gui/gui.h" int Text::mInstances = 0; +ImageRect Text::mBubble; +Image *Text::mBubbleArrow; Text::Text(const std::string &text, int x, int y, - gcn::Graphics::Alignment alignment, gcn::Color colour) : - mText(text), mColour(colour) + gcn::Graphics::Alignment alignment, + gcn::Color colour, bool isSpeech) : + mText(text), + mColour(colour), + mIsSpeech(isSpeech) { if (textManager == 0) { - textManager = new TextManager(); + textManager = new TextManager; + ResourceManager *resman = ResourceManager::getInstance(); + Image *sbImage = resman->getImage("graphics/gui/bubble.png|W:#" + + config.getValue("speechBubbleColour", "000000")); + mBubble.grid[0] = sbImage->getSubImage(0, 0, 5, 5); + mBubble.grid[1] = sbImage->getSubImage(5, 0, 5, 5); + mBubble.grid[2] = sbImage->getSubImage(10, 0, 5, 5); + mBubble.grid[3] = sbImage->getSubImage(0, 5, 5, 5); + mBubble.grid[4] = sbImage->getSubImage(5, 5, 5, 5); + mBubble.grid[5] = sbImage->getSubImage(10, 5, 5, 5); + mBubble.grid[6] = sbImage->getSubImage(0, 10, 5, 5); + mBubble.grid[7] = sbImage->getSubImage(5, 10, 5, 5); + mBubble.grid[8] = sbImage->getSubImage(10, 10, 5, 5); + mBubbleArrow = sbImage->getSubImage(0, 15, 15, 10); + const float bubbleAlpha = config.getValue("speechBubbleAlpha", 1.0); + for (int i = 0; i < 9; i++) + { + mBubble.grid[i]->setAlpha(bubbleAlpha); + } + mBubbleArrow->setAlpha(bubbleAlpha); + sbImage->decRef(); } ++mInstances; mHeight = boldFont->getHeight(); mWidth = boldFont->getWidth(text); + switch (alignment) { case gcn::Graphics::LEFT: @@ -55,11 +87,6 @@ Text::Text(const std::string &text, int x, int y, textManager->addText(this); } -void Text::adviseXY(int x, int y) -{ - textManager->moveText(this, x - mXOffset, y); -} - Text::~Text() { textManager->removeText(this); @@ -67,34 +94,81 @@ Text::~Text() { delete textManager; textManager = 0; + delete mBubble.grid[0]; + delete mBubble.grid[1]; + delete mBubble.grid[2]; + delete mBubble.grid[3]; + delete mBubble.grid[4]; + delete mBubble.grid[5]; + delete mBubble.grid[6]; + delete mBubble.grid[7]; + delete mBubble.grid[8]; + delete mBubbleArrow; } } +void Text::adviseXY(int x, int y) +{ + textManager->moveText(this, x - mXOffset, y); +} + void Text::draw(gcn::Graphics *graphics, int xOff, int yOff) { graphics->setFont(boldFont); + if (mIsSpeech) { + static_cast<Graphics*>(graphics)->drawImageRect( + mX - xOff - 5, mY - yOff - 5, mWidth + 10, mHeight + 10, + mBubble); + /* + if (mWidth >= 15) { + static_cast<Graphics*>(graphics)->drawImage( + mBubbleArrow, mX - xOff - 7 + mWidth / 2, + mY - yOff + mHeight + 4); + } + */ + } + // Text shadow graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawText(mText, mX - xOff + 1, mY - yOff + 1, - gcn::Graphics::LEFT); - - // Text outline - graphics->drawText(mText, mX - xOff + 1, mY - yOff, - gcn::Graphics::LEFT); - graphics->drawText(mText, mX - xOff - 1, mY - yOff, - gcn::Graphics::LEFT); - graphics->drawText(mText, mX - xOff, mY - yOff + 1, - gcn::Graphics::LEFT); - graphics->drawText(mText, mX - xOff, mY - yOff - 1, - gcn::Graphics::LEFT); + gcn::Graphics::LEFT); + + if (!mIsSpeech) { + graphics->setColor(gcn::Color(0, 0, 0, 64)); + /* + // TODO: Reanable when we can draw it nicely in software mode + graphics->drawText(mText, mX - xOff + 2, mY - yOff + 2, + gcn::Graphics::LEFT); + graphics->drawText(mText, mX - xOff + 1, mY - yOff + 2, + gcn::Graphics::LEFT); + graphics->drawText(mText, mX - xOff + 2, mY - yOff + 1, + gcn::Graphics::LEFT); + */ + + // Text outline + graphics->setColor(gcn::Color(0, 0, 0)); + graphics->drawText(mText, mX - xOff + 1, mY - yOff, + gcn::Graphics::LEFT); + + graphics->drawText(mText, mX - xOff - 1, mY - yOff, + gcn::Graphics::LEFT); + + graphics->drawText(mText, mX - xOff, mY - yOff + 1, + gcn::Graphics::LEFT); + + graphics->drawText(mText, mX - xOff, mY - yOff - 1, + gcn::Graphics::LEFT); + } graphics->setColor(mColour); - graphics->drawText(mText, mX - xOff, mY - yOff, gcn::Graphics::LEFT); + graphics->drawText(mText, mX - xOff, mY - yOff, + gcn::Graphics::LEFT); } FlashText::FlashText(const std::string &text, int x, int y, - gcn::Graphics::Alignment alignment, gcn::Color colour) : + gcn::Graphics::Alignment alignment, + gcn::Color colour) : Text(text, x, y, alignment, colour), mTime(0) { @@ -1,29 +1,31 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +/* + * Support for non-overlapping floating text + * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> + * Copyright (C) 2008 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef TEXT_H #define TEXT_H #include <guichan/color.hpp> -#include <guichan/graphics.hpp> +#include "graphics.h" #include "guichanfwd.h" class TextManager; @@ -37,7 +39,8 @@ class Text * Constructor creates a text object to display on the screen. */ Text(const std::string &text, int x, int y, - gcn::Graphics::Alignment alignment, gcn::Color colour); + gcn::Graphics::Alignment alignment, + gcn::Color colour, bool isSpeech = false); /** * Destructor. The text is removed from the screen. @@ -63,13 +66,19 @@ class Text static int mInstances; /**< Instances of text. */ std::string mText; /**< The text to display. */ gcn::Color mColour; /**< The colour of the text. */ + bool mIsSpeech; /**< Is this text a speech bubble? */ + + protected: + static ImageRect mBubble; /**< Speech bubble graphic */ + static Image *mBubbleArrow; /**< Speech bubble arrow graphic */ }; class FlashText : public Text { public: FlashText(const std::string &text, int x, int y, - gcn::Graphics::Alignment alignment, gcn::Color colour); + gcn::Graphics::Alignment alignment, + gcn::Color colour); /** * Remove the text from the screen @@ -77,12 +86,12 @@ class FlashText : public Text virtual ~FlashText() {} /** - * Flash the text for so many refreshes + * Flash the text for so many refreshes. */ void flash(int time) {mTime = time; } /** - * Draws the text + * Draws the text. */ virtual void draw(gcn::Graphics *graphics, int xOff, int yOff); diff --git a/src/textmanager.cpp b/src/textmanager.cpp index d40ba4d2..6bc8f8b6 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -1,27 +1,29 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +/* + * Support for non-overlapping floating text + * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "textmanager.h" #include <cstring> #include "text.h" -#include "textmanager.h" TextManager *textManager = 0; diff --git a/src/textmanager.h b/src/textmanager.h index b1e10f08..ee8e1209 100644 --- a/src/textmanager.h +++ b/src/textmanager.h @@ -1,22 +1,23 @@ -/*************************************************************************** - * Copyright (C) 2008 by Douglas Boffey * - * * - * DougABoffey@netscape.net * - * This program 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 * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +/* + * Support for non-overlapping floating text + * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> + * + * This file is part of The Mana World. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef TEXTMANAGER_H #define TEXTMANAGER_H diff --git a/src/aethyra.rc b/src/tmw.rc index d2db954f..9661ac6b 100644 --- a/src/aethyra.rc +++ b/src/tmw.rc @@ -1,22 +1,23 @@ -#include <windows.h> // include for version info constants
-
-#include "winver.h"
-
-A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "data/icons/aethyra.ico"
-
-1 VERSIONINFO
-FILEVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD
-PRODUCTVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD
-FILETYPE VFT_APP {
- BLOCK "StringFileInfo" {
- BLOCK "040904E4" {
- VALUE "CompanyName", "Aethyra Development Team"
- VALUE "FileVersion", PACKAGE_VERSION
- VALUE "FileDescription", "Aethyra Experiment"
- VALUE "LegalCopyright", "2008 (C)"
- VALUE "OriginalFilename", "aethyra.exe"
- VALUE "ProductName", "Aethyra MMORPG"
- VALUE "ProductVersion", PACKAGE_VERSION
- }
- }
+#include <windows.h> // include for version info constants + +#include "winver.h" + +A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "data/icons/tmw.ico" + +1 VERSIONINFO +FILEVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD +PRODUCTVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD +FILETYPE VFT_APP { + BLOCK "StringFileInfo" { + BLOCK "040904E4" { + VALUE "CompanyName", "The Mana World Development Team" + VALUE "FileVersion", PACKAGE_VERSION + VALUE "FileDescription", "The Mana World" + VALUE "LegalCopyright", "2004-2006 (C)" + VALUE "OriginalFilename", "tmw.exe" + VALUE "ProductName", "The Mana World MMORPG" + VALUE "ProductVersion", PACKAGE_VERSION + } + } } + diff --git a/src/utils/dtor.h b/src/utils/dtor.h index 0b71fa50..8dbc441f 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -51,5 +51,4 @@ inline void delete_all(Container &c) std::for_each(c.begin(), c.end(), make_dtor(c)); } - #endif diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 24058558..d5dd54be 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -28,7 +28,7 @@ namespace XML { Document::Document(const std::string &filename): - mDoc(NULL) + mDoc(0) { int size; ResourceManager *resman = ResourceManager::getInstance(); @@ -87,7 +87,8 @@ namespace XML return ret; } - std::string getProperty(xmlNodePtr node, const char *name, const std::string &def) + std::string getProperty(xmlNodePtr node, const char *name, + const std::string &def) { xmlChar *prop = xmlGetProp(node, BAD_CAST name); if (prop) { @@ -107,4 +108,5 @@ namespace XML return NULL; } -} + +} // namespace XML diff --git a/src/utils/xml.h b/src/utils/xml.h index 2e08dd50..76a63ff4 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -22,10 +22,10 @@ #ifndef XML_H #define XML_H -#include <string> - #include <libxml/tree.h> +#include <string> + /** * XML helper functions. */ @@ -81,7 +81,8 @@ namespace XML /** * Gets a string property from an xmlNodePtr. */ - std::string getProperty(xmlNodePtr node, const char *name, const std::string &def); + std::string getProperty(xmlNodePtr node, const char *name, + const std::string &def); /** * Finds the first child node with the given name diff --git a/src/winver.h b/src/winver.h index ac53cd73..45043409 100644 --- a/src/winver.h +++ b/src/winver.h @@ -1,6 +1,6 @@ -/* VERSION DEFINITIONS */
-#define VER_MAJOR 0
-#define VER_MINOR 0
-#define VER_RELEASE 27
-#define VER_BUILD 1
-#define PACKAGE_VERSION "0.0.27.1" +/* VERSION DEFINITIONS */ +#define VER_MAJOR 0 +#define VER_MINOR 0 +#define VER_RELEASE 28 +#define VER_BUILD 0 +#define PACKAGE_VERSION "0.0.28" |