theme::refresh_title() offers a way to change the title of a button midgame.

This commit is contained in:
Jörg Hinrichs 2007-10-04 19:23:40 +00:00
parent f48dd59e87
commit 2eaaac8db7
2 changed files with 18 additions and 0 deletions

View file

@ -724,3 +724,15 @@ std::vector<std::string> theme::get_known_themes(){
return(names);
}
theme::menu* theme::refresh_title(std::string id, const std::string new_title){
theme::menu* res = NULL;
for (std::vector<theme::menu>::iterator m = menus_.begin(); m != menus_.end(); ++m){
if (m->get_id() == id) {
res = &(*m);
res->set_title(new_title);
}
}
return res;
}

View file

@ -182,6 +182,8 @@ public:
const std::string& image() const { return image_; }
const std::vector<std::string>& items() const { return items_; }
void set_title(const std::string new_title) { title_ = new_title; }
private:
bool context_;
std::string title_, tooltip_, image_, type_;
@ -199,6 +201,10 @@ public:
const menu* context_menu() const
{ return context_.is_context() ? &context_ : NULL; }
//Changes the title of a menu entry, identified by its id.
//If no menu entry is found, an empty menu object is being returned.
menu* refresh_title(std::string id, const std::string new_title);
const status_item* get_status_item(const std::string& item) const;
const SDL_Rect& main_map_location(const SDL_Rect& screen) const