aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/satellite_map.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 08:25:22 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 08:25:22 +0300
commit9f360911f4af29307b566c0acacf1f5661ea9970 (patch)
tree9477bb8961f835fffe75d8e5a9d3cf5fe88720b8 /apps/fparkan-game/src/satellite_map.rs
parentea9051e68a9de762a3d6f79c2e8d26bd1ce4310c (diff)
downloadfparkan-9f360911f4af29307b566c0acacf1f5661ea9970.tar.xz
fparkan-9f360911f4af29307b566c0acacf1f5661ea9970.zip
feat(ui): show the original strategic toolbar in AutoDemo
Diffstat (limited to 'apps/fparkan-game/src/satellite_map.rs')
-rw-r--r--apps/fparkan-game/src/satellite_map.rs59
1 files changed, 11 insertions, 48 deletions
diff --git a/apps/fparkan-game/src/satellite_map.rs b/apps/fparkan-game/src/satellite_map.rs
index 6eef249b..d2a240eb 100644
--- a/apps/fparkan-game/src/satellite_map.rs
+++ b/apps/fparkan-game/src/satellite_map.rs
@@ -1,7 +1,6 @@
use super::{
- append_environment_gradient_material, append_environment_range, quad_indices,
- screen_tl_quad_vertices_pixels, world_pipeline_state, EnvironmentGpuRange, LegacyBlendMode,
- LegacyDepthMode, StaticPreviewScene, VulkanSmokeRenderer, VulkanStaticTexture,
+ mission_overlay::{add_overlay_sprite, overlay_texture},
+ EnvironmentGpuRange, StaticPreviewScene, VulkanSmokeRenderer,
};
use fparkan_assets::{
satellite_map::{load_satellite_map, MAP_INSET, MAP_RECT},
@@ -12,12 +11,10 @@ use fparkan_vfs::DirectoryVfs;
use fparkan_world::ObjectHandle;
use std::{path::Path, sync::Arc};
-const UV: [[f32; 2]; 4] = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0]];
// Native initial background colour, iron3d+0x74cf0.
const MAP_TINT: [f32; 3] = [55.0 / 255.0, 1.0, 55.0 / 255.0];
const MAP_ALPHA: f32 = 128.0 / 255.0;
const MAP_SIZE: usize = 256;
-const UI_VIEWPORT: [f32; 2] = [640.0, 480.0];
pub(super) struct SatelliteMap {
frame: EnvironmentGpuRange,
@@ -53,10 +50,10 @@ impl SatelliteMap {
compass_bottom,
];
Ok(Some(Self {
- frame: add_sprite(preview, assets.frame, bounds, [1.0; 3], 1.0)?,
- background: add_sprite(preview, assets.background, image, MAP_TINT, MAP_ALPHA)?,
- compass: add_sprite(preview, assets.compass, compass, [1.0; 3], 1.0)?,
- contact_layer: add_sprite(preview, empty_layer(), image, [1.0; 3], 1.0)?,
+ frame: add_overlay_sprite(preview, assets.frame, bounds, [1.0; 3], 1.0)?,
+ background: add_overlay_sprite(preview, assets.background, image, MAP_TINT, MAP_ALPHA)?,
+ compass: add_overlay_sprite(preview, assets.compass, compass, [1.0; 3], 1.0)?,
+ contact_layer: add_overlay_sprite(preview, empty_layer(), image, [1.0; 3], 1.0)?,
icons: assets.icons,
extent: satellite_contacts::landscape_extent(engine),
buildings: Vec::new(),
@@ -121,7 +118,11 @@ impl SatelliteMap {
paint_unit(&mut layer, unit);
}
renderer
- .update_material_texture(self.contact_layer.material_index, 0, &texture(layer))
+ .update_material_texture(
+ self.contact_layer.material_index,
+ 0,
+ &overlay_texture(layer),
+ )
.map_err(|error| error.to_string())?;
self.buildings = buildings;
self.units = units;
@@ -250,41 +251,3 @@ fn paint_building(
}
}
}
-
-fn texture(image: RgbaImage) -> VulkanStaticTexture {
- VulkanStaticTexture {
- width: image.width,
- height: image.height,
- rgba8: image.rgba8,
- mip_levels: Vec::new(),
- }
-}
-
-fn add_sprite(
- preview: &mut StaticPreviewScene,
- image: RgbaImage,
- [left, top, right, bottom]: [f32; 4],
- color: [f32; 3],
- alpha: f32,
-) -> Result<EnvironmentGpuRange, String> {
- let material = append_environment_gradient_material(&mut preview.materials)?;
- preview.materials[material].screen_tl = true;
- preview.materials[material].sky_far_depth = false;
- preview.materials[material].texture = texture(image);
- append_environment_range(
- &mut preview.mesh,
- material,
- screen_tl_quad_vertices_pixels(
- [(left + right) * 0.5, (top + bottom) * 0.5],
- (right - left) * 0.5,
- (bottom - top) * 0.5,
- UI_VIEWPORT,
- color,
- alpha,
- UV,
- )
- .to_vec(),
- quad_indices(1)?,
- world_pipeline_state(LegacyBlendMode::SourceAlpha, LegacyDepthMode::Disabled),
- )
-}