fixed some problems with too-large dialog boxes

This commit is contained in:
uid68803 2004-01-02 21:53:50 +00:00
parent 3e92c0ae6a
commit 01ed318d5f
2 changed files with 21 additions and 0 deletions

View file

@ -98,6 +98,19 @@ void draw_dialog_background(int x, int y, int w, int h, display& disp)
const scoped_sdl_surface bg(image::get_image(menu_background,image::UNSCALED));
const SDL_Rect& screen_bounds = disp.screen_area();
if(x < 0)
x = 0;
if(y < 0)
y = 0;
if(x + w > screen_bounds.w)
w = screen_bounds.w - x;
if(y + h > screen_bounds.h)
h = screen_bounds.h - y;
for(int i = 0; i < w; i += bg->w) {
for(int j = 0; j < h; j += bg->h) {
SDL_Rect src = {0,0,0,0};

View file

@ -103,6 +103,12 @@ void update_rect(const SDL_Rect& rect)
if(update_all)
return;
SDL_Surface* const fb = SDL_GetVideoSurface();
if(fb != NULL) {
if(rect.x + rect.w > fb->w || rect.y + rect.h > fb->h)
return;
}
for(std::vector<SDL_Rect>::iterator i = update_rects.begin();
i != update_rects.end(); ++i) {
if(rect_contains(*i,rect)) {
@ -161,6 +167,8 @@ int CVideo::modePossible( int x, int y, int bits_per_pixel, int flags )
int CVideo::setMode( int x, int y, int bits_per_pixel, int flags )
{
update_rects.clear();
flags = get_flags(flags);
const int res = SDL_VideoModeOK( x, y, bits_per_pixel, flags );