From d331ff3193989b6067dc018e5f98b98cb8049b41 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 24 Apr 2021 23:30:13 +0200 Subject: [PATCH] overlays: implement text_align::right --- rpcs3/Emu/RSX/Overlays/overlay_controls.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index c1ca8cdbcf..647343f23b 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -336,7 +336,8 @@ namespace rsx enum text_align { left = 0, - center + center, + right }; u16 x = 0; @@ -524,10 +525,10 @@ namespace rsx v.values[1] += y + padding_top + static_cast(renderer->get_size_px()); } - if (alignment == center) + if (alignment != text_align::left) { // Scan for lines and measure them - // Reposition them to the center + // Reposition them to the center or right depending on the alignment std::vector> lines; u32 line_begin = 0; u32 ctr = 0; @@ -549,6 +550,7 @@ namespace rsx lines.emplace_back(line_begin, ctr); const auto max_region_w = std::max(text_extents_w, w); + const f32 offset_extent = (alignment == text_align::center ? 0.5f : 1.0f); for (auto p : lines) { @@ -563,7 +565,7 @@ namespace rsx if (line_length < max_region_w) { - f32 offset = (max_region_w - line_length) * 0.5f; + const f32 offset = (max_region_w - line_length) * offset_extent; for (auto n = p.first; n < p.second; ++n) { result[n].values[0] += offset;