Add [unit_type]image_icon key (FR bug #15466)

This commit is contained in:
Alexander van Gessel 2011-11-06 21:18:50 +01:00
parent 865e7bad30
commit 210fa9f5d2
6 changed files with 26 additions and 4 deletions

View file

@ -124,6 +124,8 @@ Version 1.9.9+svn:
* Introduce [capture_village]fire_event=yes|no (def no) whether to fire
any capture events (was previously always yes)
* Made [move_unit] respect image modifications applied by EffectWML to single units
* Introduce [unit_type]image_icon key to override image for 72x72 icons
(FR bug #15466)
* Miscellaneous and bug fixes:
* Add --language/-L commandline option to set the language for that session
* Fixed: Avoid copying of singular iterators in the whiteboard code

View file

@ -120,8 +120,9 @@ Xu , Xu , Qxu , Qxu , Ql , Ql
[unit]
# Unhealable unit
x,y=9,8
type="Peasant"
type="Peasant_unhealable"
name="Unhealable"
image_icon="misc/key.png"
generate_name=yes
[status]
unhealable=yes
@ -3103,6 +3104,16 @@ Result:
[/event]
[/test]
[+units]
[unit_type]
id=Peasant_unhealable
[base_unit]
id=Peasant
[/base_unit]
image_icon="misc/key.png"
[/unit_type]
[/units]
[+language]
range_very_long= _ "very long"
type_electrical= _ "electrical"

View file

@ -525,7 +525,7 @@ unit::unit(const config &cfg, bool use_traits, game_state* state, const vconfig*
static char const *raw_attrs[] = { "description", "halo",
"profile", "small_profile", "upkeep", "usage", "ellipse",
"image", "random_traits", "generate_name" };
"image", "image_icon", "random_traits", "generate_name" };
foreach (const char *attr, raw_attrs) {
input_cfg.remove_attribute(attr);
}
@ -796,7 +796,7 @@ void unit::advance_to(const config &old_cfg, const unit_type *t,
// except for a few attributes.
config new_cfg;
static char const *persistent_attrs[] = { "upkeep", "ellipse",
"image", "usage", "random_traits", "generate_name" };
"image", "image_icon", "usage", "random_traits", "generate_name" };
foreach (const char *attr, persistent_attrs) {
if (const config::attribute_value *v = old_cfg.get(attr)) {
new_cfg[attr] = *v;
@ -2708,6 +2708,10 @@ void unit::add_trait_description(const config& trait, const t_string& descriptio
}
}
std::string unit::absolute_image() const {
return cfg_["image_icon"].empty() ? cfg_["image"] : cfg_["image_icon"];
}
const unit_animation* unit::choose_animation(const game_display& disp, const map_location& loc,const std::string& event,
const map_location& second_loc,const int value,const unit_animation::hit_type hit,
const attack_type* attack, const attack_type* second_attack, int swing_num) const

View file

@ -277,7 +277,7 @@ public:
Uint32 text_color = 0, STATE state = STATE_ANIM);
/** The name of the file to game_display (used in menus). */
std::string absolute_image() const { return cfg_["image"]; }
std::string absolute_image() const;
std::string image_halo() const { return cfg_["halo"]; }
std::string image_ellipse() const { return cfg_["ellipse"]; }

View file

@ -568,6 +568,7 @@ unit_type::unit_type(const unit_type& o) :
usage_(o.usage_),
undead_variation_(o.undead_variation_),
image_(o.image_),
icon_(o.icon_),
small_profile_(o.small_profile_),
big_profile_(o.big_profile_),
flag_rgb_(o.flag_rgb_),
@ -614,6 +615,7 @@ unit_type::unit_type(config &cfg) :
usage_(),
undead_variation_(),
image_(),
icon_(),
small_profile_(),
big_profile_(),
flag_rgb_(),
@ -775,6 +777,7 @@ void unit_type::build_help_index(const movement_type_map &mv_types,
usage_ = cfg_["usage"].str();
undead_variation_ = cfg_["undead_variation"].str();
image_ = cfg_["image"].str();
icon_ = cfg_["image_icon"].str();
small_profile_ = cfg_["small_profile"].str();
big_profile_ = cfg_["profile"].str();
adjust_profile(small_profile_, big_profile_, image_);

View file

@ -228,6 +228,7 @@ public:
int cost() const { return cost_; }
const std::string& usage() const { return usage_; }
const std::string& image() const { return image_; }
const std::string& icon() const { return icon_; }
const std::string &small_profile() const { return small_profile_; }
const std::string &big_profile() const { return big_profile_; }
@ -306,6 +307,7 @@ private:
std::string undead_variation_;
std::string image_;
std::string icon_;
std::string small_profile_;
std::string big_profile_;
std::string flag_rgb_;