Added new reports: unit_amla and unit_advancement_options

This commit is contained in:
John W. C. McNabb 2005-11-06 15:38:57 +00:00
parent 929592ed79
commit b0b55bc961
15 changed files with 161 additions and 32 deletions

View file

@ -4,8 +4,9 @@
#define AMLA_TOUGH HP_ADVANCE
[advancement]
max_times=100
id=tough
id=tough_{HP_ADVANCE}
description= _ "Max HP bonus +" {HP_ADVANCE}
image="misc/icon-amla-tough.png"
[effect]
apply_to=hitpoints
increase={HP_ADVANCE}
@ -20,6 +21,7 @@ increase_total={HP_ADVANCE}
max_times=100
id=necroheal
description= _ "Full Heal"
image="misc/icon-amla-fullheal.png"
[effect]
apply_to=hitpoints
increase_total=0%
@ -27,3 +29,4 @@ heal_full=yes
[/effect]
[/advancement]
#enddef

View file

@ -89,7 +89,10 @@ default=yes
observer_image=misc/eye.png
download_campaign_image=""
level_image="misc/icon-advance.png"
ellipsis_image="misc/icon-ellipsis.png"
[/game_config]
[textdomain]

View file

@ -193,7 +193,7 @@ height=768
id=label-hp
font_size=10
text= _ "HP"
rect="=+84,=+13,+54,+12"
rect="=+84,=+15,+54,+12"
xanchor=right
yanchor=fixed
[/label]
@ -202,7 +202,7 @@ height=768
id=label-xp
font_size=10
text= _ "XP"
rect="=+84,=+44,=+54,+12"
rect="=+84,=+46,=+54,+12"
xanchor=right
yanchor=fixed
[/label]
@ -346,10 +346,11 @@ height=768
ref=terrain-panel
id=status-terrain
font_size=12
rect="=+9,=+1,=-5,=+15"
rect="=+9,=+1,=-5,+15"
xanchor=right
yanchor=fixed
[/terrain]
[position]
ref=terrain-panel
id=status-position
@ -422,6 +423,14 @@ height=768
xanchor=right
yanchor=fixed
[/unit_moves]
[unit_amla]
id=unit_amla
font_size=12
ref=unit-panel
rect="=+84,=+3,+54,+12"
xanchor=right
yanchor=fixed
[/unit_amla]
[unit_hp]
id=unit-hp
font_size=12
@ -467,6 +476,15 @@ height=768
xanchor=right
yanchor=bottom
[/report_clock]
[unit_advancement_options]
id=unit_advancement_options
font_size=12
ref=label-xp
rect="=+15,-12,+54,+14"
xanchor=right
yanchor=fixed
[/unit_advancement_options]
[/status]
[/resolution]

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

View file

@ -948,8 +948,13 @@ void display::draw_report(reports::TYPE report_num)
// Loop through and display each report element
size_t tallest = 0;
int image_count = 0;
bool used_ellipsis=false;
std::stringstream ellipsis_tooltip;
SDL_Rect ellipsis_area =rect;
for(reports::report::iterator i = report.begin(); i != report.end(); ++i) {
if(i->text.empty() == false) {
if(i->text.empty() == false){
if(used_ellipsis == false) {
// Draw a text element
area = font::draw_text(&screen_,rect,item->font_size(),font::NORMAL_COLOUR,i->text,x,y);
if(area.h > tallest) tallest = area.h;
@ -960,7 +965,9 @@ void display::draw_report(reports::TYPE report_num)
} else {
x += area.w;
}
} else if(i->image.empty() == false) {
}
} else if(i->image.empty() == false){
if(used_ellipsis == false) {
// Draw an image element
surface img(image::get_image(i->image,image::UNSCALED));
@ -973,22 +980,42 @@ void display::draw_report(reports::TYPE report_num)
continue;
}
if(rect.w + rect.x - x < img->w && image_count){
//we have more than one image, and this one doesn't fit.
img=surface(image::get_image(game_config::ellipsis_image,image::UNSCALED));
used_ellipsis=true;
}
area.x = x;
area.y = y;
area.w = minimum<int>(rect.w + rect.x - x, img->w);
area.h = minimum<int>(rect.h + rect.y - y, img->h);
draw_image_for_report(img, area);
image_count++;
if(area.h > tallest) tallest = area.h;
x += area.w;
if(! used_ellipsis){
x += area.w;
}else{
ellipsis_area=area;
}
}
} else {
// No text or image, skip this element
continue;
}
if(i->tooltip.empty() == false) {
if(! used_ellipsis){
tooltips::add_tooltip(area,i->tooltip);
}else{ //collect all tooltips for the ellipsis
ellipsis_tooltip<<i->tooltip<<"\n";
}
}
}
if(used_ellipsis){
tooltips::add_tooltip(ellipsis_area,ellipsis_tooltip.str());
}
}
} else {
reportSurfaces_[report_num].assign(NULL);

View file

@ -66,6 +66,9 @@ namespace game_config
std::string download_campaign_image;
std::string level_image;
std::string ellipsis_image;
namespace sounds {
const std::string turn_bell = "bell.wav",
receive_message = "receive.wav",
@ -140,5 +143,7 @@ namespace game_config
observer_image = v["observer_image"];
download_campaign_image = v["download_campaign_image"];
level_image = v["level_image"];
ellipsis_image = v["ellipsis_image"];
}
}

