summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-26 19:48:33 -0700
committerIra Rice <irarice@gmail.com>2009-01-26 19:48:33 -0700
commit306e345adab33a67e3fc12aad2f7ae7c6c86302c (patch)
tree78cefbb888c945a6d785ea806c54d606c9528dca
parent6b658b783521d17dffaa7609491c627f1d9763db (diff)
downloadmana-306e345adab33a67e3fc12aad2f7ae7c6c86302c.tar.gz
mana-306e345adab33a67e3fc12aad2f7ae7c6c86302c.tar.bz2
mana-306e345adab33a67e3fc12aad2f7ae7c6c86302c.tar.xz
mana-306e345adab33a67e3fc12aad2f7ae7c6c86302c.zip
Slight bit of code cleanup, as well as minor fixes to logic. For some
reason, the windows will gladly shrink when resizeable, but not grow. This will need to get resolved some time later. Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r--src/engine.cpp31
-rw-r--r--src/game.cpp8
-rw-r--r--src/gui/minimap.cpp28
3 files changed, 33 insertions, 34 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index ab13450e..29b8921a 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -81,16 +81,13 @@ void Engine::changeMap(const std::string &mapPath)
map_path = "maps/" + mapPath.substr(0, mapPath.rfind(".")) + ".tmx";
ResourceManager *resman = ResourceManager::getInstance();
if (!resman->exists(map_path))
- {
map_path += ".gz";
- }
// Attempt to load the new map
Map *newMap = MapReader::readMap(map_path);
- if (!newMap) {
+ if (!newMap)
logger->error("Could not find map file");
- }
// Notify the minimap and beingManager about the map change
Image *mapImage = NULL;
@@ -100,28 +97,24 @@ void Engine::changeMap(const std::string &mapPath)
// 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());
+ logger->log("WARNING: Map file '%s' defines a minimap image but "
+ "does not define a 'mapname' property",
+ map_path.c_str());
}
- // How many pixels equal one tile. .5 (which is the TMW default) is 2 tiles to a pixel,
- // while 1 is 1 tile to 1 pixel
+
+ // How many pixels equal one tile. .5 (which is the TMW default) is
+ // 2 tiles to a pixel, while 1 is 1 tile to 1 pixel
if (newMap->hasProperty("minimapproportion"))
- {
- minimap->setProportion(atof(newMap->getProperty("minimapproportion").c_str()));
- }
+ minimap->setProportion(atof(
+ newMap->getProperty("minimapproportion").c_str()));
else
- {
minimap->setProportion(0.5);
- }
}
minimap->setMapImage(mapImage);
beingManager->setMap(newMap);
@@ -134,16 +127,16 @@ void Engine::changeMap(const std::string &mapPath)
// Start playing new music file when necessary
std::string oldMusic = "";
- if (mCurrentMap) {
+ if (mCurrentMap)
+ {
oldMusic = mCurrentMap->getProperty("music");
delete mCurrentMap;
}
std::string newMusic = newMap->getProperty("music");
- if (newMusic != oldMusic) {
+ if (newMusic != oldMusic)
sound.playMusic(newMusic, -1);
- }
mCurrentMap = newMap;
mMapName = mapPath;
diff --git a/src/game.cpp b/src/game.cpp
index 76cf792e..5b37d409 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -234,12 +234,8 @@ void createGuiWindows(Network *network)
itemShortcutWindow->getWindowName() + "Visible", true));
emoteShortcutWindow->setVisible((bool) config.getValue(
emoteShortcutWindow->getWindowName() + "Visible", true));
-
- if (!(bool) config.getValue("MinimapVisible", true))
- minimap->toggle();
-
- if (config.getValue("logToChat", 0))
- logger->setChatWindow(chatWindow);
+ minimap->setVisible((bool) config.getValue(
+ minimap->getWindowName() + "Visible", true));
}
/**
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index e52a20ac..7802b583 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -33,14 +33,16 @@
#include "../utils/gettext.h"
-bool Minimap::mShow = config.getValue("MinimapVisible", true);
+bool Minimap::mShow = true;
Minimap::Minimap():
- Window(_("Map")),
+ Window(_("MiniMap")),
mMapImage(NULL),
mProportion(0.5)
{
setWindowName(_("MiniMap"));
+ mShow = config.getValue(getWindowName() + "Visible", true);
+ setDefaultSize(5, 25, 100, 100);
setResizable(true);
}
@@ -59,8 +61,8 @@ void Minimap::setMapImage(Image *img)
if (mMapImage)
{
- const int offsetX = getPadding() + 4;
- const int offsetY = getTitleBarHeight() + 4;
+ const int offsetX = 2 * getPadding();
+ const int offsetY = getTitleBarHeight() + getPadding();
const int titleWidth = getFont()->getWidth(getCaption()) + 15;
const int mapWidth = mMapImage->getWidth() < 100 ?
mMapImage->getWidth() + offsetX : 100;
@@ -73,10 +75,18 @@ void Minimap::setMapImage(Image *img)
setMaxHeight(mMapImage->getHeight() + offsetY);
mMapImage->setAlpha(config.getValue("guialpha", 0.8));
- setDefaultSize(offsetX, offsetY, getMinWidth() > getWidth() ?
- getMinWidth() : getWidth(),
- getMaxHeight() < getHeight() ?
- getMaxHeight() : getHeight());
+
+ // Set content size to be within the minimum and maximum boundaries
+ setWidth(getMinWidth() < getWidth() ? getWidth() : getMinWidth());
+ if (getMaxWidth() > getWidth())
+ setWidth(getMaxWidth());
+ setHeight(getMinHeight() < getHeight() ? getHeight() : getMinHeight());
+ if (getMaxHeight() > getHeight())
+ setHeight(getMaxHeight());
+
+ setDefaultSize(getX(), getY(), getWidth(), getHeight());
+ resetToDefaultSize();
+
loadWindowState();
setVisible(mShow);
}
@@ -89,7 +99,7 @@ void Minimap::setMapImage(Image *img)
void Minimap::toggle()
{
mShow = !mShow;
- config.setValue("MinimapVisible", mShow);
+ config.setValue(getWindowName() + "Visible", mShow);
}
void Minimap::draw(gcn::Graphics *graphics)