summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2011-05-30 11:13:31 -0600
committerJared Adams <jaxad0127@gmail.com>2011-05-30 12:35:08 -0600
commit0248b2f58c783f21b7e68a20deadc0a3f942c869 (patch)
treefb9487625c282f59325f0585f08e2efd0683cd39 /src
parentb69c0511206d68a61fd08042d1c122c9fac22202 (diff)
downloadmana-0248b2f58c783f21b7e68a20deadc0a3f942c869.tar.gz
mana-0248b2f58c783f21b7e68a20deadc0a3f942c869.tar.bz2
mana-0248b2f58c783f21b7e68a20deadc0a3f942c869.tar.xz
mana-0248b2f58c783f21b7e68a20deadc0a3f942c869.zip
Remove some uneeded offsetting
Also fix position of being names. Reviewed-by: Bertram
Diffstat (limited to 'src')
-rw-r--r--src/actorsprite.cpp18
-rw-r--r--src/being.cpp6
-rw-r--r--src/compoundsprite.cpp33
-rw-r--r--src/compoundsprite.h3
-rw-r--r--src/gui/widgets/playerbox.cpp4
-rw-r--r--src/net/tmwa/charserverhandler.cpp2
6 files changed, 27 insertions, 39 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index b4b56451..68b92a1f 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -22,6 +22,7 @@
#include "client.h"
#include "event.h"
+#include "game.h"
#include "imagesprite.h"
#include "localplayer.h"
#include "log.h"
@@ -67,11 +68,8 @@ ActorSprite::~ActorSprite()
bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
{
- // TODO: Eventually, we probably should fix all sprite offsets so that
- // these translations aren't necessary anymore. The sprites know
- // best where their base point should be.
- const int px = getPixelX() + offsetX - 16;
- const int py = getPixelY() + offsetY - 16;
+ int px = getPixelX() + offsetX;
+ int py = getPixelY() + offsetY;
if (mUsedTargetCursor)
{
@@ -80,6 +78,12 @@ bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
mUsedTargetCursor->draw(graphics, px, py);
}
+ Map *map = Game::instance() ? Game::instance()->getCurrentMap() : 0;
+ if (map)
+ {
+ py += map->getTileHeight() / 2;
+ }
+
return drawSpriteAt(graphics, px, py);
}
@@ -450,8 +454,8 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
for (unsigned int i = 0; i < currentImageSet->size(); ++i)
{
anim->addFrame(currentImageSet->get(i), 75,
- (16 - (currentImageSet->getWidth() / 2)),
- (16 - (currentImageSet->getHeight() / 2)));
+ -(currentImageSet->getWidth() / 2),
+ -(currentImageSet->getHeight() / 2));
}
SimpleAnimation *currentCursor = new SimpleAnimation(anim);
diff --git a/src/being.cpp b/src/being.cpp
index d4bca7ce..48e29258 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -953,11 +953,9 @@ void Being::updateCoords()
// Monster names show above the sprite instead of below it
if (getType() == MONSTER)
- mDispName->adviseXY(getPixelX(),
- getPixelY() - getHeight() - getOffsetY()
- - mDispName->getHeight());
+ mDispName->adviseXY(getPixelX(), getPixelY() - getHeight());
else
- mDispName->adviseXY(getPixelX(), getPixelY());
+ mDispName->adviseXY(getPixelX(), getPixelY() + mDispName->getHeight());
}
void Being::flashName(int time)
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 4e91d281..e96137c4 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -281,19 +281,8 @@ void CompoundSprite::redraw() const
{
mWidth = at(0)->getWidth();
mHeight = at(0)->getHeight();
-
- // Temporary fix for position
- Map *map = Game::instance() ? Game::instance()->getCurrentMap() : 0;
- if (map)
- {
- mOffsetX = map->getTileWidth() / 2;
- mOffsetY = map->getTileHeight();
- }
- else // Char selection screen fix
- {
- mOffsetX = 16;
- mOffsetY = 32;
- }
+ mOffsetX = 0;
+ mOffsetY = 0;
mNeedsRedraw = false;
return;
}
@@ -326,18 +315,6 @@ void CompoundSprite::redraw() const
mOffsetX -= posX;
mOffsetY -= posY;
- Map *map = Game::instance() ? Game::instance()->getCurrentMap() : 0;
- if (map)
- {
- mOffsetX += map->getTileWidth() / 2;
- mOffsetY += map->getTileHeight();
- }
- else // Char selection screen fix
- {
- mOffsetX += 16;
- mOffsetY += 32;
- }
-
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int rmask = 0xff000000;
int gmask = 0x00ff0000;
@@ -369,6 +346,12 @@ void CompoundSprite::redraw() const
s->draw(graphics, posX - s->getWidth() / 2, posY - s->getHeight());
}
+ // Uncomment to see buffer sizes
+ /*graphics->fillRectangle(gcn::Rectangle(0, 0, 3, 3));
+ graphics->fillRectangle(gcn::Rectangle(mWidth - 3, 0, 3, 3));
+ graphics->fillRectangle(gcn::Rectangle(mWidth - 3, mHeight - 3, 3, 3));
+ graphics->fillRectangle(gcn::Rectangle(0, mHeight - 3, 3, 3));*/
+
delete graphics;
SDL_Surface *surfaceA = SDL_CreateRGBSurface(SDL_HWSURFACE, mWidth, mHeight,
diff --git a/src/compoundsprite.h b/src/compoundsprite.h
index 5754c4e1..3a5e0129 100644
--- a/src/compoundsprite.h
+++ b/src/compoundsprite.h
@@ -96,6 +96,9 @@ public:
*/
virtual size_t getFrameCount(size_t layer);
+ void doRedraw()
+ { mNeedsRedraw = true; }
+
private:
typedef CompoundSprite::iterator SpriteIterator;
typedef CompoundSprite::const_iterator SpriteConstIterator;
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 559ac5a6..f71889bb 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -85,8 +85,8 @@ void PlayerBox::draw(gcn::Graphics *graphics)
{
// Draw character
const int bs = getFrameSize();
- const int x = getWidth() / 2 + bs - 16;
- const int y = getHeight() - bs - 32;
+ const int x = getWidth() / 2 + bs;
+ const int y = getHeight() - bs;
mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
}
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index e6dc84a2..dcc68fb3 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -159,10 +159,10 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
mapServer.hostname = ipToString(msg.readInt32());
mapServer.port = msg.readInt16();
- // Prevent the selected local player from being deleted
player_node = mSelectedCharacter->dummy;
PlayerInfo::setBackend(mSelectedCharacter->data);
+ // Prevent the selected local player from being deleted
mSelectedCharacter->dummy = 0;
delete_all(mCharacters);