Skip to content

Commit

Permalink
sdl_fill_rect -> fill_rect.
Browse files Browse the repository at this point in the history
As the function is now part of the sdl namespace, the sdl_ prefix is
quite redundant.
  • Loading branch information
lipk committed Jun 3, 2014
1 parent c441630 commit 51095a3
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 52 deletions.
22 changes: 11 additions & 11 deletions src/attack_prediction_display.cpp
Expand Up @@ -436,26 +436,26 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
Uint32 grey_color = SDL_MapRGBA(surf->format, 0xb7, 0xc1, 0xc1, 255);

Uint32 background_color = SDL_MapRGBA(surf->format, 25, 25, 25, 255);
sdl::sdl_fill_rect(surf, &clip_rect, background_color);
sdl::fill_rect(surf, &clip_rect, background_color);

// Draw the surrounding borders and separators.
SDL_Rect top_border_rect = sdl::create_rect(0, 0, width, 2);
sdl::sdl_fill_rect(surf, &top_border_rect, grey_color);
sdl::fill_rect(surf, &top_border_rect, grey_color);

SDL_Rect bottom_border_rect = sdl::create_rect(0, height - 2, width, 2);
sdl::sdl_fill_rect(surf, &bottom_border_rect, grey_color);
sdl::fill_rect(surf, &bottom_border_rect, grey_color);

SDL_Rect left_border_rect = sdl::create_rect(0, 0, 2, height);
sdl::sdl_fill_rect(surf, &left_border_rect, grey_color);
sdl::fill_rect(surf, &left_border_rect, grey_color);

SDL_Rect right_border_rect = sdl::create_rect(width - 2, 0, 2, height);
sdl::sdl_fill_rect(surf, &right_border_rect, grey_color);
sdl::fill_rect(surf, &right_border_rect, grey_color);

SDL_Rect hp_sep_rect = sdl::create_rect(hp_sep, 0, 2, height);
sdl::sdl_fill_rect(surf, &hp_sep_rect, grey_color);
sdl::fill_rect(surf, &hp_sep_rect, grey_color);

SDL_Rect percent_sep_rect = sdl::create_rect(width - percent_sep - 2, 0, 2, height);
sdl::sdl_fill_rect(surf, &percent_sep_rect, grey_color);
sdl::fill_rect(surf, &percent_sep_rect, grey_color);

// Draw the rows (lower HP values are at the bottom).
for(int i = 0; i < static_cast<int>(hp_prob_vector.size()); i++) {
Expand Down Expand Up @@ -503,16 +503,16 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
int bar_len = std::max<int>(static_cast<int>((prob * (bar_space - 4)) + 0.5), 2);

SDL_Rect bar_rect_1 = sdl::create_rect(hp_sep + 4, 6 + (fs + 2) * i, bar_len, 8);
sdl::sdl_fill_rect(surf, &bar_rect_1, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 100));
sdl::fill_rect(surf, &bar_rect_1, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 100));

SDL_Rect bar_rect_2 = sdl::create_rect(hp_sep + 4, 7 + (fs + 2) * i, bar_len, 6);
sdl::sdl_fill_rect(surf, &bar_rect_2, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 66));
sdl::fill_rect(surf, &bar_rect_2, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 66));

SDL_Rect bar_rect_3 = sdl::create_rect(hp_sep + 4, 8 + (fs + 2) * i, bar_len, 4);
sdl::sdl_fill_rect(surf, &bar_rect_3, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 33));
sdl::fill_rect(surf, &bar_rect_3, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 33));

SDL_Rect bar_rect_4 = sdl::create_rect(hp_sep + 4, 9 + (fs + 2) * i, bar_len, 2);
sdl::sdl_fill_rect(surf, &bar_rect_4, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 0));
sdl::fill_rect(surf, &bar_rect_4, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 0));

