change progress display for font installation

This commit is contained in:
ALEZ-DEV 2024-05-04 19:34:30 +02:00
parent 8bbbeb59c0
commit 2d642f412e
2 changed files with 15 additions and 22 deletions

View File

@ -70,12 +70,9 @@ async fn main() {
} }
GameState::FontNotInstalled => { GameState::FontNotInstalled => {
info!("Fonts not installed, installing it..."); info!("Fonts not installed, installing it...");
GameManager::install_font( GameManager::install_font(&proton.clone().unwrap())
&proton.clone().unwrap(), .await
DownloadReporter::create(false), .expect("Failed to install fonts");
)
.await
.expect("Failed to install fonts");
info!("Fonts installed"); info!("Fonts installed");
} }
GameState::DependecieNotInstalled => { GameState::DependecieNotInstalled => {

View File

@ -67,47 +67,43 @@ impl GameManager {
Ok(()) Ok(())
} }
pub async fn install_font<P>(proton: &Proton, progress: Arc<P>) -> anyhow::Result<()> pub async fn install_font(proton: &Proton) -> anyhow::Result<()> {
where
P: Reporter + 'static,
{
let wine_with_proton_prefix = proton // wine take the data/wine/pfx prefix, but we want the data/wine prefix let wine_with_proton_prefix = proton // wine take the data/wine/pfx prefix, but we want the data/wine prefix
.wine() .wine()
.clone() .clone()
.with_prefix(proton.wine().prefix.parent().unwrap()); .with_prefix(proton.wine().prefix.parent().unwrap());
progress.setup(Some(10), ""); info!("0/10 font installed");
progress.progress(0);
wine_with_proton_prefix.install_font(Font::Arial)?; wine_with_proton_prefix.install_font(Font::Arial)?;
progress.progress(1); info!("1/10 font installed");
wine_with_proton_prefix.install_font(Font::Andale)?; wine_with_proton_prefix.install_font(Font::Andale)?;
progress.progress(2); info!("2/10 font installed");
wine_with_proton_prefix.install_font(Font::Courier)?; wine_with_proton_prefix.install_font(Font::Courier)?;
progress.progress(3); info!("3/10 font installed");
wine_with_proton_prefix.install_font(Font::ComicSans)?; wine_with_proton_prefix.install_font(Font::ComicSans)?;
progress.progress(4); info!("4/10 font installed");
wine_with_proton_prefix.install_font(Font::Georgia)?; wine_with_proton_prefix.install_font(Font::Georgia)?;
progress.progress(5); info!("5/10 font installed");
wine_with_proton_prefix.install_font(Font::Impact)?; wine_with_proton_prefix.install_font(Font::Impact)?;
progress.progress(6); info!("6/10 font installed");
wine_with_proton_prefix.install_font(Font::Times)?; wine_with_proton_prefix.install_font(Font::Times)?;
progress.progress(7); info!("7/10 font installed");
wine_with_proton_prefix.install_font(Font::Trebuchet)?; wine_with_proton_prefix.install_font(Font::Trebuchet)?;
progress.progress(8); info!("8/10 font installed");
wine_with_proton_prefix.install_font(Font::Verdana)?; wine_with_proton_prefix.install_font(Font::Verdana)?;
progress.progress(9); info!("9/10 font installed");
wine_with_proton_prefix.install_font(Font::Webdings)?; wine_with_proton_prefix.install_font(Font::Webdings)?;
progress.progress(10); info!("10/10 font installed");
let mut config = GameState::get_config().await; let mut config = GameState::get_config().await;
config.is_font_installed = true; config.is_font_installed = true;