Skip to content

Commit

Permalink
inline unit::still_image, only used in a dialog function
Browse files Browse the repository at this point in the history
This helps us to remove graphics related headers from unit.hpp
  • Loading branch information
cbeck88 committed Jun 17, 2014
1 parent 6603de6 commit 4056321
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
16 changes: 15 additions & 1 deletion src/dialogs.cpp
Expand Up @@ -1242,7 +1242,21 @@ const unit_preview_pane::details units_list_preview_pane::get_details() const
const unit &u = *units_[index_];
details det;

det.image = u.still_image();
/** Get an SDL surface, ready for display for place where we need a still-image of the unit. */
image::locator image_loc;

#ifdef LOW_MEM
image_loc = image::locator(u.absolute_image());
#else
std::string mods=u.image_mods();
if(!mods.empty()){
image_loc = image::locator(u.absolute_image(),mods);
} else {
image_loc = image::locator(u.absolute_image());
}
#endif
det.image = image::get_image(image_loc, image::UNSCALED);
/***/

det.name = u.name();
det.type_name = u.type_name();
Expand Down
19 changes: 0 additions & 19 deletions src/unit.cpp
Expand Up @@ -1718,25 +1718,6 @@ void unit::write(config& cfg) const

}

const surface unit::still_image(bool scaled) const
{
image::locator image_loc;

#ifdef LOW_MEM
image_loc = image::locator(absolute_image());
#else
std::string mods=image_mods();
if(!mods.empty()){
image_loc = image::locator(absolute_image(),mods);
} else {
image_loc = image::locator(absolute_image());
}
#endif

surface unit_image(image::get_image(image_loc, scaled ? image::SCALED_TO_ZOOM : image::UNSCALED));
return unit_image;
}

void unit::set_facing(map_location::DIRECTION dir) const {
if(dir != map_location::NDIRECTIONS) {
facing_ = dir;
Expand Down
5 changes: 1 addition & 4 deletions src/unit.hpp
Expand Up @@ -20,7 +20,7 @@
#include <boost/tuple/tuple.hpp>
#include <boost/scoped_ptr.hpp>

#include "sdl/utils.hpp"
#include "sdl/utils.hpp" //only needed for SDL_Color
#include "unit_types.hpp"
#include "unit_map.hpp"
#include "unit_ptr.hpp"
Expand Down Expand Up @@ -245,9 +245,6 @@ class unit

int damage_from(const attack_type& attack,bool attacker,const map_location& loc) const { return resistance_against(attack,attacker,loc); }

/** A SDL surface, ready for display for place where we need a still-image of the unit. */
const surface still_image(bool scaled = false) const;

unit_animation_component & anim_comp() const { return *anim_comp_; }
void set_facing(map_location::DIRECTION dir) const;
map_location::DIRECTION facing() const { return facing_; }
Expand Down

0 comments on commit 4056321

Please sign in to comment.