View file

@ -42,7 +42,7 @@ namespace game_config
enemy_energy_image,ally_energy_image,flag_image,
dot_image,cross_image,
missile_n_image,missile_ne_image,terrain_mask_image,observer_image,download_campaign_image,
checked_menu_image,unchecked_menu_image;
checked_menu_image,unchecked_menu_image,level_image,ellipsis_image;
extern std::vector<std::string> foot_left_nw,foot_left_n,foot_right_nw,foot_right_n;

View file

@ -29,13 +29,15 @@
#include <sstream>
namespace {
const std::string report_names[] = { "unit_description", "unit_type", "unit_level",
"unit_traits","unit_status","unit_alignment","unit_abilities","unit_hp","unit_xp",
"unit_moves","unit_weapons","unit_image","unit_profile","time_of_day",
const std::string report_names[] = { "unit_description", "unit_type",
"unit_level","unit_amla","unit_traits","unit_status",
"unit_alignment","unit_abilities","unit_hp","unit_xp",
"unit_advancement_options","unit_moves","unit_weapons",
"unit_image","unit_profile","time_of_day",
"turn","gold","villages","num_units","upkeep", "expenses",
"income", "terrain", "position", "side_playing", "observers",
"report_clock",
"selected_terrain","edit_left_button_function"};
"income", "terrain", "position", "side_playing", "observers",
"report_clock","selected_terrain","edit_left_button_function"
};
std::map<reports::TYPE, std::string> report_contents;
}
@ -112,6 +114,14 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
case UNIT_LEVEL:
str << u->second.type().level();
break;
case UNIT_AMLA: {
report res;
const std::vector<std::pair<std::string,std::string> > & amla_icons=u->second.amla_icons();
for(std::vector<std::pair<std::string,std::string> >::const_iterator i=amla_icons.begin();i!=amla_icons.end();i++){
res.add_image(i->first,i->second);
}
return(res);
}
case UNIT_TRAITS:
return report(u->second.traits_description(),"",u->second.modification_description("trait"));
case UNIT_STATUS: {
@ -171,7 +181,7 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
str << font::GOOD_TEXT;
str << u->second.hitpoints()
<< "/" << u->second.max_hitpoints() << "\n";
<< "/" << u->second.max_hitpoints();
break;
case UNIT_XP:
@ -187,6 +197,15 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
}
break;
case UNIT_ADVANCEMENT_OPTIONS: {
report res;
const std::map<std::string,std::string>& adv_icons=u->second.advancement_icons();
for(std::map<std::string,std::string>::const_iterator i=adv_icons.begin();i!=adv_icons.end();i++){
res.add_image(i->first,i->second);
}
return(res);
}
case UNIT_MOVES:
str << u->second.movement_left() << "/" << u->second.total_movement();
break;
@ -322,31 +341,28 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
if(owner == 0 || current_team.fogged(mouseover.x,mouseover.y)) {
str << _("Village");
} else if(owner == current_side) {
str << _("Owned village");
str << _("Owned village");
} else if(current_team.is_enemy(owner)) {
str << _("Enemy village");
str << _("Enemy village");
} else {
str << _("Allied village");
str << _("Allied village");
}
str << " ";
} else {
str << map.get_terrain_info(terrain).name();
str << map.get_terrain_info(terrain).name();
}
if(underlying.size() != 1 || underlying[0] != terrain) {
str << " (";
str << "(";
for(std::string::const_iterator i = underlying.begin(); i != underlying.end(); ++i) {
str << map.get_terrain_info(*i).name();
str << map.get_terrain_info(*i).name();
if(i+1 != underlying.end()) {
str << ",";
str << ",";
}
}
str << ")";
}
break;
}
case POSITION: {
@ -425,7 +441,6 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
return report();
}
}
default:
wassert(false);
break;

