Fixup 950a156 (revert unintended changes)

This commit is contained in:
Charles Dang 2018-03-11 15:26:38 +11:00
parent 950a156712
commit 7ed2e57ebc

View File

@ -1442,13 +1442,24 @@ static void draw_panel(CVideo &video, const theme::panel& panel, std::vector<std
} }
} }
static void draw_label(CVideo& video, font::pango_text& text_renderer, surface target, const theme::label& label) static void draw_label(CVideo& video, surface target, const theme::label& label)
{ {
//log_scope("draw label"); //log_scope("draw label");
const std::string& text = label.text(); const color_t& RGB = label.font_rgb();
const std::string& icon = label.icon();
std::string c_start="<";
std::string c_sep=",";
std::string c_end=">";
std::stringstream color;
color<< c_start << RGB.r << c_sep << RGB.g << c_sep << RGB.b << c_end;
std::string text = label.text();
if(label.font_rgb_set()) {
color<<text;
text = color.str();
}
const std::string& icon = label.icon();
SDL_Rect& loc = label.location(video.screen_area()); SDL_Rect& loc = label.location(video.screen_area());
if(icon.empty() == false) { if(icon.empty() == false) {
@ -1465,14 +1476,7 @@ static void draw_label(CVideo& video, font::pango_text& text_renderer, surface t
tooltips::add_tooltip(loc,text); tooltips::add_tooltip(loc,text);
} }
} else if(text.empty() == false) { } else if(text.empty() == false) {
text_renderer.set_font_size(label.font_size()); font::draw_text(&video,loc,label.font_size(),font::NORMAL_COLOR,text,loc.x,loc.y);
text_renderer.set_text(text, false);
if(label.font_rgb_set()) {
text_renderer.set_foreground_color(label.font_rgb());
}
sdl_blit(text_renderer.render(), nullptr, target, &loc);
} }
} }
@ -1491,10 +1495,8 @@ void display::draw_all_panels()
draw_panel(video(), panel, menu_buttons_); draw_panel(video(), panel, menu_buttons_);
} }
font::pango_text text_renderer;
for(const auto& label : theme_.labels()) { for(const auto& label : theme_.labels()) {
draw_label(video(), text_renderer, screen, label); draw_label(video(), screen, label);
} }
render_buttons(); render_buttons();
@ -1535,17 +1537,19 @@ void display::draw_text_in_hex(const map_location& loc,
const size_t font_sz = static_cast<size_t>(font_size * get_zoom_factor()); const size_t font_sz = static_cast<size_t>(font_size * get_zoom_factor());
font::pango_text text_renderer; surface text_surf = font::get_rendered_text(text, font_sz, color);
text_renderer.set_font_size(font_sz); surface back_surf = font::get_rendered_text(text, font_sz, font::BLACK_COLOR);
text_renderer.set_text(text, false); const int x = get_location_x(loc) - text_surf->w/2
text_renderer.set_add_outline(true); + static_cast<int>(x_in_hex* hex_size());
text_renderer.set_foreground_color(color); const int y = get_location_y(loc) - text_surf->h/2
+ static_cast<int>(y_in_hex* hex_size());
surface text_surf = make_neutral_surface(text_renderer.render()); for (int dy=-1; dy <= 1; ++dy) {
for (int dx=-1; dx <= 1; ++dx) {
const int x = get_location_x(loc) - text_surf->w / 2 + static_cast<int>(x_in_hex * hex_size()); if (dx!=0 || dy!=0) {
const int y = get_location_y(loc) - text_surf->h / 2 + static_cast<int>(y_in_hex * hex_size()); drawing_buffer_add(layer, loc, x + dx, y + dy, back_surf);
}
}
}
drawing_buffer_add(layer, loc, x, y, text_surf); drawing_buffer_add(layer, loc, x, y, text_surf);
} }
@ -2680,16 +2684,10 @@ void display::draw_hex(const map_location& loc) {
} }
if (on_map) { if (on_map) {
font::pango_text text_renderer;
text_renderer.set_font_size(font::SIZE_SMALL);
if (draw_coordinates_) { if (draw_coordinates_) {
int off_x = xpos + hex_size()/2; int off_x = xpos + hex_size()/2;
int off_y = ypos + hex_size()/2; int off_y = ypos + hex_size()/2;
surface text = font::get_rendered_text(lexical_cast<std::string>(loc), font::SIZE_SMALL, font::NORMAL_COLOR);
text_renderer.set_text(lexical_cast<std::string>(loc), false);
surface text = make_neutral_surface(text_renderer.render());
surface bg = create_neutral_surface(text->w, text->h); surface bg = create_neutral_surface(text->w, text->h);
SDL_Rect bg_rect {0, 0, text->w, text->h}; SDL_Rect bg_rect {0, 0, text->w, text->h};
sdl::fill_surface_rect(bg, &bg_rect, 0xaa000000); sdl::fill_surface_rect(bg, &bg_rect, 0xaa000000);
@ -2707,10 +2705,7 @@ void display::draw_hex(const map_location& loc) {
if (draw_terrain_codes_ && (game_config::debug || !shrouded(loc))) { if (draw_terrain_codes_ && (game_config::debug || !shrouded(loc))) {
int off_x = xpos + hex_size()/2; int off_x = xpos + hex_size()/2;
int off_y = ypos + hex_size()/2; int off_y = ypos + hex_size()/2;
surface text = font::get_rendered_text(lexical_cast<std::string>(get_map().get_terrain(loc)), font::SIZE_SMALL, font::NORMAL_COLOR);
text_renderer.set_text(lexical_cast<std::string>(get_map().get_terrain(loc)), false);
surface text = make_neutral_surface(text_renderer.render());
surface bg = create_neutral_surface(text->w, text->h); surface bg = create_neutral_surface(text->w, text->h);
SDL_Rect bg_rect {0, 0, text->w, text->h}; SDL_Rect bg_rect {0, 0, text->w, text->h};
sdl::fill_surface_rect(bg, &bg_rect, 0xaa000000); sdl::fill_surface_rect(bg, &bg_rect, 0xaa000000);
@ -2727,10 +2722,7 @@ void display::draw_hex(const map_location& loc) {
if (draw_num_of_bitmaps_) { if (draw_num_of_bitmaps_) {
int off_x = xpos + hex_size()/2; int off_x = xpos + hex_size()/2;
int off_y = ypos + hex_size()/2; int off_y = ypos + hex_size()/2;
surface text = font::get_rendered_text(lexical_cast<std::string>(num_images_bg + num_images_fg), font::SIZE_SMALL, font::NORMAL_COLOR);
text_renderer.set_text(lexical_cast<std::string>(num_images_bg + num_images_fg), false);
surface text = make_neutral_surface(text_renderer.render());
surface bg = create_neutral_surface(text->w, text->h); surface bg = create_neutral_surface(text->w, text->h);
SDL_Rect bg_rect {0, 0, text->w, text->h}; SDL_Rect bg_rect {0, 0, text->w, text->h};
sdl::fill_surface_rect(bg, &bg_rect, 0xaa000000); sdl::fill_surface_rect(bg, &bg_rect, 0xaa000000);