summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine.cpp23
-rw-r--r--src/gui/minimap.cpp36
-rw-r--r--src/gui/minimap.h18
-rw-r--r--src/gui/shortcutcontainer.h8
-rw-r--r--src/gui/shortcutwindow.cpp1
-rw-r--r--src/gui/shortcutwindow.h2
6 files changed, 34 insertions, 54 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 5cceb4cc..ece98d5d 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -43,7 +43,7 @@
#include "utils/stringutils.h"
Engine::Engine():
- mCurrentMap(NULL)
+ mCurrentMap(0)
{
}
@@ -84,27 +84,6 @@ bool Engine::changeMap(const std::string &mapPath)
logger->error("Could not find map file");
// Notify the minimap and beingManager about the map change
- if (newMap->hasProperty("minimap"))
- {
- // Set the title for the Minimap
- if (newMap->hasProperty("mapname"))
- minimap->setCaption(newMap->getProperty("mapname"));
- else if (newMap->hasProperty("name"))
- minimap->setCaption(newMap->getProperty("name"));
- else
- {
- minimap->setCaption("Unknown");
- logger->log("WARNING: Map file '%s' defines a minimap image but "
- "does not define a 'mapname' property",
- map_path.c_str());
- }
- }
- if (newMap->hasProperty("name"))
- {
- minimap->setCaption(newMap->getProperty("name"));
- } else {
- minimap->setCaption("Map");
- }
minimap->setMap(newMap);
beingManager->setMap(newMap);
particleEngine->setMap(newMap);
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 019ffe6b..174151c6 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -39,10 +39,10 @@
bool Minimap::mShow = true;
Minimap::Minimap():
- Window(_("MiniMap")),
- mMapImage(NULL),
- mHeightProportion(0.5),
- mWidthProportion(0.5)
+ Window(_("Map")),
+ mMapImage(0),
+ mWidthProportion(0.5),
+ mHeightProportion(0.5)
{
setWindowName("MiniMap");
mShow = config.getValue(getWindowName() + "Show", true);
@@ -55,8 +55,6 @@ Minimap::Minimap():
setSticky(false);
loadWindowState();
-
- //Debug
}
Minimap::~Minimap()
@@ -69,13 +67,24 @@ Minimap::~Minimap()
void Minimap::setMap(Map *map)
{
+ // Set the title for the Minimap
+ std::string caption;
+
+ if (map->hasProperty("name"))
+ caption = map->getProperty("name");
+ else if (map->hasProperty("mapname"))
+ caption = map->getProperty("mapname");
+ else
+ caption = _("Map");
+
+ minimap->setCaption(caption);
+
+ // Adapt the image
if (mMapImage)
mMapImage->decRef();
- mMap = map;
-
ResourceManager *resman = ResourceManager::getInstance();
- mMapImage = resman->getImage(mMap->getProperty("minimap"));
+ mMapImage = resman->getImage(map->getProperty("minimap"));
if (mMapImage)
{
@@ -90,12 +99,9 @@ void Minimap::setMap(Map *map)
setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
setMinHeight(mapHeight);
- mWidthProportion = (float) mMapImage->getWidth() / (float) mMap->getWidth();
- mHeightProportion = (float) mMapImage->getHeight() / (float) mMap->getHeight();
-
- logger->log("Minimap width : %d ; %d ; %f", mMapImage->getWidth(), mMap->getWidth(), mWidthProportion);
- logger->log("Minimap height : %d ; %d ; %f", mMapImage->getHeight(), mMap->getHeight(), mHeightProportion);
-
+ mWidthProportion = (float) mMapImage->getWidth() / map->getWidth();
+ mHeightProportion = (float) mMapImage->getHeight() / map->getHeight();
+
setMaxWidth(mMapImage->getWidth() > titleWidth ?
mMapImage->getWidth() + offsetX : titleWidth);
setMaxHeight(mMapImage->getHeight() + offsetY);
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index 8196683e..36f7578d 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -23,33 +23,30 @@
#define MINIMAP_H
#include "gui/widgets/window.h"
-#include "map.h"
class Image;
+class Map;
/**
- * Minimap dialog.
+ * Minimap window. Shows a minimap image and the name of the current map.
+ *
+ * The name of the map is defined by the map property "name". The minimap image
+ * is defined by the map property "minimap". The path to the image should be
+ * given relative to the root of the client data.
*
* \ingroup Interface
*/
class Minimap : public Window
{
public:
- /**
- * Constructor.
- */
Minimap();
-
- /**
- * Destructor.
- */
~Minimap();
/**
* Sets the map image that should be displayed.
*/
void setMap(Map *map);
-
+
/**
* Toggles the displaying of the minimap.
*/
@@ -61,7 +58,6 @@ class Minimap : public Window
void draw(gcn::Graphics *graphics);
private:
- Map *mMap;
Image *mMapImage;
float mWidthProportion;
float mHeightProportion;
diff --git a/src/gui/shortcutcontainer.h b/src/gui/shortcutcontainer.h
index 7b09fb96..fff48423 100644
--- a/src/gui/shortcutcontainer.h
+++ b/src/gui/shortcutcontainer.h
@@ -46,7 +46,7 @@ class ShortcutContainer : public gcn::Widget,
/**
* Destructor.
*/
- ~ShortcutContainer(){}
+ ~ShortcutContainer() {}
/**
* Draws the shortcuts
@@ -74,13 +74,13 @@ class ShortcutContainer : public gcn::Widget,
*/
virtual void mouseReleased(gcn::MouseEvent &event) = 0;
- virtual int getMaxItems()
+ virtual int getMaxItems() const
{ return mMaxItems; }
- virtual int getBoxWidth()
+ virtual int getBoxWidth() const
{ return mBoxWidth; }
- virtual int getBoxHeight()
+ virtual int getBoxHeight() const
{ return mBoxHeight; }
protected:
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 18a6829d..2025d332 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -75,4 +75,3 @@ ShortcutWindow::~ShortcutWindow()
{
delete mItems;
}
-
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index 826243a5..b3daf0b2 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -28,7 +28,7 @@ class ScrollArea;
class ShortcutContainer;
/**
- * A window around the ItemShortcutContainer.
+ * A window around a ShortcutContainer.
*
* \ingroup Interface
*/