View file

@ -28,11 +28,14 @@ class gamestatus;
//various game and unit statistics
namespace reports {
enum TYPE { UNIT_DESCRIPTION, UNIT_TYPE, UNIT_LEVEL, UNIT_TRAITS, UNIT_STATUS,
UNIT_ALIGNMENT, UNIT_ABILITIES, UNIT_HP, UNIT_XP, UNIT_MOVES, UNIT_WEAPONS,
UNIT_IMAGE, UNIT_PROFILE, TIME_OF_DAY,
TURN, GOLD, VILLAGES, NUM_UNITS, UPKEEP, EXPENSES, INCOME, TERRAIN, POSITION,
SIDE_PLAYING, OBSERVERS, REPORT_CLOCK,
enum TYPE { UNIT_DESCRIPTION, UNIT_TYPE, UNIT_LEVEL, UNIT_AMLA,
UNIT_TRAITS, UNIT_STATUS,
UNIT_ALIGNMENT, UNIT_ABILITIES, UNIT_HP, UNIT_XP,
UNIT_ADVANCEMENT_OPTIONS, UNIT_MOVES, UNIT_WEAPONS,
UNIT_IMAGE, UNIT_PROFILE, TIME_OF_DAY,
TURN, GOLD, VILLAGES, NUM_UNITS, UPKEEP, EXPENSES,
INCOME, TERRAIN, POSITION,
SIDE_PLAYING, OBSERVERS, REPORT_CLOCK,
SELECTED_TERRAIN, EDIT_LEFT_BUTTON_FUNCTION,
NUM_REPORTS};

View file

@ -999,6 +999,57 @@ bool unit::can_advance() const
return type().can_advance() || get_modification_advances().empty() == false;
}
std::map<std::string,std::string> unit::advancement_icons() const
{
std::map<std::string,std::string> temp;
std::string image;
if(can_advance()){
if(type().can_advance()){
std::stringstream tooltip;
image=game_config::level_image;
std::vector<std::string> adv=type().advances_to();
for(std::vector<std::string>::const_iterator i=adv.begin();i!=adv.end();i++){
if((*i).size()){
tooltip<<(*i).c_str()<<"\n";
}
}
temp[image]=tooltip.str();
}
const config::child_list mods=get_modification_advances();
for(config::child_list::const_iterator i = mods.begin(); i != mods.end(); ++i) {
image=(**i)["image"];
if(image.size()){
std::stringstream tooltip;
tooltip<<temp[image];
std::string tt=(**i)["description"];
if(tt.size()){
tooltip<<tt<<"\n";
}
temp[image]=tooltip.str();
}
}
}
return(temp);
}
std::vector<std::pair<std::string,std::string> > unit::amla_icons() const
{
std::vector<std::pair<std::string,std::string> > temp;
std::pair<std::string,std::string> icon; //<image,tooltip>
const config::child_list& advances = type().modification_advancements();
for(config::child_list::const_iterator i = advances.begin(); i != advances.end(); ++i) {
icon.first=(**i)["image"];
icon.second=(**i)["description"];
for(int j=0;j<(modification_count("advance",(**i)["id"]));j++) {
temp.push_back(icon);
}
}
return(temp);
}
config::child_list unit::get_modification_advances() const
{
config::child_list res;

View file

@ -151,6 +151,10 @@ public:
bool is_flying() const;
bool can_advance() const;
std::map<std::string,std::string> advancement_icons() const;
std::vector<std::pair<std::string,std::string> > amla_icons() const;
config::child_list get_modification_advances() const;
size_t modification_count(const std::string& type, const std::string& id) const;