From 146714d88267b638cf5bb50c16859885dd504447 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Wed, 15 Mar 2023 19:46:53 +0100 Subject: [PATCH] feat(dtmm): Use Nexus mod details when available --- crates/dtmm/src/state/data.rs | 4 ++-- crates/dtmm/src/ui/window/main.rs | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/dtmm/src/state/data.rs b/crates/dtmm/src/state/data.rs index 83c979f..37d66e7 100644 --- a/crates/dtmm/src/state/data.rs +++ b/crates/dtmm/src/state/data.rs @@ -74,7 +74,7 @@ pub(crate) struct NexusInfo { pub id: u64, pub version: String, pub author: String, - pub summary: String, + pub summary: Arc, pub description: Arc, } @@ -84,7 +84,7 @@ impl From for NexusInfo { id: value.mod_id, version: value.version, author: value.author, - summary: value.summary, + summary: Arc::new(value.summary), description: Arc::new(value.description), } } diff --git a/crates/dtmm/src/ui/window/main.rs b/crates/dtmm/src/ui/window/main.rs index b251767..c8d5bf9 100644 --- a/crates/dtmm/src/ui/window/main.rs +++ b/crates/dtmm/src/ui/window/main.rs @@ -15,8 +15,8 @@ use druid::{Data, ImageBuf, LifeCycleCtx}; use lazy_static::lazy_static; use crate::state::{ - ModInfo, State, View, ACTION_ADD_MOD, ACTION_SELECTED_MOD_DOWN, ACTION_SELECTED_MOD_UP, - ACTION_SELECT_MOD, ACTION_SET_WINDOW_HANDLE, ACTION_START_CHECK_UPDATE, + ModInfo, NexusInfo, NexusInfoLens, State, View, ACTION_ADD_MOD, ACTION_SELECTED_MOD_DOWN, + ACTION_SELECTED_MOD_UP, ACTION_SELECT_MOD, ACTION_SET_WINDOW_HANDLE, ACTION_START_CHECK_UPDATE, ACTION_START_DELETE_SELECTED_MOD, ACTION_START_DEPLOY, ACTION_START_RESET_DEPLOYMENT, }; use crate::ui::theme::{self, ColorExt, COLOR_YELLOW_LIGHT}; @@ -294,12 +294,18 @@ fn build_mod_details_info() -> impl Widget { .lens(ModInfo::name.in_arc()); let summary = Label::raw() .with_line_break_mode(LineBreaking::WordWrap) - .lens(ModInfo::summary.in_arc()); + .lens(NexusInfoLens::new(NexusInfo::summary, ModInfo::summary).in_arc()); // TODO: Image/icon? let version_line = Label::dynamic(|info: &Arc, _| { - if let Some(author) = &info.author { + let author = info + .nexus + .as_ref() + .map(|n| &n.author) + .or(info.author.as_ref()); + + if let Some(author) = &author { format!("Version: {}, by {author}", info.version) } else { format!("Version: {}", info.version)