new animation parameter: submerge.
Not really useful, but needed for future refactoring
This commit is contained in:
parent
c978a28d52
commit
a82b592ae5
5 changed files with 30 additions and 7 deletions
|
@ -94,6 +94,7 @@ Version 1.5.0-svn:
|
|||
* clean up gcc 4.3 warnings so the game now builds on fedora rawhide
|
||||
with warnings treated as errors. A few of bugs were found in the
|
||||
process as well.
|
||||
* new progressive parameter for animations : submerge
|
||||
|
||||
Version 1.4:
|
||||
* language and i18n:
|
||||
|
|
|
@ -1672,7 +1672,6 @@ void unit::redraw_unit(game_display& disp, const gamemap::location& loc, const b
|
|||
|
||||
const t_translation::t_terrain terrain = map.get_terrain(loc);
|
||||
const terrain_type& terrain_info = map.get_terrain_info(terrain);
|
||||
const double submerge = is_flying() ? 0.0 : terrain_info.unit_submerge();
|
||||
int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * disp.get_zoom_factor());
|
||||
if (is_flying() && height_adjust < 0) {
|
||||
height_adjust = 0;
|
||||
|
@ -1684,6 +1683,8 @@ void unit::redraw_unit(game_display& disp, const gamemap::location& loc, const b
|
|||
}
|
||||
anim_->update_last_draw_time();
|
||||
const frame_parameters params = anim_->get_current_params();
|
||||
double submerge = params.submerge;
|
||||
if(!submerge) submerge= is_flying() ? 0.0 : terrain_info.unit_submerge();
|
||||
|
||||
if(frame_begin_time_ != anim_->get_current_frame_begin_time()) {
|
||||
frame_begin_time_ = anim_->get_current_frame_begin_time();
|
||||
|
|
|
@ -731,6 +731,7 @@ void unit_animation::particule::start_animation(int start_time,
|
|||
{
|
||||
halo::remove(halo_id_);
|
||||
halo_id_ = halo::NO_HALO;
|
||||
parameters_.duration(get_animation_duration());
|
||||
animated<unit_frame>::start_animation(start_time,cycles);
|
||||
last_frame_begin_time_ = get_begin_time() -1;
|
||||
if(src != gamemap::location::null_location || dst != gamemap::location::null_location) {
|
||||
|
|
|
@ -183,6 +183,7 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
|
|||
}
|
||||
highlight(cfg[frame_string+"alpha"]);
|
||||
offset(cfg[frame_string+"offset"]);
|
||||
submerge(cfg[frame_string+"submerge"]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -202,6 +203,7 @@ const frame_parameters frame_builder::parameters(int current_time, const frame_p
|
|||
result.blend_ratio = blend_ratio_.get_current_element(current_time,default_val.blend_ratio);
|
||||
result.highlight_ratio = highlight_ratio_.get_current_element(current_time,default_val.highlight_ratio);
|
||||
result.offset = offset_.get_current_element(current_time,default_val.offset);
|
||||
result.submerge = submerge_.get_current_element(current_time,default_val.submerge);
|
||||
return result;
|
||||
}
|
||||
frame_builder & frame_builder::image(const image::locator image )
|
||||
|
@ -235,13 +237,18 @@ frame_builder & frame_builder::halo(const std::string &halo, const std::string &
|
|||
frame_builder & frame_builder::duration(const int duration)
|
||||
{
|
||||
duration_= duration;
|
||||
recalculate_duration();
|
||||
return *this;
|
||||
}
|
||||
void frame_builder::recalculate_duration()
|
||||
{
|
||||
halo_ = progressive_string(halo_.get_original(),duration_);
|
||||
halo_x_ = progressive_int(halo_x_.get_original(),duration_);
|
||||
halo_y_ = progressive_int(halo_y_.get_original(),duration_);
|
||||
blend_ratio_=progressive_double(blend_ratio_.get_original(),duration_);
|
||||
highlight_ratio_=progressive_double(highlight_ratio_.get_original(),duration_);
|
||||
offset_=progressive_double(offset_.get_original(),duration_);
|
||||
return *this;
|
||||
submerge_=progressive_double(submerge_.get_original(),duration_);
|
||||
}
|
||||
frame_builder & frame_builder::blend(const std::string& blend_ratio,const Uint32 blend_color)
|
||||
{
|
||||
|
@ -259,6 +266,11 @@ frame_builder & frame_builder::offset(const std::string& offset)
|
|||
offset_=progressive_double(offset,duration_);
|
||||
return *this;
|
||||
}
|
||||
frame_builder & frame_builder::submerge(const std::string& submerge)
|
||||
{
|
||||
submerge_=progressive_double(submerge,duration_);
|
||||
return *this;
|
||||
}
|
||||
bool frame_builder::does_not_change() const
|
||||
{
|
||||
return halo_.does_not_change() &&
|
||||
|
@ -266,7 +278,8 @@ bool frame_builder::does_not_change() const
|
|||
halo_y_.does_not_change() &&
|
||||
blend_ratio_.does_not_change() &&
|
||||
highlight_ratio_.does_not_change() &&
|
||||
offset_.does_not_change();
|
||||
offset_.does_not_change() &&
|
||||
submerge_.does_not_change();
|
||||
}
|
||||
bool frame_builder::need_update() const
|
||||
{
|
||||
|
@ -275,7 +288,8 @@ bool frame_builder::need_update() const
|
|||
!halo_y_.does_not_change() ||
|
||||
!blend_ratio_.does_not_change() ||
|
||||
!highlight_ratio_.does_not_change() ||
|
||||
!offset_.does_not_change() ) {
|
||||
!offset_.does_not_change() ||
|
||||
!submerge_.does_not_change() ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -326,7 +340,7 @@ void unit_frame::redraw(const int frame_time,bool first_time,const gamemap::loca
|
|||
bool facing_west = direction == gamemap::location::NORTH_WEST || direction == gamemap::location::SOUTH_WEST;
|
||||
bool facing_north = direction == gamemap::location::NORTH_WEST || direction == gamemap::location::NORTH || direction == gamemap::location::NORTH_EAST;
|
||||
game_display::get_singleton()->render_unit_image(x- image->w/2, y - image->h/2, false, gamemap::get_drawing_order(src), image, facing_west, false,
|
||||
ftofxp(current_data.highlight_ratio), current_data.blend_with, current_data.blend_ratio,0,!facing_north);
|
||||
ftofxp(current_data.highlight_ratio), current_data.blend_with, current_data.blend_ratio,current_data.submerge,!facing_north);
|
||||
}
|
||||
halo::remove(*halo_id);
|
||||
*halo_id = halo::NO_HALO;
|
||||
|
|
|
@ -78,7 +78,8 @@ class frame_parameters{
|
|||
blend_with(0),
|
||||
blend_ratio(0.0),
|
||||
highlight_ratio(1.0),
|
||||
offset(0)
|
||||
offset(0),
|
||||
submerge(0.0)
|
||||
{};
|
||||
|
||||
image::locator image;
|
||||
|
@ -94,6 +95,7 @@ class frame_parameters{
|
|||
double blend_ratio;
|
||||
double highlight_ratio;
|
||||
double offset;
|
||||
double submerge;
|
||||
} ;
|
||||
//! keep most parameters in a separate class to simplify handling of large number of parameters
|
||||
class frame_builder {
|
||||
|
@ -112,7 +114,8 @@ class frame_builder {
|
|||
blend_with_(0),
|
||||
blend_ratio_(""),
|
||||
highlight_ratio_(""),
|
||||
offset_("")
|
||||
offset_(""),
|
||||
submerge_("")
|
||||
{};
|
||||
frame_builder(const config& cfg,const std::string &frame_string = "");
|
||||
//! allow easy chained modifications will raised assert if used after initialization
|
||||
|
@ -125,10 +128,12 @@ class frame_builder {
|
|||
frame_builder & blend(const std::string& blend_ratio,const Uint32 blend_color);
|
||||
frame_builder & highlight(const std::string& highlight);
|
||||
frame_builder & offset(const std::string& offset);
|
||||
frame_builder & submerge(const std::string& submerge);
|
||||
//! getters for the different parameters
|
||||
const frame_parameters parameters(int current_time, const frame_parameters & default_val = frame_parameters()) const;
|
||||
|
||||
int duration() const{ return duration_;};
|
||||
void recalculate_duration();
|
||||
bool does_not_change() const;
|
||||
bool need_update() const;
|
||||
private:
|
||||
|
@ -145,6 +150,7 @@ class frame_builder {
|
|||
progressive_double blend_ratio_;
|
||||
progressive_double highlight_ratio_;
|
||||
progressive_double offset_;
|
||||
progressive_double submerge_;
|
||||
|
||||
};
|
||||
//! Describe a unit's animation sequence.
|
||||
|
|
Loading…
Add table
Reference in a new issue