Refactored out display::rgb, red, blue, green, and blend_rgb
This commit is contained in:
parent
dfe091caff
commit
a60433356d
6 changed files with 27 additions and 32 deletions
|
@ -171,17 +171,6 @@ public:
|
|||
void reset_halo_manager(halo::manager & hm);
|
||||
halo::manager & get_halo_manager() { return *halo_man_; }
|
||||
|
||||
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
|
||||
{ return 0xFF000000 | (red << 16) | (green << 8) | blue; }
|
||||
static Uint8 red(Uint32 color)
|
||||
{ return (color & 0x00FF0000) >> 16;}
|
||||
static Uint8 green(Uint32 color)
|
||||
{ return (color & 0x0000FF00) >> 8;}
|
||||
static Uint8 blue(Uint32 color)
|
||||
{ return (color & 0x000000FF) ;}
|
||||
static Uint32 max_rgb(Uint32 first,Uint32 second)
|
||||
{ return rgb(std::max(red(first),red(second)),std::max(green(first),green(second)),std::max(blue(first),blue(second))) ; }
|
||||
|
||||
/**
|
||||
* Add r,g,b from tod_manager to the map
|
||||
*
|
||||
|
|
|
@ -506,7 +506,7 @@ int cs_modification::get_b() const
|
|||
|
||||
surface blend_modification::operator()(const surface& src) const
|
||||
{
|
||||
return blend_surface(src, a_, display::rgb(r_, g_, b_));
|
||||
return blend_surface(src, a_, color_t(r_, g_, b_).to_argb_bytes());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "map/map.hpp"
|
||||
#include "play_controller.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "sdl/color.hpp"
|
||||
#include "units/unit.hpp"
|
||||
#include "units/animation_component.hpp"
|
||||
#include "units/filter.hpp"
|
||||
|
@ -485,7 +486,7 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
|
|||
|
||||
animations.push_back(unit_animation(0,frame_builder().image(default_image).duration(1),"_disabled_",0));
|
||||
animations.push_back(unit_animation(0,frame_builder().image(default_image).duration(300).
|
||||
blend("0.0~0.3:100,0.3~0.0:200",display::rgb(255,255,255)),"_disabled_selected_",0));
|
||||
blend("0.0~0.3:100,0.3~0.0:200", color_t(255,255,255).to_argb_bytes()),"_disabled_selected_",0));
|
||||
for(itor = animation_base.begin() ; itor != animation_base.end() ; ++itor ) {
|
||||
//unit_animation tmp_anim = *itor;
|
||||
// provide all default anims
|
||||
|
@ -506,7 +507,7 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
|
|||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("selected");
|
||||
animations.back().unit_anim_.override(0,300,particule::UNSET,"","0.0~0.3:100,0.3~0.0:200",display::rgb(255,255,255));
|
||||
animations.back().unit_anim_.override(0,300,particule::UNSET,"","0.0~0.3:100,0.3~0.0:200", color_t(255,255,255).to_argb_bytes());
|
||||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("recruited");
|
||||
|
@ -514,11 +515,11 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
|
|||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("levelin");
|
||||
animations.back().unit_anim_.override(0,600,particule::NO_CYCLE,"","1~0:600",display::rgb(255,255,255));
|
||||
animations.back().unit_anim_.override(0,600,particule::NO_CYCLE,"","1~0:600", color_t(255,255,255).to_argb_bytes());
|
||||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("levelout");
|
||||
animations.back().unit_anim_.override(0,600,particule::NO_CYCLE,"","0~1:600,1",display::rgb(255,255,255));
|
||||
animations.back().unit_anim_.override(0,600,particule::NO_CYCLE,"","0~1:600,1", color_t(255,255,255).to_argb_bytes());
|
||||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("pre_movement");
|
||||
|
@ -534,7 +535,7 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
|
|||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("defend");
|
||||
animations.back().unit_anim_.override(0,animations.back().unit_anim_.get_animation_duration(),particule::NO_CYCLE,"","0.0,0.5:75,0.0:75,0.5:75,0.0",game_display::rgb(255,0,0));
|
||||
animations.back().unit_anim_.override(0,animations.back().unit_anim_.get_animation_duration(),particule::NO_CYCLE,"","0.0,0.5:75,0.0:75,0.5:75,0.0", color_t(255,0,0).to_argb_bytes());
|
||||
animations.back().hits_.push_back(hit_type::HIT);
|
||||
animations.back().hits_.push_back(hit_type::KILL);
|
||||
|
||||
|
@ -576,7 +577,7 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
|
|||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("healed");
|
||||
animations.back().unit_anim_.override(0,300,particule::NO_CYCLE,"","0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30",display::rgb(255,255,255));
|
||||
animations.back().unit_anim_.override(0,300,particule::NO_CYCLE,"","0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30", color_t(255,255,255).to_argb_bytes());
|
||||
std::string healed_sound;
|
||||
if (cfg["healed_sound"].empty()) {
|
||||
healed_sound = "heal.wav";
|
||||
|
@ -587,7 +588,7 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
|
|||
|
||||
animations.push_back(*itor);
|
||||
animations.back().event_ = utils::split("poisoned");
|
||||
animations.back().unit_anim_.override(0,300,particule::NO_CYCLE,"","0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30",display::rgb(0,255,0));
|
||||
animations.back().unit_anim_.override(0,300,particule::NO_CYCLE,"","0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30", color_t(0,255,0).to_argb_bytes());
|
||||
animations.back().sub_anims_["_poison_sound"] = particule();
|
||||
animations.back().sub_anims_["_poison_sound"].add_frame(1,frame_builder().sound(game_config::sounds::status::poisoned),true);
|
||||
|
||||
|
@ -740,7 +741,7 @@ void unit_animation::add_anims( std::vector<unit_animation> & animations, const
|
|||
animations.back().add_frame(225,frame_builder()
|
||||
.image(image_loc.get_filename()+image_loc.get_modifications())
|
||||
.duration(225)
|
||||
.blend("0.0,0.5:75,0.0:75,0.5:75,0.0",game_display::rgb(255,0,0)));
|
||||
.blend("0.0,0.5:75,0.0:75,0.5:75,0.0", color_t(255,0,0).to_argb_bytes()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -755,7 +756,7 @@ void unit_animation::add_anims( std::vector<unit_animation> & animations, const
|
|||
animations.back().add_frame(225,frame_builder()
|
||||
.image(image_loc.get_filename()+image_loc.get_modifications())
|
||||
.duration(225)
|
||||
.blend("0.0,0.5:75,0.0:75,0.5:75,0.0",game_display::rgb(255,0,0)));
|
||||
.blend("0.0,0.5:75,0.0:75,0.5:75,0.0", color_t(255,0,0).to_argb_bytes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "halo.hpp"
|
||||
#include "map/map.hpp"
|
||||
#include "map/location.hpp"
|
||||
#include "sdl/color.hpp"
|
||||
#include "sdl/utils.hpp"
|
||||
#include "team.hpp"
|
||||
#include "units/unit.hpp"
|
||||
|
@ -133,7 +134,7 @@ void unit_drawer::redraw_unit (const unit & u) const
|
|||
tints += 1;
|
||||
}
|
||||
if(tints > 0) {
|
||||
params.blend_with = disp.rgb((red/tints),(green/tints),(blue/tints));
|
||||
params.blend_with = color_t((red/tints),(green/tints),(blue/tints)).to_argb_bytes();
|
||||
params.blend_ratio = ((blend_ratio/tints));
|
||||
}
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
|
|||
std::vector<std::string> color = utils::split(cfg[frame_string + "text_color"]);
|
||||
if (color.size() == 3) {
|
||||
try {
|
||||
text_color_ = display::rgb(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2]));
|
||||
text_color_ = color_t(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2])).to_argb_bytes();
|
||||
} catch(std::invalid_argument) {
|
||||
ERR_NG << "Invalid RGB color value in unit animation: " << color[0] << ", " << color[1] << ", " << color[2] << "\n";
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
|
|||
color = utils::split(cfg[frame_string + "blend_color"]);
|
||||
if (color.size() == 3) {
|
||||
try {
|
||||
blend_with_ = display::rgb(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2]));
|
||||
blend_with_ = color_t(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2])).to_argb_bytes();
|
||||
} catch(std::invalid_argument) {
|
||||
ERR_NG << "Invalid RGB color value in unit animation: " << color[0] << ", " << color[1] << ", " << color[2] << "\n";
|
||||
}
|
||||
|
@ -945,7 +945,10 @@ const frame_parameters unit_frame::merge_parameters(int current_time,const frame
|
|||
|
||||
/** engine provide a blend color for poisoned units */
|
||||
result.blend_with = current_val.blend_with?current_val.blend_with:animation_val.blend_with;
|
||||
if(primary&& engine_val.blend_with) result.blend_with = display::max_rgb(engine_val.blend_with,result.blend_with);
|
||||
if(primary&& engine_val.blend_with) result.blend_with =
|
||||
color_t::from_argb_bytes(engine_val.blend_with)
|
||||
.blend_lighten(color_t::from_argb_bytes(result.blend_with))
|
||||
.to_argb_bytes();
|
||||
|
||||
/** engine provide a blend color for poisoned units */
|
||||
result.blend_ratio = current_val.blend_ratio?current_val.blend_ratio:animation_val.blend_ratio;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "log.hpp"
|
||||
#include "mouse_events.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "sdl/color.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "terrain/filter.hpp"
|
||||
#include "units/unit.hpp"
|
||||
|
@ -617,7 +618,7 @@ void unit_attack(display * disp, game_board & board,
|
|||
}
|
||||
animator.add_animation(&attacker, "attack", att->get_location(),
|
||||
def->get_location(), damage, true, text_2,
|
||||
(drain_amount >= 0) ? display::rgb(0, 255, 0) : display::rgb(255, 0, 0),
|
||||
(drain_amount >= 0) ? color_t(0, 255, 0).to_argb_bytes() : color_t(255, 0, 0).to_argb_bytes(),
|
||||
hit_type, &attack, secondary_attack, swing);
|
||||
|
||||
// note that we take an anim from the real unit, we'll use it later
|
||||
|
@ -625,7 +626,7 @@ void unit_attack(display * disp, game_board & board,
|
|||
def->get_location(), "defend", att->get_location(), damage,
|
||||
hit_type, &attack, secondary_attack, swing);
|
||||
animator.add_animation(&defender, defender_anim, def->get_location(),
|
||||
true, text , display::rgb(255, 0, 0));
|
||||
true, text , color_t(255, 0, 0).to_argb_bytes());
|
||||
|
||||
for (const unit_ability & ability : leaders) {
|
||||
if(ability.second == a) continue;
|
||||
|
@ -750,16 +751,16 @@ void unit_healing(unit &healed, const std::vector<unit *> &healers, int healing,
|
|||
animator.add_animation(&healed, "poisoned", healed_loc,
|
||||
map_location::null_location(), -healing, false,
|
||||
number_and_text(-healing, extra_text),
|
||||
display::rgb(255,0,0));
|
||||
color_t(255,0,0).to_argb_bytes());
|
||||
} else if ( healing > 0 ) {
|
||||
animator.add_animation(&healed, "healed", healed_loc,
|
||||
map_location::null_location(), healing, false,
|
||||
number_and_text(healing, extra_text),
|
||||
display::rgb(0,255,0));
|
||||
color_t(0,255,0).to_argb_bytes());
|
||||
} else {
|
||||
animator.add_animation(&healed, "healed", healed_loc,
|
||||
map_location::null_location(), 0, false,
|
||||
extra_text, display::rgb(0,255,0));
|
||||
extra_text, color_t(0,255,0).to_argb_bytes());
|
||||
}
|
||||
animator.start_animations();
|
||||
animator.wait_for_end();
|
||||
|
@ -858,9 +859,9 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m
|
|||
hits = unit_animation::hit_type::KILL;
|
||||
}
|
||||
if(cfg["red"].empty() && cfg["green"].empty() && cfg["blue"].empty()) {
|
||||
text_color = display::rgb(0xff,0xff,0xff);
|
||||
text_color = color_t(0xff,0xff,0xff).to_argb_bytes();
|
||||
} else {
|
||||
text_color = display::rgb(cfg["red"], cfg["green"], cfg["blue"]);
|
||||
text_color = color_t(cfg["red"], cfg["green"], cfg["blue"]).to_argb_bytes();
|
||||
}
|
||||
resources::screen->scroll_to_tile(u->get_location(), game_display::ONSCREEN, true, false);
|
||||
vconfig t_filter_data = cfg.child("facing");
|
||||
|
|
Loading…
Add table
Reference in a new issue