for (vector<Hero>::size_type i(0), end(heroes.size()); i < end; ++i) {
spellMenus.push_back(res->spellMenuPrototype);
// TODO: insert real spell menu entries
- spellMenus.back().Add("Reset : 0", 0);
+ spellMenus.back().Add("Reset : 0", 0, false);
spellMenus.back().Add("Strong : 3", 0);
spellMenus.back().Add("Stronger : 8", 0);
spellMenus.back().Add("Champion :16", 0);
class Sprite;
-// TODO: disabled entries + alternate font for those
+// TODO: alternate font for disabled entries
// TODO: sprite for the cursor
// TODO: animation when top row changes
template<class T>
T &Selected() { return entries[selected].value; }
const T &Selected() const { return entries[selected].value; }
const char *SelectedTitle() const { return entries[selected].title; }
+ bool SelectedIsEnabled() const { return entries[selected].enabled; }
void NextItem();
void PreviousItem();
void PreviousRow();
void SelectIndex(int index);
- void Add(const char *title, const T &value, const Sprite *icon = 0) { entries.push_back(Entry(title, value, icon)); }
+ int EntryCount() const { return entries.size(); }
+ T &ValueAt(int index) { return entries[index].value; }
+ const T &ValueAt(int index) const { return entries[index].value; }
+
+ void Add(const char *title, const T &value, bool enabled = true, const Sprite *icon = 0) { entries.push_back(Entry(title, value, enabled, icon)); }
+ void Disable(int index) { entries[index].enabled = false; }
+ void Enable(int index) { entries[index].enabled = true; }
void Reserve(int n) { entries.reserve(n); }
void Draw(SDL_Surface *dest, geometry::Point<int> position) const;
private:
struct Entry {
- Entry(const char *title, const T &value, const Sprite *icon = 0)
- : title(title), icon(icon), value(value) { }
+ Entry(const char *title, const T &value, bool enabled = true, const Sprite *icon = 0)
+ : title(title), icon(icon), value(value), enabled(enabled) { }
const char *title;
const Sprite *icon;
T value;
+ bool enabled;
};
const Font *font;
std::vector<Entry> entries;