summaryrefslogtreecommitdiff
path: root/src/gui
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
parentd7904f7b7e25bbdd7205e5c18e06d184b2078732 (diff)
downloadmana-client-d283db70abe904fddd8aefbd52b35d6e066dd98f.tar.gz
mana-client-d283db70abe904fddd8aefbd52b35d6e066dd98f.tar.bz2
mana-client-d283db70abe904fddd8aefbd52b35d6e066dd98f.tar.xz
mana-client-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')
-rw-r--r--src/gui/button.cpp3
-rw-r--r--src/gui/gui.cpp6
-rw-r--r--src/gui/minimap.cpp80
-rw-r--r--src/gui/minimap.h17
-rw-r--r--src/gui/window.cpp1
5 files changed, 91 insertions, 16 deletions
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index c95ab968..10fbe625 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -85,7 +85,8 @@ Button::~Button()
}
}
-void Button::draw(gcn::Graphics* graphics) {
+void Button::draw(gcn::Graphics* graphics)
+{
int mode;
if (!isEnabled()) {
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 73e77073..b6562b77 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -28,6 +28,7 @@
#include "../engine.h"
#include "../net/protocol.h"
#include "../main.h"
+#include "../game.h"
// Guichan stuff
Gui *gui;
@@ -126,6 +127,7 @@ void Gui::mousePress(int mx, int my, int button)
if (player_node && player_node->action != DEAD && current_npc == 0 &&
button == gcn::MouseInput::LEFT)
{
+ Map *tiledMap = engine->getCurrentMap();
int tilex = mx / 32 + camera_x;
int tiley = my / 32 + camera_y;
@@ -133,7 +135,7 @@ void Gui::mousePress(int mx, int my, int button)
walk(tilex, tiley, 0);
player_node->setDestination(tilex, tiley);
}
-
- autoTarget = 0;
+
+ autoTarget = NULL;
}
}
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));
+ }
+ }
}
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index 8e75a78c..3710332c 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -24,6 +24,7 @@
#ifndef _TMW_MINIMAP_H
#define _TMW_MINIMAP_H
+#include "../map.h"
#include "gui.h"
#include "window.h"
@@ -32,7 +33,8 @@
*
* \ingroup Interface
*/
-class Minimap : public Window {
+class Minimap : public Window
+{
public:
/**
* Constructor.
@@ -40,9 +42,22 @@ class Minimap : public Window {
Minimap();
/**
+ * Destructor.
+ */
+ ~Minimap();
+
+ /**
+ * Sets the map that should be displayed.
+ */
+ void setMap(Map *map);
+
+ /**
* Draws the minimap.
*/
void draw(gcn::Graphics *graphics);
+
+ private:
+ Image *mMapImage;
};
#endif
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 95965960..c5ef7a54 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -64,6 +64,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent):
setBorderSize(0);
setPadding(3);
+ setTitleBarHeight(20);
// Add chrome
chrome = new gcn::Container();