Skip to content

Commit

Permalink
feat: also position the new DMD window (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
francisdb authored Feb 12, 2025
1 parent 6ce13ab commit d981266
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions vpxtool_cli/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,13 @@ fn auto_position_dmd(config: &ResolvedConfig, info: &&IndexedTable) -> Result<St
hole.width(),
hole.height(),
);

table_config.set_window_position(WindowType::DMD, dmd_x, dmd_y);
table_config.set_window_size(
WindowType::DMD,
hole.width(),
hole.height(),
);
table_config.write(&table_ini_path).unwrap();
Ok(format!(
"DMD window dimensions an position in {} updated to {}x{} at {},{}",
Expand Down
17 changes: 15 additions & 2 deletions vpxtool_shared/src/vpinball_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum WindowType {
PUPDMD,
PUPPlayfield,
PUPFullDMD,
DMD,
}
impl Display for WindowType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand All @@ -31,6 +32,7 @@ impl Display for WindowType {
WindowType::PUPDMD => write!(f, "PUPDMD"),
WindowType::PUPPlayfield => write!(f, "PUPPlayfield"),
WindowType::PUPFullDMD => write!(f, "PUPFullDMD"),
WindowType::DMD => write!(f, "DMD"),
}
}
}
Expand All @@ -47,12 +49,14 @@ fn config_prefix(window_type: WindowType) -> &'static str {
WindowType::PUPDMD => "PUPDMDWindow",
WindowType::PUPPlayfield => "PUPPlayfieldWindow",
WindowType::PUPFullDMD => "PUPFullDMDWindow",
WindowType::DMD => "DMD",
}
}

fn section_name(window_type: WindowType) -> String {
match window_type {
WindowType::Playfield => "Player".to_string(),
WindowType::DMD => "DMD".to_string(),
_ => "Standalone".to_string(),
}
}
Expand Down Expand Up @@ -135,6 +139,15 @@ impl VPinballConfig {
pub fn is_window_enabled(&self, window_type: WindowType) -> bool {
match window_type {
WindowType::Playfield => true,
WindowType::DMD => {
let section = section_name(window_type);
if let Some(ini_section) = self.ini.section(Some(section)) {
let prefix = config_prefix(window_type);
ini_section.get(format!("{}Output", prefix)) == Some("2")
} else {
false
}
}
WindowType::B2SBackglass => {
let section = section_name(window_type);
if let Some(ini_section) = self.ini.section(Some(section)) {
Expand Down Expand Up @@ -243,11 +256,11 @@ impl VPinballConfig {
// see https://github.com/zonyitoo/rust-ini/issues/77

let x_suffix = match window_type {
WindowType::Playfield => "WndX",
WindowType::Playfield | WindowType::DMD => "WndX",
_ => "X",
};
let y_suffix = match window_type {
WindowType::Playfield => "WndY",
WindowType::Playfield | WindowType::DMD => "WndY",
_ => "Y",
};

Expand Down

0 comments on commit d981266

Please sign in to comment.