Convert unit animation code to use color_t
boost::optional was used for certain colors in frame.*pp since there isn't a good way to convert a color_t to an "is present" bool.
This commit is contained in:
parent
1662abb622
commit
f2d730bd86
8 changed files with 90 additions and 87 deletions
|
@ -502,7 +502,7 @@ void unit_animation::fill_initial_animations(std::vector<unit_animation>& animat
|
|||
|
||||
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", color_t(255,255,255).to_argb_bytes()),
|
||||
frame_builder().image(default_image).duration(300).blend("0.0~0.3:100,0.3~0.0:200", {255,255,255}),
|
||||
"_disabled_selected_", 0));
|
||||
|
||||
for(const auto& base : animation_base) {
|
||||
|
@ -512,15 +512,15 @@ void unit_animation::fill_initial_animations(std::vector<unit_animation>& animat
|
|||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "ghosted" };
|
||||
animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),particle::UNSET,"0.9", "", 0, "", "", "~GS()");
|
||||
animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),particle::UNSET,"0.9", "", {0,0,0}, "", "", "~GS()");
|
||||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "disabled_ghosted" };
|
||||
animations.back().unit_anim_.override(0, 1, particle::UNSET, "0.4", "", 0, "", "", "~GS()");
|
||||
animations.back().unit_anim_.override(0, 1, particle::UNSET, "0.4", "", {0,0,0}, "", "", "~GS()");
|
||||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "selected" };
|
||||
animations.back().unit_anim_.override(0, 300, particle::UNSET, "", "0.0~0.3:100,0.3~0.0:200", color_t(255,255,255).to_argb_bytes());
|
||||
animations.back().unit_anim_.override(0, 300, particle::UNSET, "", "0.0~0.3:100,0.3~0.0:200", {255,255,255});
|
||||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "recruited" };
|
||||
|
@ -528,11 +528,11 @@ void unit_animation::fill_initial_animations(std::vector<unit_animation>& animat
|
|||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "levelin" };
|
||||
animations.back().unit_anim_.override(0, 600, particle::NO_CYCLE, "", "1~0:600", color_t(255,255,255).to_argb_bytes());
|
||||
animations.back().unit_anim_.override(0, 600, particle::NO_CYCLE, "", "1~0:600", {255,255,255});
|
||||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "levelout" };
|
||||
animations.back().unit_anim_.override(0, 600, particle::NO_CYCLE, "", "0~1:600,1", color_t(255,255,255).to_argb_bytes());
|
||||
animations.back().unit_anim_.override(0, 600, particle::NO_CYCLE, "", "0~1:600,1", {255,255,255});
|
||||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "pre_movement" };
|
||||
|
@ -545,12 +545,12 @@ void unit_animation::fill_initial_animations(std::vector<unit_animation>& animat
|
|||
animations.push_back(base);
|
||||
animations.back().event_ = { "movement" };
|
||||
animations.back().unit_anim_.override(0, 200,
|
||||
particle::NO_CYCLE, "", "", 0, "0~1:200", std::to_string(display::LAYER_UNIT_MOVE_DEFAULT - display::LAYER_UNIT_FIRST));
|
||||
particle::NO_CYCLE, "", "", {0,0,0}, "0~1:200", std::to_string(display::LAYER_UNIT_MOVE_DEFAULT - display::LAYER_UNIT_FIRST));
|
||||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "defend" };
|
||||
animations.back().unit_anim_.override(0, animations.back().unit_anim_.get_animation_duration(),
|
||||
particle::NO_CYCLE, "", "0.0,0.5:75,0.0:75,0.5:75,0.0", color_t(255,0,0).to_argb_bytes());
|
||||
particle::NO_CYCLE, "", "0.0,0.5:75,0.0:75,0.5:75,0.0", {255,0,0});
|
||||
animations.back().hits_.push_back(hit_type::HIT);
|
||||
animations.back().hits_.push_back(hit_type::KILL);
|
||||
|
||||
|
@ -559,7 +559,7 @@ void unit_animation::fill_initial_animations(std::vector<unit_animation>& animat
|
|||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "attack" };
|
||||
animations.back().unit_anim_.override(-150, 300, particle::NO_CYCLE, "", "", 0, "0~0.6:150,0.6~0:150", std::to_string(display::LAYER_UNIT_MOVE_DEFAULT-display::LAYER_UNIT_FIRST));
|
||||
animations.back().unit_anim_.override(-150, 300, particle::NO_CYCLE, "", "", {0,0,0}, "0~0.6:150,0.6~0:150", std::to_string(display::LAYER_UNIT_MOVE_DEFAULT-display::LAYER_UNIT_FIRST));
|
||||
animations.back().primary_attack_filter_.push_back(config());
|
||||
animations.back().primary_attack_filter_.back()["range"] = "melee";
|
||||
|
||||
|
@ -592,7 +592,7 @@ void unit_animation::fill_initial_animations(std::vector<unit_animation>& animat
|
|||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "healed" };
|
||||
animations.back().unit_anim_.override(0, 300, particle::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());
|
||||
animations.back().unit_anim_.override(0, 300, particle::NO_CYCLE, "", "0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30", {255,255,255});
|
||||
|
||||
const std::string healed_sound = get_heal_sound(cfg);
|
||||
|
||||
|
@ -600,7 +600,7 @@ void unit_animation::fill_initial_animations(std::vector<unit_animation>& animat
|
|||
|
||||
animations.push_back(base);
|
||||
animations.back().event_ = { "poisoned" };
|
||||
animations.back().unit_anim_.override(0, 300, particle::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().unit_anim_.override(0, 300, particle::NO_CYCLE, "", "0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30", {0,255,0});
|
||||
animations.back().sub_anims_["_poison_sound"] = particle();
|
||||
animations.back().sub_anims_["_poison_sound"].add_frame(1, frame_builder().sound(game_config::sounds::status::poisoned), true);
|
||||
}
|
||||
|
@ -781,7 +781,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", color_t(255,0,0).to_argb_bytes()));
|
||||
.blend("0.0,0.5:75,0.0:75,0.5:75,0.0", {255,0,0}));
|
||||
} else {
|
||||
for(const std::string& hit_type : utils::split(anim["hits"])) {
|
||||
config tmp = anim;
|
||||
|
@ -794,7 +794,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", color_t(255,0,0).to_argb_bytes()));
|
||||
.blend("0.0,0.5:75,0.0:75,0.5:75,0.0", {255,0,0}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ void unit_animation::particle::override(int start_time
|
|||
, const cycle_state cycles
|
||||
, const std::string& highlight
|
||||
, const std::string& blend_ratio
|
||||
, Uint32 blend_color
|
||||
, color_t blend_color
|
||||
, const std::string& offset
|
||||
, const std::string& layer
|
||||
, const std::string& modifiers)
|
||||
|
@ -1035,7 +1035,7 @@ void unit_animation::start_animation(int start_time
|
|||
, const map_location& src
|
||||
, const map_location& dst
|
||||
, const std::string& text
|
||||
, const Uint32 text_color
|
||||
, const color_t text_color
|
||||
, const bool accelerate)
|
||||
{
|
||||
unit_anim_.accelerate = accelerate;
|
||||
|
@ -1301,7 +1301,7 @@ void unit_animator::add_animation(const unit* animated_unit
|
|||
, const int value
|
||||
, bool with_bars
|
||||
, const std::string& text
|
||||
, const Uint32 text_color
|
||||
, const color_t text_color
|
||||
, const unit_animation::hit_type hit_type
|
||||
, const attack_type* attack
|
||||
, const attack_type* second_attack
|
||||
|
@ -1330,7 +1330,7 @@ void unit_animator::add_animation(const unit* animated_unit
|
|||
, const map_location &src
|
||||
, bool with_bars
|
||||
, const std::string& text
|
||||
, const Uint32 text_color)
|
||||
, const color_t text_color)
|
||||
{
|
||||
if(!animated_unit) return;
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ void unit_animator::replace_anim_if_invalid(const unit* animated_unit
|
|||
, const int value
|
||||
, bool with_bars
|
||||
, const std::string& text
|
||||
, const Uint32 text_color
|
||||
, const color_t text_color
|
||||
, const unit_animation::hit_type hit_type
|
||||
, const attack_type* attack
|
||||
, const attack_type* second_attack
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
, const map_location& src = map_location::null_location()
|
||||
, const map_location& dst = map_location::null_location()
|
||||
, const std::string& text = ""
|
||||
, const Uint32 text_color = 0
|
||||
, const color_t text_color = {0,0,0}
|
||||
, const bool accelerate = true);
|
||||
|
||||
void update_parameters(const map_location& src, const map_location& dst);
|
||||
|
@ -138,7 +138,7 @@ private:
|
|||
, const cycle_state cycles
|
||||
, const std::string& highlight = ""
|
||||
, const std::string& blend_ratio =""
|
||||
, Uint32 blend_color = 0
|
||||
, color_t blend_color = {0,0,0}
|
||||
, const std::string& offset = ""
|
||||
, const std::string& layer = ""
|
||||
, const std::string& modifiers = "");
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
, const map_location& src = map_location::null_location()
|
||||
, bool with_bars = false
|
||||
, const std::string& text = ""
|
||||
, const Uint32 text_color = 0);
|
||||
, const color_t text_color = {0,0,0});
|
||||
|
||||
void add_animation(const unit* animated_unit
|
||||
, const std::string& event
|
||||
|
@ -205,7 +205,7 @@ public:
|
|||
, const int value = 0
|
||||
, bool with_bars = false
|
||||
, const std::string& text = ""
|
||||
, const Uint32 text_color = 0
|
||||
, const color_t text_color = {0,0,0}
|
||||
, const unit_animation::hit_type hit_type =
|
||||
unit_animation::hit_type::INVALID
|
||||
, const attack_type* attack = nullptr
|
||||
|
@ -219,7 +219,7 @@ public:
|
|||
, const int value = 0
|
||||
, bool with_bars = false
|
||||
, const std::string& text = ""
|
||||
, const Uint32 text_color = 0
|
||||
, const color_t text_color = {0,0,0}
|
||||
, const unit_animation::hit_type hit_type = unit_animation::hit_type::INVALID
|
||||
, const attack_type* attack = nullptr
|
||||
, const attack_type* second_attack = nullptr
|
||||
|
@ -250,7 +250,7 @@ private:
|
|||
: my_unit(0)
|
||||
, animation(0)
|
||||
, text()
|
||||
, text_color(0)
|
||||
, text_color()
|
||||
, src()
|
||||
, with_bars(false)
|
||||
{}
|
||||
|
@ -258,7 +258,7 @@ private:
|
|||
unit_const_ptr my_unit;
|
||||
const unit_animation * animation;
|
||||
std::string text;
|
||||
Uint32 text_color;
|
||||
color_t text_color;
|
||||
map_location src;
|
||||
bool with_bars;
|
||||
};
|
||||
|
|
|
@ -50,10 +50,10 @@ void unit_animation_component::set_standing(bool with_bars)
|
|||
display *disp = display::get_singleton();
|
||||
if (preferences::show_standing_animations()&& !u_.incapacitated()) {
|
||||
start_animation(INT_MAX, choose_animation(*disp, u_.loc_, "standing"),
|
||||
with_bars, "", 0, STATE_STANDING);
|
||||
with_bars, "", {0,0,0}, STATE_STANDING);
|
||||
} else {
|
||||
start_animation(INT_MAX, choose_animation(*disp, u_.loc_, "_disabled_"),
|
||||
with_bars, "", 0, STATE_STANDING);
|
||||
with_bars, "", {0,0,0}, STATE_STANDING);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ void unit_animation_component::set_idling()
|
|||
{
|
||||
display *disp = display::get_singleton();
|
||||
start_animation(INT_MAX, choose_animation(*disp, u_.loc_, "idling"),
|
||||
true, "", 0, STATE_FORGET);
|
||||
true, "", {0,0,0}, STATE_FORGET);
|
||||
}
|
||||
|
||||
void unit_animation_component::set_selecting()
|
||||
|
@ -84,15 +84,15 @@ void unit_animation_component::set_selecting()
|
|||
const display *disp = display::get_singleton();
|
||||
if (preferences::show_standing_animations() && !u_.incapacitated()) {
|
||||
start_animation(INT_MAX, choose_animation(*disp, u_.loc_, "selected"),
|
||||
true, "", 0, STATE_FORGET);
|
||||
true, "", {0,0,0}, STATE_FORGET);
|
||||
} else {
|
||||
start_animation(INT_MAX, choose_animation(*disp, u_.loc_, "_disabled_selected_"),
|
||||
true, "", 0, STATE_FORGET);
|
||||
true, "", {0,0,0}, STATE_FORGET);
|
||||
}
|
||||
}
|
||||
|
||||
void unit_animation_component::start_animation (int start_time, const unit_animation *animation,
|
||||
bool with_bars, const std::string &text, Uint32 text_color, STATE state)
|
||||
bool with_bars, const std::string &text, color_t text_color, STATE state)
|
||||
{
|
||||
const display * disp = display::get_singleton();
|
||||
if (!animation) {
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
/** Begin an animation. */
|
||||
void start_animation (int start_time, const unit_animation *animation,
|
||||
bool with_bars, const std::string &text = "",
|
||||
Uint32 text_color = 0, STATE state = STATE_ANIM);
|
||||
color_t text_color = {}, STATE state = STATE_ANIM);
|
||||
|
||||
/** Invalidates an animation with respect to a display object, preparing it for redraw. */
|
||||
bool invalidate(const display & disp);
|
||||
|
|
|
@ -134,7 +134,7 @@ void unit_drawer::redraw_unit (const unit & u) const
|
|||
tints += 1;
|
||||
}
|
||||
if(tints > 0) {
|
||||
params.blend_with = color_t((red/tints),(green/tints),(blue/tints)).to_argb_bytes();
|
||||
params.blend_with = color_t((red/tints),(green/tints),(blue/tints));
|
||||
params.blend_ratio = ((blend_ratio/tints));
|
||||
}
|
||||
|
||||
|
|
|
@ -255,8 +255,8 @@ frame_parameters::frame_parameters() :
|
|||
halo_mod(""),
|
||||
sound(""),
|
||||
text(""),
|
||||
text_color(0),
|
||||
blend_with(0),
|
||||
text_color(),
|
||||
blend_with(),
|
||||
blend_ratio(0.0),
|
||||
highlight_ratio(1.0),
|
||||
offset(0),
|
||||
|
@ -282,8 +282,8 @@ frame_builder::frame_builder() :
|
|||
halo_mod_(""),
|
||||
sound_(""),
|
||||
text_(""),
|
||||
text_color_(0),
|
||||
blend_with_(0),
|
||||
text_color_(),
|
||||
blend_with_(),
|
||||
blend_ratio_(""),
|
||||
highlight_ratio_(""),
|
||||
offset_(""),
|
||||
|
@ -309,8 +309,8 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
|
|||
halo_mod_(cfg[frame_string + "halo_mod"]),
|
||||
sound_(cfg[frame_string + "sound"]),
|
||||
text_(cfg[frame_string + "text"]),
|
||||
text_color_(0),
|
||||
blend_with_(0),
|
||||
text_color_(),
|
||||
blend_with_(),
|
||||
blend_ratio_(cfg[frame_string + "blend_ratio"]),
|
||||
highlight_ratio_(cfg[frame_string + "alpha"]),
|
||||
offset_(cfg[frame_string + "offset"]),
|
||||
|
@ -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_ = color_t(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2])).to_argb_bytes();
|
||||
text_color_ = color_t(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2]));
|
||||
} 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_ = color_t(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2])).to_argb_bytes();
|
||||
blend_with_ = color_t(std::stoi(color[0]), std::stoi(color[1]), std::stoi(color[2]));
|
||||
} catch(std::invalid_argument) {
|
||||
ERR_NG << "Invalid RGB color value in unit animation: " << color[0] << ", " << color[1] << ", " << color[2] << "\n";
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ frame_builder & frame_builder::sound(const std::string& sound)
|
|||
sound_=sound;
|
||||
return *this;
|
||||
}
|
||||
frame_builder & frame_builder::text(const std::string& text,const Uint32 text_color)
|
||||
frame_builder & frame_builder::text(const std::string& text,const color_t text_color)
|
||||
{
|
||||
text_=text;
|
||||
text_color_=text_color;
|
||||
|
@ -413,7 +413,7 @@ frame_builder & frame_builder::duration(const int duration)
|
|||
duration_= duration;
|
||||
return *this;
|
||||
}
|
||||
frame_builder & frame_builder::blend(const std::string& blend_ratio,const Uint32 blend_color)
|
||||
frame_builder & frame_builder::blend(const std::string& blend_ratio,const color_t blend_color)
|
||||
{
|
||||
blend_with_=blend_color;
|
||||
blend_ratio_=blend_ratio;
|
||||
|
@ -577,7 +577,7 @@ const frame_parameters frame_parsed_parameters::parameters(int current_time) con
|
|||
void frame_parsed_parameters::override( int duration
|
||||
, const std::string& highlight
|
||||
, const std::string& blend_ratio
|
||||
, Uint32 blend_color
|
||||
, color_t blend_color
|
||||
, const std::string& offset
|
||||
, const std::string& layer
|
||||
, const std::string& modifiers)
|
||||
|
@ -634,11 +634,15 @@ std::vector<std::string> frame_parsed_parameters::debug_strings() const {
|
|||
if (!sound_.empty()) v.push_back("sound="+sound_);
|
||||
if (!text_.empty()) {
|
||||
v.push_back("text="+text_);
|
||||
v.push_back("text_color="+std::to_string(text_color_));
|
||||
if(text_color_) {
|
||||
v.push_back("text_color=" + text_color_.get().to_rgba_string());
|
||||
}
|
||||
}
|
||||
if (!blend_ratio_.get_original().empty()) {
|
||||
v.push_back("blend_ratio="+blend_ratio_.get_original());
|
||||
v.push_back("blend_with="+std::to_string(blend_with_));
|
||||
if(blend_with_) {
|
||||
v.push_back("blend_with=" + blend_with_.get().to_rgba_string());
|
||||
}
|
||||
}
|
||||
if (!highlight_ratio_.get_original().empty()) v.push_back("highlight_ratio="+highlight_ratio_.get_original());
|
||||
if (!offset_.get_original().empty()) v.push_back("offset="+offset_.get_original());
|
||||
|
@ -679,9 +683,8 @@ void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of
|
|||
if(!current_data.sound.empty() ) {
|
||||
sound::play_sound(current_data.sound);
|
||||
}
|
||||
if(!current_data.text.empty() ) {
|
||||
game_display::get_singleton()->float_label(src, current_data.text,
|
||||
color_t::from_argb_bytes(current_data.text_color));
|
||||
if(!current_data.text.empty() && current_data.text_color) {
|
||||
game_display::get_singleton()->float_label(src, current_data.text, current_data.text_color.get());
|
||||
}
|
||||
}
|
||||
image::locator image_loc;
|
||||
|
@ -716,11 +719,11 @@ void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of
|
|||
my_y -= current_data.directional_y;
|
||||
}
|
||||
|
||||
game_display::get_singleton()->render_image( my_x,my_y,
|
||||
static_cast<display::drawing_layer>(display::LAYER_UNIT_FIRST+current_data.drawing_layer),
|
||||
src, image, facing_west, false,
|
||||
ftofxp(current_data.highlight_ratio), color_t::from_argb_bytes(current_data.blend_with),
|
||||
current_data.blend_ratio,current_data.submerge,!facing_north);
|
||||
game_display::get_singleton()->render_image(my_x, my_y,
|
||||
static_cast<display::drawing_layer>(display::LAYER_UNIT_FIRST + current_data.drawing_layer),
|
||||
src, image, facing_west, false,
|
||||
ftofxp(current_data.highlight_ratio), current_data.blend_with ? current_data.blend_with.get() : color_t(),
|
||||
current_data.blend_ratio, current_data.submerge, !facing_north);
|
||||
}
|
||||
halo_id = halo::handle(); //halo::NO_HALO;
|
||||
|
||||
|
@ -940,15 +943,13 @@ const frame_parameters unit_frame::merge_parameters(int current_time,const frame
|
|||
assert(engine_val.text.empty());
|
||||
result.text = current_val.text.empty()?animation_val.text:current_val.text;
|
||||
|
||||
assert(engine_val.text_color == 0);
|
||||
result.text_color = current_val.text_color?current_val.text_color:animation_val.text_color;
|
||||
// TODO: how should this be handled now that we use color_t?
|
||||
assert(!engine_val.text_color);
|
||||
result.text_color = current_val.text_color && current_val.text_color ? current_val.text_color : animation_val.text_color;
|
||||
|
||||
/** 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 =
|
||||
color_t::from_argb_bytes(engine_val.blend_with)
|
||||
.blend_lighten(color_t::from_argb_bytes(result.blend_with))
|
||||
.to_argb_bytes();
|
||||
result.blend_with = current_val.blend_with ? current_val.blend_with : animation_val.blend_with;
|
||||
if(primary&& engine_val.blend_with) result.blend_with = engine_val.blend_with.get().blend_lighten(result.blend_with.get());
|
||||
|
||||
/** engine provide a blend color for poisoned units */
|
||||
result.blend_ratio = current_val.blend_ratio?current_val.blend_ratio:animation_val.blend_ratio;
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "halo.hpp"
|
||||
#include "image.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
class config;
|
||||
|
||||
class progressive_string {
|
||||
|
@ -82,8 +84,8 @@ class frame_parameters{
|
|||
std::string halo_mod;
|
||||
std::string sound;
|
||||
std::string text;
|
||||
Uint32 text_color;
|
||||
Uint32 blend_with;
|
||||
boost::optional<color_t> text_color;
|
||||
boost::optional<color_t> blend_with;
|
||||
double blend_ratio;
|
||||
double highlight_ratio;
|
||||
double offset;
|
||||
|
@ -110,9 +112,9 @@ class frame_builder {
|
|||
frame_builder & image(const std::string& image ,const std::string & image_mod="");
|
||||
frame_builder & image_diagonal(const std::string& image_diagonal,const std::string & image_mod="");
|
||||
frame_builder & sound(const std::string& sound);
|
||||
frame_builder & text(const std::string& text,const Uint32 text_color);
|
||||
frame_builder & text(const std::string& text,const color_t text_color);
|
||||
frame_builder & halo(const std::string &halo, const std::string &halo_x, const std::string& halo_y,const std::string& halo_mod);
|
||||
frame_builder & blend(const std::string& blend_ratio,const Uint32 blend_color);
|
||||
frame_builder & blend(const std::string& blend_ratio,const color_t blend_color);
|
||||
frame_builder & highlight(const std::string& highlight);
|
||||
frame_builder & offset(const std::string& offset);
|
||||
frame_builder & submerge(const std::string& submerge);
|
||||
|
@ -137,8 +139,8 @@ class frame_builder {
|
|||
std::string halo_mod_;
|
||||
std::string sound_;
|
||||
std::string text_;
|
||||
Uint32 text_color_;
|
||||
Uint32 blend_with_;
|
||||
boost::optional<color_t> text_color_;
|
||||
boost::optional<color_t> blend_with_;
|
||||
std::string blend_ratio_;
|
||||
std::string highlight_ratio_;
|
||||
std::string offset_;
|
||||
|
@ -163,7 +165,7 @@ class frame_parsed_parameters {
|
|||
void override( int duration
|
||||
, const std::string& highlight = ""
|
||||
, const std::string& blend_ratio =""
|
||||
, Uint32 blend_color = 0
|
||||
, color_t blend_color = {0,0,0}
|
||||
, const std::string& offset = ""
|
||||
, const std::string& layer = ""
|
||||
, const std::string& modifiers = "");
|
||||
|
@ -185,8 +187,8 @@ class frame_parsed_parameters {
|
|||
std::string halo_mod_;
|
||||
std::string sound_;
|
||||
std::string text_;
|
||||
Uint32 text_color_;
|
||||
Uint32 blend_with_;
|
||||
boost::optional<color_t> text_color_;
|
||||
boost::optional<color_t> blend_with_;
|
||||
progressive_double blend_ratio_;
|
||||
progressive_double highlight_ratio_;
|
||||
progressive_double offset_;
|
||||
|
|
|
@ -129,7 +129,7 @@ static int move_unit_between(const map_location& a, const map_location& b,
|
|||
disp.invalidate(a);
|
||||
temp_unit->set_facing(a.get_relative_dir(b));
|
||||
animator.replace_anim_if_invalid(temp_unit.get(),"movement",a,b,step_num,
|
||||
false,"",0,unit_animation::hit_type::INVALID,nullptr,nullptr,step_left);
|
||||
false,"",{0,0,0},unit_animation::hit_type::INVALID,nullptr,nullptr,step_left);
|
||||
animator.start_animations();
|
||||
animator.pause_animation();
|
||||
disp.scroll_to_tiles(a, b, game_display::ONSCREEN, true, 0.0, false);
|
||||
|
@ -508,8 +508,8 @@ void unit_draw_weapon(const map_location& loc, unit& attacker,
|
|||
unit_animator animator;
|
||||
attacker.set_facing(loc.get_relative_dir(defender_loc));
|
||||
defender->set_facing(defender_loc.get_relative_dir(loc));
|
||||
animator.add_animation(&attacker,"draw_weapon",loc,defender_loc,0,false,"",0,unit_animation::hit_type::HIT,attack,secondary_attack,0);
|
||||
animator.add_animation(defender,"draw_weapon",defender_loc,loc,0,false,"",0,unit_animation::hit_type::MISS,secondary_attack,attack,0);
|
||||
animator.add_animation(&attacker,"draw_weapon",loc,defender_loc,0,false,"",{0,0,0},unit_animation::hit_type::HIT,attack,secondary_attack,0);
|
||||
animator.add_animation(defender,"draw_weapon",defender_loc,loc,0,false,"",{0,0,0},unit_animation::hit_type::MISS,secondary_attack,attack,0);
|
||||
animator.start_animations();
|
||||
animator.wait_for_end();
|
||||
|
||||
|
@ -525,10 +525,10 @@ void unit_sheath_weapon(const map_location& primary_loc, unit* primary_unit,
|
|||
}
|
||||
unit_animator animator;
|
||||
if(primary_unit) {
|
||||
animator.add_animation(primary_unit,"sheath_weapon",primary_loc,secondary_loc,0,false,"",0,unit_animation::hit_type::INVALID,primary_attack,secondary_attack,0);
|
||||
animator.add_animation(primary_unit,"sheath_weapon",primary_loc,secondary_loc,0,false,"",{0,0,0},unit_animation::hit_type::INVALID,primary_attack,secondary_attack,0);
|
||||
}
|
||||
if(secondary_unit) {
|
||||
animator.add_animation(secondary_unit,"sheath_weapon",secondary_loc,primary_loc,0,false,"",0,unit_animation::hit_type::INVALID,secondary_attack,primary_attack,0);
|
||||
animator.add_animation(secondary_unit,"sheath_weapon",secondary_loc,primary_loc,0,false,"",{0,0,0},unit_animation::hit_type::INVALID,secondary_attack,primary_attack,0);
|
||||
}
|
||||
|
||||
if(primary_unit || secondary_unit) {
|
||||
|
@ -555,9 +555,9 @@ void unit_die(const map_location& loc, unit& loser,
|
|||
}
|
||||
unit_animator animator;
|
||||
// hide the hp/xp bars of the loser (useless and prevent bars around an erased unit)
|
||||
animator.add_animation(&loser,"death",loc,winner_loc,0,false,"",0,unit_animation::hit_type::KILL,attack,secondary_attack,0);
|
||||
animator.add_animation(&loser,"death",loc,winner_loc,0,false,"",{0,0,0},unit_animation::hit_type::KILL,attack,secondary_attack,0);
|
||||
// but show the bars of the winner (avoid blinking and show its xp gain)
|
||||
animator.add_animation(winner,"victory",winner_loc,loc,0,true,"",0,
|
||||
animator.add_animation(winner,"victory",winner_loc,loc,0,true,"",{0,0,0},
|
||||
unit_animation::hit_type::KILL,secondary_attack,attack,0);
|
||||
animator.start_animations();
|
||||
animator.wait_for_end();
|
||||
|
@ -618,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) ? color_t(0, 255, 0).to_argb_bytes() : color_t(255, 0, 0).to_argb_bytes(),
|
||||
(drain_amount >= 0) ? color_t(0,255,0) : color_t(255,0,0),
|
||||
hit_type, &attack, secondary_attack, swing);
|
||||
|
||||
// note that we take an anim from the real unit, we'll use it later
|
||||
|
@ -626,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 , color_t(255, 0, 0).to_argb_bytes());
|
||||
true, text , {255,0,0});
|
||||
|
||||
for (const unit_ability & ability : leaders) {
|
||||
if(ability.second == a) continue;
|
||||
|
@ -635,7 +635,7 @@ void unit_attack(display * disp, game_board & board,
|
|||
assert(leader.valid());
|
||||
leader->set_facing(ability.second.get_relative_dir(a));
|
||||
animator.add_animation(&*leader, "leading", ability.second,
|
||||
att->get_location(), damage, true, "", 0,
|
||||
att->get_location(), damage, true, "", {0,0,0},
|
||||
hit_type, &attack, secondary_attack, swing);
|
||||
}
|
||||
for (const unit_ability & ability : helpers) {
|
||||
|
@ -645,7 +645,7 @@ void unit_attack(display * disp, game_board & board,
|
|||
assert(helper.valid());
|
||||
helper->set_facing(ability.second.get_relative_dir(b));
|
||||
animator.add_animation(&*helper, "resistance", ability.second,
|
||||
def->get_location(), damage, true, "", 0,
|
||||
def->get_location(), damage, true, "", {0,0,0},
|
||||
hit_type, &attack, secondary_attack, swing);
|
||||
}
|
||||
|
||||
|
@ -751,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),
|
||||
color_t(255,0,0).to_argb_bytes());
|
||||
{255,0,0});
|
||||
} else if ( healing > 0 ) {
|
||||
animator.add_animation(&healed, "healed", healed_loc,
|
||||
map_location::null_location(), healing, false,
|
||||
number_and_text(healing, extra_text),
|
||||
color_t(0,255,0).to_argb_bytes());
|
||||
{0,255,0});
|
||||
} else {
|
||||
animator.add_animation(&healed, "healed", healed_loc,
|
||||
map_location::null_location(), 0, false,
|
||||
extra_text, color_t(0,255,0).to_argb_bytes());
|
||||
extra_text, {0,255,0});
|
||||
}
|
||||
animator.start_animations();
|
||||
animator.wait_for_end();
|
||||
|
@ -802,7 +802,7 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m
|
|||
{
|
||||
attack_type *primary = nullptr;
|
||||
attack_type *secondary = nullptr;
|
||||
Uint32 text_color;
|
||||
color_t text_color;
|
||||
unit_animation::hit_type hits= unit_animation::hit_type::INVALID;
|
||||
const_attack_itors attacks = u->attacks();
|
||||
const_attack_itors::const_iterator itor;
|
||||
|
@ -859,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 = color_t(0xff,0xff,0xff).to_argb_bytes();
|
||||
text_color = color_t(0xff,0xff,0xff);
|
||||
} else {
|
||||
text_color = color_t(cfg["red"], cfg["green"], cfg["blue"]).to_argb_bytes();
|
||||
text_color = color_t(cfg["red"], cfg["green"], cfg["blue"]);
|
||||
}
|
||||
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