summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-31 15:45:33 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-31 15:45:33 +0000
commitb7b9299ab765647807f25dc95e8b8cb57f6eb1c5 (patch)
tree7b9a68497ee4b8d19cddc226803b34172b5149fd
parent51bfbd368cc455b037393d3383346640113e915b (diff)
downloadmana-client-b7b9299ab765647807f25dc95e8b8cb57f6eb1c5.tar.gz
mana-client-b7b9299ab765647807f25dc95e8b8cb57f6eb1c5.tar.bz2
mana-client-b7b9299ab765647807f25dc95e8b8cb57f6eb1c5.tar.xz
mana-client-b7b9299ab765647807f25dc95e8b8cb57f6eb1c5.zip
Added check to stop scrolling at map borders. Small cleanup in the listbox drawing code.
-rw-r--r--ChangeLog6
-rw-r--r--src/engine.cpp16
-rw-r--r--src/gui/listbox.cpp28
3 files changed, 35 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d643abd..e3bb592a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-31 Björn Steinbrink <B.Steinbrink@gmx.de>
+
+ * src/gui/listbox.cpp: Small cleanup of the drawing code.
+ * src/engine.cpp: Added a check to stop scrolling when we hit the map
+ border.
+
2005-07-31 Andrej Sinicyn <andrej4000@gmail.com>
* src/game.cpp: Don't allow more than one trade dialog or requesting it at
diff --git a/src/engine.cpp b/src/engine.cpp
index c6a7a6c8..918aea7f 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -335,6 +335,22 @@ void Engine::draw()
map_x = (player_node->x - 13) * 32 + get_x_offset(player_node);
map_y = (player_node->y - 9) * 32 + get_y_offset(player_node);
+ if (map_x < 0) {
+ map_x = 0;
+ }
+ if (map_y < 0) {
+ map_y = 0;
+ }
+
+ if (mCurrentMap) {
+ if (map_x > (mCurrentMap->getWidth() - 13) * 32) {
+ map_x = (mCurrentMap->getWidth() - 13) * 32;
+ }
+ if (map_y > (mCurrentMap->getHeight() - 9) * 32) {
+ map_y = (mCurrentMap->getHeight() - 9) * 32;
+ }
+ }
+
camera_x = map_x / 32;
camera_y = map_y / 32;
int mouseTileX = mouseX / 32 + camera_x;
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp
index 3f82fe1b..fee67cbd 100644
--- a/src/gui/listbox.cpp
+++ b/src/gui/listbox.cpp
@@ -44,27 +44,25 @@ void ListBox::draw(gcn::Graphics *graphics)
graphics->setColor(gcn::Color(110, 160, 255));
graphics->setFont(getFont());
- int i;
int fontHeight = getFont()->getHeight();
- int y = 0;
- for (i = 0; i < mListModel->getNumberOfElements(); ++i)
- {
- if (i == mSelected) {
- if (useOpenGL) {
+ // Draw rectangle below the selected list element
+ if (mSelected >= 0) {
+ if (useOpenGL) {
#ifdef USE_OPENGL
- dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(
- gcn::Rectangle(0, y, getWidth(), fontHeight));
+ dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(
+ gcn::Rectangle(0, fontHeight * mSelected, getWidth(), fontHeight));
#endif
- }
- else {
- dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(
- gcn::Rectangle(0, y, getWidth(), fontHeight));
- }
}
+ else {
+ dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(
+ gcn::Rectangle(0, fontHeight * mSelected, getWidth(), fontHeight));
+ }
+ }
+ // Draw the list elements
+ for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += fontHeight)
+ {
graphics->drawText(mListModel->getElementAt(i), 1, y);
-
- y += fontHeight;
}
}