summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-02-06 18:17:09 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-02-06 18:17:09 +0000
commit5ec4143bde0fd67c7aca841804a5d165c794bdf0 (patch)
tree4ecfaf02a2f1831d545d21de3385b34b6c8c4388 /src
parent49ea67bae1d2969c21005c06bb764f3c6b479e9c (diff)
downloadmana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.tar.gz
mana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.tar.bz2
mana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.tar.xz
mana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.zip
Added minimal minimap
Diffstat (limited to 'src')
-rw-r--r--src/graphic/graphic.cpp6
-rw-r--r--src/gui/minimap.cpp84
-rw-r--r--src/gui/minimap.h51
3 files changed, 141 insertions, 0 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 591c7443..99a7c319 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -25,6 +25,7 @@
#include "../gui/gui.h"
#include "../gui/textfield.h"
#include "../gui/status.h"
+#include "../gui/minimap.h"
#include "../main.h"
#include "../being.h"
@@ -53,6 +54,7 @@ NpcTextDialog *npcTextDialog;
SkillDialog *skillDialog;
StatsWindow *statsWindow;
Setup* setupWindow;
+Minimap *minimap;
void ChatListener::action(const std::string& eventId)
{
@@ -266,6 +268,10 @@ Engine::Engine()
setupWindow = new Setup();
setupWindow->setVisible(false);
+
+ // Create minimap
+
+ minimap = new Minimap();
// Give focus to the chat input
chatInput->requestFocus();
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
new file mode 100644
index 00000000..a1104b8a
--- /dev/null
+++ b/src/gui/minimap.cpp
@@ -0,0 +1,84 @@
+/*
+ * The Mana World
+ * Copyright 2004-2005 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $IdS
+ */
+
+#define MINIMAP_W 100
+#define MINIMAP_H 100
+
+#include "minimap.h"
+#include "../being.h"
+
+Minimap::Minimap()
+{
+ setSize(MINIMAP_W, MINIMAP_H);
+ setPosition(20, 20);
+
+ mapBackground = SDL_AllocSurface(SDL_SWSURFACE, MINIMAP_W, MINIMAP_H,
+ (screen->format->BytesPerPixel*8), 0, 0, 0, 0);
+ Uint32 mapColor = SDL_MapRGB(screen->format, 255, 255, 255);
+ SDL_Rect sourceRect;
+ sourceRect.x = sourceRect.y = 0;
+ sourceRect.w = MINIMAP_W;
+ sourceRect.h = MINIMAP_H;
+ if ( mapBackground )
+ {
+ SDL_FillRect(mapBackground, &sourceRect, mapColor);
+ SDL_SetAlpha(mapBackground, SDL_SRCALPHA, 120);
+ }
+}
+
+void Minimap::draw(gcn::Graphics *graphics)
+{
+ int x, y;
+
+ getAbsolutePosition(x, y);
+
+ if ( (mapBackground->w != getWidth()) || (mapBackground->h != getHeight()) )
+ {
+ SDL_FreeSurface(mapBackground);
+ mapBackground = SDL_AllocSurface(SDL_SWSURFACE, getWidth(), getHeight(),
+ (screen->format->BytesPerPixel*8), 0, 0, 0, 0);
+ Uint32 mapColor = SDL_MapRGB(screen->format, 52, 149, 210);
+ SDL_Rect sourceRect;
+ sourceRect.x = sourceRect.y = 0;
+ sourceRect.w = getWidth();
+ sourceRect.h = getHeight();
+ if ( mapBackground )
+ {
+ SDL_FillRect(mapBackground, &sourceRect, mapColor);
+ SDL_SetAlpha(mapBackground, SDL_SRCALPHA, 120);
+ }
+
+ }
+
+ SDL_Rect screenRect;
+ screenRect.w = getWidth();
+ screenRect.h = getHeight();
+ screenRect.x = x;
+ screenRect.y = y;
+ if ( mapBackground ) SDL_BlitSurface(mapBackground, NULL, screen, &screenRect);
+
+ graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ graphics->setColor(gcn::Color(209, 52, 61));
+ graphics->fillRectangle(gcn::Rectangle(player_node->x /2,
+ player_node->y / 2, 3, 3));
+} \ No newline at end of file
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
new file mode 100644
index 00000000..08a39fb6
--- /dev/null
+++ b/src/gui/minimap.h
@@ -0,0 +1,51 @@
+/*
+ * The Mana World
+ * Copyright 2004-2005 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_MINIMAP_H
+#define _TMW_MINIMAP_H
+
+#include "gui.h"
+#include "window.h"
+
+/**
+ * Minimap dialog.
+ *
+ * \ingroup GUI
+ */
+class Minimap : public Window {
+ public:
+ /**
+ * Constructor.
+ */
+ Minimap();
+
+ /**
+ * Draws the minimap.
+ */
+ void draw(gcn::Graphics *graphics);
+
+ // The Alpha-Blended Surface for the background transluency effect.
+ SDL_Surface *mapBackground;
+};
+
+#endif