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;"; } } }