aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/mission_overlay.rs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/fparkan-game/src/mission_overlay.rs')
-rw-r--r--apps/fparkan-game/src/mission_overlay.rs54
1 files changed, 35 insertions, 19 deletions
diff --git a/apps/fparkan-game/src/mission_overlay.rs b/apps/fparkan-game/src/mission_overlay.rs
index 9a7f768e..5cd9db74 100644
--- a/apps/fparkan-game/src/mission_overlay.rs
+++ b/apps/fparkan-game/src/mission_overlay.rs
@@ -1,10 +1,15 @@
use super::{
- append_environment_gradient_material, append_environment_range, cockpit_dial::CockpitDial,
- cockpit_radar_hud::CockpitRadarHud, factory_menu::FactoryProjectPanel, horizontal_fov,
- quad_indices, satellite_map::SatelliteMap, screen_tl_quad_vertices_pixels,
- strategy_cursor_hud::StrategyCursorHud, world_pipeline_state, DirectoryVfs,
- EnvironmentGpuRange, LegacyBlendMode, LegacyDepthMode, StaticPreviewScene, StaticVulkanApp,
- VulkanStaticTexture,
+ append_environment_gradient_material, append_environment_range,
+ cockpit_dial::CockpitDial,
+ cockpit_radar_hud::CockpitRadarHud,
+ factory_menu::FactoryProjectPanel,
+ horizontal_fov, quad_indices,
+ satellite_map::SatelliteMap,
+ screen_tl_quad_vertices_pixels,
+ strategic_toolbar_hud::{StrategicToolbarHud, ToolbarFrame},
+ strategy_cursor_hud::StrategyCursorHud,
+ world_pipeline_state, EnvironmentGpuRange, LegacyBlendMode, LegacyDepthMode,
+ StaticPreviewScene, StaticVulkanApp, VulkanStaticTexture,
};
#[cfg(windows)]
use super::{
@@ -12,7 +17,7 @@ use super::{
strategic_balance_hud::StrategicBalanceHud, strategic_roster_hud::StrategicRosterHud,
strategic_tooltip_hud::StrategicTooltipHud, weapon_hud::WeaponHud,
};
-use fparkan_assets::{strategy_toolbar, RgbaImage};
+use fparkan_assets::RgbaImage;
use fparkan_runtime::{
cockpit_altimeter::cockpit_altimeter,
radar::{cockpit_radar_period, cockpit_range_readout},
@@ -25,7 +30,7 @@ pub(super) use fparkan_assets::ui_sprite::source_over;
#[derive(Default)]
pub(super) struct MissionOverlay {
pub(super) satellite_map: Option<SatelliteMap>,
- strategy_toolbar: Option<EnvironmentGpuRange>,
+ strategy_toolbar: Option<StrategicToolbarHud>,
pub(super) strategy_cursor: Option<StrategyCursorHud>,
#[cfg(windows)]
strategy_balance: Option<StrategicBalanceHud>,
@@ -89,11 +94,7 @@ impl MissionOverlay {
None
});
let strategy_toolbar = if autodemo || cockpit.is_some() {
- strategy_toolbar::load_expanded_toolbar(&DirectoryVfs::new(root))
- .and_then(|image| {
- let [width, height] = strategy_toolbar::EXTENT.map(|axis| axis as f32);
- add_overlay_sprite(preview, image, [0.0, 0.0, width, height], [1.0; 3], 1.0)
- })
+ StrategicToolbarHud::load(root, preview)
.map(Some)
.unwrap_or_else(|error| {
eprintln!("strategy_toolbar_unavailable reason={error}");
@@ -201,8 +202,8 @@ impl MissionOverlay {
remove(range, ranges, counts);
}
}
- if let Some(toolbar) = self.strategy_toolbar {
- remove(toolbar.range_index, ranges, counts);
+ if let Some(toolbar) = &self.strategy_toolbar {
+ remove(toolbar.range_index(), ranges, counts);
}
if let Some(cursor) = &self.strategy_cursor {
for range in cursor.ranges() {
@@ -269,10 +270,25 @@ impl StaticVulkanApp {
.demo_camera
.as_ref()
.is_some_and(AutoDemoCamera::shows_strategy_toolbar);
- if let Some(toolbar) = self.overlay.strategy_toolbar {
- renderer
- .set_draw_range_index_count(toolbar.range_index, if strategic { 6 } else { 0 })
- .map_err(|error| error.to_string())?;
+ if let Some(toolbar) = &mut self.overlay.strategy_toolbar {
+ let command = self
+ .command_view
+ .as_ref()
+ .zip(self.mission_engine.as_ref().zip(self.cockpit));
+ let state = command.map(|(view, (engine, cockpit))| ToolbarFrame {
+ sections: fparkan_runtime::strategic_toolbar::available_sections(engine, cockpit),
+ warbots_open: view.warbots_open,
+ map_open: self
+ .overlay
+ .satellite_map
+ .as_ref()
+ .is_some_and(SatelliteMap::is_visible),
+ pointer: view.pointer().filter(|_| {
+ self.window_focused && !self.mission_paused && self.factory_menu.is_none()
+ }),
+ now_ms: frame.clock.time_ms,
+ });
+ toolbar.draw(renderer, strategic, state)?;
}
#[cfg(windows)]
if let Some(balance) = &mut self.overlay.strategy_balance {