~widelands-dev/widelands/lenient_allowed_buildings

« back to all changes in this revision

Viewing changes to src/wui/interactive_player.cc

Merged lp:~widelands-dev/widelands/bug-1696702-fuzzy-building-plots:
Force integer precision for overlays. This fixes fuzzy overlay images when the player hits Ctrl+0 to reset the zoom.

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
                }
310
310
 
311
311
                const float scale = 1.f / given_map_view->view().zoom;
312
 
                const auto blit_overlay = [dst, f, scale](const Image* pic, const Vector2i& hotspot) {
313
 
                        dst->blitrect_scale(Rectf(f->rendertarget_pixel - hotspot.cast<float>() * scale,
314
 
                                                  pic->width() * scale, pic->height() * scale),
315
 
                                            pic, Recti(0, 0, pic->width(), pic->height()), 1.f,
316
 
                                            BlendMode::UseAlpha);
317
 
                };
318
312
 
319
313
                // Add road building overlays if applicable.
320
314
                if (f->vision > 0) {
340
334
                {
341
335
                        const auto it = work_area_overlays.find(f->fcoords);
342
336
                        if (it != work_area_overlays.end()) {
343
 
                                blit_overlay(it->second, Vector2i(it->second->width() / 2, it->second->height() / 2));
 
337
                                blit_field_overlay(dst, *f, it->second,
 
338
                                                   Vector2i(it->second->width() / 2, it->second->height() / 2), scale);
344
339
                        }
345
340
                }
346
341
 
349
344
                        if (buildhelp()) {
350
345
                                const auto* overlay = get_buildhelp_overlay(plr.get_buildcaps(f->fcoords));
351
346
                                if (overlay != nullptr) {
352
 
                                        blit_overlay(overlay->pic, overlay->hotspot);
 
347
                                        blit_field_overlay(dst, *f, overlay->pic, overlay->hotspot, scale);
353
348
                                }
354
349
                        }
355
350
 
356
351
                        // Blit the selection marker.
357
352
                        if (f->fcoords == get_sel_pos().node) {
358
353
                                const Image* pic = get_sel_picture();
359
 
                                blit_overlay(pic, Vector2i(pic->width() / 2, pic->height() / 2));
 
354
                                blit_field_overlay(dst, *f, pic, Vector2i(pic->width() / 2, pic->height() / 2), scale);
360
355
                        }
361
356
 
362
357
                        // Draw road building slopes.
363
358
                        {
364
359
                                const auto it = road_building.steepness_indicators.find(f->fcoords);
365
360
                                if (it != road_building.steepness_indicators.end()) {
366
 
                                        blit_overlay(
367
 
                                           it->second, Vector2i(it->second->width() / 2, it->second->height() / 2));
 
361
                                        blit_field_overlay(dst, *f, it->second,
 
362
                                                           Vector2i(it->second->width() / 2, it->second->height() / 2),
 
363
                                                           scale);
368
364
                                }
369
365
                        }
370
366
                }