diff --git a/app-gpui/src/sharp_deck.rs b/app-gpui/src/sharp_deck.rs index d902702d..7ce3b75d 100644 --- a/app-gpui/src/sharp_deck.rs +++ b/app-gpui/src/sharp_deck.rs @@ -489,6 +489,20 @@ impl SharpPreview { match source { "gog" => self.uninstall_gog_game(id.to_owned(), title, cx), "epic" => self.uninstall_epic_game(id.to_owned(), title, cx), + // A Windows program leaves the library; its files and the prefix stay, as from the Collection view. + "windows" => self.uninstall_app(id.to_owned(), title, cx), + // A Game Jolt game's folder goes, as from the Collection view. + "gamejolt" => { + let Some(dir) = self + .deck_entry(source, id) + .map(|entry| text(&entry, "install_dir").to_owned()) + .filter(|dir| !dir.is_empty()) + else { + crate::toast::error(cx, format!("Could not find {title}'s GameJolt folder")); + return; + }; + self.uninstall_gamejolt(id.to_owned(), title, dir, cx) + } _ => {} } } diff --git a/app-gpui/src/sharp_live.rs b/app-gpui/src/sharp_live.rs index a8247a75..9563dafe 100644 --- a/app-gpui/src/sharp_live.rs +++ b/app-gpui/src/sharp_live.rs @@ -587,7 +587,7 @@ impl SharpPreview { .detach(); } - fn uninstall_app(&mut self, id: String, name: String, cx: &mut Context) { + pub(super) fn uninstall_app(&mut self, id: String, name: String, cx: &mut Context) { live::call( cx, "POST", @@ -2181,7 +2181,7 @@ impl SharpPreview { ); } - fn uninstall_gamejolt( + pub(super) fn uninstall_gamejolt( &mut self, id: String, name: String, diff --git a/app-gpui/src/ui.rs b/app-gpui/src/ui.rs index e16baad9..d048c378 100644 --- a/app-gpui/src/ui.rs +++ b/app-gpui/src/ui.rs @@ -4759,11 +4759,22 @@ impl MetalSharpApp { }; let (card_game, hero_game, reset_game) = (game.clone(), game.clone(), game.clone()); let art = game.art_key.is_some(); - let uninstall_game = (matches!(game.page(), LibraryPage::Gog | LibraryPage::Epic) - && game.installed + // GOG and Epic games uninstall; Windows programs (and Game Jolt games) leave the library, as from the + // Collection view's settings, once they are not running (#809). + let windows_program = game.page() == LibraryPage::WindowsPrograms; + let uninstall_game = (matches!( + game.page(), + LibraryPage::Gog | LibraryPage::Epic | LibraryPage::WindowsPrograms + ) && game.installed && !game.needs_install - && game.external_id.is_some()) + && game.external_id.is_some() + && !(windows_program && self.is_running(game.appid))) .then(|| game.clone()); + let uninstall_label = if game.source.as_deref() == Some("windows") { + "Remove from Library…" + } else { + "Uninstall…" + }; let (left, right) = self.card_moves(); let ordered = self.live.card_order.contains_key(self.page.storage_id()); let order_item = |id: &'static str, label: &'static str, enabled: bool| { @@ -4818,7 +4829,7 @@ impl MetalSharpApp { )) })) .children(uninstall_game.map(|game| { - item("art-menu-uninstall", "Uninstall…").on_click(cx.listener( + item("art-menu-uninstall", uninstall_label).on_click(cx.listener( move |this, _, _, cx| { this.art_menu = None; this.game_uninstall_prompt = Some(game.clone()); @@ -4854,7 +4865,8 @@ impl MetalSharpApp { })) } - /// "Uninstall ?" for a GOG or Epic game, centred over the window. + /// "Uninstall ?" for a GOG, Epic or Game Jolt game, or "Remove from the library?" for a Windows + /// program, centred over the window. fn render_game_uninstall_prompt( &self, viewport: gpui::Size, @@ -4864,10 +4876,27 @@ impl MetalSharpApp { let layout = LibraryLayout::for_viewport(viewport.width.into(), viewport.height.into()); let theme = self.theme; let text_color = theme.control_text(); - let keeps = if game.page() == LibraryPage::Epic { - "Only the game's files are deleted. Its bottle (saves and settings) and your Epic library stay." - } else { - "Only the game's folder is deleted. The GOG prefix (saves and settings) and your GOG library stay." + let (title, keeps, action) = match game.source.as_deref() { + Some("windows") => ( + format!("Remove {} from the library?", game.name), + "MetalSharp stops listing it. Its files and the Windows Programs prefix (saves and settings) stay on disk.", + "Remove", + ), + Some("gamejolt") => ( + format!("Uninstall {}?", game.name), + "This removes its GameJolt folder and cannot be undone.", + "Uninstall", + ), + Some("epic") => ( + format!("Uninstall {}?", game.name), + "Only the game's files are deleted. Its bottle (saves and settings) and your Epic library stay.", + "Uninstall", + ), + _ => ( + format!("Uninstall {}?", game.name), + "Only the game's folder is deleted. The GOG prefix (saves and settings) and your GOG library stay.", + "Uninstall", + ), }; let button = |id: &'static str, label: &'static str, primary: bool| { div() @@ -4908,7 +4937,7 @@ impl MetalSharpApp { .text_size(px(layout.scaled(18.0))) .font_weight(FontWeight::SEMIBOLD) .text_color(rgb(text_color)) - .child(format!("Uninstall {}?", game.name)), + .child(title), ) .child( div() @@ -4928,24 +4957,22 @@ impl MetalSharpApp { cx.notify(); }), )) - .child( - button("game-uninstall-confirm", "Uninstall", true).on_click( - cx.listener(move |this, _, _, cx| { - this.game_uninstall_prompt = None; - let (Some(id), Some(sharp)) = - (confirm.external_id.clone(), this.sharp_preview.clone()) - else { - return; - }; - let source = confirm.source.clone().unwrap_or_default(); - let title = confirm.name.clone(); - sharp.update(cx, |sharp, cx| { - sharp.deck_uninstall(&source, &id, title, cx) - }); - cx.notify(); - }), - ), - ), + .child(button("game-uninstall-confirm", action, true).on_click( + cx.listener(move |this, _, _, cx| { + this.game_uninstall_prompt = None; + let (Some(id), Some(sharp)) = + (confirm.external_id.clone(), this.sharp_preview.clone()) + else { + return; + }; + let source = confirm.source.clone().unwrap_or_default(); + let title = confirm.name.clone(); + sharp.update(cx, |sharp, cx| { + sharp.deck_uninstall(&source, &id, title, cx) + }); + cx.notify(); + }), + )), ); Some( div()