From 2f746debf3503397c910c0ef825514aa014bc938 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Tue, 14 Nov 2023 15:38:51 +0100 Subject: [PATCH] Use mod name from Nexus if necessary Non-bundled mods come without `dtmt.cfg` and therefore no way to provide a user friendly name. Similar to the other fields, use the one from Nexus in that case. --- crates/dtmm/src/state/data.rs | 2 ++ crates/dtmm/src/ui/window/main.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/dtmm/src/state/data.rs b/crates/dtmm/src/state/data.rs index 8a461bd..64fdd28 100644 --- a/crates/dtmm/src/state/data.rs +++ b/crates/dtmm/src/state/data.rs @@ -73,6 +73,7 @@ impl From for ModDependency { #[derive(Clone, Data, Debug, Lens, serde::Serialize, serde::Deserialize)] pub(crate) struct NexusInfo { pub id: u64, + pub name: String, pub version: String, pub author: String, pub summary: Arc, @@ -83,6 +84,7 @@ impl From for NexusInfo { fn from(value: NexusMod) -> Self { Self { id: value.mod_id, + name: value.name, version: value.version, author: value.author, summary: Arc::new(value.summary), diff --git a/crates/dtmm/src/ui/window/main.rs b/crates/dtmm/src/ui/window/main.rs index 7de4418..baa8e22 100644 --- a/crates/dtmm/src/ui/window/main.rs +++ b/crates/dtmm/src/ui/window/main.rs @@ -135,8 +135,13 @@ fn build_mod_list() -> impl Widget { }) .lens(lens!((usize, Arc, bool), 1).then(ModInfo::enabled.in_arc())); - let name = - Label::raw().lens(lens!((usize, Arc, bool), 1).then(ModInfo::name.in_arc())); + let name = Label::dynamic(|info: &Arc, _| { + info.nexus + .as_ref() + .map(|n| n.name.clone()) + .unwrap_or_else(|| info.name.clone()) + }) + .lens(lens!((usize, Arc, bool), 1)); let version = { let icon = {