added theme dialog
This commit is contained in:
parent
1ed408dc7c
commit
bd7e59d6b1
5 changed files with 49 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
CVS HEAD:
|
||||
* Added theme dialog. started with ":theme"
|
||||
* Added UNIT, UNDEAD_UNIT, and PLACE_IMAGE macros to utils.cfg
|
||||
* terrain improvements
|
||||
* fixed swamp transition (NW, SE) graphics
|
||||
|
|
|
@ -391,6 +391,7 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
LOG_NG << "initializing display... " << (SDL_GetTicks() - ticks) << "\n";
|
||||
const config dummy_cfg;
|
||||
display gui(units,video,map,status,teams,theme_cfg != NULL ? *theme_cfg : dummy_cfg, game_config, *level);
|
||||
theme::set_known_themes(&game_config);
|
||||
|
||||
LOG_NG << "done initializing display... " << (SDL_GetTicks() - ticks) << "\n";
|
||||
|
||||
|
|
|
@ -2410,7 +2410,19 @@ void turn_info::do_command(const std::string& str)
|
|||
}
|
||||
} else if (teams_[index].is_ai()) {
|
||||
teams_[index].make_human();
|
||||
}
|
||||
} else if (cmd == "theme") {
|
||||
int action = 0;
|
||||
std::vector<std::string> options=theme::get_known_themes();
|
||||
std::string current_theme=_("Saved Theme Preference: ")+preferences::theme();
|
||||
action = gui::show_dialog(gui_,NULL,"",current_theme,gui::OK_CANCEL,&options);
|
||||
if(action >-1){
|
||||
preferences::set_theme(options[action]);
|
||||
//it would be preferable for the new theme to take effect
|
||||
//immediately, however, this will have to do for now.
|
||||
gui::show_dialog(gui_,NULL,"",_("New theme will take effect on next new or loaded game."),gui::MESSAGE);
|
||||
}
|
||||
|
||||
} else if(cmd == "ban") {
|
||||
config cfg;
|
||||
config& ban = cfg.add_child("ban");
|
||||
|
|
|
@ -424,8 +424,7 @@ const std::string& theme::menu::image() const { return image_; }
|
|||
|
||||
const std::vector<std::string>& theme::menu::items() const { return items_; }
|
||||
|
||||
theme::theme(const config& cfg, const SDL_Rect& screen) : cfg_(resolve_rects(cfg))
|
||||
{
|
||||
theme::theme(const config& cfg, const SDL_Rect& screen):cfg_(resolve_rects(cfg)){
|
||||
set_resolution(screen);
|
||||
}
|
||||
|
||||
|
@ -553,3 +552,30 @@ const SDL_Rect& theme::mini_map_location(const SDL_Rect& screen) const
|
|||
{
|
||||
return mini_map_.location(screen);
|
||||
}
|
||||
|
||||
std::map<std::string, config> theme::known_themes;
|
||||
void theme::set_known_themes(const config* cfg){
|
||||
known_themes.clear();
|
||||
if(cfg == NULL)
|
||||
return;
|
||||
const config& v = *cfg;
|
||||
const config::child_list& known_themes_cfg = v.get_children("theme");
|
||||
|
||||
for(config::child_list::const_iterator thm = known_themes_cfg.begin(); thm != known_themes_cfg.end(); ++thm) {
|
||||
std::string thm_name=(**thm)["name"];
|
||||
if(thm_name!="null" && thm_name!="editor"){
|
||||
known_themes[thm_name]=(**thm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> theme::get_known_themes(){
|
||||
std::vector<std::string> names;
|
||||
|
||||
|
||||
for(std::map<std::string, config>::iterator p_thm=known_themes.begin();p_thm!=known_themes.end();p_thm++){
|
||||
names.push_back(p_thm->first);
|
||||
}
|
||||
return(names);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class config;
|
||||
|
||||
|
@ -132,8 +133,13 @@ public:
|
|||
const SDL_Rect& main_map_location(const SDL_Rect& screen) const;
|
||||
const SDL_Rect& mini_map_location(const SDL_Rect& screen) const;
|
||||
|
||||
static void set_known_themes(const config* cfg);
|
||||
static std::vector<std::string> get_known_themes();
|
||||
|
||||
private:
|
||||
const config& cfg_;
|
||||
static std::map<std::string, config> theme::known_themes;
|
||||
std::string cur_theme;
|
||||
const config& cfg_;
|
||||
std::vector<panel> panels_;
|
||||
std::vector<label> labels_;
|
||||
std::vector<menu> menus_;
|
||||
|
|
Loading…
Add table
Reference in a new issue