summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-14 14:24:28 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-14 14:24:28 +0000
commitd283db70abe904fddd8aefbd52b35d6e066dd98f (patch)
tree7bd24c75dd65872270a4b4a859c38020d82ba451 /src/gui/minimap.cpp
parentd7904f7b7e25bbdd7205e5c18e06d184b2078732 (diff)
downloadmana-d283db70abe904fddd8aefbd52b35d6e066dd98f.tar.gz
mana-d283db70abe904fddd8aefbd52b35d6e066dd98f.tar.bz2
mana-d283db70abe904fddd8aefbd52b35d6e066dd98f.tar.xz
mana-d283db70abe904fddd8aefbd52b35d6e066dd98f.zip
Added background to minimap. Only used in Tonori Desert map for now, and its
style is up for discussion.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp80
1 files changed, 68 insertions, 12 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 719266d1..8941a390 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -23,29 +23,85 @@
#include "minimap.h"
#include "../being.h"
+#include "../resources/resourcemanager.h"
+#include "../graphics.h"
-Minimap::Minimap()
+Minimap::Minimap():
+ Window("Map"),
+ mMapImage(NULL)
{
setContentSize(100, 100);
setPosition(20, 20);
}
+Minimap::~Minimap()
+{
+ if (mMapImage)
+ {
+ mMapImage->decRef();
+ }
+}
+
+void Minimap::setMap(Map *map)
+{
+ if (mMapImage)
+ {
+ mMapImage->decRef();
+ }
+
+ if (map->hasProperty("minimap"))
+ {
+ ResourceManager *resman = ResourceManager::getInstance();
+ mMapImage = resman->getImage(map->getProperty("minimap"), IMG_ALPHA);
+ mMapImage->setAlpha(0.7);
+ }
+ else
+ {
+ mMapImage = NULL;
+ }
+}
+
void Minimap::draw(gcn::Graphics *graphics)
{
- int x, y;
+ Window::draw(graphics);
+ int x, y;
getAbsolutePosition(x, y);
- // Transparent background
- graphics->setColor(gcn::Color(52, 149, 210, 120));
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ if (mMapImage != NULL)
+ {
+ mMapImage->draw(screen, x + getPadding(), y + getTitleBarHeight());
+ }
+
+ std::list<Being*>::iterator bi;
- // Black border
- graphics->setColor(gcn::Color(0, 0, 0));
- graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ for (bi = beings.begin(); bi != beings.end(); bi++)
+ {
+ Being *being = (*bi);
- // Player dot
- graphics->setColor(gcn::Color(209, 52, 61));
- graphics->fillRectangle(gcn::Rectangle(player_node->x / 2,
- player_node->y / 2, 3, 3));
+ if (being == player_node)
+ {
+ // Player dot
+ graphics->setColor(gcn::Color(209, 52, 61));
+ graphics->fillRectangle(gcn::Rectangle(
+ being->x / 2 + getPadding() - 1,
+ being->y / 2 + getTitleBarHeight() - 1, 3, 3));
+ }
+ else if (being->isPlayer())
+ {
+ // Other player dot
+ graphics->setColor(gcn::Color(61, 52, 209));
+ graphics->fillRectangle(gcn::Rectangle(
+ being->x / 2 + getPadding(),
+ being->y / 2 + getTitleBarHeight(), 1, 1));
+ }
+ else if (being->isMonster())
+ {
+ // Enemy dot
+ graphics->setColor(gcn::Color(209, 52, 61));
+ graphics->fillRectangle(gcn::Rectangle(
+ being->x / 2 + getPadding(),
+ being->y / 2 + getTitleBarHeight(), 1, 1));
+ }
+ }
}