summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-25 23:04:58 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-25 23:04:58 +0200
commita36909f5c3408153c9b5f9477adde9b27d8c7482 (patch)
tree0acd7721cd2bb2b27878d20027d0510458581515 /src/gui
parent4e18e7619e9a8c909dea3374a2a7aa39befe0c16 (diff)
downloadmana-a36909f5c3408153c9b5f9477adde9b27d8c7482.tar.gz
mana-a36909f5c3408153c9b5f9477adde9b27d8c7482.tar.bz2
mana-a36909f5c3408153c9b5f9477adde9b27d8c7482.tar.xz
mana-a36909f5c3408153c9b5f9477adde9b27d8c7482.zip
Handle map not found gracefully
Instead of shutting down, the client will now draw a gray background. This allows the player to still contact a GM in order to be helped out of the situation. It also helps me warp out of the non-existing map I accidentally warped myself onto. ;)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/minimap.cpp19
-rw-r--r--src/gui/viewport.cpp51
2 files changed, 41 insertions, 29 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index a5bdc59d..d1c99b84 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -77,21 +77,26 @@ 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
+ if (map)
+ caption = map->getName();
+
+ if (caption.empty())
caption = _("Map");
minimap->setCaption(caption);
// Adapt the image
if (mMapImage)
+ {
mMapImage->decRef();
+ mMapImage = 0;
+ }
- ResourceManager *resman = ResourceManager::getInstance();
- mMapImage = resman->getImage(map->getProperty("minimap"));
+ if (map)
+ {
+ ResourceManager *resman = ResourceManager::getInstance();
+ mMapImage = resman->getImage(map->getProperty("minimap"));
+ }
if (mMapImage)
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 2c3f4007..d954b99f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -19,26 +19,28 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ministatus.h"
-#include "popupmenu.h"
-#include "viewport.h"
-
-#include "../beingmanager.h"
-#include "../configuration.h"
-#include "../flooritemmanager.h"
-#include "../game.h"
-#include "../graphics.h"
-#include "../keyboardconfig.h"
-#include "../localplayer.h"
-#include "../map.h"
-#include "../monster.h"
-#include "../npc.h"
-#include "../textmanager.h"
-
-#include "../resources/monsterinfo.h"
-#include "../resources/resourcemanager.h"
-
-#include "../utils/stringutils.h"
+#include "gui/viewport.h"
+
+#include "gui/gui.h"
+#include "gui/ministatus.h"
+#include "gui/popupmenu.h"
+
+#include "beingmanager.h"
+#include "configuration.h"
+#include "flooritemmanager.h"
+#include "game.h"
+#include "graphics.h"
+#include "keyboardconfig.h"
+#include "localplayer.h"
+#include "map.h"
+#include "monster.h"
+#include "npc.h"
+#include "textmanager.h"
+
+#include "resources/monsterinfo.h"
+#include "resources/resourcemanager.h"
+
+#include "utils/stringutils.h"
extern volatile int tick_time;
@@ -94,7 +96,12 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
static int lastTick = tick_time;
if (!mMap || !player_node)
+ {
+ gcnGraphics->setColor(gcn::Color(64, 64, 64));
+ gcnGraphics->fillRectangle(
+ gcn::Rectangle(0, 0, getWidth(), getHeight()));
return;
+ }
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -233,11 +240,11 @@ void Viewport::logic()
{
WindowContainer::logic();
+ Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY);
+
if (!mMap || !player_node)
return;
- Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY);
-
if (mPlayerFollowMouse && button & SDL_BUTTON(1) &&
#ifdef TMWSERV_SUPPORT
get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay)