Added wine & dxvk version selection during initial setup

This commit is contained in:
Observer KRypt0n_ 2022-08-02 19:57:17 +02:00
parent b5fe109be6
commit ceffbe795a
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 64 additions and 22 deletions

View file

@ -21,22 +21,10 @@ Gtk.Box page {
Adw.ComboRow wine_version { Adw.ComboRow wine_version {
title: "Wine version"; title: "Wine version";
model: Gtk.StringList {
strings [
"Wine-GE-Proton 7-22"
]
};
} }
Adw.ComboRow dxvk_version { Adw.ComboRow dxvk_version {
title: "DXVK version"; title: "DXVK version";
model: Gtk.StringList {
strings [
"dxvk-1.10.2"
]
};
} }
} }

View file

@ -20,8 +20,6 @@ mod page_6;
use crate::ui::*; use crate::ui::*;
use crate::ui::components::progress_bar::*; use crate::ui::components::progress_bar::*;
use crate::lib::wine::Version as WineVersion;
use crate::lib::dxvk::Version as DxvkVersion;
use crate::lib::wine_prefix::WinePrefix; use crate::lib::wine_prefix::WinePrefix;
use crate::lib::config; use crate::lib::config;
@ -208,8 +206,8 @@ impl App {
let progress_bar = this.widgets.page_5.progress_bar.clone(); let progress_bar = this.widgets.page_5.progress_bar.clone();
let wine_version = WineVersion::latest().unwrap(); let wine_version = this.widgets.page_5.get_wine_version().clone();
let dxvk_version = DxvkVersion::latest().unwrap(); let dxvk_version = this.widgets.page_5.get_dxvk_version().clone();
let wine_version_copy = wine_version.clone(); let wine_version_copy = wine_version.clone();
@ -297,8 +295,9 @@ impl App {
this.widgets.carousel.scroll_to(&this.widgets.page_6.page, true); this.widgets.carousel.scroll_to(&this.widgets.page_6.page, true);
} }
// FIXME
Actions::Restart => { Actions::Restart => {
Command::new(std::env::current_exe().unwrap()).spawn().unwrap();
this.widgets.window.close(); this.widgets.window.close();
} }

View file

@ -1,5 +1,8 @@
use gtk4 as gtk; use gtk4 as gtk;
use libadwaita as adw; use libadwaita::{self as adw, prelude::*};
use crate::lib::wine::{Version as WineVersion, List as WineList};
use crate::lib::dxvk::{Version as DxvkVersion, List as DxvkList};
use crate::ui::*; use crate::ui::*;
use crate::ui::components::progress_bar::ProgressBar; use crate::ui::components::progress_bar::ProgressBar;
@ -14,14 +17,17 @@ pub struct Page {
pub download_button: gtk::Button, pub download_button: gtk::Button,
pub exit_button: gtk::Button, pub exit_button: gtk::Button,
pub progress_bar: ProgressBar pub progress_bar: ProgressBar,
pub wine_versions: Vec<WineVersion>,
pub dxvk_versions: Vec<DxvkVersion>
} }
impl Page { impl Page {
pub fn new() -> Result<Self, String> { pub fn new() -> Result<Self, String> {
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_5.ui"); let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_5.ui");
Ok(Self { let mut result = Self {
page: get_object(&builder, "page")?, page: get_object(&builder, "page")?,
wine_version: get_object(&builder, "wine_version")?, wine_version: get_object(&builder, "wine_version")?,
@ -34,7 +40,56 @@ impl Page {
get_object(&builder, "progress_bar")?, get_object(&builder, "progress_bar")?,
get_object(&builder, "buttons_group")?, get_object(&builder, "buttons_group")?,
get_object(&builder, "progress_bar_group")? get_object(&builder, "progress_bar_group")?
) ),
})
wine_versions: Vec::new(),
dxvk_versions: Vec::new()
};
// Add wine versions
let model = gtk::StringList::new(&[]);
let versions = match WineList::get() {
Ok(versions) => versions,
Err(err) => return Err(err.to_string())
};
for version in &versions[0].versions {
if version.recommended {
model.append(&version.title);
result.wine_versions.push(version.clone());
}
}
result.wine_version.set_model(Some(&model));
// Add DXVK versions
let model = gtk::StringList::new(&[]);
let versions = match DxvkList::get() {
Ok(versions) => versions,
Err(err) => return Err(err.to_string())
};
for version in &versions.vanilla {
if version.recommended {
model.append(&version.version);
result.dxvk_versions.push(version.clone());
}
}
result.dxvk_version.set_model(Some(&model));
Ok(result)
}
pub fn get_wine_version(&self) -> &WineVersion {
&self.wine_versions[self.wine_version.selected() as usize]
}
pub fn get_dxvk_version(&self) -> &DxvkVersion {
&self.dxvk_versions[self.dxvk_version.selected() as usize]
} }
} }