summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-09 03:21:39 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-09 03:21:39 +0000
commit7593d6c71e2331c3e43c732db60ad03ee4d5385d (patch)
tree3ad242a957b6a500319d7bdae15149c553521ee4
parent81cf85e9ec1d37dc6e8dd9883f42bb50dace9135 (diff)
downloadmana-client-7593d6c71e2331c3e43c732db60ad03ee4d5385d.tar.gz
mana-client-7593d6c71e2331c3e43c732db60ad03ee4d5385d.tar.bz2
mana-client-7593d6c71e2331c3e43c732db60ad03ee4d5385d.tar.xz
mana-client-7593d6c71e2331c3e43c732db60ad03ee4d5385d.zip
Added Spriteset::get() and Spriteset::size() to hide the member vector and remove the weird mySpriteset->spriteset stuff.
-rw-r--r--ChangeLog6
-rw-r--r--src/being.cpp4
-rw-r--r--src/floor_item.cpp2
-rw-r--r--src/graphic/spriteset.cpp4
-rw-r--r--src/graphic/spriteset.h12
-rw-r--r--src/gui/equipmentwindow.cpp4
-rw-r--r--src/gui/itemcontainer.cpp14
-rw-r--r--src/gui/playerbox.cpp6
-rw-r--r--src/map.cpp4
-rw-r--r--src/player.cpp7
10 files changed, 37 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d165663..f04f4d38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2006-03-09 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/floor_item.cpp, src/map.cpp, src/being.cpp,
+ src/gui/equipmentwindow.cpp, src/gui/playerbox.cpp,
+ src/gui/itemcontainer.cpp, src/graphic/spriteset.cpp,
+ src/graphic/spriteset.h, src/player.cpp: Added Spriteset::get() and
+ Spriteset::size() to hide the member vector and remove the weird
+ mySpriteset->spriteset stuff.
* src/gui/buddywindow.cpp, src/gui/connection.cpp, src/gui/sell.cpp,
src/gui/trade.cpp, src/gui/char_server.cpp, src/gui/login.cpp,
src/gui/button.h, src/gui/newskill.cpp, src/gui/setup.cpp,
diff --git a/src/being.cpp b/src/being.cpp
index fa28a61b..504c5ab4 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -218,7 +218,7 @@ void Being::draw(Graphics *graphics, int offsetX, int offsetY)
int px = mPx + offsetX;
int py = mPy + offsetY;
- graphics->drawImage(mSpriteset->spriteset[mSpriteFrame], px, py);
+ graphics->drawImage(mSpriteset->get(mSpriteFrame), px, py);
}
void
@@ -229,7 +229,7 @@ Being::drawEmotion(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
if (emotion)
{
- graphics->drawImage(emotionset->spriteset[emotion - 1],
+ graphics->drawImage(emotionset->get(emotion - 1),
px + 3, py - 60);
}
}
diff --git a/src/floor_item.cpp b/src/floor_item.cpp
index 775a9cb8..4573d646 100644
--- a/src/floor_item.cpp
+++ b/src/floor_item.cpp
@@ -44,7 +44,7 @@ FloorItem::FloorItem(unsigned int id,
mMap(map)
{
// Retrieve item image using a global itemset and itemDb (alternative?)
- mImage = itemset->spriteset[itemDb->getItemInfo(itemId)->getImage() - 1];
+ mImage = itemset->get(itemDb->getItemInfo(itemId)->getImage() - 1);
// Add ourselves to the map
mSpriteIterator = mMap->addSprite(this);
diff --git a/src/graphic/spriteset.cpp b/src/graphic/spriteset.cpp
index 96ba4313..b008a701 100644
--- a/src/graphic/spriteset.cpp
+++ b/src/graphic/spriteset.cpp
@@ -33,12 +33,12 @@ Spriteset::Spriteset(Image *img, int width, int height)
{
for (int x = 0; x + width <= img->getWidth(); x += width)
{
- spriteset.push_back(img->getSubImage(x, y, width, height));
+ mSpriteset.push_back(img->getSubImage(x, y, width, height));
}
}
}
Spriteset::~Spriteset()
{
- for_each(spriteset.begin(), spriteset.end(), make_dtor(spriteset));
+ for_each(mSpriteset.begin(), mSpriteset.end(), make_dtor(mSpriteset));
}
diff --git a/src/graphic/spriteset.h b/src/graphic/spriteset.h
index 2f4e50ca..08ff65f5 100644
--- a/src/graphic/spriteset.h
+++ b/src/graphic/spriteset.h
@@ -34,9 +34,6 @@ class Image;
*/
class Spriteset {
public:
- // Vector storing the whole spriteset.
- std::vector<Image*> spriteset;
-
/*
* Cuts the passed image in a grid of sub images.
*/
@@ -46,6 +43,15 @@ class Spriteset {
* Destructor.
*/
~Spriteset();
+
+ typedef std::vector<Image*>::size_type size_type;
+ Image* get(size_type i) { return mSpriteset[i]; }
+
+ size_type size() { return mSpriteset.size(); }
+
+ private:
+ // Vector storing the whole spriteset.
+ std::vector<Image*> mSpriteset;
};
#endif
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index f1b9b4ba..9904af02 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -69,7 +69,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
continue;
}
- image = itemset->spriteset[item->getInfo()->getImage() - 1];
+ image = itemset->get(item->getInfo()->getImage() - 1);
dynamic_cast<Graphics*>(graphics)->drawImage(
image, 36 * (i % 4) + 10, 36 * (i / 4) + 25);
}
@@ -81,7 +81,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
return;
}
- image = itemset->spriteset[item->getInfo()->getImage() - 1];
+ image = itemset->get(item->getInfo()->getImage() - 1);
dynamic_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
std::stringstream n;
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 67cb5251..cc42066a 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -74,8 +74,8 @@ void ItemContainer::logic()
void ItemContainer::draw(gcn::Graphics* graphics)
{
- int gridWidth = itemset->spriteset[0]->getWidth() + 4;
- int gridHeight = itemset->spriteset[0]->getHeight() + 10;
+ int gridWidth = itemset->get(0)->getWidth() + 4;
+ int gridHeight = itemset->get(0)->getHeight() + 10;
int w = getWidth();
int columns = w / gridWidth;
@@ -119,7 +119,7 @@ void ItemContainer::draw(gcn::Graphics* graphics)
if ((idx = item->getInfo()->getImage()) > 0)
{
dynamic_cast<Graphics*>(graphics)->drawImage(
- itemset->spriteset[idx - 1], itemX, itemY);
+ itemset->get(idx - 1), itemX, itemY);
}
// Draw item caption
@@ -143,8 +143,8 @@ void ItemContainer::setWidth(int width)
{
gcn::Widget::setWidth(width);
- int gridWidth = itemset->spriteset[0]->getWidth() + 4;
- int gridHeight = itemset->spriteset[0]->getHeight() + 14;
+ int gridWidth = itemset->get(0)->getWidth() + 4;
+ int gridHeight = itemset->get(0)->getHeight() + 14;
int columns = getWidth() / gridWidth;
if (columns < 1)
@@ -168,8 +168,8 @@ void ItemContainer::selectNone()
void ItemContainer::mousePress(int mx, int my, int button)
{
- int gridWidth = itemset->spriteset[0]->getWidth() + 4;
- int gridHeight = itemset->spriteset[0]->getHeight() + 10;
+ int gridWidth = itemset->get(0)->getWidth() + 4;
+ int gridHeight = itemset->get(0)->getHeight() + 10;
int w = getWidth();
int columns = w / gridWidth;
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index e61cabde..34283b4c 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -90,16 +90,16 @@ void PlayerBox::draw(gcn::Graphics *graphics)
// Draw character
dynamic_cast<Graphics*>(graphics)->drawImage(
- playerset->spriteset[0], 23, 12);
+ playerset->get(0), 23, 12);
// Draw his hair
if (hairColor >= 0 && hairStyle >= 0 &&
hairColor < NR_HAIR_COLORS && hairStyle < NR_HAIR_STYLES)
{
int hf = 9 * hairColor;
- if (hf >= 0 && hf < (int)hairset[hairStyle]->spriteset.size()) {
+ if (hf >= 0 && hf < (int)hairset[hairStyle]->size()) {
dynamic_cast<Graphics*>(graphics)->drawImage(
- hairset[hairStyle]->spriteset[hf], 35, 7);
+ hairset[hairStyle]->get(hf), 35, 7);
}
}
}
diff --git a/src/map.cpp b/src/map.cpp
index 57cd5a97..c66a85c9 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -179,7 +179,7 @@ class ContainsGidFunctor
bool operator() (Tileset* set)
{
return (set->getFirstGid() <= gid &&
- gid - set->getFirstGid() < (int)set->spriteset.size());
+ gid - set->getFirstGid() < (int)set->size());
}
int gid;
} containsGid;
@@ -200,7 +200,7 @@ Map::getTileWithGid(int gid)
Tileset *set = getTilesetWithGid(gid);
if (set) {
- return set->spriteset[gid - set->getFirstGid()];
+ return set->get(gid - set->getFirstGid());
}
return NULL;
diff --git a/src/player.cpp b/src/player.cpp
index 8afd92a8..67110bd8 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -126,7 +126,7 @@ void Player::draw(Graphics *graphics, int offsetX, int offsetY)
unsigned char dir = 0;
while (!(direction & (1 << dir))) dir++;
- graphics->drawImage(playerset->spriteset[frame + 18 * dir],
+ graphics->drawImage(playerset->get(frame + 18 * dir),
px - 16, py - 32);
if (getWeapon() != 0 && action == ATTACK)
@@ -136,8 +136,7 @@ void Player::draw(Graphics *graphics, int offsetX, int offsetY)
{
frames = 5;
}
- Image *image = weaponset[getWeapon() - 1]->spriteset[
- mFrame + frames * dir];
+ Image *image = weaponset[getWeapon() - 1]->get(mFrame + frames * dir);
graphics->drawImage(image, px - 16, py - 32);
}
@@ -145,7 +144,7 @@ void Player::draw(Graphics *graphics, int offsetX, int offsetY)
{
int hf = 9 * (getHairColor() - 1) + hairframe[dir][frame];
- graphics->drawImage(hairset[getHairStyle() - 1]->spriteset[hf],
+ graphics->drawImage(hairset[getHairStyle() - 1]->get(hf),
px + 1 + hairtable[frame][dir][0],
py - 33 + hairtable[frame][dir][1]);
}