summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-06 10:38:07 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-06 10:38:07 +0100
commit7cbdab589491e007adacd7597c769cdb9308a32c (patch)
tree0269c37cccbed49a1cb15db9de816f39ef549189 /src/gui/viewport.cpp
parent616afb27c23def5661b3466d6fc86fd1c65c0082 (diff)
parentaa4229cbb9f2b264ca96c3beedc66b1c79ccc1f5 (diff)
downloadmana-7cbdab589491e007adacd7597c769cdb9308a32c.tar.gz
mana-7cbdab589491e007adacd7597c769cdb9308a32c.tar.bz2
mana-7cbdab589491e007adacd7597c769cdb9308a32c.tar.xz
mana-7cbdab589491e007adacd7597c769cdb9308a32c.zip
Merge branch 'aethyra/master'
Conflicts: src/being.cpp src/being.h src/floor_item.cpp src/floor_item.h src/flooritemmanager.cpp src/gui/inventorywindow.cpp src/gui/inventorywindow.h src/gui/itemcontainer.cpp src/gui/popupmenu.cpp src/net/beinghandler.cpp src/npc.cpp
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index cba52cf9..7f97d98c 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -43,6 +43,8 @@ extern volatile int tick_time;
Viewport::Viewport():
mMap(0),
+ mMouseX(0),
+ mMouseY(0),
mPixelViewX(0.0f),
mPixelViewY(0.0f),
mTileViewX(0),
@@ -150,18 +152,14 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
int viewYmax = (mMap->getHeight() * 32) - graphics->getHeight();
if (mMap)
{
- if (mPixelViewX < 0) {
+ if (mPixelViewX < 0)
mPixelViewX = 0;
- }
- if (mPixelViewY < 0) {
+ if (mPixelViewY < 0)
mPixelViewY = 0;
- }
- if (mPixelViewX > viewXmax) {
+ if (mPixelViewX > viewXmax)
mPixelViewX = viewXmax;
- }
- if (mPixelViewY > viewYmax) {
+ if (mPixelViewY > viewYmax)
mPixelViewY = viewYmax;
- }
}
mTileViewX = (int) (mPixelViewX + 16) / 32;
@@ -177,11 +175,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
if (mShowDebugPath)
{
// Get the current mouse position
- int mouseX, mouseY;
- SDL_GetMouseState(&mouseX, &mouseY);
+ SDL_GetMouseState(&mMouseX, &mMouseY);
- int mouseTileX = mouseX / 32 + mTileViewX;
- int mouseTileY = mouseY / 32 + mTileViewY;
+ int mouseTileX = mMouseX / 32 + mTileViewX;
+ int mouseTileY = mMouseY / 32 + mTileViewY;
Path debugPath = mMap->findPath(player_node->mX, player_node->mY,
mouseTileX, mouseTileY);
@@ -206,7 +203,6 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
player_node->setName(player_node->getName());
}
-
// Draw text
if (textManager)
{
@@ -217,8 +213,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
Beings &beings = beingManager->getAll();
for (BeingIterator i = beings.begin(); i != beings.end(); i++)
{
- (*i)->drawSpeech(-(int) mPixelViewX, -(int) mPixelViewY);
- (*i)->drawEmotion(graphics, -(int) mPixelViewX, -(int) mPixelViewY);
+ (*i)->drawSpeech((int) mPixelViewX, (int) mPixelViewY);
+ (*i)->drawEmotion(graphics, (int) mPixelViewX, (int) mPixelViewY);
}
if (miniStatusWindow)
@@ -235,14 +231,13 @@ void Viewport::logic()
if (!mMap || !player_node)
return;
- int mouseX, mouseY;
- Uint8 button = SDL_GetMouseState(&mouseX, &mouseY);
+ Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY);
if (mPlayerFollowMouse && button & SDL_BUTTON(1) &&
mWalkTime != player_node->mWalkTime)
{
- player_node->setDestination(mouseX / 32 + mTileViewX,
- mouseY / 32 + mTileViewY);
+ player_node->setDestination(mMouseX / 32 + mTileViewX,
+ mMouseY / 32 + mTileViewY);
mWalkTime = player_node->mWalkTime;
}
}
@@ -349,9 +344,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
Being::MONSTER);
if (target)
- {
player_node->setTarget(target);
- }
}
}