aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-assets/src
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 18:57:36 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 18:57:36 +0300
commit1fd51e5bbcfb4d5590fbc1ded8308fc40f6158f4 (patch)
tree9ef8276c399e238a2a692862de09f54bf5dcee65 /crates/fparkan-assets/src
parent077bead07a76908ac4e0e2b84de3940256cf6fd1 (diff)
downloadfparkan-1fd51e5bbcfb4d5590fbc1ded8308fc40f6158f4.tar.xz
fparkan-1fd51e5bbcfb4d5590fbc1ded8308fc40f6158f4.zip
feat(ui): enable manual control from the bunker list
Use the active Control camera record and its separate CPT origin and direction for the fixed turret. The original hand control opens the cockpit, its two weapon slots and aim tracks while leaving the operator at the command post. Verified from the stock Two Fortresses start against the GOG cockpit with Vulkan validation. The licensed tests cover the native camera pose, mounted weapon selection and stationary bunker and operator.
Diffstat (limited to 'crates/fparkan-assets/src')
-rw-r--r--crates/fparkan-assets/src/lib.rs8
-rw-r--r--crates/fparkan-assets/src/strategic_buildings.rs47
2 files changed, 40 insertions, 15 deletions
diff --git a/crates/fparkan-assets/src/lib.rs b/crates/fparkan-assets/src/lib.rs
index 55c2d611..6d21e70b 100644
--- a/crates/fparkan-assets/src/lib.rs
+++ b/crates/fparkan-assets/src/lib.rs
@@ -3611,7 +3611,13 @@ fn prepare_component_control_from_resource<R: ResourceRepository>(
.typed_records
.iter()
.any(|record| record.tag == 2 && !record.values.is_empty());
- let Some(point_source) = point_source.filter(|_| has_effect_rows || has_weapon_points) else {
+ let has_camera_points = control
+ .typed_records
+ .iter()
+ .any(|record| record.tag == 4 && !record.values.is_empty());
+ let Some(point_source) =
+ point_source.filter(|_| has_effect_rows || has_weapon_points || has_camera_points)
+ else {
return Ok(Some(control));
};
let Some(point_payload) =
diff --git a/crates/fparkan-assets/src/strategic_buildings.rs b/crates/fparkan-assets/src/strategic_buildings.rs
index 0ed6d140..473004a7 100644
--- a/crates/fparkan-assets/src/strategic_buildings.rs
+++ b/crates/fparkan-assets/src/strategic_buildings.rs
@@ -18,6 +18,7 @@ const TEXT_RIGHT: u32 = 313;
const COMMAND_LEFT: u32 = 34;
const BUTTON_WIDTH: u32 = 35;
pub const COMMAND_TOOLTIP: u32 = 0x5ed;
+pub const MANUAL_TOOLTIP: u32 = 0x5de;
pub const VISIBLE_ROWS: usize = (EXTENT[1] / ROW_PITCH - 1) as usize;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -25,6 +26,7 @@ pub enum Hit {
Close,
Row(usize),
Command(usize),
+ Manual(usize),
}
pub fn hit_test([x, y]: [f32; 2], rows: usize, command_buttons: bool) -> Option<Hit> {
@@ -42,8 +44,11 @@ pub fn hit_test([x, y]: [f32; 2], rows: usize, command_buttons: bool) -> Option<
return None;
}
let command = COMMAND_LEFT as f32..(COMMAND_LEFT + BUTTON_WIDTH) as f32;
+ let manual = command.end..command.end + BUTTON_WIDTH as f32;
if command_buttons && command.contains(&x) {
Some(Hit::Command(row))
+ } else if command_buttons && manual.contains(&x) {
+ Some(Hit::Manual(row))
} else {
Some(Hit::Row(row))
}
@@ -55,6 +60,7 @@ pub struct Row<'a> {
pub size: u32,
pub selected: bool,
pub durability_percent: Option<i32>,
+ pub manual_control: bool,
}
pub struct Images {
@@ -69,6 +75,7 @@ pub struct Images {
atlas: RgbaImage,
command_frame: [RgbaImage; 2],
command_icon: RgbaImage,
+ manual_icon: RgbaImage,
}
impl Images {
@@ -90,7 +97,7 @@ impl Images {
"ccres_ray_ending",
],
)?;
- let [exit, command_off, command_on, command_icon] = load_ui_sprites(
+ let [exit, command_off, command_on, command_icon, manual_icon] = load_ui_sprites(
vfs,
"ui/hq.cfg",
[
@@ -98,6 +105,7 @@ impl Images {
"buildscreen_button1",
"buildscreen_button2",
"buildscreen_direct_icon",
+ "buildscreen_hq_icon",
],
)?;
let font = load_layout_font(vfs)?;
@@ -127,6 +135,7 @@ impl Images {
atlas: load_ui_page(vfs, "ui_menu")?,
command_frame: [command_off, command_on],
command_icon,
+ manual_icon,
})
}
@@ -156,18 +165,27 @@ impl Images {
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],
- );
+ for (offset, icon, enabled) in [
+ (COMMAND_LEFT, &self.command_icon, true),
+ (
+ COMMAND_LEFT + BUTTON_WIDTH,
+ &self.manual_icon,
+ row.manual_control,
+ ),
+ ] {
+ stamp(
+ &mut image,
+ &self.command_frame[selected],
+ [offset, y, offset + BUTTON_WIDTH + 1, bottom],
+ [255; 3],
+ );
+ stamp(
+ &mut image,
+ icon,
+ [offset + 10, y + 2, offset + 25, y + 17],
+ if enabled { [255; 3] } else { [128; 3] },
+ );
+ }
}
if let Some([x, atlas_y]) = building_glyph(row.class) {
let glyph = atlas_region(&self.atlas, [x, atlas_y, 15, 15])
@@ -221,6 +239,7 @@ mod tests {
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)));
+ assert_eq!(hit_test([120.0, 25.0], 1, true), Some(Hit::Manual(0)));
+ assert_eq!(hit_test([155.0, 25.0], 1, true), Some(Hit::Row(0)));
}
}