made it so that race selection dialog shows icons for each race

This commit is contained in:
uid68803 2004-01-07 06:05:47 +00:00
parent a6fbf351a3
commit 2eb5a56a1f
5 changed files with 27 additions and 6 deletions

View file

@ -301,7 +301,7 @@ ggggggggggggggggggggffffffffffffffffff
{battleworld.cfg}
[multiplayer_side]
name=Elves
name=&elvish-lord.png,Elves
type=Elvish Lord
recruit=Elvish Fighter,Elvish Archer,Mage,Elvish Shaman,Gryphon Rider,Thief,Elvish Scout
recruitment_pattern=fighter,fighter,scout
@ -310,7 +310,7 @@ ggggggggggggggggggggffffffffffffffffff
[/multiplayer_side]
[multiplayer_side]
name=Orcs
name=&orcish-warlord.png,Orcs
type=Orcish Warlord
recruit=Orcish Grunt,Troll Whelp,Wolf Rider,Orcish Archer,Orcish Assassin,Naga
recruitment_pattern=fighter,fighter,archer,scout
@ -319,7 +319,7 @@ ggggggggggggggggggggffffffffffffffffff
[/multiplayer_side]
[multiplayer_side]
name=Humans
name=&human-general.png,Humans
type=General
recruit=Cavalry,Mage,Spearman,Fencer,Heavy Infantry,Horseman,Merman
recruitment_pattern=scout,fighter,fighter,fighter
@ -328,7 +328,7 @@ ggggggggggggggggggggffffffffffffffffff
[/multiplayer_side]
[multiplayer_side]
name=Undead
name=&undead-lich.png,Undead
type=Lich
recruit=Skeleton,Skeleton Archer,Walking Corpse,Ghost,Vampire Bat,Dark Adept
recruitment_pattern=scout,fighter,fighter,archer

View file

@ -53,6 +53,8 @@ team::team_info::team_info(const config& cfg)
if(team_name.empty())
team_name = cfg["side"];
description = cfg["description"];
const std::string& village_income = cfg["village_gold"];
if(village_income.empty())
income_per_village = game_config::tower_income;
@ -136,6 +138,7 @@ void team::team_info::write(config& cfg) const
cfg["income"] = income;
cfg["name"] = name;
cfg["team_name"] = team_name;
cfg["description"] = description;
char buf[50];
sprintf(buf,"%d",income_per_village);

View file

@ -47,6 +47,8 @@ public:
std::vector<int> enemies;
std::string team_name;
std::string description;
enum CONTROLLER { HUMAN, AI, NETWORK };
CONTROLLER controller;

View file

@ -33,6 +33,8 @@ button::button(display& disp, const std::string& label, button::TYPE type,
x_(0), y_(0), button_(true),
state_(UNINIT), type_(type)
{
set_label(label);
if(button_image_name.empty() && type == TYPE_PRESS) {
button_image_name = "button";
} else if(button_image_name.empty() && type == TYPE_CHECK) {
@ -173,12 +175,26 @@ bool button::hit(int x, int y) const
return false;
}
namespace {
bool not_image(const std::string& str) { return str != "" && str[0] != '&'; }
}
void button::set_x(int val) { x_ = val; }
void button::set_y(int val) { y_ = val; }
void button::set_xy(int valx, int valy) { x_ = valx; y_ = valy; }
void button::set_label(std::string val)
void button::set_label(const std::string& val)
{
label_ = val;
//if we have a list of items, use the first one that isn't an image
if(std::find(label_.begin(),label_.end(),',') != label_.end()) {
const std::vector<std::string>& items = config::split(label_);
const std::vector<std::string>::const_iterator i = std::find_if(items.begin(),items.end(),not_image);
if(i != items.end()) {
label_ = *i;
}
}
textRect_ = display_->screen_area();
textRect_ = font::draw_text(NULL,textRect_,font_size,
font::BUTTON_COLOUR,label_,0,0);

View file

@ -43,7 +43,7 @@ public:
void set_x(int val);
void set_y(int val);
void set_xy(int valx, int valy);
void set_label(std::string val);
void set_label(const std::string& val);
int width() const;
int height() const;