|
From: Tapio V. <aa...@us...> - 2010-08-22 13:01:50
|
Module: performous
Branch: master
Commit: a84373059aec782ee5f7eae0ef1a1d653fa0283a
Author: Tapio Vierros <tap...@gm...>
Date: Sun Aug 22 16:00:17 2010 +0300
Alpha-blend options that are not available.
---
game/instrumentgraph.cc | 2 +-
game/menu.cc | 10 ++++++++++
game/menu.hh | 2 ++
3 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/game/instrumentgraph.cc b/game/instrumentgraph.cc
index 10d11ca..c4464b7 100644
--- a/game/instrumentgraph.cc
+++ b/game/instrumentgraph.cc
@@ -103,7 +103,7 @@ void InstrumentGraph::drawMenu() {
txt = &th.option_selected;
}
txt->dimensions.middle(x).center(y);
- txt->draw(it->getName());
+ txt->draw(it->getName(), it->isActive() ? 1.0f : 0.5f);
w = std::max(w, txt->w() + 2 * step + button_margin * 2); // Calculate the widest entry
y += step;
}
diff --git a/game/menu.cc b/game/menu.cc
index 30ca24d..b2a4377 100644
--- a/game/menu.cc
+++ b/game/menu.cc
@@ -58,6 +58,16 @@ MenuOption::MenuOption(const std::string& nm, const std::string& comm, const std
if (!img.empty()) image.reset(new Surface(getThemePath(img)));
}
+bool MenuOption::isActive() const {
+ if (type == OPEN_SUBMENU && options.empty()) return false;
+ else if (type == CHANGE_VALUE) {
+ if (!value) return false;
+ if (value->get_type() == "option_list" && value->ol().size() <= 1)
+ return false;
+ }
+ return true;
+}
+
Menu::Menu():
diff --git a/game/menu.hh b/game/menu.hh
index 9845969..37b7ae3 100644
--- a/game/menu.hh
+++ b/game/menu.hh
@@ -36,6 +36,8 @@ class MenuOption {
const std::string& getName() const { if (namePtr) return *namePtr; else return name; }
/// Return comment
const std::string& getComment() const { if (commentPtr) return *commentPtr; else return comment; }
+ /// Check if this option can be selected
+ bool isActive() const;
/// Value
ConfigItem* value;
/// Value-to-be-set
|