diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/equipmentwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 8 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 32 | ||||
-rw-r--r-- | src/gui/viewport.h | 16 |
4 files changed, 32 insertions, 25 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index ec525c47..ec84491e 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -30,7 +30,6 @@ #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../resources/spriteset.h" #include "../utils/tostring.h" diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 055a07cb..334770f8 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -35,7 +35,6 @@ #include "../resources/image.h" #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../resources/spriteset.h" #include "../utils/tostring.h" @@ -65,7 +64,8 @@ ItemContainer::logic() int i = mInventory->getLastUsedSlot() - 1; // Count from 0, usage from 2 - if (i != mMaxItems) { + if (i != mMaxItems) + { mMaxItems = i; setWidth(getWidth()); } @@ -197,9 +197,9 @@ ItemContainer::mousePressed(gcn::MouseEvent &event) int my = event.getY(); int index = mx / gridWidth + ((my / gridHeight) * columns) + 2; - if (index > INVENTORY_SIZE) { + if (index > INVENTORY_SIZE) index = INVENTORY_SIZE - 1; - } + setSelectedItem(mInventory->getItem(index)); } } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index c1f17804..84634ca6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -41,7 +41,7 @@ #include "../resources/animation.h" #include "../resources/monsterinfo.h" #include "../resources/resourcemanager.h" -#include "../resources/spriteset.h" +#include "../resources/imageset.h" #include "../utils/tostring.h" @@ -66,25 +66,26 @@ Viewport::Viewport(): mPopupMenu = new PopupMenu(); - // Load target cursors. + // Load target cursors 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(); - //Load animation frames into a spriteset, with each frame being 44x35 - Spriteset *ssInRange = resman->getSpriteset("graphics/gui/target-cursor-blue.png", 44, 35); - for(int i = 0; i < 8; ++i) + Animation *animOutRange = new Animation(); + + for (unsigned int i = 0; i < mInRangeImages->size(); ++i) { - //Have a delay of 75 - animInRange->addFrame(ssInRange->get(i),75,0,0); + animInRange->addFrame(mInRangeImages->get(i), 75, 0, 0); } - mTargetCursorInRange = new SimpleAnimation(animInRange); - Animation *animOutRange = new Animation(); - //Load animation frames into a spriteset, with each frame being 44x35 - Spriteset *ssOutRange = resman->getSpriteset("graphics/gui/target-cursor-red.png", 44, 35); - for(int j = 0; j < 8; ++j) + + for (unsigned int j = 0; j < mOutRangeImages->size(); ++j) { - //Have a delay of 75 - animOutRange->addFrame(ssOutRange->get(j),75,0,0); + animOutRange->addFrame(mOutRangeImages->get(j), 75, 0, 0); } + + mTargetCursorInRange = new SimpleAnimation(animInRange); mTargetCursorOutRange = new SimpleAnimation(animOutRange); } @@ -94,6 +95,9 @@ Viewport::~Viewport() delete mTargetCursorInRange; delete mTargetCursorOutRange; + + mInRangeImages->decRef(); + mOutRangeImages->decRef(); } void diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 6bb82d7f..84efeff3 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -33,6 +33,7 @@ class Map; class Being; class FloorItem; +class ImageSet; class Item; class PopupMenu; class Graphics; @@ -139,13 +140,13 @@ class Viewport : public WindowContainer, public gcn::MouseListener, * TODO Find some way to get rid of Being here */ void showPopup(int x, int y, Being *being); - + /** * Draws range based target cursor */ void drawTargetCursor(Graphics *graphics); - + /** * Draws target name */ @@ -162,11 +163,14 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int mCameraX; /**< Current viewpoint in tiles. */ int mCameraY; /**< Current viewpoint in tiles. */ bool mShowDebugPath; /**< Show a path from player to pointer. */ - - /** - * Target animated cursor. - */ + + 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; bool mPlayerFollowMouse; |