diff options
Diffstat (limited to 'src')
90 files changed, 1457 insertions, 615 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86deec0c..c7e3d936 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) @@ -81,8 +81,8 @@ SET(SRCS gui/chatinput.h gui/checkbox.cpp gui/checkbox.h - gui/colour.cpp - gui/colour.h + gui/color.cpp + gui/color.h gui/confirm_dialog.cpp gui/confirm_dialog.h gui/connection.cpp @@ -164,8 +164,8 @@ SET(SRCS gui/setup.h gui/setup_audio.cpp gui/setup_audio.h - gui/setup_colours.cpp - gui/setup_colours.h + gui/setup_colors.cpp + gui/setup_colors.h gui/setup_joystick.cpp gui/setup_joystick.h gui/setup_keyboard.cpp @@ -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 4a6461dd..8de13464 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,8 @@ AUTOMAKE_OPTIONS = subdir-objects -bin_PROGRAMS = aethyra -aethyra_SOURCES = gui/widgets/dropdown.cpp \ - gui/widgets/dropdown.h \ +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 \ @@ -31,8 +31,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ gui/chatinput.h \ gui/checkbox.cpp \ gui/checkbox.h \ - gui/colour.cpp \ - gui/colour.h \ + gui/color.cpp \ + gui/color.h \ gui/confirm_dialog.cpp \ gui/confirm_dialog.h \ gui/connection.cpp \ @@ -100,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 \ @@ -114,8 +114,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ gui/setup.h \ gui/setup_audio.cpp \ gui/setup_audio.h \ - gui/setup_colours.cpp \ - gui/setup_colours.h \ + gui/setup_colors.cpp \ + gui/setup_colors.h \ gui/setup_joystick.cpp \ gui/setup_joystick.h \ gui/setup_keyboard.cpp \ @@ -335,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 \ @@ -347,12 +349,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ # set the include path found by configure INCLUDES = \ - $(all_includes) \ - -DPKG_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) \ + -DPKG_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 0ac86d13..521947e3 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" @@ -50,11 +49,17 @@ #include "gui/speechbubble.h" #include "utils/dtor.h" -#include "utils/gettext.h" -#include "utils/tostring.h" +#include "utils/gettext.h" +#include "utils/tostring.h" #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); @@ -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) @@ -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); @@ -545,6 +564,62 @@ 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 @@ -602,3 +677,175 @@ int Being::getHeight() const } } + +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 colors -> black only + hairColorsNr = 1; + hairColors.resize(hairColorsNr, "#000000"); + } + + hairInitialized = 1; +} diff --git a/src/being.h b/src/being.h index dcbd3553..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 */ @@ -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/game.cpp b/src/game.cpp index f8903ed2..48ca1c73 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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(); } @@ -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) diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 65659df6..48b1cda4 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -24,7 +24,7 @@ #include <guichan/graphics.hpp> #include "browserbox.h" -#include "colour.h" +#include "color.h" #include "linkhandler.h" #include "truetypefont.h" @@ -254,7 +254,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) bool valid; if ((mHighMode & BACKGROUND)) { - graphics->setColor(gcn::Color(textColour->getColour('H', valid))); + graphics->setColor(gcn::Color(textColor->getColor('H', valid))); graphics->fillRectangle(gcn::Rectangle( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, @@ -265,7 +265,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) if ((mHighMode & UNDERLINE)) { - graphics->setColor(gcn::Color(textColour->getColour('<', valid))); + graphics->setColor(gcn::Color(textColor->getColor('<', valid))); graphics->drawLine( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y2, @@ -331,7 +331,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) else { bool valid; - int rgb = textColour->getColour(c, valid); + int rgb = textColor->getColor(c, valid); if (c == '<') { const int size = mLinks[link].x2 - mLinks[link].x1; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 92dd46d7..1c0cea13 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -143,13 +143,15 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) 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: @@ -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") { @@ -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()) { diff --git a/src/gui/colour.cpp b/src/gui/color.cpp index cdb5a3fd..e37affda 100644 --- a/src/gui/colour.cpp +++ b/src/gui/color.cpp @@ -19,40 +19,40 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "colour.h" +#include "color.h" #include "../configuration.h" #include "../utils/gettext.h" #include "../utils/tostring.h" -Colour::Colour() +Color::Color() { - addColour('C', 0x000000, _("Chat")); - addColour('G', 0xff0000, _("GM")); - addColour('H', 0xebc873, _("Highlight")); - addColour('Y', 0x1fa052, _("Player")); - addColour('W', 0x0000ff, _("Whisper")); - addColour('I', 0xf1dc27, _("Is")); - addColour('P', 0xff00d8, _("Party")); - addColour('S', 0x8415e2, _("Server")); - addColour('L', 0x919191, _("Logger")); - addColour('<', 0xe50d0d, _("Hyperlink")); + addColor('C', 0x000000, _("Chat")); + addColor('G', 0xff0000, _("GM")); + addColor('H', 0xebc873, _("Highlight")); + addColor('Y', 0x1fa052, _("Player")); + addColor('W', 0x0000ff, _("Whisper")); + addColor('I', 0xf1dc27, _("Is")); + addColor('P', 0xff00d8, _("Party")); + addColor('S', 0x8415e2, _("Server")); + addColor('L', 0x919191, _("Logger")); + addColor('<', 0xe50d0d, _("Hyperlink")); commit(); } -Colour::~Colour() +Color::~Color() { for (ColVector::iterator col = mColVector.begin(), colEnd = mColVector.end(); col != colEnd; ++col) { - config.setValue("Colour" + col->text, toString(col->rgb)); + config.setValue("color" + col->text, toString(col->rgb)); } } -void Colour::setColour(const char c, const int rgb) +void Color::setColor(const char c, const int rgb) { for (ColVector::iterator col = mColVector.begin(), colEnd = mColVector.end(); @@ -67,7 +67,7 @@ void Colour::setColour(const char c, const int rgb) } } -int Colour::getColour(const char c, bool &valid) const +int Color::getColor(const char c, bool &valid) const { for (ColVector::const_iterator col = mColVector.begin(), colEnd = mColVector.end(); @@ -84,7 +84,7 @@ int Colour::getColour(const char c, bool &valid) const return 0x000000; } -std::string Colour::getElementAt(int i) +std::string Color::getElementAt(int i) { if (i < 0 || i >= getNumberOfElements()) { @@ -93,7 +93,7 @@ std::string Colour::getElementAt(int i) return mColVector[i].text; } -char Colour::getColourCharAt(int i) +char Color::getColorCharAt(int i) { if (i < 0 || i >= getNumberOfElements()) { @@ -102,13 +102,13 @@ char Colour::getColourCharAt(int i) return mColVector[i].ch; } -void Colour::addColour(const char c, const int rgb, const std::string &text) +void Color::addColor(const char c, const int rgb, const std::string &text) { - int trueRgb = config.getValue("Colour" + text, rgb); - mColVector.push_back(ColourElem(c, trueRgb, text)); + int trueRgb = config.getValue("color" + text, rgb); + mColVector.push_back(colorElem(c, trueRgb, text)); } -int Colour::getColourAt(int i) +int Color::getColorAt(int i) { if (i < 0 || i >= getNumberOfElements()) { @@ -117,7 +117,7 @@ int Colour::getColourAt(int i) return mColVector[i].rgb; } -void Colour::setColourAt(int i, int rgb) +void Color::setColorAt(int i, int rgb) { if (i >= 0 && i < getNumberOfElements()) { @@ -125,7 +125,7 @@ void Colour::setColourAt(int i, int rgb) } } -void Colour::commit() +void Color::commit() { for (ColVector::iterator i = mColVector.begin(), iEnd = mColVector.end(); i != iEnd; @@ -135,7 +135,7 @@ void Colour::commit() } } -void Colour::rollback() +void Color::rollback() { for (ColVector::iterator i = mColVector.begin(), iEnd = mColVector.end(); i != iEnd; diff --git a/src/gui/colour.h b/src/gui/color.h index 6ea02840..509448e7 100644 --- a/src/gui/colour.h +++ b/src/gui/color.h @@ -27,110 +27,110 @@ #include <guichan/listmodel.hpp> -class Colour : public gcn::ListModel +class Color : public gcn::ListModel { public: /** * Constructor */ - Colour(); + Color(); /** * Destructor */ - ~Colour(); + ~Color(); /** - * Define the colour replacement for a character + * Define the color replacement for a character * * @param c charater to be replaced - * @param rgb colour to replace character + * @param rgb color to replace character */ - void setColour(const char c, const int rgb); + void setColor(const char c, const int rgb); /** - * Define the colour replacement for a character + * Define the color replacement for a character * * @param c character to be replaced * @param r red component * @param g green component * @param b blue component */ - void setColour(const char c, const int r, const int g, const int b) + void setColor(const char c, const int r, const int g, const int b) { - setColour(c, (r << 16) | (g << 8) | b); + setColor(c, (r << 16) | (g << 8) | b); } /** - * Return the colour associated with a character, if exists + * Return the color associated with a character, if exists * * @param c character requested * @param valid indicate whether character is known */ - int getColour(const char c, bool &valid) const; + int getColor(const char c, bool &valid) const; /** - * Return the number of colours known + * Return the number of colors known */ int getNumberOfElements() {return mColVector.size(); } /** - * Return the name of the ith colour + * Return the name of the ith color * - * @param i index of colour interested in + * @param i index of color interested in */ std::string getElementAt(int i); /** - * Get the colour for the element at index i in the current colour + * Get the color for the element at index i in the current color * model */ - int getColourAt(int i); + int getColorAt(int i); /** - * Get the character used by the colour for the element at index i in - * the current colour model + * Get the character used by the color for the element at index i in + * the current color model */ - char getColourCharAt(int i); + char getColorCharAt(int i); /** - * Set the colour for the element at index i + * Set the color for the element at index i */ - void setColourAt(int i, int rgb); + void setColorAt(int i, int rgb); /** - * Commit the colours + * Commit the colors */ void commit(); /** - * Rollback the colours + * Rollback the colors */ void rollback(); private: - struct ColourElem + struct colorElem { - ColourElem(const char c, const int rgb, const std::string &text) : + colorElem(const char c, const int rgb, const std::string &text) : ch(c), rgb(rgb), text(text) {} char ch; int rgb; int committedRgb; std::string text; }; - typedef std::vector<ColourElem> ColVector; + typedef std::vector<colorElem> ColVector; ColVector mColVector; /** - * Initialise colour + * Initialise color * * @param c character that needs initialising - * @param rgb default colour if not found in config - * @param text identifier of colour + * @param rgb default color if not found in config + * @param text identifier of color */ - void addColour(const char c, const int rgb, const std::string &text); + void addColor(const char c, const int rgb, const std::string &text); }; -extern Colour *textColour; +extern Color *textColor; #endif 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/gui.cpp b/src/gui/gui.cpp index 7779a503..87304bd1 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -134,7 +134,7 @@ Gui::Gui(Graphics *graphics): gcn::Widget::setGlobalFont(mGuiFont); - // Load hits' colourful fonts + // Load hits' colorful fonts try { hitRedFont = new gcn::ImageFont("graphics/gui/hits_red.png", 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 23b9e5e1..71fcc5d0 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -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 ddce449a..df7afa48 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -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 1d37346e..c820e3a0 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -5,18 +5,18 @@ * * 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 */ 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/listbox.cpp b/src/gui/listbox.cpp index b63d6424..63e55e24 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -23,7 +23,7 @@ #include <guichan/graphics.hpp> #include <guichan/listmodel.hpp> -#include "colour.h" +#include "color.h" #include "listbox.h" #include "../configuration.h" @@ -44,9 +44,9 @@ void ListBox::draw(gcn::Graphics *graphics) mAlpha = config.getValue("guialpha", 0.8); bool valid; - const int red = (textColour->getColour('H', valid) >> 16) & 0xFF; - const int green = (textColour->getColour('H', valid) >> 8) & 0xFF; - const int blue = textColour->getColour('H', valid) & 0xFF; + const int red = (textColor->getColor('H', valid) >> 16) & 0xFF; + const int green = (textColor->getColor('H', valid) >> 8) & 0xFF; + const int blue = textColor->getColor('H', valid) & 0xFF; const int alpha = mAlpha * 255; graphics->setColor(gcn::Color(red, green, blue, alpha)); diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 3c8e7cb3..47d5a99e 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -54,13 +54,9 @@ 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"); std::vector<std::string> dfltPort; - dfltPort.push_back("21001"); - dfltPort.push_back("22001"); - dfltPort.push_back("21001"); + dfltPort.push_back("6901"); mServerList = new DropDownList("MostRecent00", dfltServer, dfltPort, MAX_SERVER_LIST_SIZE); mServerListBox = new ListBox(mServerList); @@ -75,7 +71,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/ministatus.cpp b/src/gui/ministatus.cpp index 13351915..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 @@ -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/popupmenu.cpp b/src/gui/popupmenu.cpp index 53c24960..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,38 +66,38 @@ 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(); + 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; + 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 + "@@"); @@ -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 && + 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,12 +208,12 @@ 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); - buddyWindow->addBuddy(mBeing->getName()); + buddyWindow->addBuddy(being->getName()); }*/ // Pick Up Floor Item action @@ -254,12 +257,12 @@ void PopupMenu::handleLink(const std::string& link) 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()); + outMsg.writeInt32(being->getId()); } // Unknown actions @@ -270,7 +273,7 @@ void PopupMenu::handleLink(const std::string& link) setVisible(false); - mBeing = NULL; + mBeingId = 0; mFloorItem = NULL; mItem = NULL; } 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.cpp b/src/gui/recorder.cpp index c7989495..153bffae 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -2,7 +2,7 @@ * 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 diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 4f41ff42..0bbab012 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -2,7 +2,7 @@ * 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 diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 19575cfb..09eaeff0 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -22,7 +22,7 @@ #include "button.h" #include "setup.h" #include "setup_audio.h" -#include "setup_colours.h" +#include "setup_colors.h" #include "setup_joystick.h" #include "setup_keyboard.h" #include "setup_players.h" @@ -90,7 +90,7 @@ Setup::Setup(): panel->addTab(_("Keyboard"), tab); mTabs.push_back(tab); - tab = new Setup_Colours(); + tab = new Setup_Colors(); panel->addTab(_("Colors"), tab); mTabs.push_back(tab); diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colors.cpp index 49e08aeb..269f8fd1 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colors.cpp @@ -20,17 +20,18 @@ */ #include <string> +#include <cmath> #include <guichan/listmodel.hpp> #include <guichan/widgets/label.hpp> #include <guichan/widgets/slider.hpp> #include "browserbox.h" -#include "colour.h" +#include "color.h" #include "itemlinkhandler.h" #include "listbox.h" #include "scrollarea.h" -#include "setup_colours.h" +#include "setup_colors.h" #include "slider.h" #include "textfield.h" @@ -41,16 +42,16 @@ #include "../utils/gettext.h" #include "../utils/tostring.h" -Setup_Colours::Setup_Colours() : +Setup_Colors::Setup_Colors() : mSelected(-1) { setOpaque(false); - mColourBox = new ListBox(textColour); - mColourBox->setActionEventId("colour_box"); - mColourBox->addActionListener(this); + mcolorBox = new ListBox(textColor); + mcolorBox->setActionEventId("color_box"); + mcolorBox->addActionListener(this); - mScroll = new ScrollArea(mColourBox); + mScroll = new ScrollArea(mcolorBox); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mPreview = new BrowserBox(BrowserBox::AUTO_WRAP); @@ -128,7 +129,7 @@ Setup_Colours::Setup_Colours() : setDimension(gcn::Rectangle(0, 0, 290, 250)); } -Setup_Colours::~Setup_Colours() +Setup_Colors::~Setup_Colors() { delete mRedLabel; delete mRedSlider; @@ -145,20 +146,20 @@ Setup_Colours::~Setup_Colours() delete mScroll; } -void Setup_Colours::action(const gcn::ActionEvent &event) +void Setup_Colors::action(const gcn::ActionEvent &event) { - if (event.getId() == "colour_box") + if (event.getId() == "color_box") { - mSelected = mColourBox->getSelected(); - int col = textColour->getColourAt(mSelected); - char ch = textColour->getColourCharAt(mSelected); + mSelected = mcolorBox->getSelected(); + int col = textColor->getColorAt(mSelected); + char ch = textColor->getColorCharAt(mSelected); std::string msg; if (ch == '<') - msg = toString("@@|") + + msg = toString("@@|") + _("This is what the color looks like") + "@@"; else - msg = "##" + toString(ch) + + msg = "##" + toString(ch) + _("This is what the color looks like"); mPreview->clearRows(); @@ -171,33 +172,27 @@ void Setup_Colours::action(const gcn::ActionEvent &event) if (event.getId() == "slider_red") { - char buffer[30]; - std::sprintf(buffer, "%d", static_cast<int>(mRedSlider->getValue())); - mRedText->setText(buffer); - updateColour(); + mRedText->setText(toString(std::floor(mRedSlider->getValue()))); + updateColor(); return; } if (event.getId() == "slider_green") { - char buffer[30]; - std::sprintf(buffer, "%d", static_cast<int>(mGreenSlider->getValue())); - mGreenText->setText(buffer); - updateColour(); + mGreenText->setText(toString(std::floor(mGreenSlider->getValue()))); + updateColor(); return; } if (event.getId() == "slider_blue") { - char buffer[30]; - std::sprintf(buffer, "%d", static_cast<int>(mBlueSlider->getValue())); - mBlueText->setText(buffer); - updateColour(); + mBlueText->setText(toString(std::floor(mBlueSlider->getValue()))); + updateColor(); return; } } -void Setup_Colours::setEntry(gcn::Slider *s, TextField *t, int value) +void Setup_Colors::setEntry(gcn::Slider *s, TextField *t, int value) { s->setValue(value); char buffer[100]; @@ -205,43 +200,43 @@ void Setup_Colours::setEntry(gcn::Slider *s, TextField *t, int value) t->setText(buffer); } -void Setup_Colours::apply() +void Setup_Colors::apply() { - textColour->commit(); + textColor->commit(); } -void Setup_Colours::cancel() +void Setup_Colors::cancel() { - textColour->rollback(); - int col = textColour->getColourAt(mSelected); + textColor->rollback(); + int col = textColor->getColorAt(mSelected); setEntry(mRedSlider, mRedText, col >> 16); setEntry(mGreenSlider, mGreenText, (col >> 8) & 0xff); setEntry(mBlueSlider, mBlueText, col & 0xff); } -void Setup_Colours::listen(const TextField *tf) +void Setup_Colors::listen(const TextField *tf) { if (tf == mRedText) { mRedSlider->setValue(tf->getValue()); - updateColour(); + updateColor(); return; } if (tf == mGreenText) { mGreenSlider->setValue(tf->getValue()); - updateColour(); + updateColor(); return; } if (tf == mBlueText) { mBlueSlider->setValue(tf->getValue()); - updateColour(); + updateColor(); return; } } -void Setup_Colours::updateColour() +void Setup_Colors::updateColor() { if (mSelected == -1) { @@ -250,5 +245,5 @@ void Setup_Colours::updateColour() int rgb = static_cast<int>(mRedSlider->getValue()) << 16 | static_cast<int>(mGreenSlider->getValue()) << 8 | static_cast<int>(mBlueSlider->getValue()); - textColour->setColourAt(mSelected, rgb); + textColor->setColorAt(mSelected, rgb); } diff --git a/src/gui/setup_colours.h b/src/gui/setup_colors.h index 57d9e304..1e56cfa8 100644 --- a/src/gui/setup_colours.h +++ b/src/gui/setup_colors.h @@ -36,19 +36,19 @@ class BrowserBox; -class Setup_Colours : public SetupTab, public gcn::ActionListener, +class Setup_Colors : public SetupTab, public gcn::ActionListener, public TextFieldListener { public: - Setup_Colours(); - ~Setup_Colours(); + Setup_Colors(); + ~Setup_Colors(); void apply(); void cancel(); void action(const gcn::ActionEvent &event); void listen(const TextField *tf); private: - gcn::ListBox *mColourBox; + gcn::ListBox *mcolorBox; gcn::ScrollArea *mScroll; BrowserBox *mPreview; gcn::ScrollArea *mPreviewBox; @@ -70,6 +70,6 @@ class Setup_Colours : public SetupTab, public gcn::ActionListener, int mBlueValue; void setEntry(gcn::Slider *s, TextField *t, int value); - void updateColour(); + void updateColor(); }; #endif 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/shoplistbox.cpp b/src/gui/shoplistbox.cpp index b5761535..94187818 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -22,7 +22,7 @@ #include <guichan/font.hpp> #include <guichan/listmodel.hpp> -#include "colour.h" +#include "color.h" #include "shop.h" #include "shoplistbox.h" @@ -64,9 +64,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) mAlpha = config.getValue("guialpha", 0.8); bool valid; - const int red = (textColour->getColour('H', valid) >> 16) & 0xFF; - const int green = (textColour->getColour('H', valid) >> 8) & 0xFF; - const int blue = textColour->getColour('H', valid) & 0xFF; + const int red = (textColor->getColor('H', valid) >> 16) & 0xFF; + const int green = (textColor->getColor('H', valid) >> 8) & 0xFF; + const int blue = textColor->getColor('H', valid) & 0xFF; const int alpha = mAlpha * 255; Graphics *graphics = static_cast<Graphics*>(gcnGraphics); diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index dd7c3a4e..5cf8c51f 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -45,9 +45,14 @@ struct SkillInfo { bool modifiable; }; +static const SkillInfo fakeSkillInfo = { + _("Mystery Skill"), + false +}; + std::vector<SkillInfo> skill_db; -static void initSkillinfo(void); +static void initSkillinfo(); class SkillGuiTableModel : public StaticTableModel { @@ -73,15 +78,13 @@ public: return 35; } - virtual int getRowHeight(void) + virtual int getRowHeight() { return 12; } - virtual void update(void) + virtual void update() { - static const SkillInfo fakeSkillInfo = { _("???"), false }; - mEntriesNr = mDialog->getSkills().size(); resize(); @@ -112,7 +115,6 @@ public: } } - private: SkillDialog *mDialog; int mEntriesNr; @@ -172,10 +174,18 @@ void SkillDialog::action(const gcn::ActionEvent &event) if (selectedSkill >= 0) player_node->raiseSkill(mSkillList[selectedSkill]->id); } - else if (event.getId() == "skill") + else if (event.getId() == "skill" && mTable->getSelectedRow() > -1) { - mIncButton->setEnabled(mTable->getSelectedRow() > -1 && - player_node->mSkillPoint > 0); + SKILL *skill = mSkillList[mTable->getSelectedRow()]; + SkillInfo const *info; + + if (skill->id >= 0 && (unsigned int) skill->id < skill_db.size()) + info = &skill_db[skill->id]; + else + info = &fakeSkillInfo; + + mIncButton->setEnabled(player_node->mSkillPoint > 0 && + info->modifiable); } else if (event.getId() == "close") setVisible(false); @@ -246,11 +256,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 43267a4e..d2d81332 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -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/status.cpp b/src/gui/status.cpp index 271b6f1e..e8426ec4 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..1ee9da0f 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -23,7 +23,7 @@ #include <guichan/graphics.hpp> #include <guichan/key.hpp> -#include "colour.h" +#include "color.h" #include "table.h" #include "../configuration.h" @@ -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 @@ -199,7 +199,7 @@ void GuiTable::setSelectedRow(int selected) { mSelectedRow = 0; } - else if ((selected >= mModel->getRows() && !mWrappingEnabled) || + else if ((selected >= mModel->getRows() && !mWrappingEnabled) || (selected < 0 && mWrappingEnabled)) { mSelectedRow = mModel->getRows() - 1; @@ -224,7 +224,7 @@ void GuiTable::setSelectedColumn(int selected) { mSelectedColumn = 0; } - else if ((selected >= mModel->getColumns() && !mWrappingEnabled) || + else if ((selected >= mModel->getColumns() && !mWrappingEnabled) || (selected < 0 && mWrappingEnabled)) { mSelectedColumn = mModel->getColumns() - 1; @@ -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; @@ -324,11 +324,11 @@ void GuiTable::draw(gcn::Graphics* graphics) if (!mLinewiseMode && c == mSelectedColumn && r == mSelectedRow) { bool valid; - const int red = - (textColour->getColour('H', valid) >> 16) & 0xFF; + const int red = + (textColor->getColor('H', valid) >> 16) & 0xFF; const int green = - (textColour->getColour('H', valid) >> 8) & 0xFF; - const int blue = textColour->getColour('H', valid) & 0xFF; + (textColor->getColor('H', valid) >> 8) & 0xFF; + const int blue = textColor->getColor('H', valid) & 0xFF; const int alpha = mAlpha * 127; graphics->setColor(gcn::Color(red, green, blue, alpha)); @@ -346,11 +346,11 @@ void GuiTable::draw(gcn::Graphics* graphics) if (mLinewiseMode && r == mSelectedRow) { bool valid; - const int red = - (textColour->getColour('H', valid) >> 16) & 0xFF; + const int red = + (textColor->getColor('H', valid) >> 16) & 0xFF; const int green = - (textColour->getColour('H', valid) >> 8) & 0xFF; - const int blue = textColour->getColour('H', valid) & 0xFF; + (textColor->getColor('H', valid) >> 8) & 0xFF; + const int blue = textColor->getColor('H', valid) & 0xFF; const int alpha = mAlpha * 127; graphics->setColor(gcn::Color(red, green, blue, alpha)); @@ -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()); } @@ -401,25 +401,25 @@ void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) else if (key.getValue() == gcn::Key::UP) { setSelectedRow(mSelectedRow - 1); - + keyEvent.consume(); } else if (key.getValue() == gcn::Key::DOWN) { setSelectedRow(mSelectedRow + 1); - + keyEvent.consume(); } else if (key.getValue() == gcn::Key::LEFT) { setSelectedColumn(mSelectedColumn - 1); - + keyEvent.consume(); } else if (key.getValue() == gcn::Key::RIGHT) { setSelectedColumn(mSelectedColumn + 1); - + keyEvent.consume(); } else if (key.getValue() == gcn::Key::HOME) @@ -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/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 6b6c982a..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; @@ -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); } diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 31d35cb0..29c6c69c 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -23,7 +23,7 @@ #include "dropdown.h" -#include "../colour.h" +#include "../color.h" #include "../listbox.h" #include "../scrollarea.h" @@ -40,7 +40,7 @@ Image *DropDown::buttons[2][2]; ImageRect DropDown::skin; float DropDown::mAlpha = config.getValue("guialpha", 0.8); -DropDown::DropDown(gcn::ListModel *listModel, gcn::ScrollArea *scrollArea, +DropDown::DropDown(gcn::ListModel *listModel, gcn::ScrollArea *scrollArea, gcn::ListBox *listBox, bool opacity): gcn::DropDown::DropDown(listModel, scrollArea, listBox), mOpaque(opacity) @@ -138,7 +138,7 @@ void DropDown::draw(gcn::Graphics* graphics) const int alpha = mAlpha * 255; gcn::Color faceColor = getBaseColor(); faceColor.a = alpha; - gcn::Color highlightColor = textColour->getColour('H', valid); + gcn::Color highlightColor = textColor->getColor('H', valid); highlightColor.a = alpha; gcn::Color shadowColor = faceColor - 0x303030; shadowColor.a = alpha; diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 8000179d..797b4be9 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -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 25bf903a..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 @@ -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 6c836a62..6405966c 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. * 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 d047cc80..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" @@ -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) @@ -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 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 35943abf..244f8972 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,7 +55,7 @@ #include "gui/button.h" #include "gui/char_server.h" #include "gui/char_select.h" -#include "gui/colour.h" +#include "gui/color.h" #include "gui/gui.h" #include "gui/login.h" #include "gui/ok_dialog.h" @@ -135,7 +135,7 @@ CharServerHandler charServerHandler; LoginData loginData; LockedArray<LocalPlayer*> charInfo(MAX_SLOT + 1); -Colour *textColour; +Color *textColor; // This anonymous namespace hides whatever is inside from other modules. namespace { @@ -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 @@ -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 @@ -337,8 +337,8 @@ void init_engine(const Options &options) // Fill configuration with defaults logger->log(_("Initializing configuration...")); - config.setValue("host", "www.aethyra.org"); - config.setValue("port", 21001); + config.setValue("host", "www.themanaworld.org"); + config.setValue("port", 6901); config.setValue("hwaccel", 0); #if (defined __APPLE__ || defined WIN32) && defined USE_OPENGL config.setValue("opengl", 1); @@ -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(PKG_DATADIR "data/icons/aethyra.png"); + SDL_Surface *icon = IMG_Load(PKG_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 } @@ -650,16 +649,11 @@ void accountLogin(Network *network, LoginData *loginData) config.setValue("remember", loginData->remember); } -inline int MIN(int x, int y) -{ - return x < y ? x : y; -} - -void positionDialog(Window *dialog, int screenWidth, int screenHeight) +static void positionDialog(Window *dialog, int screenWidth, int screenHeight) { dialog->setPosition( - MIN(screenWidth * 5 / 8, screenWidth - dialog->getWidth()), - MIN(screenHeight * 5 / 8, screenHeight - dialog->getHeight())); + (screenWidth - dialog->getWidth()) / 2, + (screenHeight - dialog->getHeight()) / 2); } void charLogin(Network *network, LoginData *loginData) @@ -737,11 +731,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 @@ -763,7 +760,7 @@ int main(int argc, char *argv[]) unsigned int oldstate = !state; // We start with a status change. // Needs to be created in main, as the updater uses it - textColour = new Colour(); + textColor = new Color(); Game *game = NULL; Window *currentDialog = NULL; @@ -796,8 +793,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; @@ -820,7 +817,10 @@ int main(int argc, char *argv[]) else if (screenWidth >= 1600) wallpaperName = "graphics/images/login_wallpaper_1600x1200.png"; - login_wallpaper = ResourceManager::getInstance()-> getImage(wallpaperName); + if (!ResourceManager::getInstance()->exists(wallpaperName)) + wallpaperName = "graphics/images/login_wallpaper.png"; + + login_wallpaper = ResourceManager::getInstance()->getImage(wallpaperName); if (!login_wallpaper) logger->log(_("Couldn't load %s as wallpaper"), wallpaperName.c_str()); @@ -870,7 +870,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())); } @@ -984,8 +984,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)-> @@ -1095,7 +1095,7 @@ int main(int argc, char *argv[]) usleep(50000); } - delete textColour; + delete textColor; #ifdef PACKAGE_VERSION delete versionLabel; #endif diff --git a/src/map.cpp b/src/map.cpp index 716e9aee..b5e815f3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -68,10 +68,6 @@ TileAnimation::TileAnimation(Animation *ani): { } -TileAnimation::~TileAnimation() -{ - delete mLastImage; -} void TileAnimation::update() { @@ -330,7 +326,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 +335,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 +353,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 +455,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) @@ -72,7 +72,6 @@ class TileAnimation { public: TileAnimation(Animation *ani); - ~TileAnimation(); void update(); void addAffectedTile(MapLayer *layer, int index) { mAffected.push_back(std::make_pair(layer, index)); } diff --git a/src/monster.cpp b/src/monster.cpp index 4cdcbb11..3b1e4c80 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -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 2f5f0fee..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: @@ -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) @@ -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,10 +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/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/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/colordb.h b/src/resources/colordb.h index 2166abcf..892411f8 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -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/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/resourcemanager.cpp b/src/resources/resourcemanager.cpp index a5d927dd..d005c212 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -213,7 +213,7 @@ std::string ResourceManager::getPath(const std::string &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 3a97c05f..c3c68d88 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -115,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. @@ -125,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 @@ -155,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 5a015139..5d88bd69 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> * Copyright (C) 2008 The Mana World Development Team * - * 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 @@ -20,26 +20,56 @@ * 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 color, bool isSpeech) : + mText(text), + mcolor(color), + 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("speechBubblecolor", "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: @@ -57,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); @@ -69,35 +94,82 @@ 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); - - graphics->setColor(mColour); - graphics->drawText(mText, mX - xOff, mY - yOff, 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(mcolor); + 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) : - Text(text, x, y, alignment, colour), + gcn::Graphics::Alignment alignment, + gcn::Color color) : + Text(text, x, y, alignment, color), mTime(0) { } @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> * Copyright (C) 2008 The Mana World Development Team * - * 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 @@ -24,8 +24,8 @@ #define TEXT_H #include <guichan/color.hpp> -#include <guichan/graphics.hpp> +#include "graphics.h" #include "guichanfwd.h" class TextManager; @@ -39,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 color, bool isSpeech = false); /** * Destructor. The text is removed from the screen. @@ -64,14 +65,20 @@ class Text int mXOffset; /**< The offset of mX from the desired x. */ static int mInstances; /**< Instances of text. */ std::string mText; /**< The text to display. */ - gcn::Color mColour; /**< The colour of the text. */ + gcn::Color mcolor; /**< The color 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 color); /** * Remove the text from the screen @@ -79,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 0cf09478..6bc8f8b6 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -2,7 +2,7 @@ * Support for non-overlapping floating text * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.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 @@ -19,10 +19,11 @@ * 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 d6485e34..ee8e1209 100644 --- a/src/textmanager.h +++ b/src/textmanager.h @@ -2,7 +2,7 @@ * Support for non-overlapping floating text * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.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 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" |