GithubHelp home page GithubHelp logo

gamecollector's Introduction

GameCollector

a fork of GameFinder

CI codecov

.NET library for finding games. GameCollector expands on upstream GameFinder (which is primarily designed to support modding tools), by adding additional supported store launchers, emulators, and data sources, and includes additional information about each game (sufficient for a multi-store game launcher such as GLC). This fork is indebted to erri120's hard work, but as he is reticent to expand the scope of GameFinder, GameCollector continues with a different philosophy.

The following launchers and emulators are supported:

handler package
Amazon Games Nuget
Arc Nuget
Bethesda.net Nuget
Big Fish Game Manager Nuget
Blizzard Battle.net Nuget
Dolphin Emulator Nuget
EA app Nuget Nuget
Epic Games Store Nuget Nuget
Game Jolt Client Nuget
GOG Galaxy Nuget Nuget
Humble App Nuget
Indiegala IGClient Nuget
itch Nuget
Legacy Games Launcher Nuget
Multiple Arcade Machine Emulator (MAME) Nuget
Oculus Nuget
Origin Nuget Nuget
Paradox Launcher Nuget
Plarium Play Nuget
Riot Client Nuget
RobotCache Client Nuget
Rockstar Games Launcher Nuget
Steam Nuget Nuget
Ubisoft Connect Nuget
Wargaming.net Game Center Nuget
Xbox Game Pass Nuget Nuget

If you are interested in understanding how GameCollector/GameFinder finds these games, check the upstream wiki for more information (descriptions of the added handlers should eventually be added to a wiki here).

Additionally, the following Linux tools are supported:

handler package
Wine Nuget Nuget

Example and Binaries

The example project uses every available store handler and can be used as a reference. You can go to Releases to download Windows builds of GameCollector.exe, or the GitHub Actions Page and click on one of the latest CI workflow runs to download pre-release binaries for this project.

