Fix overlay calculations with rect.

This commit is contained in:
Themaister 2013-10-21 14:26:42 +02:00
parent 96352a13c5
commit b17d113ac4
2 changed files with 34 additions and 29 deletions

View File

@ -190,12 +190,17 @@ static void input_overlay_scale(struct overlay *overlay, float scale)
for (size_t i = 0; i < overlay->size; i++)
{
struct overlay_desc *desc = &overlay->descs[i];
desc->mod_w = 2.0f * scale * desc->range_x;
desc->mod_h = 2.0f * scale * desc->range_y;
float center_x = (desc->x - overlay->center_x) * scale + overlay->center_x;
float center_y = (desc->y - overlay->center_y) * scale + overlay->center_y;
desc->mod_x = center_x - scale * desc->range_x;
desc->mod_y = center_y - scale * desc->range_y;
float scale_w = overlay->mod_w * desc->range_x;
float scale_h = overlay->mod_h * desc->range_y;
desc->mod_w = 2.0f * scale_w;
desc->mod_h = 2.0f * scale_h;
float adj_center_x = overlay->mod_x + desc->x * overlay->mod_w;
float adj_center_y = overlay->mod_y + desc->y * overlay->mod_h;
desc->mod_x = adj_center_x - scale_w;
desc->mod_y = adj_center_y - scale_h;
}
}
@ -658,7 +663,7 @@ input_overlay_t *input_overlay_new(const char *overlay)
ol->enable = true;
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
input_overlay_set_scale_factor(ol, 1.0f);
input_overlay_set_scale_factor(ol, g_settings.input.overlay_scale);
ol->next_index = (ol->index + 1) % ol->size;
return ol;

View File

@ -1,6 +1,6 @@
overlays = 1
# overlay0_overlay omitted. We don't need to splat an overlay across the screen.
overlay0_rect = "0.50,0.50,0.50,0.50" # Place entire overlay in bottom right part of screen.
overlay0_rect = "0.35,0.35,0.65,0.65" # Place overlay somewhere.
overlay0_full_screen = true
# These set defaults across the entire overlay. They can be overridden per-desc with overlayN_descM_alpha_mod = foo, etc.