feat(ui): utilized new recommended feature for wine / dxvk versions

This commit is contained in:
Observer KRypt0n_ 2023-04-07 21:25:27 +02:00
parent 487fdd79ee
commit 941851c234
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
4 changed files with 36 additions and 21 deletions

4
Cargo.lock generated
View file

@ -86,8 +86,8 @@ dependencies = [
[[package]]
name = "anime-launcher-sdk"
version = "0.5.10"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.10#186aa204d6a87a26198a00c9fb59e0a313f68227"
version = "0.5.11"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.11#46547a886f51ba8c58918c0903273c3d3c63d5fa"
dependencies = [
"anime-game-core",
"anyhow",

View file

@ -17,7 +17,7 @@ glib-build-tools = "0.17"
[dependencies.anime-launcher-sdk]
git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "0.5.10"
tag = "0.5.11"
# path = "../anime-launcher-sdk" # ! for dev purposes only

View file

@ -56,10 +56,14 @@ impl From<wine::Version> for ComponentsListVersion {
#[inline]
fn from(version: wine::Version) -> Self {
Self {
recommended: match version.version_features() {
Some(features) => features.recommended,
None => true
},
name: version.name,
title: version.title,
uri: version.uri,
recommended: true
uri: version.uri
}
}
}
@ -68,10 +72,14 @@ impl From<dxvk::Version> for ComponentsListVersion {
#[inline]
fn from(version: dxvk::Version) -> Self {
Self {
recommended: match version.version_features() {
Some(features) => features.recommended,
None => true
},
name: version.name,
title: version.title,
uri: version.uri,
recommended: true
uri: version.uri
}
}
}

View file

@ -732,9 +732,14 @@ impl SimpleAsyncComponent for GeneralApp {
group.versions = group.versions.into_iter().take(12).collect();
let mut group: ComponentsListGroup = group.into();
let mut recommended = 6;
if group.versions.len() > 6 {
for i in 6..group.versions.len() {
for i in 0..group.versions.len() {
if recommended > 0 && group.versions[i].recommended {
recommended -= 1;
}
else {
group.versions[i].recommended = false;
}
}
@ -758,9 +763,14 @@ impl SimpleAsyncComponent for GeneralApp {
group.versions = group.versions.into_iter().take(12).collect();
let mut group: ComponentsListGroup = group.into();
let mut recommended = 6;
if group.versions.len() > 6 {
for i in 6..group.versions.len() {
for i in 0..group.versions.len() {
if recommended > 0 && group.versions[i].recommended {
recommended -= 1;
}
else {
group.versions[i].recommended = false;
}
}
@ -940,16 +950,13 @@ impl SimpleAsyncComponent for GeneralApp {
self.downloaded_wine_versions = wine::get_downloaded(&CONFIG.components.path, &CONFIG.game.wine.builds)
.unwrap_or_default()
.into_iter()
.flat_map(|group| group.versions
.into_iter()
.map(move |version| (
version.clone(),
version.features.unwrap_or_else(
|| group.features.to_owned().unwrap_or_default()
))
)
)
.collect();
.flat_map(|group| group.versions.clone().into_iter()
.map(move |version| {
let features = version.features_in(&group).unwrap_or_default();
(version, features)
})
).collect();
self.selected_wine_version = if let Some(selected) = &CONFIG.game.wine.selected {
let mut index = 0;