Enabled drawing of minimap in-game
This commit is contained in:
parent
e7d1c970bc
commit
eaac01c9a2
3 changed files with 19 additions and 18 deletions
|
@ -1789,11 +1789,8 @@ void display::draw_minimap()
|
|||
}
|
||||
}
|
||||
|
||||
const surface& screen(screen_.getSurface());
|
||||
clip_rect_setter clip_setter(screen, &area);
|
||||
|
||||
color_t back_color {31,31,23,SDL_ALPHA_OPAQUE};
|
||||
draw_centered_on_background(minimap_, area, back_color, screen);
|
||||
draw_centered_on_background(minimap_, area, back_color);
|
||||
|
||||
//update the minimap location for mouse and units functions
|
||||
minimap_location_.x = area.x + (area.w - minimap_->w) / 2;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "sdl/utils.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "sdl/render_utils.hpp"
|
||||
#include "color.hpp"
|
||||
#include "xBRZ/xbrz.hpp"
|
||||
|
||||
|
@ -2383,19 +2384,22 @@ SDL_Rect get_non_transparent_portion(const surface &surf)
|
|||
return res;
|
||||
}
|
||||
|
||||
void draw_centered_on_background(surface surf, const SDL_Rect& rect, const color_t& color, surface target)
|
||||
void draw_centered_on_background(surface surf, const SDL_Rect& rect, const color_t& color)
|
||||
{
|
||||
clip_rect_setter clip_setter(target, &rect);
|
||||
|
||||
uint32_t col = SDL_MapRGBA(target->format, color.r, color.g, color.b, color.a);
|
||||
//TODO: only draw background outside the image
|
||||
SDL_Rect r = rect;
|
||||
sdl::fill_surface_rect(target, &r, col);
|
||||
|
||||
if (surf != nullptr) {
|
||||
r.x = rect.x + (rect.w-surf->w)/2;
|
||||
r.y = rect.y + (rect.h-surf->h)/2;
|
||||
sdl_blit(surf, nullptr, target, &r);
|
||||
render_clip_rect_setter clip_setter(&r);
|
||||
|
||||
sdl::fill_rectangle(r, color);
|
||||
|
||||
if(surf != nullptr) {
|
||||
r.x = rect.x + (rect.w - surf->w) / 2;
|
||||
r.y = rect.y + (rect.h - surf->h) / 2;
|
||||
r.w = surf->w;
|
||||
r.h = surf->h;
|
||||
|
||||
texture tex(surf);
|
||||
CVideo::get_singleton().copy_to_screen(tex, nullptr, &r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ SDL_Rect get_non_transparent_portion(const surface &surf);
|
|||
void put_pixel(const surface& surf, surface_lock& surf_lock, int x, int y, uint32_t pixel);
|
||||
uint32_t get_pixel(const surface& surf, const const_surface_lock& surf_lock, int x, int y);
|
||||
|
||||
// blit the image on the center of the rectangle
|
||||
// and a add a colored background
|
||||
void draw_centered_on_background(surface surf, const SDL_Rect& rect,
|
||||
const color_t& color, surface target);
|
||||
/**
|
||||
* Fills the provided rect with the provided color and draws the given image in the center.
|
||||
*/
|
||||
void draw_centered_on_background(surface surf, const SDL_Rect& rect, const color_t& color);
|
||||
|
|
Loading…
Add table
Reference in a new issue