Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app-gpui/src/sharp_deck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
_ => {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app-gpui/src/sharp_live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ impl SharpPreview {
.detach();
}

fn uninstall_app(&mut self, id: String, name: String, cx: &mut Context<Self>) {
pub(super) fn uninstall_app(&mut self, id: String, name: String, cx: &mut Context<Self>) {
live::call(
cx,
"POST",
Expand Down Expand Up @@ -2181,7 +2181,7 @@ impl SharpPreview {
);
}

fn uninstall_gamejolt(
pub(super) fn uninstall_gamejolt(
&mut self,
id: String,
name: String,
Expand Down
83 changes: 55 additions & 28 deletions app-gpui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -4854,7 +4865,8 @@ impl MetalSharpApp {
}))
}

/// "Uninstall <game>?" for a GOG or Epic game, centred over the window.
/// "Uninstall <game>?" for a GOG, Epic or Game Jolt game, or "Remove <program> from the library?" for a Windows
/// program, centred over the window.
fn render_game_uninstall_prompt(
&self,
viewport: gpui::Size<gpui::Pixels>,
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Loading