aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-assets/src/satellite_map.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 08:12:48 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 08:12:48 +0300
commitea9051e68a9de762a3d6f79c2e8d26bd1ce4310c (patch)
treef97e7492be703434471a16440300bf94d5214f9f /crates/fparkan-assets/src/satellite_map.rs
parent9bb041a090dab428469647a203a57147a5d09c0b (diff)
downloadfparkan-ea9051e68a9de762a3d6f79c2e8d26bd1ce4310c.tar.xz
fparkan-ea9051e68a9de762a3d6f79c2e8d26bd1ce4310c.zip
feat(ui): show the original framed map in AutoDemo
Diffstat (limited to 'crates/fparkan-assets/src/satellite_map.rs')
-rw-r--r--crates/fparkan-assets/src/satellite_map.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/crates/fparkan-assets/src/satellite_map.rs b/crates/fparkan-assets/src/satellite_map.rs
index 39af61bf..d1d11ce3 100644
--- a/crates/fparkan-assets/src/satellite_map.rs
+++ b/crates/fparkan-assets/src/satellite_map.rs
@@ -1,6 +1,9 @@
//! Resources used by the satellite map overlay.
-use crate::ui_configuration::{field, number, object, read};
+use crate::{
+ mission_pager::{scale, UiFrame},
+ ui_configuration::{field, number, object, read},
+};
use fparkan_nres::{decode, EntryId, ReadProfile};
use fparkan_path::{normalize_relative, PathPolicy};
use fparkan_resource::{resource_name, CachedResourceRepository, ResourceRepository};
@@ -8,8 +11,14 @@ use fparkan_texm::{decode_mip_rgba8, decode_texm, RgbaImage};
use fparkan_vfs::Vfs;
use std::sync::Arc;
+/// Framed map bounds in the original 640×480 coordinates (iron3d+0x733e0).
+pub const MAP_RECT: [u32; 4] = [374, 0, 640, 266];
+/// Inset between the frame and the mission image (iron3d+0x74cf0).
+pub const MAP_INSET: u32 = 5;
+
/// The mission map, compass and contact atlas from the installed game.
pub struct SatelliteMapAssets {
+ pub frame: RgbaImage,
pub background: RgbaImage,
pub compass: RgbaImage,
pub icons: RgbaImage,
@@ -71,7 +80,17 @@ pub fn load_satellite_map(
if icons.width != 256 || icons.height != 256 {
return Err("unexpected satellite icon atlas dimensions".into());
}
+ let [left, top, right, bottom] = MAP_RECT;
+ let bounds = [0, 0, right - left, bottom - top];
+ let [_, _, width, height] = bounds.map(scale);
+ let mut frame = RgbaImage {
+ width,
+ height,
+ rgba8: vec![0; (width * height * 4) as usize],
+ };
+ UiFrame::load(vfs.as_ref())?.paint(&mut frame, bounds, [0; 4]);
Ok(Some(SatelliteMapAssets {
+ frame,
background,
compass,
icons,
@@ -134,6 +153,12 @@ mod tests {
[256, 256]
);
assert_eq!([range.compass.width, range.compass.height], [21, 42]);
+ assert_eq!([range.frame.width, range.frame.height], [332, 332]);
+ assert_eq!(range.frame, fortresses.frame);
+ assert!(range.frame.rgba8[..332 * 4]
+ .chunks_exact(4)
+ .any(|pixel| pixel[3] != 0));
+ assert_eq!(range.frame.rgba8[(166 * 332 + 166) * 4 + 3], 0);
assert_ne!(range.background.rgba8, fortresses.background.rgba8);
assert_eq!(range.compass, fortresses.compass);
assert!(range