feat: display module for chunithm

Also make the progress bar all shiny
This commit is contained in:
2025-04-12 17:33:39 +00:00
parent 7db36b7bc0
commit 6270fce05f
17 changed files with 188 additions and 83 deletions

View File

@ -1,6 +1,7 @@
use crate::model::profile::{Display, DisplayMode};
use crate::{model::{misc::Game, profile::{Display, DisplayMode}}, util::bool_to_01};
use anyhow::Result;
use displayz::{query_displays, DisplaySet};
use ini::Ini;
use tauri::{AppHandle, Listener};
#[derive(Clone)]
@ -30,7 +31,7 @@ impl Display {
});
}
pub fn line_up(&self) -> Result<Option<DisplayInfo>> {
pub fn prepare(&self) -> Result<Option<DisplayInfo>> {
use anyhow::anyhow;
use displayz::{query_displays, Orientation, Resolution, Frequency};
@ -63,11 +64,23 @@ impl Display {
set: Some(display_set.clone()),
};
if self.rotation == 90 || self.rotation == 270 {
if let Some(rotation) = self.rotation {
let rez = settings.borrow_mut().resolution;
settings.borrow_mut().orientation = if self.rotation == 90 { Orientation::PortraitFlipped } else { Orientation::Portrait };
settings.borrow_mut().orientation = match rotation {
0 => Orientation::Landscape,
90 => Orientation::PortraitFlipped,
180 => Orientation::LandscapeFlipped,
270 => Orientation::Portrait,
_ => panic!("Invalid display rotation")
};
if rez.height < rez.width {
settings.borrow_mut().resolution = Resolution::new(rez.height, rez.width);
if rotation == 90 || rotation == 270 {
settings.borrow_mut().resolution = Resolution::new(rez.height, rez.width);
}
} else {
if rotation == 0 || rotation == 180 {
settings.borrow_mut().resolution = Resolution::new(rez.height, rez.width);
}
}
}
@ -99,6 +112,20 @@ impl Display {
Ok(Some(res))
}
pub fn line_up(&self, game: Game, ini: &mut Ini) {
if game == Game::Chunithm {
let autism = self.monitor_index_override.unwrap_or(0).to_string();
ini.with_section(Some("gfx"))
.set("enable", "1")
.set("windowed", bool_to_01(self.mode != DisplayMode::Fullscreen))
.set("framed", bool_to_01(self.mode == DisplayMode::Window))
.set("monitor", if self.dont_switch_primary { &autism } else { "0" });
ini.with_section(Some("system"))
.set("dipsw2", bool_to_01(self.frequency == 60))
.set("dipsw3", bool_to_01(self.frequency == 60));
}
}
pub fn clean_up(info: &DisplayInfo) -> Result<()> {
use anyhow::anyhow;