Added ability to define color ranges and color palettes...
...in scenarios, units, and unit modification effects. Added ability to add unit image modifications to a unit via a unit modification effect tag.
This commit is contained in:
parent
57cffddaf5
commit
8428bbcb7d
8 changed files with 77 additions and 20 deletions
|
@ -41,6 +41,7 @@ Version 1.3-svn:
|
|||
* show leader's name and colour at status table even when that team is fogged
|
||||
(patch #605)
|
||||
* WML engine
|
||||
* added ability to define color ranges and palettes in scenario, units, and unit modification effects. Added ability to add image modifications in a unit modification [effect] tag
|
||||
* overhaul of team coloring engine. Now possible to apply multiple TC to an image.
|
||||
* added fourth color in team_rgb definitions for representative color in minimap
|
||||
* added a 'hide_help' key that prevents a unit type from being listed in the
|
||||
|
|
|
@ -108,7 +108,7 @@ name=moveto
|
|||
[/status]
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=4,9
|
||||
x,y=12,8
|
||||
type="Thief"
|
||||
generate_description=yes
|
||||
[/unit]
|
||||
|
@ -235,6 +235,11 @@ name=moveto
|
|||
text="change coloring"
|
||||
[/label]
|
||||
|
||||
[color_range]
|
||||
id=blonde
|
||||
rgb=255,255,0,255,255,128,0,0,0
|
||||
[/color_range]
|
||||
|
||||
[event]
|
||||
name=moveto
|
||||
first_time_only=no
|
||||
|
@ -242,19 +247,41 @@ name=moveto
|
|||
side=1
|
||||
x=12
|
||||
y=6
|
||||
type="Thief"
|
||||
[/filter]
|
||||
[object]
|
||||
id=bleach
|
||||
name= _ "Potion of bleach"
|
||||
image=items/potion-red.png
|
||||
duration=level
|
||||
description= _ "Oooh tingly!!!"
|
||||
[effect]
|
||||
apply_to=image_mod
|
||||
replace="TC(thief>blonde)"
|
||||
|
||||
[color_palette]
|
||||
thief=133,167,202,73,102,151,215,240,240,185,206,228,41,61,95,97,124,171
|
||||
[/color_palette]
|
||||
[/effect]
|
||||
[/object]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
name=moveto
|
||||
first_time_only=no
|
||||
[filter]
|
||||
side=1
|
||||
x=12
|
||||
y=6
|
||||
[not]
|
||||
type="Thief"
|
||||
[/not]
|
||||
[/filter]
|
||||
[message]
|
||||
speaker=narrator
|
||||
image=units/elves-wood/captain.png~TC(magenta>3)
|
||||
message=_ "Now you can spy on the green team.
|
||||
Does not work yet."
|
||||
message=_ "Send me a thief to spy on the blondes"
|
||||
[/message]
|
||||
[effect]
|
||||
apply_to=image
|
||||
[image_mod]
|
||||
type=TC(magenta>3)
|
||||
[/image_mod]
|
||||
[/effect]
|
||||
[/event]
|
||||
|
||||
[item]
|
||||
|
|
|
@ -165,6 +165,15 @@ namespace game_config
|
|||
level_image = v["level_image"];
|
||||
ellipsis_image = v["ellipsis_image"];
|
||||
|
||||
add_color_info(v);
|
||||
|
||||
flag_rgb = v["flag_rgb"];
|
||||
if( !flag_rgb.size()){
|
||||
flag_rgb="green";
|
||||
}
|
||||
}
|
||||
|
||||
const void add_color_info(const config& v){
|
||||
const config::child_list& team_colors = v.get_children("color_range");
|
||||
for(config::child_list::const_iterator teamC = team_colors.begin(); teamC != team_colors.end(); ++teamC) {
|
||||
if(!(**teamC)["id"].empty() && !(**teamC)["rgb"].empty()){
|
||||
|
@ -192,11 +201,11 @@ namespace game_config
|
|||
LOG_NG << str.str() <<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const config* rgbv = v.child("color_palette");
|
||||
if(rgbv) {
|
||||
for(string_map::const_iterator rgb_it = rgbv->values.begin(); rgb_it != rgbv->values.end(); ++rgb_it) {
|
||||
}
|
||||
|
||||
const config::child_list& colors = v.get_children("color_palette");
|
||||
for(config::child_list::const_iterator cp = colors.begin(); cp != colors.end(); ++cp) {
|
||||
for(string_map::const_iterator rgb_it = (*cp)->values.begin(); rgb_it != (*cp)->values.end(); ++rgb_it) {
|
||||
try {
|
||||
// team_rgb_colors.insert(std::make_pair(rgb_it->first,string2rgb(rgb_it->second)));
|
||||
//should new colors overwrite old colors?
|
||||
|
@ -206,10 +215,6 @@ namespace game_config
|
|||
}
|
||||
}
|
||||
}
|
||||
flag_rgb = v["flag_rgb"];
|
||||
if( !flag_rgb.size()){
|
||||
flag_rgb="green";
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Uint32>& tc_info(const std::string& name)
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace game_config
|
|||
}
|
||||
|
||||
void load_config(const config* cfg);
|
||||
|
||||
const void add_color_info(const config& v);
|
||||
const std::vector<Uint32>& tc_info(const std::string& name);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ play_controller::play_controller(const config& level, const game_data& gameinfo,
|
|||
skip_replay_ = skip_replay;
|
||||
browse_ = false;
|
||||
|
||||
game_config::add_color_info(level);
|
||||
|
||||
init(video);
|
||||
}
|
||||
|
||||
|
|
20
src/unit.cpp
20
src/unit.cpp
|
@ -97,6 +97,7 @@ unit::unit(const unit& o):
|
|||
level_(o.level_),
|
||||
alignment_(o.alignment_),
|
||||
flag_rgb_(o.flag_rgb_),
|
||||
image_mods_(o.image_mods_),
|
||||
|
||||
unrenamable_(o.unrenamable_),
|
||||
side_(o.side_),
|
||||
|
@ -190,6 +191,7 @@ unit::unit(const game_data* gamedata, unit_map* unitmap, const gamemap* map,
|
|||
if(race_->not_living()) {
|
||||
set_state("not_living","yes");
|
||||
}
|
||||
game_config::add_color_info(cfg);
|
||||
}
|
||||
|
||||
unit::unit(const game_data& gamedata,const config& cfg) : movement_(0),
|
||||
|
@ -2672,6 +2674,20 @@ void unit::add_modification(const std::string& type, const config& mod,
|
|||
if (ap) {
|
||||
mod_mdr_merge(*mv, *ap, !utils::string_bool(replace));
|
||||
}
|
||||
}else if (apply_to == "image_mod") {
|
||||
LOG_UT << "applying image_mod \n";
|
||||
std::string mod = (**i.first)["replace"];
|
||||
if (!mod.empty()){
|
||||
image_mods_ = mod;
|
||||
}
|
||||
LOG_UT << "applying image_mod \n";
|
||||
mod = (**i.first)["add"];
|
||||
if (mod.empty()){
|
||||
image_mods_ += mod;
|
||||
}
|
||||
|
||||
game_config::add_color_info(**i.first);
|
||||
LOG_UT << "applying image_mod \n";
|
||||
}
|
||||
|
||||
if(!description.empty())
|
||||
|
@ -3255,6 +3271,8 @@ std::string unit::image_mods() const{
|
|||
if(flag_rgb_.size()){
|
||||
modifier << "~TC("<< flag_rgb_ << ">" << team::get_side_colour_index(side()) << ")";
|
||||
}
|
||||
|
||||
if(image_mods_.size()){
|
||||
modifier << "~" << image_mods_;
|
||||
}
|
||||
return modifier.str();
|
||||
}
|
||||
|
|
|
@ -312,7 +312,8 @@ class unit
|
|||
int level_;
|
||||
unit_type::ALIGNMENT alignment_;
|
||||
std::string flag_rgb_;
|
||||
|
||||
std::string image_mods_;
|
||||
|
||||
bool unrenamable_;
|
||||
unsigned int side_;
|
||||
unit_race::GENDER gender_;
|
||||
|
|
|
@ -901,6 +901,7 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
|
|||
// always have a levelout animation
|
||||
}
|
||||
flag_rgb_ = cfg["flag_rgb"];
|
||||
game_config::add_color_info(cfg);
|
||||
// deprecation messages, only seen when unit is parsed for the first time
|
||||
|
||||
hide_help_= cfg_["hide_help"] == "true" ? true : false;
|
||||
|
|
Loading…
Add table
Reference in a new issue