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] [/bigmap]
[side] [side]
race=Elves
type=Commander type=Commander
description=Konrad description=Konrad
side=1 side=1
canrecruit=1 canrecruit=1
controller=human controller=human
recruit=Elvish Scout,Elvish Fighter,Elvish Archer,Horseman,Mage,Elvish Shaman,Merman recruit=Elvish Scout,Elvish Fighter,Elvish Archer,Horseman,Mage,Elvish Shaman,Merman
team_name=elves
[/side] [/side]
[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) { 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) && if((report.image.find_first_of(",") == -1) &&
(report.image.find_first_of(";") == -1)) { (report.image.find_first_of(";") == -1)) {
scoped_sdl_surface img(image::get_image(report.image,image::UNSCALED)); scoped_sdl_surface img(image::get_image(report.image,image::UNSCALED));
@ -694,52 +694,45 @@ void display::draw_report(reports::TYPE report_num)
} }
draw_image_for_report(img,surf,rect); draw_image_for_report(img,surf,rect);
} else { } else {
SDL_Rect composed_rect; //draw a table of images...
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);
int x_off; //first back up the current area for later restoration
int y_off = 0; 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 x = rect.x, y = rect.y;
int last_image_height = 0; 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); 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) { SDL_Rect tooltip_rect = {x,y,image->w,image->h};
std::cerr << "Col: " << *col << std::endl; if(current_tooltip != tooltip_rows.end()) {
if(!col->empty()){ if(*current_tooltip != "") {
scoped_sdl_surface composing_img(image::get_image(*col,image::UNSCALED)); tooltips::add_tooltip(tooltip_rect,*current_tooltip);
if(composing_img == NULL) {
std::cerr << "could not find image for report: '" << *col << "'\n";
return;
} }
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;
last_image_height = composing_img->h;
std::cout << "\tImage: " << *col << std::endl;
} }
x += image->w;
} }
y_off += last_image_height;
x = rect.x;
y += tallest_image;
} }
scoped_sdl_surface img(composed_img);
draw_image_for_report(img,surf,rect);
} }
} }
} else { } else {

View file

@ -77,54 +77,26 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
case UNIT_STATUS: { case UNIT_STATUS: {
std::stringstream unit_status; std::stringstream unit_status;
std::stringstream tooltip; 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(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){ unit_status << "misc/invisible.png,";
if((num % cols) == 0) unit_status << ";"; tooltip << string_table["invisible"] << ": " <<
else unit_status << ","; string_table["invisible_description"] << ";";
tooltip << std::endl;
}
num++;
unit_status << "misc/invisible.png";
tooltip << string_table["invisible"] << "; " <<
string_table["invisible_description"] << std::endl;
} }
if(u->second.has_flag("slowed")) { if(u->second.has_flag("slowed")) {
if(num != 0){ unit_status << "misc/slowed.png,";
if((num % cols) == 0) unit_status << ";"; tooltip << string_table["slowed"] << ": " <<
else unit_status << ","; string_table["slowed_description"] << ";";
tooltip << std::endl;
}
num++;
unit_status << "misc/slowed.png";
tooltip << string_table["slowed"] << "; " <<
string_table["slowed_description"] << std::endl;
} }
if(u->second.has_flag("poisoned")) { if(u->second.has_flag("poisoned")) {
if(num != 0){ unit_status << "misc/poisoned.png,";
if((num % cols) == 0) unit_status << ";"; tooltip << string_table["poisoned"] << ": " <<
else unit_status << ","; string_table["poisoned_description"] << ";";
tooltip << std::endl;
}
num++;
unit_status << "misc/poisoned.png";
tooltip << string_table["poisoned"] << "; " <<
string_table["poisoned_description"] << std::endl;
} }
if(u->second.has_flag("stone")) { if(u->second.has_flag("stone")) {
if(num != 0){ unit_status << "misc/stone.png,";
if((num % cols) == 0) unit_status << ";"; tooltip << string_table["stone"] << ": " <<
else unit_status << ","; string_table["stone_description"] << ";";
tooltip << std::endl;
}
num++;
unit_status << "misc/stone.png";
tooltip << string_table["stone"] << "; " <<
string_table["stone_description"] << std::endl;
} }
std::cerr << "Status report: " << unit_status.str() << std::endl; std::cerr << "Status report: " << unit_status.str() << std::endl;