// Draw probability percentage, aligned right.
format_prob(str_buf, prob);
Expand Down
10 changes: 5 additions & 5 deletions src/display.cpp
Expand Up @@ -479,7 +479,7 @@ void display::draw_bar(const std::string& image, int xpos, int ypos,
const Uint8 r_alpha = std::min<unsigned>(unsigned(fxpmult(alpha,255)),255);
surface filled_surf = create_compatible_surface(bar_surf, bar_loc.w, height - unfilled);
SDL_Rect filled_area = sdl::create_rect(0, 0, bar_loc.w, height-unfilled);
sdl::sdl_fill_rect(filled_surf,&filled_area,SDL_MapRGBA(bar_surf->format,col.r,col.g,col.b, r_alpha));
sdl::fill_rect(filled_surf,&filled_area,SDL_MapRGBA(bar_surf->format,col.r,col.g,col.b, r_alpha));
drawing_buffer_add(LAYER_UNIT_BAR, loc, xpos + bar_loc.x, ypos + bar_loc.y + unfilled, filled_surf);
}
}
Expand Down Expand Up @@ -1955,7 +1955,7 @@ void display::draw_minimap_units()
, round_double(u_w)
, round_double(u_h));

sdl::sdl_fill_rect(video().getSurface(), &r, mapped_col);
sdl::fill_rect(video().getSurface(), &r, mapped_col);
}
}

Expand Down Expand Up @@ -2520,7 +2520,7 @@ void display::clear_screen()
{
surface disp(screen_.getSurface());
SDL_Rect area = screen_area();
sdl::sdl_fill_rect(disp, &area, SDL_MapRGB(disp->format, 0, 0, 0));
sdl::fill_rect(disp, &area, SDL_MapRGB(disp->format, 0, 0, 0));
}

