added attack icons from Svetac

This commit is contained in:
uid68803 2003-12-30 20:28:47 +00:00
parent b650ff7a53
commit 0f0cdbb175
22 changed files with 52 additions and 12 deletions

BIN
images/misc/dagger.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/misc/knife.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/misc/spear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/misc/staff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/misc/sword.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/misc/trident.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -211,6 +211,7 @@ battle_stats evaluate_battle_stats(
if(include_strings) {
res.attack_special = attack.special();
res.attack_icon = attack.icon();
//don't show backstabbing unless it's actually happening
if(res.attack_special == "backstab" && !backstab)
@ -262,6 +263,7 @@ battle_stats evaluate_battle_stats(
if(include_strings) {
res.defend_special = defender_attacks[defend].special();
res.defend_icon = defender_attacks[defend].icon();
}
//if the defender drains, and the attacker is a living creature, then

View file

@ -51,6 +51,7 @@ struct battle_stats
std::string attack_type, defend_type;
std::string attack_special, defend_special;
std::string range;
std::string attack_icon, defend_icon;
int chance_to_hit_attacker, chance_to_hit_defender;
int damage_attacker_takes, damage_defender_takes;
int amount_attacker_drains, amount_defender_drains;

View file

@ -314,8 +314,7 @@ int play_game(int argc, char** argv)
}
std::cerr << "setting mode to " << resolution.first << "x" << resolution.second << "\n";
const int res = video.setMode(resolution.first,resolution.second,
16,video_flags);
const int res = video.setMode(resolution.first,resolution.second,16,video_flags);
if(res != 16) {
std::cerr << "required video mode, " << resolution.first << "x"
<< resolution.second << "x16 is not supported\n";

View file

@ -432,7 +432,7 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
stats.range : lang_range;
std::stringstream att;
att << attack_name << " (" << attack_type
att << "&" << stats.attack_icon << "," << attack_name << " (" << attack_type
<< ") " << stats.damage_defender_takes << "-"
<< stats.nattacks << " " << range << " "
<< stats.chance_to_hit_defender
@ -443,7 +443,7 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
<< ") " << stats.damage_attacker_takes << "-"
<< stats.ndefends << " "
<< stats.chance_to_hit_attacker
<< "%";
<< "%,&" << stats.defend_icon;
items.push_back(att.str());
units_list.push_back(enemy->second);

View file

@ -33,6 +33,10 @@ attack_type::attack_type(const config& cfg)
name_ = cfg["name"];
type_ = cfg["type"];
special_ = cfg["special"];
icon_ = cfg["icon"];
if(icon_.empty())
icon_ = "misc/" + name_ + ".png";
range_ = cfg["range"] == "long" ? LONG_RANGE : SHORT_RANGE;
hexes_ = maximum<int>(1,atoi(cfg["hexes"].c_str()));
damage_ = atol(cfg["damage"].c_str());
@ -93,6 +97,11 @@ const std::string& attack_type::special() const
return special_;
}
const std::string& attack_type::icon() const
{
return icon_;
}
attack_type::RANGE attack_type::range() const
{
return range_;

View file

@ -32,6 +32,7 @@ public:
const std::string& name() const;
const std::string& type() const;
const std::string& special() const;
const std::string& icon() const;
RANGE range() const;
int hexes() const;
int damage() const;
@ -63,6 +64,7 @@ private:
std::string name_;
std::string type_;
std::string special_;
std::string icon_;
RANGE range_;
int hexes_;
int damage_;

View file

@ -279,6 +279,27 @@ bool menu::double_clicked() const
return double_clicked_;
}
namespace {
const char ImagePrefix = '&';
SDL_Rect item_size(const std::string& item) {
SDL_Rect res = {0,0,0,0};
if(item.empty() == false && item[0] == ImagePrefix) {
const std::string image_name(item.begin()+1,item.end());
SDL_Surface* const img = image::get_image(image_name,image::UNSCALED);
if(img != NULL) {
res.w = img->w;
res.h = img->h;
}
} else {
const SDL_Rect area = {0,0,10000,10000};
res = font::draw_text(NULL,area,menu_font_size,font::NORMAL_COLOUR,item,0,0);
}
return res;
}
}
const std::vector<int>& menu::column_widths() const
{
if(column_widths_.empty()) {
@ -286,9 +307,7 @@ const std::vector<int>& menu::column_widths() const
for(size_t col = 0; col != items_[row].size(); ++col) {
static const SDL_Rect area = {0,0,display_->x(),display_->y()};
const SDL_Rect res =
font::draw_text(NULL,area,menu_font_size,
font::NORMAL_COLOUR,items_[row][col],x_,y_);
const SDL_Rect res = item_size(items_[row][col]);
if(col == column_widths_.size()) {
column_widths_.push_back(res.w + menu_cell_padding);
@ -327,8 +346,18 @@ void menu::draw_item(int item)
int xpos = rect.x;
for(size_t i = 0; i != items_[item].size(); ++i) {
font::draw_text(display_,area,menu_font_size,font::NORMAL_COLOUR,
items_[item][i],xpos,rect.y);
const std::string& str = items_[item][i];
if(str.empty() == false && str[0] == ImagePrefix) {
const std::string image_name(str.begin()+1,str.end());
SDL_Surface* const img = image::get_image(image_name,image::UNSCALED);
if(img != NULL && xpos+img->w < display_->x() && rect.y+img->h < display_->y()) {
SDL_Rect dest = {xpos,rect.y,img->w,img->h};
SDL_BlitSurface(img,NULL,display_->video().getSurface(),&dest);
}
} else {
font::draw_text(display_,area,menu_font_size,font::NORMAL_COLOUR,str,xpos,rect.y);
}
xpos += widths[i];
}
}
@ -378,10 +407,8 @@ SDL_Rect menu::get_item_rect(int item) const
SDL_Rect res = {x_,y,0,0};
//use the first field that is non-blank
for(size_t n = 0; n != items_[item].size(); ++n) {
SDL_Rect rect = font::draw_text(NULL,area,menu_font_size,
font::NORMAL_COLOUR,items_[item][n],x_,y);
SDL_Rect rect = item_size(items_[item][n]);
res.h = maximum<int>(rect.h,res.h);
}