From e7c3c0ae918caf70f67b378743f0ede929285e42 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Sun, 20 May 2007 20:27:32 +0000 Subject: Added different target cursor sizes for monsters. Graphics for small and large cursor are provisional until better versions based on the original SVG of the medium sized one are available. --- ChangeLog | 22 +++++++-- data/graphics/gui/target-cursor-blue-l.png | Bin 0 -> 19137 bytes data/graphics/gui/target-cursor-blue-m.png | Bin 0 -> 8353 bytes data/graphics/gui/target-cursor-blue-s.png | Bin 0 -> 8227 bytes data/graphics/gui/target-cursor-red-l.png | Bin 0 -> 18825 bytes data/graphics/gui/target-cursor-red-m.png | Bin 0 -> 8361 bytes data/graphics/gui/target-cursor-red-s.png | Bin 0 -> 8134 bytes src/being.h | 14 ++++++ src/gui/viewport.cpp | 74 ++++++++++++++++++++--------- src/gui/viewport.h | 21 ++++---- src/monster.cpp | 6 +++ src/monster.h | 3 ++ src/resources/monsterdb.cpp | 21 ++++++++ src/resources/monsterinfo.h | 11 ++++- 14 files changed, 135 insertions(+), 37 deletions(-) create mode 100644 data/graphics/gui/target-cursor-blue-l.png create mode 100644 data/graphics/gui/target-cursor-blue-m.png create mode 100644 data/graphics/gui/target-cursor-blue-s.png create mode 100644 data/graphics/gui/target-cursor-red-l.png create mode 100644 data/graphics/gui/target-cursor-red-m.png create mode 100644 data/graphics/gui/target-cursor-red-s.png diff --git a/ChangeLog b/ChangeLog index d7fa45b6..6f4b865e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,11 +4,23 @@ 2007-05-20 Philipp Sehmisch - * src/gui/buy.cpp, src/gui/sell.cpp: Unified some differences between - buy and sell dialog. Money label now shows money after transaction - instead of current money. - * src/gui/sell.cpp: Fixed the amount-not-reset-when-using-scrollwheel - bug. + * src/gui/buy.cpp, src/gui/sell.cpp: Unified some differences between buy + and sell dialog. Money label now shows money after transaction instead of + current money. + * src/gui/sell.cpp: Fixed the amount-not-reset-when-using-scrollwheel bug. + * src/being.h, src/gui/viewport.cpp, src/gui/viewport.h: Added 3 different + target cursor sizes. + * src/monster.h, src/monster.cpp, src/resources/monsterdb.cpp, + scr/resources/monsterinfo.h, data/monsters.xml: Target cursor size for monster + is read from the monsters.xml. + * data/graphics/gui/target-cursor-blue-s.png, + data/graphics/gui/target-cursor-blue-m.png, + data/graphics/gui/target-cursor-blue-l.png, + data/graphics/gui/target-cursor-red-s.png, + data/graphics/gui/target-cursor-red-m.png, + data/graphics/gui/target-cursor-red-l.png: Added temporary placeholders for + small and large target cursors until better versions based on the original + SVG are available. 2007-05-08 Philipp Sehmisch diff --git a/data/graphics/gui/target-cursor-blue-l.png b/data/graphics/gui/target-cursor-blue-l.png new file mode 100644 index 00000000..6f575bd7 Binary files /dev/null and b/data/graphics/gui/target-cursor-blue-l.png differ diff --git a/data/graphics/gui/target-cursor-blue-m.png b/data/graphics/gui/target-cursor-blue-m.png new file mode 100644 index 00000000..3e81c75d Binary files /dev/null and b/data/graphics/gui/target-cursor-blue-m.png differ diff --git a/data/graphics/gui/target-cursor-blue-s.png b/data/graphics/gui/target-cursor-blue-s.png new file mode 100644 index 00000000..0f515d59 Binary files /dev/null and b/data/graphics/gui/target-cursor-blue-s.png differ diff --git a/data/graphics/gui/target-cursor-red-l.png b/data/graphics/gui/target-cursor-red-l.png new file mode 100644 index 00000000..d3ef5849 Binary files /dev/null and b/data/graphics/gui/target-cursor-red-l.png differ diff --git a/data/graphics/gui/target-cursor-red-m.png b/data/graphics/gui/target-cursor-red-m.png new file mode 100644 index 00000000..09195f44 Binary files /dev/null and b/data/graphics/gui/target-cursor-red-m.png differ diff --git a/data/graphics/gui/target-cursor-red-s.png b/data/graphics/gui/target-cursor-red-s.png new file mode 100644 index 00000000..44e49aec Binary files /dev/null and b/data/graphics/gui/target-cursor-red-s.png differ diff --git a/src/being.h b/src/being.h index a1f59c91..cdae05dc 100644 --- a/src/being.h +++ b/src/being.h @@ -93,6 +93,13 @@ class Being : public Sprite VECTOREND_SPRITE }; + enum TargetCursorSize { + TC_SMALL = 0, + TC_MEDIUM, + TC_LARGE, + NUM_TC + }; + /** * Directions, to be used as bitmask values @@ -362,6 +369,13 @@ class Being : public Sprite virtual int getHeight() const; + /** + * Returns the required size of a target cursor for this being + */ + virtual Being::TargetCursorSize + getTargetCursorSize() const + { return TC_MEDIUM; } + std::auto_ptr mEquipment; /** diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 3def2055..17b072cf 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -68,37 +68,63 @@ Viewport::Viewport(): mPopupMenu = new PopupMenu(); // Load target cursors + loadTargetCursor("graphics/gui/target-cursor-blue-s.png", 32, 25, + false, Being::TC_SMALL); + loadTargetCursor("graphics/gui/target-cursor-red-s.png", 32, 25, + true, Being::TC_SMALL); + loadTargetCursor("graphics/gui/target-cursor-blue-m.png", 44, 35, + false, Being::TC_MEDIUM); + loadTargetCursor("graphics/gui/target-cursor-red-m.png", 44, 35, + true, Being::TC_MEDIUM); + loadTargetCursor("graphics/gui/target-cursor-blue-l.png", 57, 45, + false, Being::TC_LARGE); + loadTargetCursor("graphics/gui/target-cursor-red-l.png", 57, 45, + true, Being::TC_LARGE); +} + +void +Viewport::loadTargetCursor (std::string filename, int width, int height, + bool outRange, Being::TargetCursorSize size) +{ + assert(size > -1); + assert(size < 3); + + ImageSet* currentImageSet; + SimpleAnimation* currentCursor; + ResourceManager *resman = ResourceManager::getInstance(); - mInRangeImages = resman->getImageSet( - "graphics/gui/target-cursor-blue.png", 44, 35); - mOutRangeImages = resman->getImageSet( - "graphics/gui/target-cursor-red.png", 44, 35); - Animation *animInRange = new Animation(); - Animation *animOutRange = new Animation(); - - for (unsigned int i = 0; i < mInRangeImages->size(); ++i) + + currentImageSet = resman->getImageSet(filename, width, height); + Animation *anim = new Animation(); + for (unsigned int i = 0; i < currentImageSet->size(); ++i) { - animInRange->addFrame(mInRangeImages->get(i), 75, 0, 0); + anim->addFrame(currentImageSet->get(i), 75, 0, 0); } + currentCursor = new SimpleAnimation(anim); - for (unsigned int j = 0; j < mOutRangeImages->size(); ++j) + if (outRange) { - animOutRange->addFrame(mOutRangeImages->get(j), 75, 0, 0); + mOutRangeImages[size] = currentImageSet; + mTargetCursorOutRange[size] = currentCursor; + } + else { + mInRangeImages[size] = currentImageSet; + mTargetCursorInRange[size] = currentCursor; } - - mTargetCursorInRange = new SimpleAnimation(animInRange); - mTargetCursorOutRange = new SimpleAnimation(animOutRange); } Viewport::~Viewport() { delete mPopupMenu; - delete mTargetCursorInRange; - delete mTargetCursorOutRange; + delete[] mTargetCursorInRange; + delete[] mTargetCursorOutRange; - mInRangeImages->decRef(); - mOutRangeImages->decRef(); + for (int i = Being::TC_SMALL; i < Being::NUM_TC; i++) + { + mInRangeImages[i]->decRef(); + mOutRangeImages[i]->decRef(); + } } void @@ -262,8 +288,11 @@ Viewport::logic() mWalkTime = player_node->mWalkTime; } - mTargetCursorInRange->update(10); - mTargetCursorOutRange->update(10); + for(int i = 0; i < 3; i++) + { + mTargetCursorInRange[i]->update(10); + mTargetCursorOutRange[i]->update(10); + } } void @@ -281,13 +310,14 @@ Viewport::drawTargetCursor(Graphics *graphics) int attackRange = player_node->getAttackRange(); // get the correct target cursors graphic + Being::TargetCursorSize cursorSize = target->getTargetCursorSize(); Image* targetCursor; if (rangeX > attackRange || rangeY > attackRange) { - targetCursor = mTargetCursorOutRange->getCurrentImage(); + targetCursor = mTargetCursorOutRange[cursorSize]->getCurrentImage(); } else { - targetCursor = mTargetCursorInRange->getCurrentImage(); + targetCursor = mTargetCursorInRange[cursorSize]->getCurrentImage(); } // Draw the target cursor at the correct position diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 84efeff3..a0f69407 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -29,9 +29,9 @@ #include "windowcontainer.h" #include "../configlistener.h" +#include "../being.h" class Map; -class Being; class FloorItem; class ImageSet; class Item; @@ -141,6 +141,13 @@ class Viewport : public WindowContainer, public gcn::MouseListener, */ void showPopup(int x, int y, Being *being); + /** + * Helper function for loading target cursors + */ + void + loadTargetCursor(std::string filename, int width, int height, + bool outRange, Being::TargetCursorSize size); + /** * Draws range based target cursor */ @@ -164,14 +171,10 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int mCameraY; /**< Current viewpoint in tiles. */ bool mShowDebugPath; /**< Show a path from player to pointer. */ - ImageSet *mInRangeImages; /**< Images of in range target cursor. */ - ImageSet *mOutRangeImages; /**< Images of out of range target cursor.*/ - - /** Animated in range target cursor. */ - SimpleAnimation *mTargetCursorInRange; - - /** Animated out of range target cursor. */ - SimpleAnimation *mTargetCursorOutRange; + ImageSet *mInRangeImages[Being::NUM_TC]; /**< Images of in range target cursor. */ + ImageSet *mOutRangeImages[Being::NUM_TC]; /**< Images of out of range target cursor.*/ + SimpleAnimation *mTargetCursorInRange[Being::NUM_TC]; /**< Animated in range target cursor. */ + SimpleAnimation *mTargetCursorOutRange[Being::NUM_TC];/**< Animated out of range target cursor. */ bool mPlayerFollowMouse; int mWalkTime; diff --git a/src/monster.cpp b/src/monster.cpp index c20e12d0..687fe625 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -103,6 +103,12 @@ Monster::handleAttack(Being *victim, int damage) sound.playSfx(mi.getSound((damage > 0) ? EVENT_HIT : EVENT_MISS)); } +Being::TargetCursorSize +Monster::getTargetCursorSize() const +{ + return getInfo().getTargetCursorSize(); +} + const MonsterInfo& Monster::getInfo() const { diff --git a/src/monster.h b/src/monster.h index 0e0e1af5..4a24068f 100644 --- a/src/monster.h +++ b/src/monster.h @@ -39,6 +39,9 @@ class Monster : public Being virtual Type getType() const; + virtual TargetCursorSize + getTargetCursorSize() const; + /** * Handles an attack of another being by this monster. Plays a hit or * miss sound when appropriate. diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index ac3ac3bc..89afc549 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -83,6 +83,27 @@ MonsterDB::load() currentInfo->setName (XML::getProperty(monsterNode, "name", "unnamed")); + std::string targetCursor; + targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium"); + if (targetCursor == "small") + { + currentInfo->setTargetCursorSize(Being::TC_SMALL); + } + else if (targetCursor == "medium") + { + currentInfo->setTargetCursorSize(Being::TC_MEDIUM); + } + else if (targetCursor == "large") + { + currentInfo->setTargetCursorSize(Being::TC_LARGE); + } + else + { + logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s - using medium sized one", + targetCursor.c_str(), currentInfo->getName().c_str()); + currentInfo->setTargetCursorSize(Being::TC_MEDIUM); + } + //iterate s and s for_each_xml_child_node(spriteNode, monsterNode) { diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index b65237da..5a820659 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -28,6 +28,8 @@ #include #include +#include "../being.h" + enum SoundEvent { @@ -62,6 +64,10 @@ class MonsterInfo void setSprite(std::string filename) { mSprite = filename; } + void + setTargetCursorSize(Being::TargetCursorSize targetCursorSize) + { mTargetCursorSize = targetCursorSize; } + void addSound(SoundEvent event, std::string filename); @@ -71,13 +77,16 @@ class MonsterInfo const std::string& getSprite() const { return mSprite; } + const Being::TargetCursorSize + getTargetCursorSize() const { return mTargetCursorSize; } + std::string getSound(SoundEvent event) const; private: std::string mName; std::string mSprite; - + Being::TargetCursorSize mTargetCursorSize; std::map* > mSounds; }; -- cgit v1.2.3-60-g2f50