const SDL_Rect& display::get_clip_rect()
Expand Down Expand Up @@ -2655,7 +2655,7 @@ void display::draw_hex(const map_location& loc) {
surface text = font::get_rendered_text(lexical_cast<std::string>(loc), font::SIZE_SMALL, font::NORMAL_COLOR);
surface bg = create_neutral_surface(text->w, text->h);
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
sdl::sdl_fill_rect(bg, &bg_rect, 0xaa000000);
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
off_x -= text->w / 2;
if (draw_terrain_codes_) {
off_y -= text->h;
Expand All @@ -2671,7 +2671,7 @@ void display::draw_hex(const map_location& loc) {
surface text = font::get_rendered_text(lexical_cast<std::string>(get_map().get_terrain(loc)), font::SIZE_SMALL, font::NORMAL_COLOR);
surface bg = create_neutral_surface(text->w, text->h);
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
sdl::sdl_fill_rect(bg, &bg_rect, 0xaa000000);
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
off_x -= text->w / 2;
if (!draw_coordinates_) {
off_y -= text->h / 2;
Expand Down
2 changes: 1 addition & 1 deletion src/editor/action/mouse/mouse_action.cpp
Expand Up @@ -156,7 +156,7 @@ void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_trans

// Create a transparent surface of the right size.
surface image = create_compatible_surface(image_fg, image_fg->w, image_fg->h);
sdl::sdl_fill_rect(image,NULL,SDL_MapRGBA(image->format,0,0,0, 0));
sdl::fill_rect(image,NULL,SDL_MapRGBA(image->format,0,0,0, 0));

// For efficiency the size of the tile is cached.
// We assume all tiles are of the same size.
Expand Down
4 changes: 2 additions & 2 deletions src/font.cpp
Expand Up @@ -982,7 +982,7 @@ surface floating_label::create_surface()
}

Uint32 color = SDL_MapRGBA(foreground->format, bgcolor_.r,bgcolor_.g, bgcolor_.b, bgalpha_);
sdl::sdl_fill_rect(background,NULL, color);
sdl::fill_rect(background,NULL, color);

// we make the text less transparent, because the blitting on the
// dark background will darken the anti-aliased part.
Expand All @@ -1003,7 +1003,7 @@ surface floating_label::create_surface()
// background is blurred shadow of the text
surface background = create_neutral_surface
(foreground->w + 4, foreground->h + 4);
sdl::sdl_fill_rect(background, NULL, 0);
sdl::fill_rect(background, NULL, 0);
SDL_Rect r = { 2, 2, 0, 0 };
blit_surface(foreground, NULL, background, &r);
background = shadow_image(background, false);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/widgets/widget.cpp
Expand Up @@ -537,7 +537,7 @@ void twidget::draw_debug_border(surface& frame_buffer)
break;

case 2:
sdl::sdl_fill_rect(frame_buffer, &r, debug_border_colour_);
sdl::fill_rect(frame_buffer, &r, debug_border_colour_);
break;

default:
Expand All @@ -563,7 +563,7 @@ twidget::draw_debug_border(surface& frame_buffer, int x_offset, int y_offset)
break;

case 2:
sdl::sdl_fill_rect(frame_buffer, &r, debug_border_colour_);
sdl::fill_rect(frame_buffer, &r, debug_border_colour_);
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions src/intro.cpp
Expand Up @@ -39,7 +39,7 @@ void the_end(display &disp, std::string text, unsigned int duration)

SDL_Rect area = screen_area();
CVideo &video = disp.video();
sdl::sdl_fill_rect(video.getSurface(),&area,0);
sdl::fill_rect(video.getSurface(),&area,0);

update_whole_screen();
disp.flip();
Expand All @@ -52,7 +52,7 @@ void the_end(display &disp, std::string text, unsigned int duration)

for(size_t n = 0; n < 255; n += 5) {
if(n)
sdl::sdl_fill_rect(video.getSurface(),&area,0);
sdl::fill_rect(video.getSurface(),&area,0);

const SDL_Color col = create_color(n, n, n, n);
font::draw_text(&video,area,font_size,col,text,area.x,area.y);
Expand Down
20 changes: 10 additions & 10 deletions src/loadscreen.cpp
Expand Up @@ -148,42 +148,42 @@ void loadscreen::draw_screen(const std::string &text)
// Draw top border.
area.x = pbx; area.y = pby;
area.w = pbw + 2*(bw+bispw); area.h = bw;
sdl::sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
sdl::fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
// Draw bottom border.
area.x = pbx; area.y = pby + pbh + bw + 2*bispw;
area.w = pbw + 2*(bw+bispw); area.h = bw;
sdl::sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
sdl::fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
// Draw left border.
area.x = pbx; area.y = pby + bw;
area.w = bw; area.h = pbh + 2*bispw;
sdl::sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
sdl::fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
// Draw right border.
area.x = pbx + pbw + bw + 2*bispw; area.y = pby + bw;
area.w = bw; area.h = pbh + 2*bispw;
sdl::sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
sdl::fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
// Draw the finished bar area.
area.x = pbx + bw + bispw; area.y = pby + bw + bispw;
area.w = (prcnt_ * pbw) / 100; area.h = pbh;
sdl::sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,fcr,fcg,fcb));
sdl::fill_rect(gdis,&area,SDL_MapRGB(gdis->format,fcr,fcg,fcb));

SDL_Rect lightning = area;
lightning.h = lightning_thickness;
//we add 25% of white to the color of the bar to simulate a light effect
sdl::sdl_fill_rect(gdis,&lightning,SDL_MapRGB(gdis->format,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4));
sdl::fill_rect(gdis,&lightning,SDL_MapRGB(gdis->format,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4));
lightning.y = area.y+area.h-lightning.h;
//remove 50% of color to simulate a shadow effect
sdl::sdl_fill_rect(gdis,&lightning,SDL_MapRGB(gdis->format,fcr/2,fcg/2,fcb/2));
sdl::fill_rect(gdis,&lightning,SDL_MapRGB(gdis->format,fcr/2,fcg/2,fcb/2));

// Draw the leftover bar area.
area.x = pbx + bw + bispw + (prcnt_ * pbw) / 100; area.y = pby + bw + bispw;
area.w = ((100 - prcnt_) * pbw) / 100; area.h = pbh;
sdl::sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,lcr,lcg,lcb));
sdl::fill_rect(gdis,&area,SDL_MapRGB(gdis->format,lcr,lcg,lcb));