GameCollector Issues

  • Known issues: See GameCollector issues here or upstream GameFinder issues here. Please do not submit bugs/requests for GameCollector on GameFinder's GitHub.
  • DLCs/clones: When an entry is detected as a DLC addon (or a clone in the MAME handler), the BaseGame field is set to the ID of the main game (or sometimes the string "False" when the relationship can't be determined). To hide DLCs from the consumer application, use FindAllGames(baseOnly: true), or do not use entries with a non-null BaseGame.
  • Owned not-installed games: Some handlers can find owned not-installed games. To support this feature for Steam games, see note below. To show only installed games, use FindAllGames(installedOnly: true), or do not use entries where IsInstalled is False.
  • Unowned games: A few handlers can find all entries in the launcher database. Unowned games are not collected by default, but using FindAllGames(ownedOnly: false) will add these entries with IsOwned set to False.

Dolphin/MAME

These handlers both require you pass the path to the emulator executable.

Oculus

If the Oculus service is running (as it does even when the program is not open), the database is usually locked and connot be read. The handler attempts to stop the service, but this only works if the consumer application is running as administrator.

Differences from Upstream

GameCollector adds a FindClient() function to get the path to a given store client's executable.

The TGame implementations of GameCollector's handlers inherit a generic GameData record. Unfortunately, no handler populates all of the fields, and many only provide a few:

  • enum Handler
  • string GameId
  • string GameName
  • AbsolutePath GamePath
  • AbsolutePath? SavePath
  • AbsolutePath Launch
  • string LaunchArgs
  • string LaunchUrl
  • AbsolutePath Icon
  • AbsolutePath Uninstall
  • string UninstallArgs
  • string UninstallUrl
  • DateTime? InstallDate
  • DateTime? LastRunDate
  • uint NumRuns
  • TimeSpan? RunTime
  • bool IsInstalled
  • bool IsOwned
  • bool IsHidden
  • List<Problem>? Problems
  • List<string>? Tags
  • ushort? MyRating
  • string? BaseGame
  • Dictionary<string, List<string>>? Metadata

The Metadata dictionary may include (depending on available information): "ReleaseDate", "Description", "Developers", "Publishers", "Genres", "ImageUrl", etc.

Supported Emulators

This is a new category of handler for GameCollector. They are Windows-only for now.

  • Dolphin
  • MAME

New Supported Launchers

The following 17 handlers have been added for GameCollector. They are all Windows-only for now:

  • Amazon Games
  • Arc
  • Big Fish Game Manager
  • Blizzard Battle.net
  • Game Jolt
  • Humble App
  • Indiegala IGClient
  • itch
  • Legacy Games Launcher
  • Oculus
  • Paradox Launcher
  • Plarium Play
  • Riot Client
  • RobotCache Client
  • Rockstar Games Launcher
  • Ubisoft Connect
  • Wargaming.net Game Center

Usage

Like GameFinder, all store handlers inherit from AHandler<TGame, TId> and implement FindAllGames() which returns IEnumerable<OneOf<TGame, ErrorMessage>>. The OneOf struct is a F# style union and is guaranteed to only contain one of the following: a TGame or an ErrorMessage. I recommended checking out the OneOf library, if you want to learn more.

Some important things to remember:

  • All store handler methods are pure, meaning they do not change the internal state of the store handler because they don't have any. This also means that the results are not cached and you shouldn't call the same method multiple times. It's up to the library consumer to cache the results somewhere.
  • GameIds are store dependent. Each store handler has their own type of id and figuring out the right id for your game might require some testing. You can find useful resources in this README for some store handlers.

Basic Usage

var results = handler.FindAllGames();

foreach (var result in results)
{
    // using the switch method
    result.Switch(game =>
    {
        Console.WriteLine($"Found {game}");
    }, error =>
    {
        Console.WriteLine(error);
    });

    // using the provided extension functions
    if (result.TryGetGame(out var game))
    {
        Console.WriteLine($"Found {game}");
    } else
    {
        Console.WriteLine(result.AsError());
    }
}

Finding a single game

If you're working on an application that only needs to find 1 game, then you can use the FindOneGameById method instead. IMPORTANT NOTE: the results are not cached. If you call this method multiple, the store handler will do the same thing multiple times, which is search for every game installed. Do not call this method if you need to find multiple games.

var game = handler.FindOneGameById(someId, out var errors);

// I highly recommend logging errors regardless of whether or not the game was found.
foreach (var error in errors)
{
    Console.WriteLine(error);
}

if (game is null)
{
    Console.WriteLine("Unable to find game");
} else
{
    Console.WriteLine($"Found {game}");
}

Finding multiple games

If you need to find multiple games at once, you can use the FindAllGamesById method instead. This returns an IReadOnlyDictionary<TId, TGame> which you can use to lookup games by id. IMPORTANT NOTE: the results are not cached. You have to do that yourself.

var games = handler.FindAllGamesById(out var errors);

// I highly recommend always logging errors.
foreach (var error in errors)
{
    Console.WriteLine(error);
}

if (games.TryGetValue(someId, out var game))
{
    Console.WriteLine($"Found {game}");
} else
{
    Console.WriteLine($"Unable to find game with the id {someId}");
}

Upstream Supported Launchers

The following handlers come from upstream GameFinder:

Steam

Steam is supported natively on Windows and Linux. Use SteamDB to find the ID of a game.

Usage (cross-platform):

var handler = new SteamHandler(FileSystem.Shared, OperatingSystem.IsWindows() ? WindowsRegistry.Shared : null);

GameCollector adds the ability to check a Steam profile for owned not-installed games. A specific Steam ID may be specified, though it will automatically attempt to find one. However, this feature requires that an API key be activated and specified, and the user profile set to public.

GOG Galaxy

GOG Galaxy is supported natively on Windows, and with Wine on Linux. Use the GOG Database to find the ID of a game.

Usage (native on Windows):

var handler = new GOGHandler(WindowsRegistry.Shared, FileSystem.Shared);

Usage (Wine on Linux):

See Wine for more information.

// requires a valid prefix
var wineFileSystem = winePrefix.CreateOverlayFileSystem(FileSystem.Shared);
var wineRegistry = winePrefix.CreateRegistry(FileSystem.Shared);

var handler = new GOGHandler(wineRegistry, wineFileSystem);

GameCollector adds finding all GOG games in the launcher's database, whether installed, owned not-installed, or unowned.

Epic Games Store

The Epic Games Store is supported natively on Windows, and with Wine on Linux. Use the Epic Games Store Database to find the ID of a game (WIP).

Usage (native on Windows):

var handler = new EGSHandler(WindowsRegistry.Shared, FileSystem.Shared);

Usage (Wine on Linux):

See Wine for more information.

// requires a valid prefix
var wineFileSystem = winePrefix.CreateOverlayFileSystem(FileSystem.Shared);
var wineRegistry = winePrefix.CreateRegistry(FileSystem.Shared);

var handler = new EGSHandler(wineRegistry, wineFileSystem);

GameCollector adds finding owned not-installed EGS games.

Origin

Origin is supported natively on Windows, and with Wine on Linux. Note: EA is deprecating Origin and will replace it with EA app.

Usage (native on Windows):

var handler = new OriginHandler(FileSystem.Shared);

Usage (Wine on Linux):

See Wine for more information.

// requires a valid prefix
var wineFileSystem = winePrefix.CreateOverlayFileSystem(FileSystem.Shared);

var handler = new OriginHandler(wineFileSystem);

EA app

The EA app is the replacement for Origin on Windows: See EA is deprecating Origin. This is by far the most complicated Store Handler. You should read the upstream wiki entry. This implementation decrypts the encrypted file created by the EA app. You should be aware that the key used to encrypt the file is derived from hardware information. If the user changes their hardware, the decryption process might fail because they key has changed.

The EA app is only supported on Windows.

Usage:

var handler = new EADesktopHandler(FileSystem.Shared, new HardwareInfoProvider());

Xbox Game Pass

This package used to be deprecated, but support was re-added in GameFinder 3.0.0. Xbox Game Pass used to install games inside a SYSTEM protected folder, making modding not feasible for the average user. You can read more about this here.

Xbox Game Pass is only supported on Windows.

Usage:

var handler = new XboxHandler(FileSystem.Shared);

Bethesda.net

As of May 11, 2022, the Bethesda.net launcher is no longer in use. The upstream package GameFinder.StoreHandlers.BethNet has been deprecated and marked as legacy.

Wine

Wine is a compatibility layer capable of running Windows applications on Linux. Wine uses prefixes to create and store virtual C: drives. A user can install and run Windows program inside these prefixes, and applications running inside the prefixes likely won't even notice they are not actually running on Windows.

Since GameCollector/GameFinder is all about finding games, it also has to be able to find games inside Wine prefixes to provide good Linux support. The package NexusMods.Paths from NexusMods.App provides a file system abstraction IFileSystem which enables path re-mappings:

AWinePrefix prefix = //...

// creates a new IFileSystem, with path mappings into the wine prefix
IFileSystem wineFileSystem = prefix.CreateOverlayFileSystem(FileSystem.Shared);

// this wineFileSystem can be used instead of FileSystem.Shared:
var handler = new OriginHandler(wineFileSystem);

// you can also create a new IRegistry:
IRegistry wineRegistry = prefix.CreateRegistry(FileSystem.Shared);

// and use both:
var handler = new EGSHandler(wineRegistry, wineFileSystem);

Default Prefix Manager

GameCollector.Wine implements a IWinePrefixManager for finding Wine prefixes.

Usage:

var prefixManager = new DefaultWinePrefixManager(FileSystem.Shared);

foreach (var result in prefixManager.FindPrefixes())
{
    result.Switch(prefix =>
    {
        Console.WriteLine($"Found wine prefix at {prefix.ConfigurationDirectory}");
    }, error =>
    {
        Console.WriteLine(error.Value);
    });
}

Bottles

GameCollector.Wine implements a IWinePrefixManager for finding Wine prefixes managed by Bottles.

Usage:

var prefixManager = new BottlesWinePrefixManager(FileSystem.Shared);

foreach (var result in prefixManager.FindPrefixes())
{
    result.Switch(prefix =>
    {
        Console.WriteLine($"Found wine prefix at {prefix.ConfigurationDirectory}");
    }, error =>
    {
        Console.WriteLine(error.Value);
    });
}

Proton

Valve's Proton is a compatibility tool for Steam and is mostly based on Wine. The Wine prefixes managed by Proton are in the compatdata directory of the steam library where the game itself is installed. Since the path is relative to the game itself and requires the app id, erri120 decided to put this functionality in the Steam store handler:

SteamGame? steamGame = steamHandler.FindOneGameById(1237970, out var errors);
if (steamGame is null) return;

ProtonWinePrefix protonPrefix = steamGame.GetProtonPrefix();
var protonPrefixDirectory = protonPrefix.ProtonDirectory;

if (protonDirectory != default && fileSystem.DirectoryExists(protonDirectory))
{
    Console.WriteLine($"Proton prefix is at {protonDirectory}");
}

Trimming

Self-contained deployments and executables can be trimmed starting with .NET 6. This feature is only available to applications that are published self-contained.

Trimmable:

  • GameCollector.Common
  • GameCollector.RegistryUtils
  • GameCollector.Wine
  • GameCollector.StoreHandlers.Steam
  • GameCollector.StoreHandlers.GOG
  • GameCollector.StoreHandlers.EGS
  • GameCollector.StoreHandlers.Origin

NOT Trimmable:

I recommend looking at the project file of the example project, if you run into warnings or errors with trimming.

Contributing

See CONTRIBUTING for more information.

License

See LICENSE for more information.

gamecollector's People

Contributors

erri120 avatar halgari avatar lostdragonist avatar nutzzz avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gamecollector's Issues

Hide EGS, GOG, and Ubisoft DLCs

EDIT: I'd forgotten that I included DLCs on purpose, and added the baseOnly parameter to FindAllGames() (or the consumer can just ignore games where BaseGame is not null).

Maybe add a new flag to FindAllGames() to only list games (not software, tools, assets, source code, etc.)

I currently strip out some categories of items out for some handlers (e.g., for Epic I allow "software" but not "engines"; for itch I allow "tool" but not "asset"; for Humble I don't allow "source"). [Also, sometimes the launcher or one of its features/prereqs is muddled up with its games and I have to strip that out, though I don't think that ought to change.]

On the other hand, I really don't want to keep adding flags. Maybe it's time to use a class or even ConfigurationManager or something.

Add a list of reasons for (or instead of) the HasProblem flag

HasProblem usually indicates an expired trial (currently for Big Fish, Humble, and Oculus), but for MAME ROMs it could indicate that it didn't verify correctly or that the MachineStatus doesn't meet the minimum criteria (I was OK with it being equivocal since "DriverStatus" can be checked manually). Now, however, I decided to flip the bit to indicate a workaround for #23 a Legacy Games Launcher issue I ran into where the launcher lost track of an installed game.

I imagined the use-case for a consumer application would involve adding a yellow yield-sign pling next to the title to let the user know there was an issue that needed to be investigated. However, if this flag is going to indicate a lot of different conditions, it makes the application's job much harder to produce an appropriate message to the user.

I'll use an enum rather than a full error message, so it's still up to the application how to communicate/translate the issue.

EDIT: Here's my first pass at a list of problems for the enum; not all of them are currently used, but I think I've seen all of them so I can try to flag them where possible:

  • Install pending (queued, downloading, or install in progress)
  • Not found in data (i.e., the launcher's manifests or database; the game is installed, but the launcher may not agree) [opposite of NotFoundOnDisk]
  • Not found on disk (The launcher thinks the game is installed, but it's not) [opposite of NotFoundInData]
  • Expired trial or part of a lapsed membership
  • Does not meet requirements [the MAME handler uses this when the driver emulation status doesn't meet the minimum ("imperfect" by default)]
  • Failed to verify (The game is on the disk, but files may be corrupt or a mismatched version)

Bad titles for Plarium Play games and owned, not-installed EA games

I'm not sure what to do about Plarium. Examples:

  • Throne [Throne: Kingdom at War]
  • Vikings [Vikings: War of Clans]

As for EA, here are some examples:

  • Apex [Apex Legends]
  • Syndicate (EA) [Syndicate 1993]
  • ItTakesTwo [It Takes Two]
  • RocketArena [Rocket Arena]
  • Ultima Underworld 1 (EA) [Ultima Underworld The Stygian Abyss]
  • Ultima Underworld 2 (EA) [Ultima Underworld 2 Labyrinth of Worlds]

I'm thinking about adding my fork of @JaydenMaalouf 's archived PureOrigin.API to optionally get titles, but this would require the consumer application to send a name and password, and it uses the old Origin API--though it still works for now, it looks like the new Juno API will eventually replace it.

Hide Epic "audience" entries and alternate installations ("beta"/"experimental", etc.)

  • audience, e.g.:
    AbsoluteZeroGeneralAudience
    AethiaGeneralAudience
    AmberGeneralAudience
    Among Us General Audience
    BaneGeneralAudience
    BichirGeneralAudience
    BluebirdGeneralAudience
    ...etc.

  • beta/experimental, e.g.:
    Auto Chess Experimental
    Barony (Beta)
    KillingFloor2Beta
    Mortal Shell Tech Beta
    Ooblets Experimental
    Satisfactory Experimental
    Satisfactory Dedicated Server - Experimental

Maybe the latter could be shown as DLC?

EDIT: In the catcache.bin file, DLCs have a mainGameItem entry populated, and are listed in the main game's dlcItemList. The only thing that connects these entries is a shared namespace (and I am already exposing this field). However, it isn't clear which is the main entry. It looks like a good first step is to look in categories and strip entries which contain "audience". It doesn't look like relying on entries that are missing keyImages gets me anything else.

FWIW, I do notice I have one entry that's got an "addons" category without a mainGameItem ("Horizon Chase Turbo - Rookie Series").

Rename namespace of GameFinder handler replacements

Retaining the old filenames is important for upstream compatibility, but even if these are theoretically supposed to operate as drop-in replacements, it doesn't hurt much to change the namespace to prevent confusion.

Auto-publish NuGet packages

This should happen automatically with the workflow inherited from upstream. I've added API keys for NuGet and Codeconv, but it looks like I need to do further investigating, as these aren't yet working.

Add ability to gather unowned games

Obviously this will only apply to some launchers, e.g.:

  • Humble
  • Legacy
  • GOG
    TODO: Research whether this is possible for any other platforms

EDIT: I forgot what these extra Humble games were; they're actually owned, just not installable via the Humble launcher (though they are shown there). My changes will result in these games being shown only if ownedOnly is false, but they'll still be marked as IsOwned true (though I've added the bool CanInstall to HumbleGame). Is that too weird? Either way, I think I'll keep hiding the source code ones (or maybe not #30 ).

EDIT 2: Should expired trials, generally, count as not-owned for this purpose? If it's still installed, you'd prefer it to be on your radar so you can either uninstall it or buy it. This is a bit complicated since ownedOnly is true by default, but I'd rather not add another flag to FindAllGames()... [EDIT: After moving to the Settings class, I set OwnedOnly to false by default]
EDIT 3: Also, if your Humble Choice subscription has lapsed, I think all Collection games and all not-installed Vault games should become unowned [EDIT: though it looks like they removed the Humble Collection a few months ago].

Fix/add unit tests

Note I am currently skipping many of the upstream unit tests, and none of the added handlers have unit tests yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.