void Hotkey::ReadFromOptions(OptionsDB& db) { for (std::map<std::string, Hotkey>::iterator i = s_hotkeys->begin(); i != s_hotkeys->end(); i++) { Hotkey& hotkey = i->second; std::string options_db_name = "UI.hotkeys." + hotkey.m_name; if (!db.OptionExists(options_db_name)) { ErrorLogger() << "Hotkey::ReadFromOptions : no option for " << options_db_name; continue; } std::string option_string = db.Get<std::string>(options_db_name); std::pair<GG::Key, GG::Flags<GG::ModKey> > key_modkey_pair = HotkeyFromString(option_string); if (key_modkey_pair.first == GG::GGK_UNKNOWN) continue; if (key_modkey_pair.first == GG::EnumMap<GG::Key>::BAD_VALUE) { ErrorLogger() << "Hotkey::ReadFromOptions : Invalid key spec: '" << option_string << "' for hotkey " << hotkey.m_name; continue; } if (!IsTypingSafe(key_modkey_pair.first, key_modkey_pair.second)) { ErrorLogger() << "Hotkey::ReadFromOptions : Typing-unsafe key spec: '" << option_string << "' for hotkey " << hotkey.m_name; continue; } hotkey.m_key = key_modkey_pair.first; hotkey.m_mod_keys = key_modkey_pair.second; } }
void Hotkey::AddOptions(OptionsDB & db) { if(! s_hotkeys) return; for(std::map<std::string, Hotkey>::const_iterator i = s_hotkeys->begin(); i != s_hotkeys->end(); i++) { const Hotkey & sb = i->second; std::string n = "UI.hotkeys."; n += sb.m_name; db.Add(n, UserString(UserStringForHotkey(sb.m_name)), sb.ToString(),Validator<std::string>()); } }
void Hotkey::AddOptions(OptionsDB& db) { if (!s_hotkeys) return; for (std::map<std::string, Hotkey>::const_iterator i = s_hotkeys->begin(); i != s_hotkeys->end(); i++) { const Hotkey& hotkey = i->second; std::string n = "UI.hotkeys."; n += hotkey.m_name; db.Add(n, hotkey.GetDescription(), hotkey.ToString(), Validator<std::string>()); } }