void register_window(const std::string& id) { const std::vector<std::string>::iterator itor = std::find(registered_window_types().begin(), registered_window_types().end(), id); if(itor == registered_window_types().end()) { registered_window_types().push_back(id); } }
static std::set<std::string>& unit_test_registered_window_list() { static std::set<std::string> result = registered_window_types(); return result; }
/*WIKI * @begin{tag}{name="tip"}{min="0"}{max="-1"} * @begin{table}{config} * source & t_string & & Author * text & t_string & & Text of the tip. * @end{table} * @end{tag}{name="tip"} * @end{parent}{name="gui/"} */ const std::string& tgui_definition::read(const config& cfg) { id = cfg["id"].str(); description = cfg["description"]; VALIDATE(!id.empty(), missing_mandatory_wml_key("gui", "id")); VALIDATE(!description.empty(), missing_mandatory_wml_key("gui", "description")); DBG_GUI_P << "Parsing gui " << id << '\n'; /***** Control definitions *****/ for(auto & widget_type : registred_widget_type()) { widget_type.second(*this, widget_type.first, cfg, nullptr); } /***** Window types *****/ for(const auto & w : cfg.child_range("window")) { std::pair<std::string, twindow_builder> child; child.first = child.second.read(w); window_types.insert(child); } if(id == "default") { // The default gui needs to define all window types since we're the // fallback in case another gui doesn't define the window type. for(std::vector<std::string>::const_iterator itor = registered_window_types().begin(); itor != registered_window_types().end(); ++itor) { const std::string error_msg( "Window not defined in WML: '" + *itor + "'. Perhaps a mismatch between data and source versions." " Try --data-dir <trunk-dir>"); VALIDATE(window_types.find(*itor) != window_types.end(), error_msg); } } /***** settings *****/ /** * @todo Regarding sounds: * Need to evaluate but probably we want the widget definition be able to: * - Override the default (and clear it). This will allow toggle buttons in * a * listbox to sound like a toggle panel. * - Override the default and above per instance of the widget, some buttons * can give a different sound. */ const config& settings = cfg.child("settings"); popup_show_delay_ = settings["popup_show_delay"]; popup_show_time_ = settings["popup_show_time"]; help_show_time_ = settings["help_show_time"]; double_click_time_ = settings["double_click_time"]; repeat_button_repeat_time_ = settings["repeat_button_repeat_time"]; VALIDATE(double_click_time_, missing_mandatory_wml_key("settings", "double_click_time")); sound_button_click_ = settings["sound_button_click"].str(); sound_toggle_button_click_ = settings["sound_toggle_button_click"].str(); sound_toggle_panel_click_ = settings["sound_toggle_panel_click"].str(); sound_slider_adjust_ = settings["sound_slider_adjust"].str(); has_helptip_message_ = settings["has_helptip_message"]; VALIDATE(!has_helptip_message_.empty(), missing_mandatory_wml_key("[settings]", "has_helptip_message")); tips_ = tips::load(cfg); return id; }