From 66a8b16dd1d9acaa297664a27b7f4f0f37dde1d8 Mon Sep 17 00:00:00 2001 From: tkashkin Date: Sun, 25 Oct 2020 21:42:17 +0300 Subject: [PATCH] Steam: Try to detect Steam install path (#384) GameDetailsPage: reenabled functionality --- ...com.github.tkashkin.gamehub.gschema.xml.in | 2 +- res/styles/common/app.css | 4 +- src/data/compat/tools/proton/Proton.vala | 2 +- src/data/sources/steam/Steam.vala | 67 +++++++++---- .../SettingsDialog/pages/sources/Steam.vala | 48 +-------- .../GameDetailsView/GameDetailsBlock.vala | 30 ++++++ .../GameDetailsView/GameDetailsPage.vala | 98 ++++--------------- .../GameDetailsView/GameDetailsView.vala | 8 +- .../GameDetailsView/blocks/GOGDetails.vala | 6 +- .../GameDetailsView/blocks/IGDBInfo.vala | 8 +- .../GameDetailsView/blocks/SteamDetails.vala | 27 ++++- src/ui/views/GamesView/GameContextMenu.vala | 25 ++--- src/utils/fs/FS.vala | 16 +-- 13 files changed, 153 insertions(+), 188 deletions(-) diff --git a/data/com.github.tkashkin.gamehub.gschema.xml.in b/data/com.github.tkashkin.gamehub.gschema.xml.in index 64e9827d..667b85f6 100644 --- a/data/com.github.tkashkin.gamehub.gschema.xml.in +++ b/data/com.github.tkashkin.gamehub.gschema.xml.in @@ -210,7 +210,7 @@ - '~/.steam' + '~/.local/share/Steam' Steam installation directory diff --git a/res/styles/common/app.css b/res/styles/common/app.css index f87f5cbe..922a2759 100755 --- a/res/styles/common/app.css +++ b/res/styles/common/app.css @@ -143,11 +143,11 @@ list:not(:backdrop) row:selected:focus label.category-label opacity: 0.6; } -.gameinfo-background :not(.igdb-data-container-scrollable-value) > undershoot.left +.gameinfo-background :not(.data-container-scrollable-value) > undershoot.left { background: linear-gradient(to left, alpha(@theme_bg_color, 0) 50%, @theme_bg_color); } -.gameinfo-background :not(.igdb-data-container-scrollable-value) > undershoot.right +.gameinfo-background :not(.data-container-scrollable-value) > undershoot.right { background: linear-gradient(to right, alpha(@theme_bg_color, 0) 50%, @theme_bg_color); } diff --git a/src/data/compat/tools/proton/Proton.vala b/src/data/compat/tools/proton/Proton.vala index b8d5e9e7..9ac09499 100644 --- a/src/data/compat/tools/proton/Proton.vala +++ b/src/data/compat/tools/proton/Proton.vala @@ -103,7 +103,7 @@ namespace GameHub.Data.Compat.Tools.Proton task.env_var("WINEPREFIX", prefix.get_child("pfx").get_path()); } - task.env_var("STEAM_COMPAT_CLIENT_INSTALL_PATH", FS.expand(GameHub.Settings.Paths.Steam.instance.home)); + task.env_var("STEAM_COMPAT_CLIENT_INSTALL_PATH", Steam.instance.steam_client_install_dir.get_path()); task.env_var("PROTON_LOG", "1"); } diff --git a/src/data/sources/steam/Steam.vala b/src/data/sources/steam/Steam.vala index 335c9180..13c641f5 100644 --- a/src/data/sources/steam/Steam.vala +++ b/src/data/sources/steam/Steam.vala @@ -32,6 +32,8 @@ namespace GameHub.Data.Sources.Steam public Steam() { instance = this; + GameHub.Settings.Paths.Steam.instance.notify["home"].connect(update_install_dir); + update_install_dir(); } public string api_key; @@ -62,6 +64,7 @@ namespace GameHub.Data.Sources.Steam public string? user_name { get; protected set; } private bool? installed = null; + public File? steam_client_install_dir; public BinaryVDF.ListNode? appinfo; public BinaryVDF.ListNode? packageinfo; @@ -70,11 +73,33 @@ namespace GameHub.Data.Sources.Steam { get { - var loginusers = FS.find_case_insensitive(FS.file(GameHub.Settings.Paths.Steam.instance.home), FS.Paths.Steam.LoginUsersVDF); + var loginusers = FS.find_case_insensitive(steam_client_install_dir, FS.Paths.Steam.LoginUsersVDF); return loginusers != null && loginusers.query_exists(); } } + private void update_install_dir() + { + var install_dir_path = GameHub.Settings.Paths.Steam.instance.home; + if(install_dir_path.length == 0) + { + foreach(var path in FS.Paths.Steam.InstallDirs) + { + steam_client_install_dir = FS.file(path); + if(steam_client_install_dir != null && steam_client_install_dir.query_exists()) + { + GameHub.Settings.Paths.Steam.instance.home = path; + break; + } + } + } + else + { + steam_client_install_dir = FS.file(install_dir_path); + } + _library_folders = null; + } + public override bool is_installed(bool refresh) { if(installed != null && !refresh) @@ -82,6 +107,8 @@ namespace GameHub.Data.Sources.Steam return (!) installed; } + update_install_dir(); + #if OS_LINUX var distro = OS.get_distro().down(); if("ubuntu" in distro || "elementary" in distro || "pop!_os" in distro) @@ -90,11 +117,11 @@ namespace GameHub.Data.Sources.Steam || OS.is_package_installed("steam64") || OS.is_package_installed("steam-launcher") || OS.is_package_installed("steam-installer") - || FS.file(GameHub.Settings.Paths.Steam.instance.home).query_exists(); + || (steam_client_install_dir != null && steam_client_install_dir.query_exists()); } else { - installed = FS.file(GameHub.Settings.Paths.Steam.instance.home).query_exists(); + installed = steam_client_install_dir != null && steam_client_install_dir.query_exists(); } #endif @@ -104,7 +131,7 @@ namespace GameHub.Data.Sources.Steam public static bool find_app_install_dir(string app, out File? install_dir) { install_dir = null; - foreach(var dir in Steam.LibraryFolders) + foreach(var dir in Steam.library_folders) { var acf = FS.find_case_insensitive(FS.file(dir), @"appmanifest_$(app).acf"); if(acf != null && acf.query_exists()) @@ -150,7 +177,7 @@ namespace GameHub.Data.Sources.Steam } Utils.thread("Steam-loginusers", () => { - var loginusers = FS.find_case_insensitive(FS.file(GameHub.Settings.Paths.Steam.instance.home), FS.Paths.Steam.LoginUsersVDF); + var loginusers = FS.find_case_insensitive(steam_client_install_dir, FS.Paths.Steam.LoginUsersVDF); if(loginusers == null || !loginusers.query_exists()) { @@ -211,11 +238,11 @@ namespace GameHub.Data.Sources.Steam { if(appinfo == null) { - appinfo = new AppInfoVDF(FS.find_case_insensitive(FS.file(GameHub.Settings.Paths.Steam.instance.home), FS.Paths.Steam.AppInfoVDF)).read(); + appinfo = new AppInfoVDF(FS.find_case_insensitive(steam_client_install_dir, FS.Paths.Steam.AppInfoVDF)).read(); } if(packageinfo == null) { - packageinfo = new PackageInfoVDF(FS.find_case_insensitive(FS.file(GameHub.Settings.Paths.Steam.instance.home), FS.Paths.Steam.PackageInfoVDF)).read(); + packageinfo = new PackageInfoVDF(FS.find_case_insensitive(steam_client_install_dir, FS.Paths.Steam.PackageInfoVDF)).read(); } } @@ -393,7 +420,7 @@ namespace GameHub.Data.Sources.Steam private void watch_client_registry() { - var regfile = FS.find_case_insensitive(FS.file(GameHub.Settings.Paths.Steam.instance.home), FS.Paths.Steam.RegistryVDF); + var regfile = steam_client_install_dir.get_child(FS.Paths.Steam.RegistryVDF); if(regfile == null || !regfile.query_exists()) return; Timeout.add_seconds(5, () => { @@ -435,23 +462,23 @@ namespace GameHub.Data.Sources.Steam } } - public static ArrayList? folders = null; - public static ArrayList LibraryFolders + private static ArrayList? _library_folders = null; + public static ArrayList library_folders { get { - if(folders != null) return folders; - folders = new ArrayList(); + if(_library_folders != null || instance == null || instance.steam_client_install_dir == null) return _library_folders; + _library_folders = new ArrayList(); - var steamapps = FS.find_case_insensitive(FS.file(GameHub.Settings.Paths.Steam.instance.home), FS.Paths.Steam.SteamApps); + var steamapps = FS.find_case_insensitive(instance.steam_client_install_dir, FS.Paths.Steam.SteamApps); - if(steamapps == null || !steamapps.query_exists()) return folders; + if(steamapps == null || !steamapps.query_exists()) return _library_folders; - folders.add(steamapps.get_path()); + _library_folders.add(steamapps.get_path()); var libraryfolders = FS.find_case_insensitive(steamapps, FS.Paths.Steam.LibraryFoldersVDF); - if(libraryfolders == null || !libraryfolders.query_exists()) return folders; + if(libraryfolders == null || !libraryfolders.query_exists()) return _library_folders; var root = Parser.parse_vdf_file(libraryfolders.get_path()); var lf = Parser.json_object(root, {"LibraryFolders"}); @@ -464,12 +491,12 @@ namespace GameHub.Data.Sources.Steam if(libdir != null && libdir.query_exists()) { var dir = FS.find_case_insensitive(libdir, "steamapps"); - if(dir != null && dir.query_exists()) folders.add(dir.get_path()); + if(dir != null && dir.query_exists()) _library_folders.add(dir.get_path()); } } } - return folders; + return _library_folders; } } @@ -480,10 +507,10 @@ namespace GameHub.Data.Sources.Steam public static File? get_userdata_dir() { - if(instance == null || instance.user_id == null) return null; + if(instance == null || instance.user_id == null || instance.steam_client_install_dir == null) return null; uint64 communityid = uint64.parse(instance.user_id); uint64 steamid3 = communityid_to_steamid3(communityid); - return FS.find_case_insensitive(FS.file(GameHub.Settings.Paths.Steam.instance.home), @"steam/userdata/$(steamid3)"); + return FS.find_case_insensitive(instance.steam_client_install_dir, @"userdata/$(steamid3)"); } public static void add_game_shortcut(Game game) diff --git a/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala b/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala index 1d49ba8f..bfbada21 100644 --- a/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala +++ b/src/ui/dialogs/SettingsDialog/pages/sources/Steam.vala @@ -75,7 +75,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Sources new DirectoriesMenuSetting.paths( _("Steam library directories"), _("Steam library directories that are configured in the Steam client"), - GameHub.Data.Sources.Steam.Steam.LibraryFolders + GameHub.Data.Sources.Steam.Steam.library_folders ) ); add_widget(sgrp_dirs); @@ -84,52 +84,6 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Pages.Sources sgrp_api_key.add_setting(new EntrySetting(_("API key"), null, get_steam_apikey_entry())); sgrp_api_key.add_setting(new LinkLabelSetting(_("Provide your API key to access private Steam profile or if default key does not work"), _("Generate key"), "steam://openurl/https://steamcommunity.com/dev/apikey")); add_widget(sgrp_api_key); - - /*sgrp_proton = new SettingsGroup("Proton"); - add_widget(sgrp_proton);*/ - - notify["active"].connect(() => { - update(); - //request_restart(); - }); - - update(); - } - - private void update() - { - /*sgrp_proton.settings.foreach(r => { - if(r != null) r.destroy(); - }); - - foreach(var tool in CompatTools) - { - if(tool is Proton) - { - var proton = tool as Proton; - if(proton != null && !proton.is_latest) - { - Button? install = null; - var description = _("Not installed"); - if(proton.installed && proton.executable != null) - { - description = proton.executable.get_path(); - } - else - { - install = new Button.with_label(_("Install")); - install.clicked.connect(() => { - install.sensitive = false; - request_restart(); - proton.install_app(); - }); - } - sgrp_proton.add_setting(new BaseSetting("""%s • %s""".printf(proton.name, proton.appid), description, install)).icon_name = proton.icon; - } - } - } - - sgrp_proton.show_all();*/ } private Entry get_steam_apikey_entry() diff --git a/src/ui/views/GameDetailsView/GameDetailsBlock.vala b/src/ui/views/GameDetailsView/GameDetailsBlock.vala index 5a8fd1eb..d75e864f 100644 --- a/src/ui/views/GameDetailsView/GameDetailsBlock.vala +++ b/src/ui/views/GameDetailsView/GameDetailsBlock.vala @@ -60,5 +60,35 @@ namespace GameHub.UI.Views.GameDetailsView return box; } + + protected Box? add_scrollable_label(string title, string? text, bool markup=false, Container? parent=null) + { + var title_label = Styled.H4Label(title); + title_label.margin_start = title_label.margin_end = 7; + title_label.get_style_context().add_class("data-container-scrollable-header"); + title_label.set_size_request(128, -1); + title_label.valign = Align.CENTER; + + var text_scroll = new ScrolledWindow(null, null); + text_scroll.get_style_context().add_class("data-container-scrollable-value"); + text_scroll.vscrollbar_policy = PolicyType.NEVER; + text_scroll.hexpand = true; + + var text_label = new Label(text); + text_label.margin_start = text_label.margin_end = 7; + text_label.get_style_context().add_class("gameinfo-multiline-value"); + text_label.hexpand = false; + text_label.xalign = 0; + text_label.use_markup = markup; + + text_scroll.add(text_label); + + var box = new Box(Orientation.VERTICAL, 0); + box.add(title_label); + box.add(text_scroll); + (parent ?? this).add(box); + + return box; + } } } diff --git a/src/ui/views/GameDetailsView/GameDetailsPage.vala b/src/ui/views/GameDetailsView/GameDetailsPage.vala index 5108220d..5c892f06 100644 --- a/src/ui/views/GameDetailsView/GameDetailsPage.vala +++ b/src/ui/views/GameDetailsView/GameDetailsPage.vala @@ -66,7 +66,6 @@ namespace GameHub.UI.Views.GameDetailsView private ActionButton action_install; private ActionButton action_run; - private ActionButton action_run_with_compat; private ActionButton action_properties; private ActionButton action_open_directory; private ActionButton action_open_installer_collection_directory; @@ -233,11 +232,7 @@ namespace GameHub.UI.Views.GameDetailsView action_install = add_action("go-down", null, _("Install"), install_game, true); action_run = add_action("media-playback-start", null, _("Run"), run_game, true); - action_run_with_compat = add_action("media-playback-start", "platform-windows-symbolic", _("Run with compatibility layer"), run_game_with_compat, true); action_open_directory = add_action("folder", null, _("Open installation directory"), open_game_directory); - action_open_installer_collection_directory = add_action("folder-download", null, _("Open installers collection directory"), open_installer_collection_directory); - action_open_bonus_collection_directory = add_action("folder-documents", null, _("Open bonus collection directory"), open_bonus_collection_directory); - action_open_screenshots_directory = add_action("folder-pictures", null, _("Open screenshots directory"), open_screenshots_directory); action_open_store_page = add_action("web-browser", null, _("Open store page"), open_game_store_page); action_uninstall = add_action("edit-delete", null, (game is Sources.User.UserGame) ? _("Remove") : _("Uninstall"), uninstall_game); action_properties = add_action("system-run", null, _("Game properties"), game_properties); @@ -274,7 +269,7 @@ namespace GameHub.UI.Views.GameDetailsView private void set_visible_widgets(Game.Status s) { - /*status.label = s.description; + status.label = s.description; download_progress.hide(); if(s.state == Game.State.DOWNLOADING && s.download != null && s.download.status != null) { @@ -297,29 +292,12 @@ namespace GameHub.UI.Views.GameDetailsView } action_install.visible = s.state != Game.State.INSTALLED; action_install.sensitive = s.state == Game.State.UNINSTALLED && game.is_installable; - action_run_with_compat.visible = s.state == Game.State.INSTALLED && game.use_compat; - action_run_with_compat.sensitive = game.can_be_launched(); - action_run.visible = s.state == Game.State.INSTALLED && !action_run_with_compat.visible; + action_run.visible = s.state == Game.State.INSTALLED; action_run.sensitive = game.can_be_launched(); action_open_directory.visible = s.state == Game.State.INSTALLED && game.install_dir != null && game.install_dir.query_exists(); - action_open_installer_collection_directory.visible = game.installers_dir != null && game.installers_dir.query_exists(); - action_open_bonus_collection_directory.visible = game is GameHub.Data.Sources.GOG.GOGGame && (game as GameHub.Data.Sources.GOG.GOGGame).bonus_content_dir != null && (game as GameHub.Data.Sources.GOG.GOGGame).bonus_content_dir.query_exists(); - action_open_screenshots_directory.visible = game is GameHub.Data.Sources.Steam.SteamGame && (game as GameHub.Data.Sources.Steam.SteamGame).screenshots_dir != null && (game as GameHub.Data.Sources.Steam.SteamGame).screenshots_dir.query_exists(); action_open_store_page.visible = game.store_page != null; action_uninstall.visible = s.state == Game.State.INSTALLED && !(game is GameHub.Data.Sources.GOG.GOGGame.DLC); action_properties.visible = !(game is GameHub.Data.Sources.GOG.GOGGame.DLC); - - if(action_run_with_compat.visible && game.compat_tool != null) - { - foreach(var tool in CompatTools) - { - if(tool.id == game.compat_tool) - { - action_run_with_compat.icon_overlay = tool.icon; - break; - } - } - }*/ } public void update() @@ -419,98 +397,58 @@ namespace GameHub.UI.Views.GameDetailsView private void install_game() { - /*if(_game != null && game.status.state == Game.State.UNINSTALLED) + if(game != null && game.status.state == Game.State.UNINSTALLED) { game.install.begin(); - }*/ + } } private void game_properties() { - /*if(_game != null) + if(game != null) { - new Dialogs.GamePropertiesDialog(game).show_all(); - }*/ + new Dialogs.GamePropertiesDialog.GamePropertiesDialog(game).show_all(); + } } private void open_game_directory() { - /*if(_game != null && game.status.state == Game.State.INSTALLED && game.install_dir != null && game.install_dir.query_exists()) + if(game != null && game.status.state == Game.State.INSTALLED && game.install_dir != null && game.install_dir.query_exists()) { Utils.open_uri(game.install_dir.get_uri()); - }*/ - } - - private void open_installer_collection_directory() - { - /*if(_game != null && game.installers_dir != null && game.installers_dir.query_exists()) - { - Utils.open_uri(game.installers_dir.get_uri()); - }*/ - } - - private void open_bonus_collection_directory() - { - /*if(_game != null && game is GameHub.Data.Sources.GOG.GOGGame) - { - var gog_game = game as GameHub.Data.Sources.GOG.GOGGame; - if(gog_game != null && gog_game.bonus_content_dir != null && gog_game.bonus_content_dir.query_exists()) - { - Utils.open_uri(gog_game.bonus_content_dir.get_uri()); - } - }*/ - } - - private void open_screenshots_directory() - { - /*if(_game != null && game is GameHub.Data.Sources.Steam.SteamGame) - { - var steam_game = game as GameHub.Data.Sources.Steam.SteamGame; - if(steam_game != null && steam_game.screenshots_dir != null && steam_game.screenshots_dir.query_exists()) - { - Utils.open_uri(steam_game.screenshots_dir.get_uri()); - } - }*/ + } } private void open_game_store_page() { - /*if(_game != null && game.store_page != null) + if(game != null && game.store_page != null) { Utils.open_uri(game.store_page); - }*/ + } } private void run_game() { - /*if(_game != null && game.status.state == Game.State.INSTALLED) - { - game.run.begin(); - }*/ - } - - private void run_game_with_compat() - { - /*if(_game != null && game.status.state == Game.State.INSTALLED) + if(game != null && game.status.state == Game.State.INSTALLED) { - game.run_with_compat.begin(false); - }*/ + game.run_as_task.begin(); + } } private void uninstall_game() { - /*if(_game != null && game.status.state == Game.State.INSTALLED) + if(game != null && game.status.state == Game.State.INSTALLED) { game.uninstall.begin(); - }*/ + } } private void open_context_menu(Event e, bool at_pointer=true) { - /*if(_game != null) + if(game != null) { new GameContextMenu(game, this).open(e, at_pointer); - }*/ + } } private delegate void Action(); diff --git a/src/ui/views/GameDetailsView/GameDetailsView.vala b/src/ui/views/GameDetailsView/GameDetailsView.vala index f3df87e0..8c11528f 100644 --- a/src/ui/views/GameDetailsView/GameDetailsView.vala +++ b/src/ui/views/GameDetailsView/GameDetailsView.vala @@ -233,17 +233,15 @@ namespace GameHub.UI.Views.GameDetailsView if(merged) { - /*foreach(var m in merges) + foreach(var m in merges) { - if(Game.is_equal(g, m) - || !m.is_supported(null) - || (g is Sources.GOG.GOGGame.DLC && Game.is_equal((g as Sources.GOG.GOGGame.DLC).game, m))) + if(Game.is_equal(g, m) || (g is Sources.GOG.GOGGame.DLC && Game.is_equal(((Sources.GOG.GOGGame.DLC) g).game, m))) { continue; } add_page(m); - }*/ + } } stack_tabs.visible = stack.get_children().length() > 1; diff --git a/src/ui/views/GameDetailsView/blocks/GOGDetails.vala b/src/ui/views/GameDetailsView/blocks/GOGDetails.vala index 9c6f167d..efaa2d73 100644 --- a/src/ui/views/GameDetailsView/blocks/GOGDetails.vala +++ b/src/ui/views/GameDetailsView/blocks/GOGDetails.vala @@ -76,8 +76,12 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks if(langs_string.contains(",")) { langs_label = _("Languages"); + add_scrollable_label(langs_label, langs_string, true); + } + else + { + add_info_label(langs_label, langs_string, false, true); } - add_info_label(langs_label, langs_string, langs_string.contains(","), true); } if(gog_game.dlc != null && gog_game.dlc.size > 0) diff --git a/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala b/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala index 6bbd0e3a..6f071cc8 100644 --- a/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala +++ b/src/ui/views/GameDetailsView/blocks/IGDBInfo.vala @@ -152,12 +152,12 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks var links_label = Styled.H4Label(C_("igdb", "Links")); links_label.margin_start = links_label.margin_end = 7; - links_label.get_style_context().add_class("igdb-data-container-scrollable-header"); + links_label.get_style_context().add_class("data-container-scrollable-header"); links_label.valign = Align.START; add(links_label); var links_scroll = new ScrolledWindow(null, null); - links_scroll.get_style_context().add_class("igdb-data-container-scrollable-value"); + links_scroll.get_style_context().add_class("data-container-scrollable-value"); links_scroll.vscrollbar_policy = PolicyType.NEVER; links_scroll.hexpand = true; @@ -224,12 +224,12 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks { var title_label = Styled.H4Label(title); title_label.margin_start = title_label.margin_end = 7; - title_label.get_style_context().add_class("igdb-data-container-scrollable-header"); + title_label.get_style_context().add_class("data-container-scrollable-header"); title_label.set_size_request(128, -1); title_label.valign = Align.CENTER; var links_scroll = new ScrolledWindow(null, null); - links_scroll.get_style_context().add_class("igdb-data-container-scrollable-value"); + links_scroll.get_style_context().add_class("data-container-scrollable-value"); links_scroll.vscrollbar_policy = PolicyType.NEVER; links_scroll.hexpand = true; diff --git a/src/ui/views/GameDetailsView/blocks/SteamDetails.vala b/src/ui/views/GameDetailsView/blocks/SteamDetails.vala index c3506293..33f92371 100644 --- a/src/ui/views/GameDetailsView/blocks/SteamDetails.vala +++ b/src/ui/views/GameDetailsView/blocks/SteamDetails.vala @@ -75,7 +75,14 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks categories_label = _("Categories"); } add(new Separator(Orientation.HORIZONTAL)); - add_info_label(categories_label, categories_string, categories_string.contains(","), true); + if(categories_string.contains(",")) + { + add_scrollable_label(categories_label, categories_string, true); + } + else + { + add_info_label(categories_label, categories_string, false, true); + } } var genres = data.has_member("genres") ? data.get_array_member("genres") : null; @@ -94,7 +101,14 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks genres_label = _("Genres"); } add(new Separator(Orientation.HORIZONTAL)); - add_info_label(genres_label, genres_string, genres_string.contains(","), true); + if(genres_string.contains(",")) + { + add_scrollable_label(genres_label, genres_string, true); + } + else + { + add_info_label(genres_label, genres_string, false, true); + } } var langs = data.has_member("supported_languages") ? data.get_string_member("supported_languages") : null; @@ -107,7 +121,14 @@ namespace GameHub.UI.Views.GameDetailsView.Blocks langs_label = _("Languages"); } add(new Separator(Orientation.HORIZONTAL)); - add_info_label(langs_label, langs, langs.contains(","), true); + if(langs.contains(",")) + { + add_scrollable_label(langs_label, langs, true); + } + else + { + add_info_label(langs_label, langs, false, true); + } } show_all(); diff --git a/src/ui/views/GamesView/GameContextMenu.vala b/src/ui/views/GamesView/GameContextMenu.vala index 7f665637..73e39eba 100644 --- a/src/ui/views/GamesView/GameContextMenu.vala +++ b/src/ui/views/GamesView/GameContextMenu.vala @@ -42,20 +42,11 @@ namespace GameHub.UI.Views.GamesView { if(game.status.state == Game.State.INSTALLED && !(game is Sources.GOG.GOGGame.DLC)) { - /*if(game.use_compat) - { - var run_with_compat = new Gtk.MenuItem.with_label(_("Run with compatibility layer")); - run_with_compat.sensitive = game.can_be_launched(); - run_with_compat.activate.connect(() => game.run_with_compat.begin(true)); - add(run_with_compat); - } - else - {*/ - var run = new Gtk.MenuItem.with_label(_("Run")); - run.sensitive = game.can_be_launched(); - run.activate.connect(() => game.run_as_task.begin()); - add(run); - //} + var run = new Gtk.MenuItem.with_label(_("Run")); + run.sensitive = game.can_be_launched(); + run.activate.connect(() => game.run_as_task.begin()); + add(run); + add(new Gtk.SeparatorMenuItem()); /*if(game.actions != null && game.actions.size > 0) @@ -125,18 +116,18 @@ namespace GameHub.UI.Views.GamesView add(hidden); } - /*bool add_dirs_separator = true; + bool add_dirs_separator = true; if(game.status.state == Game.State.INSTALLED && game.install_dir != null && game.install_dir.query_exists()) { if(add_dirs_separator) add(new Gtk.SeparatorMenuItem()); add_dirs_separator = false; var open_dir = new Gtk.MenuItem.with_label(_("Open installation directory")); - open_dir.activate.connect(open_game_directory); + open_dir.activate.connect(() => Utils.open_uri(game.install_dir.get_uri())); add(open_dir); } - if(game.installers_dir != null && game.installers_dir.query_exists()) + /*if(game.installers_dir != null && game.installers_dir.query_exists()) { if(add_dirs_separator) add(new Gtk.SeparatorMenuItem()); add_dirs_separator = false; diff --git a/src/utils/fs/FS.vala b/src/utils/fs/FS.vala index 3da511df..e33f7cea 100644 --- a/src/utils/fs/FS.vala +++ b/src/utils/fs/FS.vala @@ -70,16 +70,18 @@ namespace GameHub.Utils.FS public class Steam { - public const string Config = "steam/config"; + public const string[] InstallDirs = {"~/.local/share/Steam", "~/.var/app/com.valvesoftware.Steam/.local/share/Steam"}; + + public const string Config = "config"; public const string LoginUsersVDF = Paths.Steam.Config + "/loginusers.vdf"; - public const string SteamApps = "steam/steamapps"; + public const string SteamApps = "steamapps"; public const string LibraryFoldersVDF = "libraryfolders.vdf"; - public const string RegistryVDF = "registry.vdf"; + public const string RegistryVDF = "../../../.steam/registry.vdf"; - public const string AppInfoVDF = "steam/appcache/appinfo.vdf"; - public const string PackageInfoVDF = "steam/appcache/packageinfo.vdf"; + public const string AppInfoVDF = "appcache/appinfo.vdf"; + public const string PackageInfoVDF = "appcache/packageinfo.vdf"; } public class Humble @@ -134,9 +136,9 @@ namespace GameHub.Utils.FS return f != null ? File.new_for_path(f) : null; } - public static File? find_case_insensitive(File root, string? path=null, string[]? parts=null) + public static File? find_case_insensitive(File? root, string? path=null, string[]? parts=null) { - if(path == null && parts == null) return null; + if(root == null || (path == null && parts == null)) return null; string[]? _parts = parts;