Added transparent() method to the unit.
Transparent returns the path to the transparent unit portrait.
This commit is contained in:
parent
3c69fec804
commit
321e804b66
2 changed files with 24 additions and 0 deletions
22
src/unit.cpp
22
src/unit.cpp
|
@ -923,6 +923,28 @@ const std::string& unit::profile() const
|
|||
return absolute_image();
|
||||
}
|
||||
|
||||
std::string unit::transparent() const {
|
||||
std::string image = profile();
|
||||
const size_t offset = image.find_last_of('/');
|
||||
if(offset != std::string::npos) {
|
||||
image.insert(offset, "/transparent");
|
||||
} else {
|
||||
image = "transparent/" + image;
|
||||
}
|
||||
|
||||
image::locator locator(image);
|
||||
if(!locator.file_exists()) {
|
||||
image = profile();
|
||||
|
||||
#ifndef LOW_MEM
|
||||
if(image == absolute_image()) {
|
||||
image += image_mods();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
SDL_Colour unit::hp_color() const
|
||||
{
|
||||
double unit_energy = 0.0;
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
|
||||
/** The unit's profile */
|
||||
const std::string& profile() const;
|
||||
/** The unit's transparent profile */
|
||||
std::string transparent() const;
|
||||
/** Information about the unit -- a detailed description of it */
|
||||
const std::string& unit_description() const { return cfg_["description"]; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue