summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-08 20:28:31 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-08 20:40:26 +0200
commite45cefb6b073447c10145b65b59f30af440ce77c (patch)
tree504a1cd3215c02fdf21345e90a695790126f1d32
parent5f59d91bf515f02f65e8883b310d89e518b4ea80 (diff)
downloadmanaverse-e45cefb6b073447c10145b65b59f30af440ce77c.tar.gz
manaverse-e45cefb6b073447c10145b65b59f30af440ce77c.tar.bz2
manaverse-e45cefb6b073447c10145b65b59f30af440ce77c.tar.xz
manaverse-e45cefb6b073447c10145b65b59f30af440ce77c.zip
Fixing code style and adding configuration option for extented minimaps.
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/minimap.cpp63
-rw-r--r--src/gui/setup_other.cpp19
-rw-r--r--src/gui/setup_other.h3
4 files changed, 63 insertions, 23 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index b6f72887a..dddded0a8 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -193,6 +193,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "usePersistentIP", false);
AddDEF(configData, "showJobExp", true);
AddDEF(configData, "showBeingPopup", true);
+ AddDEF(configData, "showExtMinimaps", false);
return configData;
}
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 9efacdce6..1dd9ba54e 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -94,31 +94,52 @@ void Minimap::setMap(Map *map)
mMapImage = 0;
}
- if (true/* TODO replace this with an option*/) {
- // should this optionally happen only if there is no resourcemanager option? i.e. a tristate always, fallback, never?
- SDL_Surface* surface = SDL_CreateRGBSurface(SDL_SWSURFACE, map->getWidth(), map->getHeight(), 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
- // I'm not sure if the locks are necessary since it's a SWSURFACE
- SDL_LockSurface(surface);
- int* data = (int*)surface->pixels;
- for (int y = 0; y < surface->h; y++)
- for (int x = 0; x < surface->w; x++)
- *(data++) = -map->getWalk(x,y);
- SDL_UnlockSurface(surface);
- mMapImage = Image::load(surface);
- SDL_FreeSurface(surface);
- }
- else if (map)
+ if (map)
{
- std::string tempname =
- "graphics/minimaps/" + map->getFilename() + ".png";
- ResourceManager *resman = ResourceManager::getInstance();
+ if (config.getBoolValue("showExtMinimaps"))
+ {
+ SDL_Surface* surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ map->getWidth(), map->getHeight(), 32,
+ 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
+ if (!surface)
+ {
+ if (!isSticky())
+ setVisible(false);
+ return;
+ }
+
+ // I'm not sure if the locks are necessary since it's a SWSURFACE
+ SDL_LockSurface(surface);
+ int* data = (int*)surface->pixels;
+ if (!data)
+ {
+ if (!isSticky())
+ setVisible(false);
+ return;
+ }
+ for (int y = 0; y < surface->h; y ++)
+ {
+ for (int x = 0; x < surface->w; x ++)
+ *(data ++) = -map->getWalk(x,y);
+ }
+ SDL_UnlockSurface(surface);
- minimapName = map->getProperty("minimap");
+ mMapImage = Image::load(surface);
+ SDL_FreeSurface(surface);
+ }
+ else
+ {
+ std::string tempname =
+ "graphics/minimaps/" + map->getFilename() + ".png";
+ ResourceManager *resman = ResourceManager::getInstance();
+
+ minimapName = map->getProperty("minimap");
- if (minimapName.empty() && resman->exists(tempname))
- minimapName = tempname;
+ if (minimapName.empty() && resman->exists(tempname))
+ minimapName = tempname;
- mMapImage = resman->getImage(minimapName);
+ mMapImage = resman->getImage(minimapName);
+ }
}
if (mMapImage && map)
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 5e7895c23..be5f31665 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -65,6 +65,7 @@
#define ACTION_SHOW_OWN_HP "show own hp"
#define ACTION_SHOW_JOB_EXP "show job exp"
#define ACTION_SHOW_BEING_POPUP "show being popup"
+#define ACTION_SHOW_EXTENDED_MINIMAPS "show extended minimaps"
Setup_Other::Setup_Other():
mShowMonstersTakedDamage(config.getBoolValue("showMonstersTakedDamage")),
@@ -92,6 +93,7 @@ Setup_Other::Setup_Other():
mShowOwnHP(config.getBoolValue("showOwnHP")),
mShowJobExp(config.getBoolValue("showJobExp")),
mShowBeingPopup(config.getBoolValue("showBeingPopup")),
+ mShowExtMinimaps(config.getBoolValue("showExtMinimaps")),
mEditDialog(0)
{
setName(_("Misc"));
@@ -192,8 +194,12 @@ Setup_Other::Setup_Other():
this, ACTION_SHOW_JOB_EXP);
mShowBeingPopupCheckBox = new CheckBox(_("Show players popups"),
- mShowBeingPopup,
- this, ACTION_SHOW_BEING_POPUP);
+ mShowBeingPopup,
+ this, ACTION_SHOW_BEING_POPUP);
+
+ mShowExtMinimapsCheckBox = new CheckBox(_("Show extended minimaps"),
+ mShowExtMinimaps,
+ this, ACTION_SHOW_EXTENDED_MINIMAPS);
// Do the layout
LayoutHelper h(this);
@@ -212,6 +218,7 @@ Setup_Other::Setup_Other():
place(12, 7, mShowOwnHPCheckBox, 10);
place(12, 8, mShowJobExpCheckBox, 10);
place(12, 9, mShowBeingPopupCheckBox, 10);
+ place(12, 10, mShowExtMinimapsCheckBox, 10);
place(0, 3, mFloorItemsHighlightCheckBox, 12);
place(0, 4, mHighlightAttackRangeCheckBox, 12);
place(0, 5, mHighlightMonsterAttackRangeCheckBox, 12);
@@ -352,6 +359,10 @@ void Setup_Other::action(const gcn::ActionEvent &event)
{
mShowBeingPopup = mShowBeingPopupCheckBox->isSelected();
}
+ else if (event.getId() == ACTION_SHOW_EXTENDED_MINIMAPS)
+ {
+ mShowExtMinimaps = mShowExtMinimapsCheckBox->isSelected();
+ }
}
void Setup_Other::cancel()
@@ -430,6 +441,9 @@ void Setup_Other::cancel()
mShowBeingPopup = config.getBoolValue("showBeingPopup");
mShowBeingPopupCheckBox->setSelected(mShowBeingPopup);
+
+ mShowExtMinimaps = config.getBoolValue("showExtMinimaps");
+ mShowExtMinimapsCheckBox->setSelected(mShowExtMinimaps);
}
void Setup_Other::apply()
@@ -459,6 +473,7 @@ void Setup_Other::apply()
config.setValue("showOwnHP", mShowOwnHP);
config.setValue("showJobExp", mShowJobExp);
config.setValue("showBeingPopup", mShowBeingPopup);
+ config.setValue("showExtMinimaps", mShowExtMinimaps);
logger->setDebugLog(mDebugLog);
}
diff --git a/src/gui/setup_other.h b/src/gui/setup_other.h
index 041aad9f3..44daa1237 100644
--- a/src/gui/setup_other.h
+++ b/src/gui/setup_other.h
@@ -119,6 +119,9 @@ class Setup_Other : public SetupTab, public gcn::ActionListener
gcn::CheckBox *mShowBeingPopupCheckBox;
bool mShowBeingPopup;
+ gcn::CheckBox *mShowExtMinimapsCheckBox;
+ bool mShowExtMinimaps;
+
EditDialog *mEditDialog;
};