mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2024-11-22 12:49:02 +03:00
Added dxvks downloading and deleting functionality
This commit is contained in:
parent
741513ab91
commit
b6bfc4d2ec
10 changed files with 115 additions and 40 deletions
|
@ -1,81 +1,97 @@
|
||||||
{
|
{
|
||||||
"vanilla": [
|
"vanilla": [
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.10.2",
|
||||||
"version": "1.10.2",
|
"version": "1.10.2",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.2/dxvk-1.10.2.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.2/dxvk-1.10.2.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.10.1",
|
||||||
"version": "1.10.1",
|
"version": "1.10.1",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.1/dxvk-1.10.1.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.1/dxvk-1.10.1.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.10",
|
||||||
"version": "1.10",
|
"version": "1.10",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10/dxvk-1.10.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10/dxvk-1.10.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.9.4",
|
||||||
"version": "1.9.4",
|
"version": "1.9.4",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.4/dxvk-1.9.4.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.4/dxvk-1.9.4.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.9.3",
|
||||||
"version": "1.9.3",
|
"version": "1.9.3",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.3/dxvk-1.9.3.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.3/dxvk-1.9.3.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.9.2",
|
||||||
"version": "1.9.2",
|
"version": "1.9.2",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.2/dxvk-1.9.2.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.2/dxvk-1.9.2.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.9.1",
|
||||||
"version": "1.9.1",
|
"version": "1.9.1",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.1/dxvk-1.9.1.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.1/dxvk-1.9.1.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.9",
|
||||||
"version": "1.9",
|
"version": "1.9",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9/dxvk-1.9.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9/dxvk-1.9.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.8.1",
|
||||||
"version": "1.8.1",
|
"version": "1.8.1",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8.1/dxvk-1.8.1.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8.1/dxvk-1.8.1.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.8",
|
||||||
"version": "1.8",
|
"version": "1.8",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8/dxvk-1.8.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8/dxvk-1.8.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.7.3",
|
||||||
"version": "1.7.3",
|
"version": "1.7.3",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.3/dxvk-1.7.3.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.3/dxvk-1.7.3.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.7.2",
|
||||||
"version": "1.7.2",
|
"version": "1.7.2",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.2/dxvk-1.7.2.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.2/dxvk-1.7.2.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.7.1",
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.1/dxvk-1.7.1.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.1/dxvk-1.7.1.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.7",
|
||||||
"version": "1.7",
|
"version": "1.7",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7/dxvk-1.7.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7/dxvk-1.7.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.6.1",
|
||||||
"version": "1.6.1",
|
"version": "1.6.1",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.6.1/dxvk-1.6.1.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.6.1/dxvk-1.6.1.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-1.6",
|
||||||
"version": "1.6",
|
"version": "1.6",
|
||||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.6/dxvk-1.6.tar.gz",
|
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.6/dxvk-1.6.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
|
@ -83,61 +99,73 @@
|
||||||
],
|
],
|
||||||
"async": [
|
"async": [
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.10.2",
|
||||||
"version": "1.10.2",
|
"version": "1.10.2",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10.2/dxvk-async-1.10.2.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10.2/dxvk-async-1.10.2.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.10.1",
|
||||||
"version": "1.10.1",
|
"version": "1.10.1",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10.1/dxvk-async-1.10.1.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10.1/dxvk-async-1.10.1.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.10",
|
||||||
"version": "1.10",
|
"version": "1.10",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10/dxvk-async-1.10.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10/dxvk-async-1.10.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.9.4",
|
||||||
"version": "1.9.4",
|
"version": "1.9.4",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.4/dxvk-async-1.9.4.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.4/dxvk-async-1.9.4.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.9.3",
|
||||||
"version": "1.9.3",
|
"version": "1.9.3",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.3/dxvk-async-1.9.3.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.3/dxvk-async-1.9.3.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.9.2",
|
||||||
"version": "1.9.2",
|
"version": "1.9.2",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.4/dxvk-async-1.9.4.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.4/dxvk-async-1.9.4.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.9.1",
|
||||||
"version": "1.9.1",
|
"version": "1.9.1",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.1/dxvk-async-1.9.1.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.1/dxvk-async-1.9.1.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.9",
|
||||||
"version": "1.9",
|
"version": "1.9",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9/dxvk-async-1.9.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9/dxvk-async-1.9.tar.gz",
|
||||||
"recommended": true
|
"recommended": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.8.1",
|
||||||
"version": "1.8.1",
|
"version": "1.8.1",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.8.1/dxvk-async-1.8.1.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.8.1/dxvk-async-1.8.1.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.8",
|
||||||
"version": "1.8",
|
"version": "1.8",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.8.1/dxvk-async-1.8.1.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.8.1/dxvk-async-1.8.1.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.7.3",
|
||||||
"version": "1.7.3",
|
"version": "1.7.3",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.7.3/dxvk-async-1.7.3.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.7.3/dxvk-async-1.7.3.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "dxvk-async-1.7.2",
|
||||||
"version": "1.7.2",
|
"version": "1.7.2",
|
||||||
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.7.2/dxvk-async-1.7.2.tar.gz",
|
"uri": "https://github.com/Sporif/dxvk-async/releases/download/1.7.2/dxvk-async-1.7.2.tar.gz",
|
||||||
"recommended": false
|
"recommended": false
|
||||||
|
|
|
@ -31,7 +31,6 @@ Gtk.Box preferences {
|
||||||
stack: stack;
|
stack: stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
separator: Gtk.Separator {};
|
|
||||||
content: Gtk.Stack stack {};
|
content: Gtk.Stack stack {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ Adw.PreferencesPage general_page {
|
||||||
Adw.PreferencesGroup {
|
Adw.PreferencesGroup {
|
||||||
title: "Wine version";
|
title: "Wine version";
|
||||||
|
|
||||||
Adw.ComboRow {
|
Adw.ComboRow wine_selected {
|
||||||
title: "Selected version";
|
title: "Selected version";
|
||||||
|
|
||||||
model: Gtk.StringList {
|
model: Gtk.StringList {
|
||||||
|
|
|
@ -130,6 +130,7 @@ pub struct Game {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub voices: Vec<String>,
|
pub voices: Vec<String>,
|
||||||
pub wine: Wine,
|
pub wine: Wine,
|
||||||
|
pub dxvk: Dxvk,
|
||||||
pub enhancements: Enhancements,
|
pub enhancements: Enhancements,
|
||||||
pub environment: HashMap<String, String>
|
pub environment: HashMap<String, String>
|
||||||
}
|
}
|
||||||
|
@ -145,6 +146,7 @@ impl Default for Game {
|
||||||
String::from("en-us")
|
String::from("en-us")
|
||||||
],
|
],
|
||||||
wine: Wine::default(),
|
wine: Wine::default(),
|
||||||
|
dxvk: Dxvk::default(),
|
||||||
enhancements: Enhancements::default(),
|
enhancements: Enhancements::default(),
|
||||||
environment: HashMap::new()
|
environment: HashMap::new()
|
||||||
}
|
}
|
||||||
|
@ -178,6 +180,24 @@ impl Default for Wine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Dxvk {
|
||||||
|
pub builds: String,
|
||||||
|
pub selected: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Dxvk {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
builds: match launcher_dir() {
|
||||||
|
Some(dir) => format!("{}/dxvks", dir),
|
||||||
|
None => String::new()
|
||||||
|
},
|
||||||
|
selected: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]
|
||||||
pub struct Enhancements {
|
pub struct Enhancements {
|
||||||
pub fsr: Fsr,
|
pub fsr: Fsr,
|
||||||
|
|
|
@ -16,6 +16,7 @@ impl List {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Version {
|
pub struct Version {
|
||||||
|
pub name: String,
|
||||||
pub version: String,
|
pub version: String,
|
||||||
pub uri: String,
|
pub uri: String,
|
||||||
pub recommended: bool
|
pub recommended: bool
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use gtk4::{self as gtk, prelude::*};
|
use gtk4::{self as gtk, prelude::*};
|
||||||
use libadwaita::{self as adw, prelude::*};
|
use libadwaita::{self as adw, prelude::*};
|
||||||
|
|
||||||
use gtk::glib;
|
|
||||||
use gtk::Align;
|
use gtk::Align;
|
||||||
|
|
||||||
use crate::lib::dxvk::Version;
|
use crate::lib::dxvk::Version;
|
||||||
|
use crate::ui::traits::download_component::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DxvkRow {
|
pub struct DxvkRow {
|
||||||
|
@ -48,31 +48,30 @@ impl DxvkRow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn download(&self) {
|
pub fn update_state<T: ToString>(&self, dxvks_folder: T) {
|
||||||
let (sender, receiver) = glib::MainContext::channel::<i32>(glib::PRIORITY_DEFAULT);
|
if self.is_downloaded(dxvks_folder) {
|
||||||
let this = self.clone();
|
self.button.set_icon_name("user-trash-symbolic");
|
||||||
|
|
||||||
this.progress_bar.set_visible(true);
|
|
||||||
this.button.set_visible(false);
|
|
||||||
|
|
||||||
receiver.attach(None, move |fraction| {
|
|
||||||
this.progress_bar.set_fraction(fraction as f64 / 100f64);
|
|
||||||
this.progress_bar.set_text(Some(&format!("Downloading: {}%", fraction)));
|
|
||||||
|
|
||||||
if fraction == 100 {
|
|
||||||
this.progress_bar.set_visible(false);
|
|
||||||
this.button.set_visible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glib::Continue(true)
|
else {
|
||||||
});
|
self.button.set_icon_name("document-save-symbolic");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
impl DownloadComponent for DxvkRow {
|
||||||
for i in 1..101 {
|
fn get_component_path<T: ToString>(&self, installation_path: T) -> String {
|
||||||
std::thread::sleep(std::time::Duration::from_millis(150));
|
format!("{}/{}", installation_path.to_string(), self.version.name)
|
||||||
|
}
|
||||||
|
|
||||||
sender.send(i);
|
fn get_downloading_widgets(&self) -> (gtk::ProgressBar, gtk::Button) {
|
||||||
|
(self.progress_bar.clone(), self.button.clone())
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
fn get_download_uri(&self) -> String {
|
||||||
|
self.version.uri.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl Send for DxvkRow {}
|
||||||
|
unsafe impl Sync for DxvkRow {}
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub struct AppWidgets {
|
||||||
|
|
||||||
impl AppWidgets {
|
impl AppWidgets {
|
||||||
fn try_get() -> Result<Self, String> {
|
fn try_get() -> Result<Self, String> {
|
||||||
let builder = gtk::Builder::from_string(include_str!("../../../assets/ui/.dist/preferences_enhanced.ui"));
|
let builder = gtk::Builder::from_string(include_str!("../../../assets/ui/.dist/preferences_enhancements.ui"));
|
||||||
|
|
||||||
let result = Self {
|
let result = Self {
|
||||||
page: get_object(&builder, "enhanced_page")?,
|
page: get_object(&builder, "enhanced_page")?,
|
||||||
|
@ -164,7 +164,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title() -> String {
|
pub fn title() -> String {
|
||||||
String::from("Enhanced")
|
String::from("Enhancements")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_page(&self) -> adw::PreferencesPage {
|
pub fn get_page(&self) -> adw::PreferencesPage {
|
|
@ -34,6 +34,8 @@ pub struct AppWidgets {
|
||||||
pub game_version: gtk::Label,
|
pub game_version: gtk::Label,
|
||||||
pub patch_version: gtk::Label,
|
pub patch_version: gtk::Label,
|
||||||
|
|
||||||
|
pub wine_selected: adw::ComboRow,
|
||||||
|
|
||||||
pub wine_groups: adw::PreferencesGroup,
|
pub wine_groups: adw::PreferencesGroup,
|
||||||
pub wine_recommended_only: gtk::Switch,
|
pub wine_recommended_only: gtk::Switch,
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ impl AppWidgets {
|
||||||
game_version: get_object(&builder, "game_version")?,
|
game_version: get_object(&builder, "game_version")?,
|
||||||
patch_version: get_object(&builder, "patch_version")?,
|
patch_version: get_object(&builder, "patch_version")?,
|
||||||
|
|
||||||
|
wine_selected: get_object(&builder, "wine_selected")?,
|
||||||
|
|
||||||
wine_groups: get_object(&builder, "wine_groups")?,
|
wine_groups: get_object(&builder, "wine_groups")?,
|
||||||
wine_recommended_only: get_object(&builder, "wine_recommended_only")?,
|
wine_recommended_only: get_object(&builder, "wine_recommended_only")?,
|
||||||
|
|
||||||
|
@ -108,6 +112,8 @@ impl AppWidgets {
|
||||||
for version in versions {
|
for version in versions {
|
||||||
let row = DxvkRow::new(version);
|
let row = DxvkRow::new(version);
|
||||||
|
|
||||||
|
row.update_state(&config.game.dxvk.builds);
|
||||||
|
|
||||||
match i {
|
match i {
|
||||||
0 => result.dxvk_vanilla.add_row(&row.row),
|
0 => result.dxvk_vanilla.add_row(&row.row),
|
||||||
1 => result.dxvk_async.add_row(&row.row),
|
1 => result.dxvk_async.add_row(&row.row),
|
||||||
|
@ -129,7 +135,7 @@ impl AppWidgets {
|
||||||
/// It may be helpful if you want to add the same event for several widgets, or call an action inside of another action
|
/// It may be helpful if you want to add the same event for several widgets, or call an action inside of another action
|
||||||
#[derive(Debug, Clone, glib::Downgrade)]
|
#[derive(Debug, Clone, glib::Downgrade)]
|
||||||
pub enum Actions {
|
pub enum Actions {
|
||||||
DownloadDXVK(Rc<usize>),
|
DxvkPerformAction(Rc<usize>),
|
||||||
WinePerformAction(Rc<(usize, usize)>)
|
WinePerformAction(Rc<(usize, usize)>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +187,10 @@ impl App {
|
||||||
|
|
||||||
/// Add default events and values to the widgets
|
/// Add default events and values to the widgets
|
||||||
fn init_events(self) -> Self {
|
fn init_events(self) -> Self {
|
||||||
|
/*self.widgets.wine_selected.connect_selected_notify(|_| {
|
||||||
|
|
||||||
|
});*/
|
||||||
|
|
||||||
// Set wine recommended only switcher event
|
// Set wine recommended only switcher event
|
||||||
self.widgets.wine_recommended_only.connect_state_notify(clone!(@strong self as this => move |switcher| {
|
self.widgets.wine_recommended_only.connect_state_notify(clone!(@strong self as this => move |switcher| {
|
||||||
for group in &*this.widgets.wine_components {
|
for group in &*this.widgets.wine_components {
|
||||||
|
@ -218,7 +228,7 @@ impl App {
|
||||||
let components = &*self.widgets.dxvk_components;
|
let components = &*self.widgets.dxvk_components;
|
||||||
|
|
||||||
for (i, component) in components.into_iter().enumerate() {
|
for (i, component) in components.into_iter().enumerate() {
|
||||||
component.button.connect_clicked(Actions::DownloadDXVK(Rc::new(i)).into_fn(&self));
|
component.button.connect_clicked(Actions::DxvkPerformAction(Rc::new(i)).into_fn(&self));
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
|
@ -240,8 +250,26 @@ impl App {
|
||||||
println!("[general page] [update] action: {:?}, values: {:?}", &action, &values);
|
println!("[general page] [update] action: {:?}, values: {:?}", &action, &values);
|
||||||
|
|
||||||
match action {
|
match action {
|
||||||
Actions::DownloadDXVK(i) => {
|
Actions::DxvkPerformAction(i) => {
|
||||||
this.widgets.dxvk_components[*i].download();
|
let config = config::get().expect("Failed to load config");
|
||||||
|
|
||||||
|
let component = this.widgets.dxvk_components[*i].clone();
|
||||||
|
|
||||||
|
if component.is_downloaded(&config.game.dxvk.builds) {
|
||||||
|
if let Err(err) = component.delete(&config.game.dxvk.builds) {
|
||||||
|
this.toast_error("Failed to delete dxvk", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
component.update_state(&config.game.dxvk.builds);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
if let Ok(awaiter) = component.download(&config.game.dxvk.builds) {
|
||||||
|
awaiter.then(move |_| {
|
||||||
|
component.update_state(&config.game.dxvk.builds);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Actions::WinePerformAction(version) => {
|
Actions::WinePerformAction(version) => {
|
||||||
|
|
|
@ -9,11 +9,11 @@ use crate::ui::*;
|
||||||
use crate::ui::traits::prelude::*;
|
use crate::ui::traits::prelude::*;
|
||||||
|
|
||||||
mod general_page;
|
mod general_page;
|
||||||
mod enhanced_page;
|
mod enhancements_page;
|
||||||
|
|
||||||
pub mod pages {
|
pub mod pages {
|
||||||
pub use super::general_page::App as GeneralPage;
|
pub use super::general_page::App as GeneralPage;
|
||||||
pub use super::enhanced_page::App as EnhancedPage;
|
pub use super::enhancements_page::App as EnhancementsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, glib::Downgrade)]
|
#[derive(Clone, glib::Downgrade)]
|
||||||
|
@ -30,7 +30,7 @@ pub struct PreferencesStack {
|
||||||
pub stack: gtk::Stack,
|
pub stack: gtk::Stack,
|
||||||
|
|
||||||
pub general_page: pages::GeneralPage,
|
pub general_page: pages::GeneralPage,
|
||||||
pub enhanced_page: pages::EnhancedPage
|
pub enhancements_page: pages::EnhancementsPage
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PreferencesStack {
|
impl PreferencesStack {
|
||||||
|
@ -50,11 +50,11 @@ impl PreferencesStack {
|
||||||
stack: get_object(&builder, "stack")?,
|
stack: get_object(&builder, "stack")?,
|
||||||
|
|
||||||
general_page: pages::GeneralPage::new(window, toast_overlay)?,
|
general_page: pages::GeneralPage::new(window, toast_overlay)?,
|
||||||
enhanced_page: pages::EnhancedPage::new()?
|
enhancements_page: pages::EnhancementsPage::new()?
|
||||||
};
|
};
|
||||||
|
|
||||||
result.stack.add_titled(&result.general_page.get_page(), None, &pages::GeneralPage::title());
|
result.stack.add_titled(&result.general_page.get_page(), None, &pages::GeneralPage::title());
|
||||||
result.stack.add_titled(&result.enhanced_page.get_page(), None, &pages::EnhancedPage::title());
|
result.stack.add_titled(&result.enhancements_page.get_page(), None, &pages::EnhancementsPage::title());
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ impl PreferencesStack {
|
||||||
self.flap.set_visible(false);
|
self.flap.set_visible(false);
|
||||||
|
|
||||||
self.general_page.prepare(&self.status_page)?;
|
self.general_page.prepare(&self.status_page)?;
|
||||||
self.enhanced_page.prepare(&self.status_page)?;
|
self.enhancements_page.prepare(&self.status_page)?;
|
||||||
|
|
||||||
self.status_page.set_visible(false);
|
self.status_page.set_visible(false);
|
||||||
self.flap.set_visible(true);
|
self.flap.set_visible(true);
|
||||||
|
|
Loading…
Reference in a new issue