aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 12:41:14 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 12:41:14 +0300
commitf12b2c55910fe4c79272a9a7b17ed49293078e4a (patch)
treea944ce00b748ea75b11d1eaa1dd2c4c66adac4ea /apps/fparkan-game/src
parentc846377ead77ef7184cdeddd25c3f2c9d76a6736 (diff)
downloadfparkan-f12b2c55910fe4c79272a9a7b17ed49293078e4a.tar.xz
fparkan-f12b2c55910fe4c79272a9a7b17ed49293078e4a.zip
feat(ui): play original warbot selection voices
Resolve the three original sound banks through the mission voice queue. Compare the first selection, repeated clicks, a reopened list, and heavy and medium warbots from the stock Two Fortresses start.
Diffstat (limited to 'apps/fparkan-game/src')
-rw-r--r--apps/fparkan-game/src/strategic_view.rs50
1 files changed, 41 insertions, 9 deletions
diff --git a/apps/fparkan-game/src/strategic_view.rs b/apps/fparkan-game/src/strategic_view.rs
index d21549ae..11ad4415 100644
--- a/apps/fparkan-game/src/strategic_view.rs
+++ b/apps/fparkan-game/src/strategic_view.rs
@@ -34,15 +34,27 @@ enum OrderInput {
}
impl ActiveCommandView {
- pub(super) fn refresh_warbots(&mut self, rows: &[WarbotRow]) {
- if !rows
+ fn refresh_warbots(&mut self, rows: &[WarbotRow]) -> Option<WarbotRow> {
+ self.warbots_open = !rows.is_empty();
+ if rows
.iter()
.any(|row| Some(row.handle) == self.selected_warbot)
{
- self.selected_warbot = rows.iter().find(|row| row.selectable).map(|row| row.handle);
- self.order_input = None;
+ return None;
}
- self.warbots_open = !rows.is_empty();
+ let first = rows.iter().copied().find(|row| row.selectable);
+ self.selected_warbot = first.map(|row| row.handle);
+ self.order_input = None;
+ first
+ }
+
+ fn select_warbot(&mut self, row: WarbotRow) -> bool {
+ if Some(row.handle) == self.selected_warbot {
+ return false;
+ }
+ self.selected_warbot = Some(row.handle);
+ self.order_input = None;
+ row.selectable
}
pub(super) fn route_draft(&self) -> Option<&[[f32; 2]]> {
@@ -352,7 +364,11 @@ impl StaticVulkanApp {
}
}
Some(ToolbarAction::Warbots) if view.warbots_open => view.warbots_open = false,
- Some(ToolbarAction::Warbots) => view.refresh_warbots(&warbot_rows(engine, cockpit)),
+ Some(ToolbarAction::Warbots) => {
+ if let Some(row) = view.refresh_warbots(&warbot_rows(engine, cockpit)) {
+ self.play_warbot_selection(row);
+ }
+ }
None => {
if view.warbots_open {
match hit_test(xy, rows.len()) {
@@ -361,9 +377,9 @@ impl StaticVulkanApp {
return;
}
Some(ListHit::Row(index)) => {
- if Some(rows[index].handle) != view.selected_warbot {
- view.order_input = None;
- view.selected_warbot = Some(rows[index].handle);
+ let row = rows[index];
+ if view.select_warbot(row) {
+ self.play_warbot_selection(row);
}
return;
}
@@ -420,6 +436,22 @@ impl StaticVulkanApp {
}
}
+ fn play_warbot_selection(&mut self, row: WarbotRow) {
+ let Some(audio) = self.audio.as_mut() else {
+ return;
+ };
+ match audio.queue_game_voice(row.selection_voice) {
+ Ok(resource) => eprintln!(
+ "strategic_warbot_voice unit={} symbol={} resource={resource}",
+ row.handle.slot, row.selection_voice
+ ),
+ Err(error) => eprintln!(
+ "sim_coverage mission_voice_unavailable=1 notice={} reason={error}",
+ row.selection_voice
+ ),
+ }
+ }
+
fn pick_route_point(&self, xy: [f32; 2], actor: Option<ObjectHandle>) -> Option<[f32; 2]> {
let engine = self.mission_engine.as_ref()?;
let actor = actor?;