Skip to content

Commit

Permalink
pass halo::manager as an argument to unit frame redraw fcn
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 27, 2014
1 parent 2b42441 commit 1010fbe
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/unit_animation.cpp
Expand Up @@ -1020,17 +1020,17 @@ void unit_animation::restart_animation()
anim_itor->second.restart_animation();
}
}
void unit_animation::redraw(frame_parameters& value)
void unit_animation::redraw(frame_parameters& value, halo::manager & halo_man)
{

invalidated_=false;
overlaped_hex_.clear();
std::map<std::string,particule>::iterator anim_itor =sub_anims_.begin();
value.primary_frame = t_true;
unit_anim_.redraw(value,src_,dst_);
unit_anim_.redraw(value,src_,dst_, halo_man);
value.primary_frame = t_false;
for( /*null*/; anim_itor != sub_anims_.end() ; ++anim_itor) {
anim_itor->second.redraw( value,src_,dst_);
anim_itor->second.redraw( value,src_,dst_, halo_man);
}
}
void unit_animation::clear_haloes()
Expand Down Expand Up @@ -1208,7 +1208,7 @@ std::ostream& operator << (std::ostream& outstream, const unit_animation& u_anim
}


void unit_animation::particule::redraw(const frame_parameters& value,const map_location &src, const map_location &dst)
void unit_animation::particule::redraw(const frame_parameters& value,const map_location &src, const map_location &dst, halo::manager & halo_man)
{
const unit_frame& current_frame= get_current_frame();
const int animation_time = get_animation_time();
Expand All @@ -1226,9 +1226,9 @@ void unit_animation::particule::redraw(const frame_parameters& value,const map_l
// for sound frames we want the first time variable set only after the frame has started.
if(get_current_frame_begin_time() != last_frame_begin_time_ && animation_time >= get_current_frame_begin_time()) {
last_frame_begin_time_ = get_current_frame_begin_time();
current_frame.redraw(get_current_frame_time(),true,in_scope_of_frame,src,dst,halo_id_,default_val,value);
current_frame.redraw(get_current_frame_time(),true,in_scope_of_frame,src,dst,halo_id_,halo_man,default_val,value);
} else {
current_frame.redraw(get_current_frame_time(),false,in_scope_of_frame,src,dst,halo_id_,default_val,value);
current_frame.redraw(get_current_frame_time(),false,in_scope_of_frame,src,dst,halo_id_,halo_man,default_val,value);
}
}
void unit_animation::particule::clear_halo()
Expand Down
4 changes: 2 additions & 2 deletions src/unit_animation.hpp
Expand Up @@ -62,7 +62,7 @@ class unit_animation
void pause_animation();
void restart_animation();
int get_current_frame_begin_time() const{ return unit_anim_.get_current_frame_begin_time() ; }
void redraw(frame_parameters& value);
void redraw(frame_parameters& value, halo::manager & halo_man);
void clear_haloes();
bool invalidate(frame_parameters& value );
std::string debug() const;
Expand Down Expand Up @@ -110,7 +110,7 @@ class unit_animation
, const std::string& offset = ""
, const std::string& layer = ""
, const std::string& modifiers = "");
void redraw( const frame_parameters& value,const map_location &src, const map_location &dst);
void redraw( const frame_parameters& value,const map_location &src, const map_location &dst, halo::manager & halo_man);
std::set<map_location> get_overlaped_hex(const frame_parameters& value,const map_location &src, const map_location &dst);
void start_animation(int start_time);
const frame_parameters parameters(const frame_parameters & default_val) const { return get_current_frame().merge_parameters(get_current_frame_time(),parameters_.parameters(get_animation_time()-get_begin_time()),default_val); }
Expand Down
2 changes: 1 addition & 1 deletion src/unit_drawer.cpp
Expand Up @@ -332,7 +332,7 @@ void unit_drawer::redraw_unit (const unit & u) const
params.y -= height_adjust_unit - height_adjust;
params.halo_y -= height_adjust_unit - height_adjust;

ac.anim_->redraw(params);
ac.anim_->redraw(params, halo_man);
ac.refreshing_ = false;
}

11 changes: 3 additions & 8 deletions src/unit_frame.cpp
Expand Up @@ -18,7 +18,6 @@

#include "game_display.hpp"
#include "halo.hpp"
#include "resources.hpp" // only for halo manager
#include "sound.hpp"
#include "unit_frame.hpp"

Expand Down Expand Up @@ -628,7 +627,7 @@ std::vector<std::string> frame_parsed_parameters::debug_strings() const {
}


void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of_frame,const map_location & src,const map_location & dst,halo::handle & halo_id,const frame_parameters & animation_val,const frame_parameters & engine_val)const
void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of_frame,const map_location & src,const map_location & dst,halo::handle & halo_id,halo::manager & halo_man, const frame_parameters & animation_val,const frame_parameters & engine_val)const
{
const int xsrc = game_display::get_singleton()->get_location_x(src);
const int ysrc = game_display::get_singleton()->get_location_y(src);
Expand Down Expand Up @@ -736,18 +735,14 @@ void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of
break;
}

if (!resources::halo) {
return;
}

if(direction != map_location::SOUTH_WEST && direction != map_location::NORTH_WEST) {
halo_id = resources::halo->add(static_cast<int>(x+current_data.halo_x* game_display::get_singleton()->get_zoom_factor()),
halo_id = halo_man.add(static_cast<int>(x+current_data.halo_x* game_display::get_singleton()->get_zoom_factor()),
static_cast<int>(y+current_data.halo_y* game_display::get_singleton()->get_zoom_factor()),
current_data.halo + current_data.halo_mod,
map_location(-1, -1),
orientation);
} else {
halo_id = resources::halo->add(static_cast<int>(x-current_data.halo_x* game_display::get_singleton()->get_zoom_factor()),
halo_id = halo_man.add(static_cast<int>(x-current_data.halo_x* game_display::get_singleton()->get_zoom_factor()),
static_cast<int>(y+current_data.halo_y* game_display::get_singleton()->get_zoom_factor()),
current_data.halo + current_data.halo_mod,
map_location(-1, -1),
Expand Down
2 changes: 1 addition & 1 deletion src/unit_frame.hpp
Expand Up @@ -205,7 +205,7 @@ class unit_frame {
public:
// Constructors
unit_frame(const frame_builder& builder=frame_builder()):builder_(builder){}
void redraw(const int frame_time,bool on_start_time,bool in_scope_of_frame,const map_location & src,const map_location & dst,halo::handle & halo_id,const frame_parameters & animation_val,const frame_parameters & engine_val)const;
void redraw(const int frame_time,bool on_start_time,bool in_scope_of_frame,const map_location & src,const map_location & dst,halo::handle & halo_id, halo::manager & halo_man, const frame_parameters & animation_val,const frame_parameters & engine_val)const;
const frame_parameters merge_parameters(int current_time,const frame_parameters & animation_val,const frame_parameters & engine_val=frame_parameters()) const;
const frame_parameters parameters(int current_time) const {return builder_.parameters(current_time);}
const frame_parameters end_parameters() const {return builder_.parameters(duration());}
Expand Down

0 comments on commit 1010fbe

Please sign in to comment.