mirror of
https://github.com/vladtrc/iw4L
synced 2026-10-26 02:11:39 -04:00
Make centred 16:9 HUD overlays cover screens wider than 16:9
The Chopper Gunner's dark frame and the night-vision goggles are drawn as one centred 854x480 item in the HUD chrome menus, so on a 2.17:1 phone screen they stopped short of both sides and left a bright strip down each edge. Items in the HUD chrome menus with exactly that rect and a background now get the `cover` scaling the main menu's background art already uses. Nothing changes at 16:9 or narrower. Cover scaling grew an item to the screen's width but kept its top edge, so the extra height all went below. For the gunner's frame that put its centre, and the reticle drawn in it, 11% of the screen height under the view centre, where the bullets go. A covering item now grows about its centre on both axes. This also applies to the main menu's background art, which is now cropped equally at the top and bottom on wide screens instead of only at the bottom. Checked on the Mac at 2868x1320: before, bright strips on both sides of the gunner's frame; after, the frame reaches both edges and the reticle sits on the view centre. On our iPhone build in a Favela match the frame reached both edges, and the bullets and crosshair lined up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -552,6 +552,23 @@ pub const HUD_CHROME_MENUS: &[&str] = &[
|
||||
"perks_info_hd",
|
||||
];
|
||||
|
||||
fn cover_wide_hud_overlays(catalog: &mut MenuCatalog) {
|
||||
for name in HUD_CHROME_MENUS {
|
||||
let Some(menu) = catalog.menus.get_mut(*name) else {
|
||||
continue;
|
||||
};
|
||||
for item in &mut menu.items {
|
||||
let rect = &item.rect;
|
||||
if !item.background.is_empty()
|
||||
&& (rect.x, rect.y, rect.w, rect.h) == (-427.0, -240.0, 854.0, 480.0)
|
||||
&& (rect.horz_align, rect.vert_align) == (2, 2)
|
||||
{
|
||||
item.cover = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ui_games_root(games: &GamesRoot) -> Result<GamesRoot, String> {
|
||||
let anchor = find_zone_file(games, "iw4:common_mp")?;
|
||||
game_root_for_zone(&anchor.path).map(GamesRoot)
|
||||
@@ -1025,6 +1042,7 @@ impl MenuSink {
|
||||
|
||||
fn finish_and_take(mut self, games: Option<&Path>) -> MenuCatalog {
|
||||
self.finish_ui_images(games);
|
||||
cover_wide_hud_overlays(&mut self.catalog);
|
||||
self.catalog
|
||||
}
|
||||
|
||||
|
||||
@@ -948,10 +948,12 @@ fn push_stretch(
|
||||
);
|
||||
if rest.w > f32::EPSILON && rest.w < surface.width() {
|
||||
let grow = surface.width() / rest.w;
|
||||
let centre = applied.x + applied.w * 0.5;
|
||||
let centre_x = applied.x + applied.w * 0.5;
|
||||
let centre_y = applied.y + applied.h * 0.5;
|
||||
applied.w *= grow;
|
||||
applied.h *= grow;
|
||||
applied.x = centre - applied.w * 0.5;
|
||||
applied.x = centre_x - applied.w * 0.5;
|
||||
applied.y = centre_y - applied.h * 0.5;
|
||||
}
|
||||
}
|
||||
let color = style.fill_color(item);
|
||||
|
||||
Reference in New Issue
Block a user