// Clear the last text and draw new if text is provided.
if (!text.empty())
{
SDL_Rect oldarea = textarea_;
sdl::sdl_fill_rect(gdis,&textarea_,SDL_MapRGB(gdis->format,0,0,0));
sdl::fill_rect(gdis,&textarea_,SDL_MapRGB(gdis->format,0,0,0));
textarea_ = font::line_size(text, font::SIZE_NORMAL);
textarea_.x = scrx/2 + bw + bispw - textarea_.w / 2;
textarea_.y = pby + pbh + 4*(bw + bispw);
Expand All @@ -203,7 +203,7 @@ void loadscreen::clear_screen()
SDL_Rect area = sdl::create_rect(0, 0, scrx, scry); // Screen area.
surface disp(screen_.getSurface()); // Screen surface.
// Make everything black.
sdl::sdl_fill_rect(disp,&area,SDL_MapRGB(disp->format,0,0,0));
sdl::fill_rect(disp,&area,SDL_MapRGB(disp->format,0,0,0));
update_whole_screen();
screen_.flip();
}
Expand Down
4 changes: 2 additions & 2 deletions src/minimap.cpp
Expand Up @@ -226,7 +226,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
}
SDL_Rect fillrect = sdl::create_rect(maprect.x, maprect.y, scale * 3/4, scale);
const Uint32 mapped_col = SDL_MapRGB(minimap->format,col.r,col.g,col.b);
sdl::sdl_fill_rect(minimap, &fillrect, mapped_col);
sdl::fill_rect(minimap, &fillrect, mapped_col);
}
}

Expand Down Expand Up @@ -261,7 +261,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
);

const Uint32 mapped_col = SDL_MapRGB(minimap->format,col.r,col.g,col.b);
sdl::sdl_fill_rect(minimap, &fillrect, mapped_col);
sdl::fill_rect(minimap, &fillrect, mapped_col);

}

Expand Down
2 changes: 1 addition & 1 deletion src/multiplayer.cpp
Expand Up @@ -658,7 +658,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config,
, 0
, 255);

sdl::sdl_fill_rect(disp.video().getSurface(), NULL, color);
sdl::fill_rect(disp.video().getSurface(), NULL, color);

