explicit subset_descriptor(const config & font) : name(font["name"].str()) , bold_name() , italic_name() , present_codepoints() { if (font.has_attribute("bold_name")) { bold_name = font["bold_name"].str(); } if (font.has_attribute("italic_name")) { italic_name = font["italic_name"].str(); } std::vector<std::string> ranges = utils::split(font["codepoints"]); for (const std::string & i : ranges) { std::vector<std::string> r = utils::split(i, '-'); if(r.size() == 1) { size_t r1 = lexical_cast_default<size_t>(r[0], 0); present_codepoints.push_back(std::pair<size_t, size_t>(r1, r1)); } else if(r.size() == 2) { size_t r1 = lexical_cast_default<size_t>(r[0], 0); size_t r2 = lexical_cast_default<size_t>(r[1], 0); present_codepoints.push_back(std::pair<size_t, size_t>(r1, r2)); } } }
// This constructor is *only* meant for loading from saves pathfind::teleport_group::teleport_group(const config& cfg) : cfg_(cfg), reversed_(utils::string_bool(cfg["reversed"], false)), id_(cfg["id"]) { assert(cfg.has_attribute("id")); assert(cfg.has_attribute("reversed")); assert(cfg_.child_count("source") == 1); assert(cfg_.child_count("target") == 1); assert(cfg_.child_count("filter") == 1); }
game_info::ADDON_REQ game_info::check_addon_version_compatibility(const config& local_item, const config& game) { if(!local_item.has_attribute("addon_id") || !local_item.has_attribute("addon_version")) { return SATISFIED; } if(const config& game_req = game.find_child("addon", "id", local_item["addon_id"])) { required_addon r = {local_item["addon_id"].str(), SATISFIED, ""}; // Local version const version_info local_ver(local_item["addon_version"].str()); version_info local_min_ver(local_item.has_attribute("addon_min_version") ? local_item["addon_min_version"] : local_item["addon_version"]); // If the UMC didn't specify last compatible version, assume no backwards compatibility. // Also apply some sanity checking regarding min version; if the min ver doens't make sense, ignore it. local_min_ver = std::min(local_min_ver, local_ver); // Remote version const version_info remote_ver(game_req["version"].str()); version_info remote_min_ver(game_req.has_attribute("min_version") ? game_req["min_version"] : game_req["version"]); remote_min_ver = std::min(remote_min_ver, remote_ver); // Check if the host is too out of date to play. if(local_min_ver > remote_ver) { r.outcome = CANNOT_SATISFY; // TODO: Figure out how to ask the add-on manager for the user-friendly name of this add-on. r.message = vgettext("The host's version of <i>$addon</i> is incompatible. They have version <b>$host_ver</b> while you have version <b>$local_ver</b>.", { {"addon", r.addon_id}, {"host_ver", remote_ver.str()}, {"local_ver", local_ver.str()} }); required_addons.push_back(r); return r.outcome; } // Check if our version is too out of date to play. if(remote_min_ver > local_ver) { r.outcome = NEED_DOWNLOAD; // TODO: Figure out how to ask the add-on manager for the user-friendly name of this add-on. r.message = vgettext("Your version of <i>$addon</i> is incompatible. You have version <b>$local_ver</b> while the host has version <b>$host_ver</b>.", { {"addon", r.addon_id}, {"host_ver", remote_ver.str()}, {"local_ver", local_ver.str()} }); required_addons.push_back(r); return r.outcome; } } return SATISFIED; }
void team::team_info::handle_legacy_share_vision(const config& cfg) { if(cfg.has_attribute("share_view") || cfg.has_attribute("share_maps")) { if(cfg["share_view"].to_bool()) { share_vision = team::SHARE_VISION::ALL; } else if(cfg["share_maps"].to_bool(true)) { share_vision = team::SHARE_VISION::SHROUD; } else { share_vision = team::SHARE_VISION::NONE; } } }
lua_candidate_action_wrapper_external(rca_context& context, const config& cfg, lua_ai_context &lua_ai_ctx) : lua_candidate_action_wrapper_base(context,cfg), location_(cfg["location"]), use_parms_(false) { if (cfg.has_attribute("exec_parms") || cfg.has_attribute("eval_parms")) { use_parms_ = true; exec_parms_ = cfg["exec_parms"].str(); eval_parms_ = cfg["eval_parms"].str(); } std::string eval_code; std::string exec_code; generate_code(eval_code, exec_code); evaluation_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(eval_code.c_str(),lua_ai_ctx)); execution_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(exec_code.c_str(),lua_ai_ctx)); }
theme::label::label(const config& cfg) : object(cfg), text_(cfg["prefix"].str() + cfg["text"].str() + cfg["postfix"].str()), icon_(cfg["icon"]), font_(cfg["font_size"]), font_rgb_set_(false), font_rgb_(DefaultFontRGB) { if(font_ == 0) font_ = DefaultFontSize; if (cfg.has_attribute("font_rgb")) { std::vector<std::string> rgb_vec = utils::split(cfg["font_rgb"]); if (3 <= rgb_vec.size()) { std::vector<std::string>::iterator c=rgb_vec.begin(); int r,g,b; r = (atoi(c->c_str())); ++c; if (c != rgb_vec.end()) { g = (atoi(c->c_str())); ++c; } else { g=0; } if (c != rgb_vec.end()) { b=(atoi(c->c_str())); } else { b=0; } font_rgb_ = (((r<<16) & 0x00FF0000) + ((g<<8) & 0x0000FF00) + ((b) & 0x000000FF)); font_rgb_set_=true; } } }
class_tag::class_tag(const config & cfg) : name_(cfg["name"].str()) , min_(cfg["min"].to_int()) , max_(cfg["max"].to_int()) , super_("") , tags_() , keys_() , links_() { if (max_ < 0){ max_ = INT_MAX; } if (cfg.has_attribute("super")){ super_ = cfg["super"].str(); } foreach (const config &child, cfg.child_range("tag")) { class_tag child_tag (child); add_tag(child_tag); } foreach (const config &child, cfg.child_range("key")) { class_key child_key (child); add_key(child_key); } foreach (const config &link, cfg.child_range("link")) { std::string link_name = link["name"].str(); add_link(link_name); } }
void carryover_info::transfer_to(config& level) { if(!level.has_attribute("next_underlying_unit_id")) { level["next_underlying_unit_id"] = next_underlying_unit_id_; } //if the game has been loaded from a snapshot, variables_ is empty since we cleared it below. level.child_or_add("variables").append(std::move(variables_)); config::attribute_value & seed_value = level["random_seed"]; if ( seed_value.empty() ) { seed_value = rng_.get_random_seed_str(); level["random_calls"] = rng_.get_random_calls(); } if(!level.has_child("menu_item")){ for(config& item : wml_menu_items_) { level.add_child("menu_item").swap(item); } } next_scenario_ = ""; variables_.clear(); wml_menu_items_.clear(); }
void carryover_info::transfer_to(config& level) { if(!level.has_attribute("next_underlying_unit_id")) { level["next_underlying_unit_id"] = next_underlying_unit_id_; } //if the game has been loaded from a snapshot, the existing variables will be the current ones if(!level.has_child("variables")) { level.add_child("variables", variables_); } config::attribute_value & seed_value = level["random_seed"]; if ( seed_value.empty() ) { seed_value = rng_.get_random_seed_str(); level["random_calls"] = rng_.get_random_calls(); } if(!level.has_child("menu_item")){ for(config& item : wml_menu_items_) { level.add_child("menu_item").swap(item); } } next_scenario_ = ""; variables_ = config(); wml_menu_items_.clear(); }
void carryover_info::transfer_all_to(config& side_cfg){ if(side_cfg["save_id"].empty()){ side_cfg["save_id"] = side_cfg["id"]; } std::vector<carryover>::iterator iside = std::find_if( carryover_sides_.begin(), carryover_sides_.end(), save_id_equals(side_cfg["save_id"]) ); if(iside != carryover_sides_.end()) { iside->transfer_all_gold_to(side_cfg); iside->transfer_all_recalls_to(side_cfg); iside->transfer_all_recruits_to(side_cfg); carryover_sides_.erase(iside); return; } else { //if no carryover was found for this side, check if starting gold is defined if(!side_cfg.has_attribute("gold") || side_cfg["gold"].empty()){ side_cfg["gold"] = default_gold_qty; } } }
void engine_lua::do_parse_candidate_action_from_config( rca_context &context, const config &cfg, std::back_insert_iterator<std::vector< candidate_action_ptr > > b ){ if (!cfg) { return; } if (!lua_ai_context_) { return; } candidate_action_ptr ca_ptr; if (!cfg["sticky"].to_bool()) { if (cfg.has_attribute("location")) { ca_ptr = candidate_action_ptr(new lua_candidate_action_wrapper_external(context,cfg,*lua_ai_context_)); } else { ca_ptr = candidate_action_ptr(new lua_candidate_action_wrapper(context,cfg,*lua_ai_context_)); } } else { ca_ptr = candidate_action_ptr(new lua_sticky_candidate_action_wrapper(context,cfg,*lua_ai_context_)); } if (ca_ptr) { *b = ca_ptr; } }
std::string engine_lua::get_engine_code(const config &cfg) const { if (cfg.has_attribute("code")) { return cfg["code"].str(); } // If there is no engine defined we create a dummy engine std::string code = "wesnoth.require(\"ai/lua/dummy_engine_lua.lua\")"; return code; }
bool handle_change(const path_element &child, config cfg) { if (!handle_delete(child)) { return false; } if (!cfg.has_attribute("id")) { cfg["id"] = child.id; } return handle_add(child,cfg); }
void name_generator_factory::add_name_generator_from_config(const config& config, const std::string id, const std::string prefix) { std::string cfg_name = prefix + "name_generator"; std::string markov_name = prefix + "names"; if(config.has_attribute(cfg_name)) { try { name_generators_[id] = std::shared_ptr<name_generator>(new context_free_grammar_generator(config[cfg_name])); } catch (const name_generator_invalid_exception& ex) { lg::wml_error() << ex.what() << '\n'; } } if(config.has_attribute(markov_name)) { config::attribute_value markov_name_list = config[markov_name]; if(!markov_name_list.blank()) { name_generators_[id] = std::shared_ptr<name_generator>(new markov_generator(utils::split(markov_name_list), config["markov_chain_size"].to_int(2), 12)); } } };
bool handle_change(const path_element &child, config cfg) { if (aspects_.find(child.id) == aspects_.end()) { return false; } if (!cfg.has_attribute("name")) { cfg["name"] = "composite_aspect"; } cfg["id"] = child.id; factory_(aspects_, cfg, child.id); return true; }
lua_goal::lua_goal(readonly_context &context, const config &cfg) : goal(context, cfg) , code_() , handler_() { if (cfg.has_attribute("code")) { code_ = cfg["code"].str(); } else { ERR_AI_GOAL << "side " << get_side() << " : Error creating Lua goal (missing code= key)" << std::endl; } }
random_map::random_map(const config& data) : scenario(data), generator_data_(), generate_whole_scenario_(data_.has_attribute("scenario_generation")), generator_name_(generate_whole_scenario_ ? data_["scenario_generation"] : data_["map_generation"]) { if (!data.has_child("generator")) { data_ = config(); generator_data_= config(); data_["description"] = "Error: Random map found with missing generator information. Scenario should have a [generator] child."; data_["error_message"] = "missing [generator] tag"; } else { generator_data_ = data.child("generator"); } if (!data.has_attribute("scenario_generation") && !data.has_attribute("map_generation")) { data_ = config(); generator_data_= config(); data_["description"] = "Error: Random map found with missing generator information. Scenario should have a [generator] child."; data_["error_message"] = "couldn't find 'scenario_generation' or 'map_generation' attribute"; } }
background_layer::background_layer(const config& cfg) : scale_horizontally_(true) , scale_vertically_(true) , tile_horizontally_(false) , tile_vertically_(false) , keep_aspect_ratio_(true) , is_base_layer_(false) , image_file_() { if(cfg.has_attribute("image")) { image_file_ = cfg["image"].str(); } if(cfg.has_attribute("scale")) { scale_vertically_ = cfg["scale"].to_bool(true); scale_horizontally_ = cfg["scale"].to_bool(true); } else { if(cfg.has_attribute("scale_vertically")) { scale_vertically_ = cfg["scale_vertically"].to_bool(true); } if(cfg.has_attribute("scale_horizontally")) { scale_horizontally_ = cfg["scale_horizontally"].to_bool(true); } } if(cfg.has_attribute("tile")) { tile_vertically_ = cfg["tile"].to_bool(false); tile_horizontally_ = cfg["tile"].to_bool(false); } else { if(cfg.has_attribute("tile_vertically")) { tile_vertically_ = cfg["tile_vertically"].to_bool(false); } if(cfg.has_attribute("tile_horizontally")) { tile_horizontally_ = cfg["tile_horizontally"].to_bool(false); } } if(cfg.has_attribute("keep_aspect_ratio")) { keep_aspect_ratio_ = cfg["keep_aspect_ratio"].to_bool(true); } if(cfg.has_attribute("base_layer")) { is_base_layer_ = cfg["base_layer"].to_bool(false); } }
carryover::carryover(const config& side) : add_(!side["carryover_add"].empty() ? side["carryover_add"].to_bool() : side["add"].to_bool()) , current_player_(side["current_player"]) , gold_(!side["carryover_gold"].empty() ? side["carryover_gold"].to_int() : side["gold"].to_int()) // if we load it from a snapshot we need to read the recruits from "recruits" and not from "previous_recruits". , previous_recruits_(side.has_attribute("recruit") ? utils::set_split(side["recruit"]) :utils::set_split(side["previous_recruits"])) , recall_list_() , save_id_(side["save_id"]) , variables_(side.child_or_empty("variables")) { for(const config& u : side.child_range("unit")) { recall_list_.push_back(u); config& u_back = recall_list_.back(); u_back.remove_attributes("side", "goto_x", "goto_y", "x", "y", "hidden"); } }
theme::label::label(const config& cfg) : object(cfg) , text_(cfg["prefix"].str() + cfg["text"].str() + cfg["postfix"].str()) , icon_(cfg["icon"]) , font_(cfg["font_size"]) , font_rgb_set_(false) , font_rgb_(DefaultFontRGB) { if(font_ == 0) font_ = DefaultFontSize; if(cfg.has_attribute("font_rgb")) { font_rgb_ = color_t::from_rgb_string(cfg["font_rgb"]); font_rgb_set_ = true; } }
bool persist_file_context::set_var(const std::string &global,const config &val, bool immediate) { // if (cfg_.empty()) { // load_persist_data(namespace_,cfg_); // } config bak; config bactive; if (immediate) { bak = cfg_; bactive = active_->cfg_.child_or_add("variables"); load(); root_node_.init(); } config &cfg = active_->cfg_.child_or_add("variables"); if (val.has_attribute(global)) { if (val[global].empty()) { clear_var(global,immediate); } else { cfg[global] = val[global]; if (immediate) bactive[global] = val[global]; } } else { cfg.clear_children(global); cfg.append(val); if (immediate) { bactive.clear_children(global); bactive.append(val); } } // dirty_ = true; if (!in_transaction_) return save_context(); else if (immediate) { bool ret = save_context(); cfg_ = bak; root_node_.init(); active_->cfg_.clear_children("variables"); active_->cfg_.remove_attribute("variables"); active_->cfg_.add_child("variables",bactive); return ret; } else return true; }
void full_rect_cfg(const config& cfg, config& result) { static std::vector<std::string> rect_fields; if (rect_fields.empty()) { rect_fields.push_back("rect"); rect_fields.push_back("ref"); rect_fields.push_back("xanchor"); rect_fields.push_back("yanchor"); } for (std::vector<std::string>::const_iterator it = rect_fields.begin(); it != rect_fields.end(); ++ it) { const std::string& key = *it; if (cfg.has_attribute(key)) { result[key] = cfg[key]; } else { result[key] = null_str; } } }
lua_map_generator::lua_map_generator(const config & cfg) : id_(cfg["id"]) , config_name_(cfg["config_name"]) , user_config_(cfg["user_config"]) , create_map_(cfg["create_map"]) , create_scenario_(cfg["create_scenario"]) , lk_() , generator_data_(cfg) { const char* required[] = {"id", "config_name", "create_map"}; for (std::string req : required) { if (!cfg.has_attribute(req)) { std::string msg = "Error when constructing a lua map generator -- missing a required attribute '"; msg += req + "'\n"; msg += "Config was '" + cfg.debug() + "'"; throw mapgen_exception(msg); } } }
theme::status_item::status_item(const config& cfg) : object(cfg) , prefix_(cfg["prefix"].str() + cfg["prefix_literal"].str()) , postfix_(cfg["postfix_literal"].str() + cfg["postfix"].str()) , label_() , font_(cfg["font_size"]) , font_rgb_set_(false) , font_rgb_(DefaultFontRGB) { if(font_ == 0) font_ = DefaultFontSize; if(const config& label_child = cfg.child("label")) { label_ = label(label_child); } if(cfg.has_attribute("font_rgb")) { font_rgb_ = color_t::from_rgb_string(cfg["font_rgb"]); font_rgb_set_ = true; } }
carryover::carryover(const config& side) : add_(side["add"].to_bool()) , color_(side["color"]) , current_player_(side["current_player"]) , gold_(side["gold"].to_int()) , name_(side["name"]) // if we load it from a snapshot we need to read the recruits from "recruits" and not from "previous_recruits". , previous_recruits_(side.has_attribute("recruit") ? utils::set_split(side["recruit"]) :utils::set_split(side["previous_recruits"])) , recall_list_() , save_id_(side["save_id"]) { BOOST_FOREACH(const config& u, side.child_range("unit")){ recall_list_.push_back(u); config& u_back = recall_list_.back(); u_back.remove_attribute("side"); u_back.remove_attribute("goto_x"); u_back.remove_attribute("goto_y"); u_back.remove_attribute("x"); u_back.remove_attribute("y"); } }
frame_builder::frame_builder(const config& cfg,const std::string& frame_string) : duration_(1), image_(cfg[frame_string + "image"]), image_diagonal_(cfg[frame_string + "image_diagonal"]), image_horizontal_(cfg[frame_string + "image_horizontal"]), image_mod_(cfg[frame_string + "image_mod"]), stext_(cfg[frame_string + "stext"]), halo_(cfg[frame_string + "halo"]), halo_x_(cfg[frame_string + "halo_x"]), halo_y_(cfg[frame_string + "halo_y"]), halo_mod_(cfg[frame_string + "halo_mod"]), sound_(cfg[frame_string + "sound"]), text_(cfg[frame_string + "text"]), text_color_(default_text_color), font_size_(cfg[frame_string + "font_size"].to_int(0)), blend_with_(0), blend_ratio_(cfg[frame_string + "blend_ratio"]), highlight_ratio_(cfg[frame_string + "alpha"]), offset_x_(cfg[frame_string + "offset_x"]), offset_y_(cfg[frame_string + "offset_y"]), submerge_(cfg[frame_string + "submerge"]), x_(cfg[frame_string + "x"]), y_(cfg[frame_string + "y"]), directional_x_(cfg[frame_string + "directional_x"]), directional_y_(cfg[frame_string + "directional_y"]), auto_vflip_(t_unset), auto_hflip_(t_unset), primary_frame_(t_unset), drawing_layer_(cfg[frame_string + "layer"]) { if(!cfg.has_attribute(frame_string + "auto_vflip")) { auto_vflip_ = t_unset; } else if(cfg[frame_string + "auto_vflip"].to_bool()) { auto_vflip_ = t_true; } else { auto_vflip_ = t_false; } if(!cfg.has_attribute(frame_string + "auto_hflip")) { auto_hflip_ = t_unset; } else if(cfg[frame_string + "auto_hflip"].to_bool()) { auto_hflip_ = t_true; } else { auto_hflip_ = t_false; } if(!cfg.has_attribute(frame_string + "primary")) { primary_frame_ = t_unset; } else if(cfg[frame_string + "primary"].to_bool()) { primary_frame_ = t_true; } else { primary_frame_ = t_false; } std::vector<std::string> color = utils::split(cfg[frame_string + "text_color"]); if (color.size() == 3) { text_color_ = display::rgb(atoi(color[0].c_str()), atoi(color[1].c_str()), atoi(color[2].c_str())); text_color_ &= 0xffffff; } if (const config::attribute_value *v = cfg.get(frame_string + "duration")) { duration(*v); } else { duration(cfg[frame_string + "end"].to_int() - cfg[frame_string + "begin"].to_int()); } color = utils::split(cfg[frame_string + "blend_color"]); if (color.size() == 3) { blend_with_ = display::rgb(atoi(color[0].c_str()), atoi(color[1].c_str()), atoi(color[2].c_str())); } }
void team::team_info::read(const config& cfg) { gold = cfg["gold"]; income = cfg["income"]; team_name = cfg["team_name"].str(); user_team_name = cfg["user_team_name"]; side_name = cfg["side_name"]; faction = cfg["faction"].str(); faction_name = cfg["faction_name"]; save_id = cfg["save_id"].str(); current_player = cfg["current_player"].str(); countdown_time = cfg["countdown_time"].str(); action_bonus_count = cfg["action_bonus_count"]; flag = cfg["flag"].str(); flag_icon = cfg["flag_icon"].str(); id = cfg["id"].str(); scroll_to_leader = cfg["scroll_to_leader"].to_bool(true); objectives = cfg["objectives"]; objectives_changed = cfg["objectives_changed"].to_bool(); disallow_observers = cfg["disallow_observers"].to_bool(); allow_player = cfg["allow_player"].to_bool(true); chose_random = cfg["chose_random"].to_bool(false); no_leader = cfg["no_leader"].to_bool(); defeat_condition = cfg["defeat_condition"].to_enum<team::DEFEAT_CONDITION>(team::DEFEAT_CONDITION::NO_LEADER); lost = cfg["lost"].to_bool(false); hidden = cfg["hidden"].to_bool(); no_turn_confirmation = cfg["suppress_end_turn_confirmation"].to_bool(); side = cfg["side"].to_int(1); carryover_percentage = cfg["carryover_percentage"].to_int(game_config::gold_carryover_percentage); carryover_add = cfg["carryover_add"].to_bool(false); carryover_bonus = cfg["carryover_bonus"].to_double(1); carryover_gold = cfg["carryover_gold"].to_int(0); variables = cfg.child_or_empty("variables"); is_local = cfg["is_local"].to_bool(true); color = get_side_color_id_from_config(cfg); // If starting new scenario override settings from [ai] tags if(!user_team_name.translatable()) user_team_name = t_string::from_serialized(user_team_name); display* disp = display::get_singleton(); // // FIXME: the display isn't constructed at this point when launching a game, // but we still want to add the ai config. On the other hand, when creating // a scenario in the editor, the display IS constructed, but there's no AI // manager. All of which leads to this awkward conditional. We really should // figure out a better one... // // --vultraz, 2018-01-26 // if(!disp || !disp->in_editor()) { if(cfg.has_attribute("ai_config")) { ai::manager::get_singleton().add_ai_for_side_from_file(side, cfg["ai_config"], true); } else { ai::manager::get_singleton().add_ai_for_side_from_config(side, cfg, true); } } std::vector<std::string> recruits = utils::split(cfg["recruit"]); can_recruit.insert(recruits.begin(), recruits.end()); // at the start of a scenario "start_gold" is not set, we need to take the // value from the gold setting (or fall back to the gold default) if(!cfg["start_gold"].empty()) { start_gold = cfg["start_gold"]; } else if(!cfg["gold"].empty()) { start_gold = gold; } else { start_gold = default_team_gold_; } if(team_name.empty()) { team_name = cfg["side"].str(); } if(save_id.empty()) { save_id = id; } income_per_village = cfg["village_gold"].to_int(game_config::village_income); recall_cost = cfg["recall_cost"].to_int(game_config::recall_cost); const std::string& village_support = cfg["village_support"]; if(village_support.empty()) { support_per_village = game_config::village_support; } else { support_per_village = lexical_cast_default<int>(village_support, game_config::village_support); } controller = team::CONTROLLER::AI; controller.parse(cfg["controller"].str()); // TODO: Why do we read disallow observers differently when controller is empty? if(controller == CONTROLLER::EMPTY) { disallow_observers = cfg["disallow_observers"].to_bool(true); } // override persistence flag if it is explicitly defined in the config // by default, persistence of a team is set depending on the controller persistent = cfg["persistent"].to_bool(this->controller == CONTROLLER::HUMAN); //======================================================== // END OF MESSY CODE // Share_view and share_maps can't both be enabled, // so share_view overrides share_maps. share_vision = cfg["share_vision"].to_enum<team::SHARE_VISION>(team::SHARE_VISION::ALL); handle_legacy_share_vision(cfg); LOG_NG << "team_info::team_info(...): team_name: " << team_name << ", share_vision: " << share_vision << ".\n"; }
frame_builder::frame_builder(const config& cfg,const std::string& frame_string) : duration_(1), image_(cfg[frame_string + "image"]), image_diagonal_(cfg[frame_string + "image_diagonal"]), image_mod_(cfg[frame_string + "image_mod"]), halo_(cfg[frame_string + "halo"]), halo_x_(cfg[frame_string + "halo_x"]), halo_y_(cfg[frame_string + "halo_y"]), halo_mod_(cfg[frame_string + "halo_mod"]), sound_(cfg[frame_string + "sound"]), text_(cfg[frame_string + "text"]), text_color_(0), blend_with_(0), blend_ratio_(cfg[frame_string + "blend_ratio"]), highlight_ratio_(cfg[frame_string + "alpha"]), offset_(cfg[frame_string + "offset"]), submerge_(cfg[frame_string + "submerge"]), x_(cfg[frame_string + "x"]), y_(cfg[frame_string + "y"]), directional_x_(cfg[frame_string + "directional_x"]), directional_y_(cfg[frame_string + "directional_y"]), auto_vflip_(t_unset), auto_hflip_(t_unset), primary_frame_(t_unset), drawing_layer_(cfg[frame_string + "layer"]) { if(!cfg.has_attribute(frame_string + "auto_vflip")) { auto_vflip_ = t_unset; } else if(cfg[frame_string + "auto_vflip"].to_bool()) { auto_vflip_ = t_true; } else { auto_vflip_ = t_false; } if(!cfg.has_attribute(frame_string + "auto_hflip")) { auto_hflip_ = t_unset; } else if(cfg[frame_string + "auto_hflip"].to_bool()) { auto_hflip_ = t_true; } else { auto_hflip_ = t_false; } if(!cfg.has_attribute(frame_string + "primary")) { primary_frame_ = t_unset; } else if(cfg[frame_string + "primary"].to_bool()) { primary_frame_ = t_true; } else { primary_frame_ = t_false; } std::vector<std::string> color = utils::split(cfg[frame_string + "text_color"]); if (color.size() == 3) { text_color_ = display::rgb(atoi(color[0].c_str()), atoi(color[1].c_str()), atoi(color[2].c_str())); } if (const config::attribute_value *v = cfg.get(frame_string + "duration")) { duration(*v); } else if (!cfg.get(frame_string + "end")) { int halo_duration = (progressive_string(halo_,1)).duration(); int image_duration = (progressive_image(image_,1)).duration(); int image_diagonal_duration = (progressive_image(image_diagonal_,1)).duration(); duration(std::max(std::max(image_duration,image_diagonal_duration),halo_duration)); } else { duration(cfg[frame_string + "end"].to_int() - cfg[frame_string + "begin"].to_int()); } duration_ = std::max(duration_,1); color = utils::split(cfg[frame_string + "blend_color"]); if (color.size() == 3) { blend_with_ = display::rgb(atoi(color[0].c_str()), atoi(color[1].c_str()), atoi(color[2].c_str())); } }
frame_builder::frame_builder(const config& cfg,const std::string& frame_string) : duration_(1) , image_(cfg[frame_string + "image"]) , image_diagonal_(cfg[frame_string + "image_diagonal"]) , image_mod_(cfg[frame_string + "image_mod"]) , halo_(cfg[frame_string + "halo"]) , halo_x_(cfg[frame_string + "halo_x"]) , halo_y_(cfg[frame_string + "halo_y"]) , halo_mod_(cfg[frame_string + "halo_mod"]) , sound_(cfg[frame_string + "sound"]) , text_(cfg[frame_string + "text"]) , blend_ratio_(cfg[frame_string + "blend_ratio"]) , highlight_ratio_(cfg[frame_string + "alpha"]) , offset_(cfg[frame_string + "offset"]) , submerge_(cfg[frame_string + "submerge"]) , x_(cfg[frame_string + "x"]) , y_(cfg[frame_string + "y"]) , directional_x_(cfg[frame_string + "directional_x"]) , directional_y_(cfg[frame_string + "directional_y"]) , auto_vflip_(boost::logic::indeterminate) , auto_hflip_(boost::logic::indeterminate) , primary_frame_(boost::logic::indeterminate) , drawing_layer_(cfg[frame_string + "layer"]) { if(!cfg.has_attribute(frame_string + "auto_vflip")) { auto_vflip_ = boost::logic::indeterminate; } else { auto_vflip_ = cfg[frame_string + "auto_vflip"].to_bool(); } if(!cfg.has_attribute(frame_string + "auto_hflip")) { auto_hflip_ = boost::logic::indeterminate; } else { auto_hflip_ = cfg[frame_string + "auto_hflip"].to_bool(); } if(!cfg.has_attribute(frame_string + "primary")) { primary_frame_ = boost::logic::indeterminate; } else { primary_frame_ = cfg[frame_string + "primary"].to_bool(); } const auto& text_color_key = cfg[frame_string + "text_color"]; if(!text_color_key.empty()) { try { text_color_ = color_t::from_rgb_string(text_color_key); } catch(const std::invalid_argument& e) { // Might be thrown either due to an incorrect number of elements or std::stoul failure. ERR_NG << "Invalid RBG text color in unit animation: " << text_color_key.str() << "\n" << e.what() << "\n;"; } } if(const config::attribute_value* v = cfg.get(frame_string + "duration")) { duration(*v); } else if(!cfg.get(frame_string + "end")) { int halo_duration = (progressive_string(halo_, 1)).duration(); int image_duration = (progressive_image(image_, 1)).duration(); int image_diagonal_duration = (progressive_image(image_diagonal_, 1)).duration(); duration(std::max(std::max(image_duration, image_diagonal_duration), halo_duration)); } else { duration(cfg[frame_string + "end"].to_int() - cfg[frame_string + "begin"].to_int()); } duration_ = std::max(duration_, 1); const auto& blend_color_key = cfg[frame_string + "blend_color"]; if(!blend_color_key.empty()) { try { blend_with_ = color_t::from_rgb_string(blend_color_key); } catch(const std::invalid_argument& e) { // Might be thrown either due to an incorrect number of elements or std::stoul failure. ERR_NG << "Invalid RBG blend color in unit animation: " << blend_color_key.str() << "\n" << e.what() << "\n;"; } } }