fixed further image glitches

This commit is contained in:
uid68803 2004-02-16 19:42:37 +00:00
parent 0d353fa393
commit d0cc8cbb96
6 changed files with 41 additions and 76 deletions

View file

@ -31,13 +31,13 @@ Defeat:
[/bigmap]
[side]
race=Elves
type=Commander
description=Konrad
side=1
canrecruit=1
controller=human
recruit=Elvish Scout,Elvish Fighter,Elvish Archer,Horseman,Mage,Elvish Shaman,Merman
team_name=elves
[/side]
[side]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 504 B

View file

@ -684,7 +684,7 @@ void display::draw_report(reports::TYPE report_num)
if(report.image.empty() == false) {
//check if it's a talbe of images or a standalone image
//check if it's a table of images or a standalone image
if((report.image.find_first_of(",") == -1) &&
(report.image.find_first_of(";") == -1)) {
scoped_sdl_surface img(image::get_image(report.image,image::UNSCALED));
@ -694,53 +694,46 @@ void display::draw_report(reports::TYPE report_num)
}
draw_image_for_report(img,surf,rect);
} else {
SDL_Rect composed_rect;
SDL_Surface *composed_img = SDL_CreateRGBSurface(SDL_SWSURFACE,
rect.w, rect.h, screen_.getSurface()->format->BitsPerPixel,
screen_.getSurface()->format->Rmask,
screen_.getSurface()->format->Gmask,
screen_.getSurface()->format->Bmask,
screen_.getSurface()->format->Amask);
//draw a table of images...
int x_off;
int y_off = 0;
//first back up the current area for later restoration
surf.assign(get_surface_portion(screen_.getSurface(),rect));
std::vector<std::string> rows = config::split(report.image,';');
//each image may have a seperate tooltip, so seperate the tooltips
tooltips::clear_tooltips(rect);
for(std::vector<std::string>::iterator row = rows.begin(); row != rows.end(); ++row) {
int last_image_height = 0;
int x = rect.x, y = rect.y;
const std::vector<std::string> rows = config::split(report.image,';');
const std::vector<std::string> tooltip_rows = config::split(report.tooltip,';');
std::vector<std::string>::const_iterator current_tooltip = tooltip_rows.begin();
for(std::vector<std::string>::const_iterator row = rows.begin(); row != rows.end(); ++row) {
std::cerr << "Row: " << *row << std::endl;
size_t tallest_image = 0;
x_off = 0;
std::vector<std::string> cols = config::split(*row);
for(std::vector<std::string>::const_iterator col = cols.begin(); col != cols.end(); ++col) {
SDL_Rect clip_rect = rect;
scoped_sdl_surface image(image::get_image(*col,image::UNSCALED));
blit_surface(x,y,image,NULL,&clip_rect);
if(image->h > tallest_image)
tallest_image = image->h;
for(std::vector<std::string>::iterator col = cols.begin(); col != cols.end(); ++col) {
std::cerr << "Col: " << *col << std::endl;
if(!col->empty()){
scoped_sdl_surface composing_img(image::get_image(*col,image::UNSCALED));
if(composing_img == NULL) {
std::cerr << "could not find image for report: '" << *col << "'\n";
return;
SDL_Rect tooltip_rect = {x,y,image->w,image->h};
if(current_tooltip != tooltip_rows.end()) {
if(*current_tooltip != "") {
tooltips::add_tooltip(tooltip_rect,*current_tooltip);
}
composed_rect.w = composing_img->w;
composed_rect.h = composing_img->h;
composed_rect.x = x_off;
composed_rect.y = y_off;
SDL_BlitSurface(composing_img,NULL,composed_img,&composed_rect);
++current_tooltip;
}
x_off += composing_img->w;
x += image->w;
}
last_image_height = composing_img->h;
std::cout << "\tImage: " << *col << std::endl;
x = rect.x;
y += tallest_image;
}
}
y_off += last_image_height;
}
scoped_sdl_surface img(composed_img);
draw_image_for_report(img,surf,rect);
}
}
} else {
reportSurfaces_[report_num].assign(NULL);

View file

@ -78,53 +78,25 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
std::stringstream unit_status;
std::stringstream tooltip;
const int cols = 3;
int num = 0;
if(map.on_board(loc) && u->second.invisible(map.underlying_terrain(map[loc.x][loc.y]),status.get_time_of_day().lawful_bonus,loc,units,teams)) {
if(num != 0){
if((num % cols) == 0) unit_status << ";";
else unit_status << ",";
tooltip << std::endl;
}
num++;
unit_status << "misc/invisible.png";
tooltip << string_table["invisible"] << "; " <<
string_table["invisible_description"] << std::endl;
unit_status << "misc/invisible.png,";
tooltip << string_table["invisible"] << ": " <<
string_table["invisible_description"] << ";";
}
if(u->second.has_flag("slowed")) {
if(num != 0){
if((num % cols) == 0) unit_status << ";";
else unit_status << ",";
tooltip << std::endl;
}
num++;
unit_status << "misc/slowed.png";
tooltip << string_table["slowed"] << "; " <<
string_table["slowed_description"] << std::endl;
unit_status << "misc/slowed.png,";
tooltip << string_table["slowed"] << ": " <<
string_table["slowed_description"] << ";";
}
if(u->second.has_flag("poisoned")) {
if(num != 0){
if((num % cols) == 0) unit_status << ";";
else unit_status << ",";
tooltip << std::endl;
}
num++;
unit_status << "misc/poisoned.png";
tooltip << string_table["poisoned"] << "; " <<
string_table["poisoned_description"] << std::endl;
unit_status << "misc/poisoned.png,";
tooltip << string_table["poisoned"] << ": " <<
string_table["poisoned_description"] << ";";
}
if(u->second.has_flag("stone")) {
if(num != 0){
if((num % cols) == 0) unit_status << ";";
else unit_status << ",";
tooltip << std::endl;
}
num++;
unit_status << "misc/stone.png";
tooltip << string_table["stone"] << "; " <<
string_table["stone_description"] << std::endl;
unit_status << "misc/stone.png,";
tooltip << string_table["stone"] << ": " <<
string_table["stone_description"] << ";";
}
std::cerr << "Status report: " << unit_status.str() << std::endl;