if(preferences::new_lobby()) {
gui2::tlobby_main dlg(game_config, li, disp);
Expand Down
2 changes: 1 addition & 1 deletion src/multiplayer_create.cpp
Expand Up @@ -478,7 +478,7 @@ void create::draw_level_image()
video().getSurface());
} else {
surface display(disp_.get_screen_surface());
sdl::sdl_fill_rect(display, &image_rect_,
sdl::fill_rect(display, &image_rect_,
SDL_MapRGB(display->format, 0, 0, 0));
update_rect(image_rect_);

Expand Down
12 changes: 6 additions & 6 deletions src/sdl/rect.cpp
Expand Up @@ -70,7 +70,7 @@ SDL_Rect union_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
void fill_rect_alpha(SDL_Rect &rect, Uint32 color, Uint8 alpha, surface target)
{
if(alpha == SDL_ALPHA_OPAQUE) {
sdl::sdl_fill_rect(target,&rect,color);
sdl::fill_rect(target,&rect,color);
return;
} else if(alpha == SDL_ALPHA_TRANSPARENT) {
return;
Expand All @@ -82,7 +82,7 @@ void fill_rect_alpha(SDL_Rect &rect, Uint32 color, Uint8 alpha, surface target)
}

SDL_Rect r = {0,0,rect.w,rect.h};
sdl::sdl_fill_rect(tmp,&r,color);
sdl::fill_rect(tmp,&r,color);
SDL_SetAlpha(tmp,SDL_SRCALPHA,alpha);
sdl_blit(tmp,NULL,target,&rect);
}
Expand All @@ -95,10 +95,10 @@ void draw_rectangle(int x, int y, int w, int h, Uint32 color, surface target)
SDL_Rect left = create_rect(x, y, 1, h);
SDL_Rect right = create_rect(x + w - 1, y, 1, h);

sdl::sdl_fill_rect(target,&top,color);
sdl::sdl_fill_rect(target,&bot,color);
sdl::sdl_fill_rect(target,&left,color);
sdl::sdl_fill_rect(target,&right,color);
sdl::fill_rect(target,&top,color);
sdl::fill_rect(target,&bot,color);
sdl::fill_rect(target,&left,color);
sdl::fill_rect(target,&right,color);
}

void draw_solid_tinted_rectangle(int x, int y, int w, int h,
Expand Down
3 changes: 2 additions & 1 deletion src/sdl/rect.hpp
Expand Up @@ -136,10 +136,11 @@ void draw_solid_tinted_rectangle(int x, int y, int w, int h,
* @param dst_rect The rectangle to fill.
* @param color Color of the rectangle.
*/
inline void sdl_fill_rect(surface& dst, SDL_Rect* dst_rect, const Uint32 color)
inline void fill_rect(surface& dst, SDL_Rect* dst_rect, const Uint32 color)
{
SDL_FillRect(dst, dst_rect, color);
}

} // namespace sdl

bool operator==(const SDL_Rect& a, const SDL_Rect& b);
Expand Down
2 changes: 1 addition & 1 deletion src/sdl/utils.cpp
Expand Up @@ -2209,7 +2209,7 @@ void draw_centered_on_background(surface surf, const SDL_Rect& rect, const SDL_C
#endif
//TODO: only draw background outside the image
SDL_Rect r = rect;
sdl::sdl_fill_rect(target, &r, col);
sdl::fill_rect(target, &r, col);

if (surf != NULL) {
r.x = rect.x + (rect.w-surf->w)/2;
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/progressbar.cpp
Expand Up @@ -57,19 +57,19 @@ void progress_bar::draw_contents()
, area.w - 2
, area.h - 2);

sdl::sdl_fill_rect(surf,&area,SDL_MapRGB(surf->format,bcr,bcg,bcb));
sdl::sdl_fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,gcr,gcg,gcb));
sdl::fill_rect(surf,&area,SDL_MapRGB(surf->format,bcr,bcg,bcb));
sdl::fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,gcr,gcg,gcb));

inner_area.w = (inner_area.w*progress_)/100;
sdl::sdl_fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,fcr,fcg,fcb));
sdl::fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,fcr,fcg,fcb));

SDL_Rect lightning = inner_area;
lightning.h = lightning_thickness;
//we add 25% of white to the color of the bar to simulate a light effect
sdl::sdl_fill_rect(surf,&lightning,SDL_MapRGB(surf->format,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4));
sdl::fill_rect(surf,&lightning,SDL_MapRGB(surf->format,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4));
lightning.y = inner_area.y+inner_area.h-lightning.h;
//remove 50% of color to simulate a shadow effect
sdl::sdl_fill_rect(surf,&lightning,SDL_MapRGB(surf->format,fcr/2,fcg/2,fcb/2));
sdl::fill_rect(surf,&lightning,SDL_MapRGB(surf->format,fcr/2,fcg/2,fcb/2));

const std::string text = text_.empty() ? str_cast(progress_) + "%" :
text_ + " (" + str_cast(progress_) + "%)";
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/slider.cpp
Expand Up @@ -171,7 +171,7 @@ void slider::draw_contents()
, loc.w - image->w
, 1);

sdl::sdl_fill_rect(screen, &line_rect, SDL_MapRGB(screen->format,
sdl::fill_rect(screen, &line_rect, SDL_MapRGB(screen->format,
line_color.r, line_color.g, line_color.b));

SDL_Rect const &slider = slider_area();
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/textbox.cpp
Expand Up @@ -174,7 +174,7 @@ void textbox::draw_cursor(int pos, CVideo &video) const
, location().h);

surface frame_buffer = video.getSurface();
sdl::sdl_fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
sdl::fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
}
}

Expand Down

0 comments on commit 51095a3

Please sign in to comment.