aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 18:05:52 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 18:05:52 +0300
commit9f442fa339371869dda44a32a9e0ec2f763d830c (patch)
treebec91edfe30d42a278502561af155c11a32de764
parent3b5a8aa4e6465ca56763cb96b4100bb1ff1c0ccf (diff)
downloadfparkan-9f442fa339371869dda44a32a9e0ec2f763d830c.tar.xz
fparkan-9f442fa339371869dda44a32a9e0ec2f763d830c.zip
feat(ui): connect the bunker list to the strategic camera
Show clan bunkers with the original compound controls and map selection. The strategic command button switches the camera anchor and preserves a view already bound to that bunker. Check the stock Two Fortresses window with Vulkan validation and exercise retargeting and the ownership guard with the licensed runtime test.
-rw-r--r--apps/fparkan-game/src/mission_overlay.rs10
-rw-r--r--apps/fparkan-game/src/strategic_buildings_hud.rs50
-rw-r--r--apps/fparkan-game/src/strategic_toolbar_hud.rs13
-rw-r--r--apps/fparkan-game/src/strategic_tooltip_hud.rs12
-rw-r--r--apps/fparkan-game/src/strategic_view.rs138
-rw-r--r--crates/fparkan-assets/src/strategic_buildings.rs86
-rw-r--r--crates/fparkan-assets/src/strategy_toolbar.rs3
-rw-r--r--crates/fparkan-runtime/src/strategic_buildings.rs30
-rw-r--r--crates/fparkan-runtime/src/strategic_toolbar.rs2
-rw-r--r--crates/fparkan-runtime/src/strategic_view.rs55
-rw-r--r--docs/appendices/knowledge-boundaries.md2
-rw-r--r--docs/appendices/ui-shell.md20
12 files changed, 336 insertions, 85 deletions
diff --git a/apps/fparkan-game/src/mission_overlay.rs b/apps/fparkan-game/src/mission_overlay.rs
index 43177b6a..d253a074 100644
--- a/apps/fparkan-game/src/mission_overlay.rs
+++ b/apps/fparkan-game/src/mission_overlay.rs
@@ -305,6 +305,12 @@ impl StaticVulkanApp {
#[cfg(windows)]
let buildings_frame = self.strategic_buildings_frame();
#[cfg(windows)]
+ let panel_tip = factory_tip.or_else(|| {
+ buildings_frame
+ .as_ref()?
+ .tooltip(self.command_view.as_ref()?.pointer()?)
+ });
+ #[cfg(windows)]
let row_count = warbot_rows.len();
#[cfg(windows)]
let cursor = self.strategy_cursor(row_count);
@@ -328,7 +334,7 @@ impl StaticVulkanApp {
sections: fparkan_runtime::strategic_toolbar::available_sections(engine, cockpit),
warbots_open: view.warbots_open,
factories_open: view.factories_open(),
- other_buildings_open: view.other_buildings_open(),
+ building_section: view.building_section(),
map_open: self
.overlay
.satellite_map
@@ -546,7 +552,7 @@ impl StaticVulkanApp {
.filter(|_| self.overlay.strategy_toolbar.is_some())
.map(|view| view.toolbar_layout()),
card_rows,
- factory_tip,
+ panel_tip,
)?;
}
Ok(())
diff --git a/apps/fparkan-game/src/strategic_buildings_hud.rs b/apps/fparkan-game/src/strategic_buildings_hud.rs
index b0b6b4ae..3ccff520 100644
--- a/apps/fparkan-game/src/strategic_buildings_hud.rs
+++ b/apps/fparkan-game/src/strategic_buildings_hud.rs
@@ -3,23 +3,39 @@ use super::{
DirectoryVfs, EnvironmentGpuRange, StaticPreviewScene, VulkanSmokeRenderer,
};
use fparkan_assets::{
- strategic_buildings::{Images, Row, EXTENT, ORIGIN, TITLE},
+ strategic_buildings::{hit_test, Hit, Images, Row, COMMAND_TOOLTIP, EXTENT, ORIGIN},
RgbaImage,
};
use fparkan_platform_winit::text::StringResources;
-use fparkan_runtime::strategic_buildings::BuildingRow;
+use fparkan_runtime::strategic_buildings::{BuildingRow, BuildingSection};
use fparkan_world::ObjectHandle;
use std::path::Path;
#[derive(PartialEq, Eq)]
pub(super) struct BuildingsFrame {
+ pub section: BuildingSection,
pub rows: Vec<BuildingRow>,
pub selected: Option<ObjectHandle>,
}
+impl BuildingsFrame {
+ pub(super) fn tooltip(&self, pointer: [f32; 2]) -> Option<u32> {
+ matches!(
+ hit_test(
+ pointer,
+ self.rows.len(),
+ self.section == BuildingSection::Bunkers
+ ),
+ Some(Hit::Command(_))
+ )
+ .then_some(COMMAND_TOOLTIP)
+ }
+}
+
pub(super) struct StrategicBuildingsHud {
range: EnvironmentGpuRange,
images: Images,
+ titles: [String; 2],
strings: StringResources,
displayed: Option<BuildingsFrame>,
}
@@ -27,10 +43,15 @@ pub(super) struct StrategicBuildingsHud {
impl StrategicBuildingsHud {
pub(super) fn load(root: &Path, preview: &mut StaticPreviewScene) -> Result<Self, String> {
let strings = StringResources::open(&root.join("iron3d.dll"))?;
- let title = strings
- .get(TITLE)
- .ok_or("missing strategic buildings title")?;
- let images = Images::load(&DirectoryVfs::new(root), &title)?;
+ let titles = [
+ strings
+ .get(0x64a)
+ .ok_or("missing strategic buildings title")?,
+ strings
+ .get(0x648)
+ .ok_or("missing strategic bunkers title")?,
+ ];
+ let images = Images::load(&DirectoryVfs::new(root))?;
let [width, height] = EXTENT;
let [x, y] = ORIGIN.map(|axis| axis as f32);
let range = add_overlay_sprite(
@@ -47,6 +68,7 @@ impl StrategicBuildingsHud {
Ok(Self {
range,
images,
+ titles,
strings,
displayed: None,
})
@@ -73,15 +95,17 @@ impl StrategicBuildingsHud {
.iter()
.map(|row| self.strings.get(row.label).unwrap_or_default())
.collect();
+ let command = frame.section == BuildingSection::Bunkers;
+ let rows = frame.rows.iter().zip(&labels).map(|(row, label)| Row {
+ label,
+ class: row.class,
+ size: row.size,
+ selected: frame.selected == Some(row.handle),
+ durability_percent: row.durability_percent,
+ });
let image = self
.images
- .paint(frame.rows.iter().zip(&labels).map(|(row, label)| Row {
- label,
- class: row.class,
- size: row.size,
- selected: frame.selected == Some(row.handle),
- durability_percent: row.durability_percent,
- }))?;
+ .paint(&self.titles[usize::from(command)], command, rows)?;
renderer
.update_material_texture(self.range.material_index, 0, &overlay_texture(image))
.map_err(|error| error.to_string())?;
diff --git a/apps/fparkan-game/src/strategic_toolbar_hud.rs b/apps/fparkan-game/src/strategic_toolbar_hud.rs
index 2ad93a59..74f313ac 100644
--- a/apps/fparkan-game/src/strategic_toolbar_hud.rs
+++ b/apps/fparkan-game/src/strategic_toolbar_hud.rs
@@ -5,6 +5,7 @@ use super::{
use fparkan_assets::strategy_toolbar::{
ButtonVisual, ToolbarHover, ToolbarImages, ToolbarLayout, CONTROL_COUNT, EXTENT,
};
+use fparkan_runtime::strategic_buildings::BuildingSection;
use std::path::Path;
pub(super) struct StrategicToolbarHud {
@@ -69,8 +70,14 @@ impl StrategicToolbarHud {
if frame.factories_open && frame.sections[4] {
visuals[5] = ButtonVisual::Lit;
}
- if frame.other_buildings_open && frame.sections[7] {
- visuals[8] = ButtonVisual::Lit;
+ if let Some(section) = frame.building_section {
+ let index = match section {
+ BuildingSection::Bunkers => 7,
+ BuildingSection::Other => 8,
+ };
+ if frame.sections[index - 1] {
+ visuals[index] = ButtonVisual::Lit;
+ }
}
// The chat button is disabled in a local mission.
visuals[9] = ButtonVisual::Disabled;
@@ -101,7 +108,7 @@ pub(super) struct ToolbarFrame {
pub sections: [bool; 8],
pub warbots_open: bool,
pub factories_open: bool,
- pub other_buildings_open: bool,
+ pub building_section: Option<BuildingSection>,
pub map_open: bool,
pub pointer: Option<[f32; 2]>,
pub now_ms: u32,
diff --git a/apps/fparkan-game/src/strategic_tooltip_hud.rs b/apps/fparkan-game/src/strategic_tooltip_hud.rs
index 0e8ee3af..812c6e06 100644
--- a/apps/fparkan-game/src/strategic_tooltip_hud.rs
+++ b/apps/fparkan-game/src/strategic_tooltip_hud.rs
@@ -4,6 +4,7 @@ use super::{
};
use fparkan_assets::{
game_font::{load_tool_font, TOOL_FONT_EXTENTS},
+ strategic_buildings::COMMAND_TOOLTIP,
strategic_factory,
strategic_roster::{hit_test, CockpitControl, ListHit},
strategy_toolbar::{button_index_at, ToolbarLayout, TOOLTIP_IDS},
@@ -16,7 +17,8 @@ use std::{path::Path, time::Instant};
// In the order in which iron3d+0x82930 assigns the original texts to the buttons.
const CARD_LABELS: [u32; 4] = [0x05de, 0x05ef, 0x05ee, 0x1864];
const FACTORY_OFFSET: usize = TOOLTIP_IDS.len() + CARD_LABELS.len();
-const LABEL_COUNT: usize = FACTORY_OFFSET + strategic_factory::TOOLTIP_IDS.len();
+const BUNKER_OFFSET: usize = FACTORY_OFFSET + strategic_factory::TOOLTIP_IDS.len();
+const LABEL_COUNT: usize = BUNKER_OFFSET + 1;
#[derive(Clone, Copy, Default)]
struct Frame {
@@ -38,6 +40,7 @@ impl StrategicTooltipHud {
.into_iter()
.chain(CARD_LABELS)
.chain(strategic_factory::TOOLTIP_IDS)
+ .chain([COMMAND_TOOLTIP])
.map(|id| {
strings
.get(id)
@@ -101,19 +104,20 @@ impl StrategicTooltipHud {
pointer: Option<[f32; 2]>,
toolbar_layout: Option<ToolbarLayout>,
card_rows: usize,
- factory_tip: Option<u32>,
+ panel_tip: Option<u32>,
) -> Result<(), String> {
let tooltip = pointer.and_then(|xy| {
let toolbar_label = toolbar_layout
.filter(|layout| layout.button_visible(xy[1]))
.and_then(|_| button_index_at(xy));
- let factory_label = factory_tip.and_then(|id| {
+ let panel_label = panel_tip.and_then(|id| {
strategic_factory::TOOLTIP_IDS
.iter()
.position(|&known| id == known)
.map(|index| FACTORY_OFFSET + index)
+ .or_else(|| (id == COMMAND_TOOLTIP).then_some(BUNKER_OFFSET))
});
- let label = toolbar_label.or(factory_label).or_else(|| {
+ let label = toolbar_label.or(panel_label).or_else(|| {
let card = match hit_test(xy, card_rows)? {
ListHit::Cockpit(CockpitControl::Manual) => 0,
ListHit::Cockpit(CockpitControl::AutoGunner) => 1,
diff --git a/apps/fparkan-game/src/strategic_view.rs b/apps/fparkan-game/src/strategic_view.rs
index a7da38da..a6719c84 100644
--- a/apps/fparkan-game/src/strategic_view.rs
+++ b/apps/fparkan-game/src/strategic_view.rs
@@ -13,11 +13,12 @@ use fparkan_assets::strategy_cursor::StrategyCursor;
use fparkan_assets::strategy_toolbar::{
command_button_at, ToolbarAction, ToolbarFold, ToolbarLayout,
};
+use fparkan_runtime::strategic_buildings::BuildingSection;
#[cfg(windows)]
-use fparkan_runtime::strategic_buildings::{other_buildings, BuildingRow};
+use fparkan_runtime::strategic_buildings::{building_rows, BuildingRow};
use fparkan_runtime::strategic_roster::{warbot_rows, WarbotRow};
use fparkan_runtime::strategic_view::{
- command_post, mobile_command_post, CommandCamera, CommandCameraInput, COMMAND_FOV,
+ command_post, mobile_command_post, CommandCamera, CommandCameraInput, CommandPost, COMMAND_FOV,
};
use fparkan_runtime::{
projectile_unit_hit, satellite_contacts,
@@ -42,13 +43,14 @@ pub(super) fn captured_command_target(
pub(super) struct ActiveCommandView {
camera: CommandCamera,
+ command_posts: Vec<CommandPost>,
pointer: Option<[f32; 2]>,
toolbar: ToolbarFold,
pub(super) warbots_open: bool,
#[cfg(windows)]
factory: Option<FactorySelection>,
#[cfg(windows)]
- other_buildings_open: bool,
+ building_section: Option<BuildingSection>,
#[cfg(windows)]
selected_building: Option<ObjectHandle>,
pub(super) selected_warbot: Option<ObjectHandle>,
@@ -111,11 +113,11 @@ impl FactorySelection {
}
impl ActiveCommandView {
- pub(super) fn other_buildings_open(&self) -> bool {
+ pub(super) fn building_section(&self) -> Option<BuildingSection> {
#[cfg(windows)]
- return self.other_buildings_open;
+ return self.building_section;
#[cfg(not(windows))]
- false
+ None
}
pub(super) fn selected_building(&self) -> Option<ObjectHandle> {
@@ -150,6 +152,24 @@ impl ActiveCommandView {
None
}
+ #[cfg(windows)]
+ fn focus_bunker(
+ &mut self,
+ engine: &super::Engine,
+ cockpit: super::StartingCockpit,
+ target: ObjectHandle,
+ ) {
+ let Some(previous) = self.camera.focus_bunker(engine, cockpit, target) else {
+ return;
+ };
+ let post = CommandPost::Bunker(target);
+ if let Some(index) = self.command_posts.iter().position(|&entry| entry == post) {
+ self.command_posts.truncate(index);
+ } else {
+ self.command_posts.push(previous);
+ }
+ }
+
pub(super) fn factories_open(&self) -> bool {
#[cfg(windows)]
{
@@ -263,13 +283,14 @@ impl StaticVulkanApp {
};
self.command_view = Some(ActiveCommandView {
camera,
+ command_posts: Vec::new(),
pointer: None,
toolbar: ToolbarFold::default(),
warbots_open: false,
#[cfg(windows)]
factory: None,
#[cfg(windows)]
- other_buildings_open: false,
+ building_section: None,
#[cfg(windows)]
selected_building: None,
selected_warbot: None,
@@ -391,6 +412,7 @@ impl StaticVulkanApp {
view.warbots_open = false;
} else if self.close_strategic_buildings()
|| self.close_strategic_factory_panel()
+ || self.back_to_previous_command_post()
{
return true;
} else {
@@ -543,7 +565,7 @@ impl StaticVulkanApp {
#[cfg(windows)]
{
view.factory = None;
- view.other_buildings_open = false;
+ view.building_section = None;
view.selected_building = None;
}
if let Some(row) = view.refresh_warbots(&warbot_rows(engine, cockpit)) {
@@ -568,28 +590,34 @@ impl StaticVulkanApp {
{
view.factory = Some(factory);
view.warbots_open = false;
- view.other_buildings_open = false;
+ view.building_section = None;
view.selected_building = None;
view.selected_warbot = None;
view.order_input = None;
}
}
}
- Some(ToolbarAction::OtherBuildings) =>
- {
+ Some(action @ (ToolbarAction::Bunkers | ToolbarAction::OtherBuildings)) => {
#[cfg(windows)]
- if view.other_buildings_open {
- view.other_buildings_open = false;
- } else if self.overlay.strategic_buildings.is_some() {
- let rows = other_buildings(engine, cockpit);
- if !rows.is_empty() {
- view.other_buildings_open = true;
- view.factory = None;
- view.warbots_open = false;
- view.selected_warbot = None;
- view.order_input = None;
- if let Some(row) = view.refresh_building_selection(&rows) {
- self.play_building_selection(row);
+ {
+ let section = if action == ToolbarAction::Bunkers {
+ BuildingSection::Bunkers
+ } else {
+ BuildingSection::Other
+ };
+ if view.building_section == Some(section) {
+ view.building_section = None;
+ } else if self.overlay.strategic_buildings.is_some() {
+ let rows = building_rows(engine, cockpit, section);
+ if !rows.is_empty() {
+ view.building_section = Some(section);
+ view.factory = None;
+ view.warbots_open = false;
+ view.selected_warbot = None;
+ view.order_input = None;
+ if let Some(row) = view.refresh_building_selection(&rows) {
+ self.play_building_selection(row);
+ }
}
}
}
@@ -601,18 +629,29 @@ impl StaticVulkanApp {
.as_deref()
.and_then(|map| map.command_destination(xy))
.and_then(|point| satellite_contacts::pick_contact(engine, cockpit, point));
- let list_visible =
- view.other_buildings_open && view.toolbar_layout().sections_visible();
- if list_visible || map_hit.is_some() {
- let rows = other_buildings(engine, cockpit);
- let row = match list_visible
- .then(|| strategic_buildings::hit_test(xy, rows.len()))
- .flatten()
- {
+ if let Some(section) = view.building_section {
+ let rows = building_rows(engine, cockpit, section);
+ let hit = view
+ .toolbar_layout()
+ .sections_visible()
+ .then(|| {
+ strategic_buildings::hit_test(
+ xy,
+ rows.len(),
+ section == BuildingSection::Bunkers,
+ )
+ })
+ .flatten();
+ let row = match hit {
Some(BuildingHit::Close) => {
- view.other_buildings_open = false;
+ view.building_section = None;
return;
}
+ Some(BuildingHit::Command(index)) => {
+ let row = rows[index];
+ view.focus_bunker(engine, cockpit, row.handle);
+ Some(row)
+ }
Some(BuildingHit::Row(index)) => rows.get(index).copied(),
None => rows.into_iter().find(|row| Some(row.handle) == map_hit),
};
@@ -621,6 +660,16 @@ impl StaticVulkanApp {
}
return;
}
+ if let Some(target) = map_hit {
+ let row = [BuildingSection::Other, BuildingSection::Bunkers]
+ .into_iter()
+ .flat_map(|section| building_rows(engine, cockpit, section))
+ .find(|row| row.handle == target);
+ if let Some(row) = row.and_then(|row| view.select_building(row)) {
+ self.play_building_selection(row);
+ }
+ return;
+ }
}
#[cfg(windows)]
if let Some(factory) = view
@@ -908,24 +957,37 @@ impl StaticVulkanApp {
return self
.command_view
.as_mut()
- .is_some_and(|view| std::mem::take(&mut view.other_buildings_open));
+ .is_some_and(|view| view.building_section.take().is_some());
#[cfg(not(windows))]
false
}
+ fn back_to_previous_command_post(&mut self) -> bool {
+ let Some((view, engine)) = self.command_view.as_mut().zip(self.mission_engine.as_ref())
+ else {
+ return false;
+ };
+ while let Some(post) = view.command_posts.pop() {
+ if let Some(camera) = CommandCamera::new(engine, post) {
+ view.camera = camera;
+ return true;
+ }
+ }
+ false
+ }
+
#[cfg(windows)]
pub(super) fn strategic_buildings_frame(
&mut self,
) -> Option<super::strategic_buildings_hud::BuildingsFrame> {
- let view = self
- .command_view
- .as_mut()
- .filter(|view| view.other_buildings_open)?;
+ let view = self.command_view.as_mut()?;
+ let section = view.building_section?;
let (engine, cockpit) = self.mission_engine.as_ref().zip(self.cockpit)?;
- let rows = other_buildings(engine, cockpit);
+ let rows = building_rows(engine, cockpit, section);
let changed = view.refresh_building_selection(&rows);
let frame = view.toolbar_layout().sections_visible().then_some(
super::strategic_buildings_hud::BuildingsFrame {
+ section,
rows,
selected: view.selected_building,
},
diff --git a/crates/fparkan-assets/src/strategic_buildings.rs b/crates/fparkan-assets/src/strategic_buildings.rs
index 53deabdf..0ed6d140 100644
--- a/crates/fparkan-assets/src/strategic_buildings.rs
+++ b/crates/fparkan-assets/src/strategic_buildings.rs
@@ -1,4 +1,4 @@
-//! Compound controls of the strategic «Другие здания» section.
+//! Shared compound controls of the strategic building sections.
use crate::{
game_font::{load_layout_font, BitmapFont},
@@ -15,16 +15,19 @@ const ROW_PITCH: u32 = 20;
const ROW_HEIGHT: u32 = 19;
const TEXT_LEFT: u32 = 44;
const TEXT_RIGHT: u32 = 313;
-pub const TITLE: u32 = 0x64a;
+const COMMAND_LEFT: u32 = 34;
+const BUTTON_WIDTH: u32 = 35;
+pub const COMMAND_TOOLTIP: u32 = 0x5ed;
pub const VISIBLE_ROWS: usize = (EXTENT[1] / ROW_PITCH - 1) as usize;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Hit {
Close,
Row(usize),
+ Command(usize),
}
-pub fn hit_test([x, y]: [f32; 2], rows: usize) -> Option<Hit> {
+pub fn hit_test([x, y]: [f32; 2], rows: usize, command_buttons: bool) -> Option<Hit> {
let x = x.round_ties_even() - ORIGIN[0] as f32;
let y = y.round_ties_even();
if (283.0..318.0).contains(&x) && (0.0..19.0).contains(&y) {
@@ -35,7 +38,15 @@ pub fn hit_test([x, y]: [f32; 2], rows: usize) -> Option<Hit> {
}
let y = y as u32 - ROW_PITCH;
let row = (y / ROW_PITCH) as usize;
- (row < rows.min(VISIBLE_ROWS) && y % ROW_PITCH < ROW_HEIGHT).then_some(Hit::Row(row))
+ if row >= rows.min(VISIBLE_ROWS) || y % ROW_PITCH >= ROW_HEIGHT {
+ return None;
+ }
+ let command = COMMAND_LEFT as f32..(COMMAND_LEFT + BUTTON_WIDTH) as f32;
+ if command_buttons && command.contains(&x) {
+ Some(Hit::Command(row))
+ } else {
+ Some(Hit::Row(row))
+ }
}
pub struct Row<'a> {
@@ -56,10 +67,12 @@ pub struct Images {
ray: RgbaImage,
end: RgbaImage,
atlas: RgbaImage,
+ command_frame: [RgbaImage; 2],
+ command_icon: RgbaImage,
}
impl Images {
- pub fn load(vfs: &dyn Vfs, title: &str) -> Result<Self, String> {
+ pub fn load(vfs: &dyn Vfs) -> Result<Self, String> {
let [title_cap, frame, close, cap_off, cap_on, separator, emitter_off, emitter_on, ray, end] =
load_ui_sprites(
vfs,
@@ -77,7 +90,16 @@ impl Images {
"ccres_ray_ending",
],
)?;
- let [exit] = load_ui_sprites(vfs, "ui/hq.cfg", ["exit_icon"])?;
+ let [exit, command_off, command_on, command_icon] = load_ui_sprites(
+ vfs,
+ "ui/hq.cfg",
+ [
+ "exit_icon",
+ "buildscreen_button1",
+ "buildscreen_button2",
+ "buildscreen_direct_icon",
+ ],
+ )?;
let font = load_layout_font(vfs)?;
let [width, height] = EXTENT;
let mut header = RgbaImage {
@@ -93,7 +115,6 @@ impl Images {
] {
stamp(&mut header, sprite, rect, [255; 3]);
}
- text(&font, &mut header, title, [5, 0, 283, 19], [255; 3])?;
Ok(Self {
header,
font,
@@ -104,25 +125,50 @@ impl Images {
ray,
end,
atlas: load_ui_page(vfs, "ui_menu")?,
+ command_frame: [command_off, command_on],
+ command_icon,
})
}
- pub fn paint<'a>(&self, rows: impl Iterator<Item = Row<'a>>) -> Result<RgbaImage, String> {
+ pub fn paint<'a>(
+ &self,
+ title: &str,
+ command_buttons: bool,
+ rows: impl Iterator<Item = Row<'a>>,
+ ) -> Result<RgbaImage, String> {
let mut image = self.header.clone();
+ text(&self.font, &mut image, title, [5, 0, 283, 19], [255; 3])?;
for (index, row) in rows.take(VISIBLE_ROWS).enumerate() {
let y = (index as u32 + 1) * ROW_PITCH;
let bottom = y + ROW_HEIGHT;
let selected = usize::from(row.selected);
+ // The original bunker layout measures the label after two 35-unit controls.
+ let emitter = COMMAND_LEFT + if command_buttons { 2 * BUTTON_WIDTH } else { 0 };
+ let text_left = emitter + (TEXT_LEFT - COMMAND_LEFT);
for (sprite, left, right) in [
(&self.cap[selected], 0, 11),
(&self.frame, 10, 30),
(&self.separator, 29, 35),
- (&self.emitter[selected], 34, 45),
- (&self.ray, TEXT_LEFT, TEXT_RIGHT + 1),
+ (&self.emitter[selected], emitter, emitter + 11),
+ (&self.ray, text_left, TEXT_RIGHT + 1),
(&self.end, TEXT_RIGHT, EXTENT[0]),
] {
stamp(&mut image, sprite, [left, y, right, bottom], [255; 3]);
}
+ if command_buttons {
+ stamp(
+ &mut image,
+ &self.command_frame[selected],
+ [COMMAND_LEFT, y, COMMAND_LEFT + BUTTON_WIDTH + 1, bottom],
+ [255; 3],
+ );
+ stamp(
+ &mut image,
+ &self.command_icon,
+ [COMMAND_LEFT + 10, y + 2, COMMAND_LEFT + 25, y + 17],
+ [255; 3],
+ );
+ }
if let Some([x, atlas_y]) = building_glyph(row.class) {
let glyph = atlas_region(&self.atlas, [x, atlas_y, 15, 15])
.ok_or("building glyph outside ui_menu")?;
@@ -135,7 +181,7 @@ impl Images {
}
if let Some((width, rgba)) = row
.durability_percent
- .and_then(|percent| durability_fill(percent, TEXT_RIGHT - TEXT_LEFT))
+ .and_then(|percent| durability_fill(percent, TEXT_RIGHT - text_left))
{
let fill = RgbaImage {
width: 1,
@@ -145,7 +191,7 @@ impl Images {
stamp(
&mut image,
&fill,
- [TEXT_LEFT + 2, y + 3, TEXT_LEFT + width, bottom - 3],
+ [text_left + 2, y + 3, text_left + width, bottom - 3],
[255; 3],
);
}
@@ -153,7 +199,7 @@ impl Images {
&self.font,
&mut image,
row.label,
- [TEXT_LEFT, y, TEXT_RIGHT, bottom],
+ [text_left, y, TEXT_RIGHT, bottom],
if row.selected { [255; 3] } else { [128; 3] },
)?;
}
@@ -167,10 +213,14 @@ mod tests {
#[test]
fn building_list_hits_labels_icons_and_close_with_native_row_gaps() {
- assert_eq!(hit_test([350.0, 9.0], 4), Some(Hit::Close));
- assert_eq!(hit_test([68.0, 39.0], 4), None);
- assert_eq!(hit_test([68.0, 40.0], 4), Some(Hit::Row(1)));
- assert_eq!(hit_test([340.0, 49.0], 4), Some(Hit::Row(1)));
- assert_eq!(hit_test([340.0, 49.0], 1), None);
+ assert_eq!(hit_test([350.0, 9.0], 4, false), Some(Hit::Close));
+ assert_eq!(hit_test([68.0, 39.0], 4, false), None);
+ assert_eq!(hit_test([68.0, 40.0], 4, false), Some(Hit::Row(1)));
+ assert_eq!(hit_test([340.0, 49.0], 4, false), Some(Hit::Row(1)));
+ assert_eq!(hit_test([340.0, 49.0], 1, false), None);
+ assert_eq!(hit_test([102.0, 25.0], 1, true), Some(Hit::Command(0)));
+ assert_eq!(hit_test([102.0, 25.0], 1, false), Some(Hit::Row(0)));
+ assert_eq!(hit_test([119.0, 25.0], 1, true), Some(Hit::Command(0)));
+ assert_eq!(hit_test([120.0, 25.0], 1, true), Some(Hit::Row(0)));
}
}
diff --git a/crates/fparkan-assets/src/strategy_toolbar.rs b/crates/fparkan-assets/src/strategy_toolbar.rs
index 29737335..e7c5ca11 100644
--- a/crates/fparkan-assets/src/strategy_toolbar.rs
+++ b/crates/fparkan-assets/src/strategy_toolbar.rs
@@ -31,6 +31,8 @@ pub enum ToolbarAction {
Warbots,
/// Toggle the clan's factory panel.
Factories,
+ /// Toggle the clan's bunkers.
+ Bunkers,
/// Toggle the clan's other buildings.
OtherBuildings,
/// Toggle the satellite map.
@@ -44,6 +46,7 @@ pub fn command_button_at([x, y]: [f32; 2]) -> Option<ToolbarAction> {
0 => Some(ToolbarAction::Hero),
1 => Some(ToolbarAction::Warbots),
5 => Some(ToolbarAction::Factories),
+ 7 => Some(ToolbarAction::Bunkers),
8 => Some(ToolbarAction::OtherBuildings),
10 => Some(ToolbarAction::Map),
_ => None,
diff --git a/crates/fparkan-runtime/src/strategic_buildings.rs b/crates/fparkan-runtime/src/strategic_buildings.rs
index 91024136..2c97c3c9 100644
--- a/crates/fparkan-runtime/src/strategic_buildings.rs
+++ b/crates/fparkan-runtime/src/strategic_buildings.rs
@@ -1,10 +1,27 @@
-//! Live rows of the strategic «Другие здания» section.
+//! Live rows of the strategic building sections.
use crate::{strategic_map_readout::building_label, Engine, StartingCockpit};
use fparkan_world::{identity_metadata, registration_sequence, ObjectHandle};
use std::cmp::Reverse;
pub(super) const OTHER_BUILDINGS: u32 = 0x8000_044e;
+pub(super) const BUNKERS: u32 = 0x8007_0000;
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum BuildingSection {
+ Bunkers,
+ Other,
+}
+
+impl BuildingSection {
+ pub fn matches(self, class: u32) -> bool {
+ let mask = match self {
+ Self::Bunkers => BUNKERS,
+ Self::Other => OTHER_BUILDINGS,
+ };
+ class != 0 && class & mask == class
+ }
+}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BuildingRow {
@@ -16,7 +33,11 @@ pub struct BuildingRow {
}
/// Buildings of the operator's clan, most recently registered first.
-pub fn other_buildings(engine: &Engine, cockpit: StartingCockpit) -> Vec<BuildingRow> {
+pub fn building_rows(
+ engine: &Engine,
+ cockpit: StartingCockpit,
+ section: BuildingSection,
+) -> Vec<BuildingRow> {
let Some((mission, owner)) = engine.loaded.as_ref().zip(
identity_metadata(&engine.world, cockpit.handle)
.ok()
@@ -31,8 +52,7 @@ pub fn other_buildings(engine: &Engine, cockpit: StartingCockpit) -> Vec<Buildin
let handle = table.handle;
let draft = mission.object_drafts.get(table.original_id?.0 as usize)?;
let class = draft.unit_dat_header_flags?;
- if class == 0
- || class & OTHER_BUILDINGS != class
+ if !section.matches(class)
|| table.node_provider_depletion_marked
|| identity_metadata(&engine.world, handle).ok()?.owner_id != Some(owner)
{
@@ -85,7 +105,7 @@ mod tests {
.unwrap();
frame(&mut engine, 1).unwrap();
let cockpit = starting_cockpit(&engine).unwrap();
- let rows = other_buildings(&engine, cockpit);
+ let rows = building_rows(&engine, cockpit, BuildingSection::Other);
assert_eq!(
rows.iter().map(|row| row.label).collect::<Vec<_>>(),
[0x179e, 0x178f, 0x1794, 0x1799]
diff --git a/crates/fparkan-runtime/src/strategic_toolbar.rs b/crates/fparkan-runtime/src/strategic_toolbar.rs
index de35f695..a086a482 100644
--- a/crates/fparkan-runtime/src/strategic_toolbar.rs
+++ b/crates/fparkan-runtime/src/strategic_toolbar.rs
@@ -11,7 +11,7 @@ const SECTION_MASKS: [u32; 8] = [
0x8000_0400,
0x8000_0010,
0x8030_0000,
- 0x8007_0000,
+ crate::strategic_buildings::BUNKERS,
crate::strategic_buildings::OTHER_BUILDINGS,
];
diff --git a/crates/fparkan-runtime/src/strategic_view.rs b/crates/fparkan-runtime/src/strategic_view.rs
index daf6f17f..ccef3b82 100644
--- a/crates/fparkan-runtime/src/strategic_view.rs
+++ b/crates/fparkan-runtime/src/strategic_view.rs
@@ -201,6 +201,28 @@ impl CommandCamera {
})
}
+ /// Switches to a live bunker of the player clan and returns the previous post.
+ pub fn focus_bunker(
+ &mut self,
+ engine: &Engine,
+ cockpit: StartingCockpit,
+ target: ObjectHandle,
+ ) -> Option<CommandPost> {
+ use crate::strategic_buildings::{building_rows, BuildingSection};
+ let post = CommandPost::Bunker(target);
+ // iron3d+0x62ee0 skips the transition when this post already supplies the view.
+ if self.post == post
+ || !building_rows(engine, cockpit, BuildingSection::Bunkers)
+ .iter()
+ .any(|row| row.handle == target)
+ {
+ return None;
+ }
+ let previous = self.post;
+ *self = Self::new(engine, post)?;
+ Some(previous)
+ }
+
/// Advances the external view and returns the pose for this frame.
/// `building_height` reports the highest building hit on the downward segment.
pub fn sample(
@@ -325,7 +347,7 @@ mod tests {
MissionRequest, MissionStartupInput,
};
use fparkan_vfs::DirectoryVfs;
- use fparkan_world::OriginalObjectId;
+ use fparkan_world::{set_owner, OriginalObjectId};
use std::sync::Arc;
#[test]
@@ -425,5 +447,36 @@ mod tests {
})
.unwrap();
assert_eq!(raised.translation(), [previous[0], previous[1], 144.54639]);
+
+ use crate::strategic_buildings::{building_rows, BuildingSection};
+ let rows = building_rows(&engine, hero, BuildingSection::Bunkers);
+ assert_eq!(rows.len(), 1);
+ assert_eq!((rows[0].handle, rows[0].label), (bunker, 0x17cc));
+
+ camera.position[0] += 10.0;
+ assert_eq!(camera.focus_bunker(&engine, hero, bunker), None);
+ assert_eq!(camera.position[0], previous[0] + 10.0);
+ let other = engine
+ .loaded
+ .as_ref()
+ .unwrap()
+ .object_drafts
+ .iter()
+ .filter(|draft| {
+ draft
+ .unit_dat_header_flags
+ .is_some_and(|class| BuildingSection::Bunkers.matches(class))
+ })
+ .filter_map(|draft| crate::mission_object_handle(&engine, draft.original_id?))
+ .find(|&handle| handle != bunker)
+ .unwrap();
+ assert_eq!(camera.focus_bunker(&engine, hero, other), None);
+ let owner = identity_metadata(&engine.world, hero.handle)
+ .unwrap()
+ .owner_id;
+ set_owner(&mut engine.world, other, owner).unwrap();
+ assert_eq!(camera.focus_bunker(&engine, hero, other), post);
+ assert_eq!(camera.post, CommandPost::Bunker(other));
+ assert_eq!(camera.position, post_position(&engine, other).unwrap());
}
}
diff --git a/docs/appendices/knowledge-boundaries.md b/docs/appendices/knowledge-boundaries.md
index e1c3e6f3..a15e7433 100644
--- a/docs/appendices/knowledge-boundaries.md
+++ b/docs/appendices/knowledge-boundaries.md
@@ -345,6 +345,8 @@ seed и общий порядок Control RNG открыты. `control_resource_
бункера используется материал пола. В мобильной камере перенесены орбита
и поворот у края. Ручное изменение дистанции и сверка входа/возврата
в окне оригинала остаются открытыми.
+Список бункеров переключает опору внешней камеры. Отдельный переход
+«Ручное управление» (состояние 6), кабина бункера и её приборы открыты.
## Render state
diff --git a/docs/appendices/ui-shell.md b/docs/appendices/ui-shell.md
index 86f73402..6ecf5c7b 100644
--- a/docs/appendices/ui-shell.md
+++ b/docs/appendices/ui-shell.md
@@ -543,6 +543,26 @@ RVA `0x97fe0` передаёт признак серии в заявку `0x205`
бесплатной сборки у выбранного завода. Строки подсказок задаёт RVA `0x965f0`.
[Хеши GOG-сборок](../reference/original-binaries.md)
+### Бункеры
+
+RVA `0x85160` открывает список бункеров собственного клана по маске
+`0x80070000`. Общая строка показывает название, прочность и значок
+размера, а щелчок по строке меняет белую отметку на спутниковой карте.
+Левая кнопка получает значок `buildscreen_direct_icon` и рамку из `ui/hq.cfg`.
+При наведении показывается строка «Стратегическое управление»
+(`iron3d.dll`, ресурс `0x5ed`).
+
+Кнопка выбирает бункер и переводит внешний вид на его позицию. Обработчик
+RVA `0x86480` передаёт переходу состояние 4, затем RVA `0x64290` ставит
+камеру над бункером и привязывает к нему предел области движения. RVA
+`0x62ee0` различает новый бункер и уже присутствующий в стеке. Повторный
+щелчок по пульту текущего бункера сохраняет положение и наклон камеры.
+Кнопка с рукой выбирает состояние 6. При входе из стратегического вида RVA
+`0x645a0` передаёт бункер камере, а сама игра показывает прицел и два
+боковых прибора. В «Двух крепостях» справа виден силуэт среднего бункера,
+слева — выбранное строение и дальность до него.
+[Хеши GOG-сборок](../reference/original-binaries.md)
+
### Другие здания
Кнопка «Другие здания» выбирает группу `0x8000044e`