diff --git a/src/data/Game.vala b/src/data/Game.vala index b6f961fd..2a73c8dc 100644 --- a/src/data/Game.vala +++ b/src/data/Game.vala @@ -168,6 +168,8 @@ namespace GameHub.Data public abstract class Installer { + private static string NSIS_INSTALLER_DESCRIPTION = "Nullsoft Installer"; + public class Part: Object { public string id { get; construct set; } @@ -228,6 +230,7 @@ namespace GameHub.Data uint f = 0; bool windows_installer = false; + bool nsis_installer = false; foreach(var file in files) { var path = file.get_path(); @@ -237,6 +240,15 @@ namespace GameHub.Data var type = yield guess_type(file, f > 0); + if(type == InstallerType.WINDOWS_EXECUTABLE) + { + var desc = yield Utils.run_thread({"file", "-b", path}); + if(desc != null && desc.length > 0 && NSIS_INSTALLER_DESCRIPTION in desc) + { + type = InstallerType.WINDOWS_NSIS_INSTALLER; + } + } + string[]? cmd = null; switch(type) @@ -248,6 +260,7 @@ namespace GameHub.Data break; case InstallerType.ARCHIVE: + case InstallerType.WINDOWS_NSIS_INSTALLER: cmd = {"file-roller", path, "-e", game.install_dir.get_path()}; // extract with file-roller break; @@ -275,11 +288,20 @@ namespace GameHub.Data yield tool.install(game, file); } } + else if(type == InstallerType.WINDOWS_NSIS_INSTALLER) + { + nsis_installer = true; + } f++; } try { + if(nsis_installer) + { + FSUtils.rm(game.install_dir.get_path(), "\\$*DIR", "-rf"); // remove anything like $PLUGINSDIR + } + string? dirname = null; FileInfo? finfo = null; var enumerator = yield game.install_dir.enumerate_children_async("standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS); @@ -390,7 +412,7 @@ namespace GameHub.Data public enum InstallerType { - UNKNOWN, EXECUTABLE, WINDOWS_EXECUTABLE, GOG_PART, ARCHIVE; + UNKNOWN, EXECUTABLE, WINDOWS_EXECUTABLE, GOG_PART, ARCHIVE, WINDOWS_NSIS_INSTALLER; public static InstallerType from_mime(string type) { diff --git a/src/ui/dialogs/SettingsDialog/tabs/GOG.vala b/src/ui/dialogs/SettingsDialog/tabs/GOG.vala index eb95b28f..686c0830 100644 --- a/src/ui/dialogs/SettingsDialog/tabs/GOG.vala +++ b/src/ui/dialogs/SettingsDialog/tabs/GOG.vala @@ -26,6 +26,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs { private Settings.Auth.GOG gog_auth; private Box enabled_box; + private Button logout_btn; public GOG(SettingsDialog dlg) { @@ -42,11 +43,24 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs add_separator(); - add_file_chooser(_("Games directory"), FileChooserAction.SELECT_FOLDER, paths.gog_games, v => { paths.gog_games = v; dialog.show_restart_message(); }); //add_cache_directory(_("Installers cache"), FSUtils.Paths.GOG.Installers); + add_separator(); + + logout_btn = new Button.with_label(_("Logout")); + logout_btn.halign = Align.END; + add_widget(logout_btn); + + logout_btn.clicked.connect(() => { + gog_auth.authenticated = false; + gog_auth.access_token = ""; + gog_auth.refresh_token = ""; + update(); + dialog.show_restart_message(); + }); + update(); } @@ -55,6 +69,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs this.foreach(w => { if(w != enabled_box) w.sensitive = gog_auth.enabled; }); + logout_btn.sensitive = gog_auth.enabled && gog_auth.authenticated && gog_auth.access_token.length > 0; } } diff --git a/src/ui/dialogs/SettingsDialog/tabs/Humble.vala b/src/ui/dialogs/SettingsDialog/tabs/Humble.vala index c2e5642f..ecbcaaff 100644 --- a/src/ui/dialogs/SettingsDialog/tabs/Humble.vala +++ b/src/ui/dialogs/SettingsDialog/tabs/Humble.vala @@ -26,6 +26,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs { private Settings.Auth.Humble humble_auth; private Box enabled_box; + private Button logout_btn; public Humble(SettingsDialog dlg) { @@ -49,6 +50,19 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs //add_cache_directory(_("Installers cache"), FSUtils.Paths.Humble.Installers); + add_separator(); + + logout_btn = new Button.with_label(_("Logout")); + logout_btn.halign = Align.END; + add_widget(logout_btn); + + logout_btn.clicked.connect(() => { + humble_auth.authenticated = false; + humble_auth.access_token = ""; + update(); + dialog.show_restart_message(); + }); + update(); } @@ -57,6 +71,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs this.foreach(w => { if(w != enabled_box) w.sensitive = humble_auth.enabled; }); + logout_btn.sensitive = humble_auth.enabled && humble_auth.authenticated && humble_auth.access_token.length > 0; } }