Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support EGS #538

Draft
wants to merge 22 commits into
base: refactoring
Choose a base branch
from
Draft
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
27 changes: 27 additions & 0 deletions data/gamehub.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,21 @@
</key>
</schema>

<schema path="@SCHEMA_PATH@/auth/epicgames/" id="@[email protected]">
<key name="enabled" type="b">
<default>true</default>
<summary>Is EpicGames enabled</summary>
</key>
<key name="authenticated" type="b">
<default>false</default>
<summary>Is user authenticated</summary>
</key>
<key name="userdata" type="s">
<default>''</default>
<summary>EpicGames userdata</summary>
</key>
</schema>

<schema path="@SCHEMA_PATH@/auth/gog/" id="@[email protected]">
<key name="enabled" type="b">
<default>true</default>
Expand Down Expand Up @@ -215,6 +230,18 @@
</key>
</schema>

<!-- Paths / EpicGames -->
<schema path="@SCHEMA_PATH@/paths/epicgames/" id="@[email protected]">
<key name="game-directories" type="as">
<default>['~/Games/EpicGames', '~/EpicGames Games']</default>
<summary>EpicGames game directories</summary>
</key>
<key name="default-game-directory" type="s">
<default>'~/Games/EpicGames'</default>
<summary>Default EpicGames games directory</summary>
</key>
</schema>

<!-- Paths / GOG -->
<schema path="@SCHEMA_PATH@/paths/gog/" id="@[email protected]">
<key name="game-directories" type="as">
Expand Down
1 change: 1 addition & 0 deletions res/icons/icons.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<gresource prefix="/res/icons">
<file alias="scalable/actions/sources-all-symbolic.svg">symbolic/sources/sources-all.svg</file>
<file alias="scalable/actions/source-steam-symbolic.svg">symbolic/sources/steam.svg</file>
<file alias="scalable/actions/source-epicgames-symbolic.svg">symbolic/sources/epicgames.svg</file>
<file alias="scalable/actions/source-gog-symbolic.svg">symbolic/sources/gog.svg</file>
<file alias="scalable/actions/source-humble-symbolic.svg">symbolic/sources/humble.svg</file>
<file alias="scalable/actions/source-humble-trove-symbolic.svg">symbolic/sources/humble-trove.svg</file>
Expand Down
30 changes: 30 additions & 0 deletions res/icons/symbolic/sources/epicgames.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using Gee;
using GameHub.Data;
using GameHub.Data.DB;
using GameHub.Data.Sources.Steam;
using GameHub.Data.Sources.EpicGames;
using GameHub.Data.Sources.GOG;
using GameHub.Data.Sources.Humble;
using GameHub.Data.Sources.Itch;
Expand Down Expand Up @@ -141,7 +142,7 @@ namespace GameHub
ImageCache.init();
Database.create();

GameSources = { new Steam(), new GOG(), new Humble(), new Trove(), new Itch(), new User() };
GameSources = { new Steam(), new EpicGames(), new GOG(), new Humble(), new Trove(), new Itch(), new User() };

Providers.ImageProviders = { new Providers.Images.Steam(), new Providers.Images.SteamGridDB(), new Providers.Images.JinxSGVI() };
Providers.DataProviders = { new Providers.Data.IGDB() };
Expand Down
1 change: 1 addition & 0 deletions src/data/GameSource.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using Gee;
using GameHub.Utils;
using GameHub.Data.Runnables;
using GameHub.Data.Sources.Steam;
using GameHub.Data.Sources.EpicGames;
using GameHub.Data.Sources.GOG;

namespace GameHub.Data
Expand Down
4 changes: 2 additions & 2 deletions src/data/adapters/GamesAdapter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ namespace GameHub.Data.Adapters

private void merge_game(Game game)
{
if(!filter_settings_merge || game is Sources.GOG.GOGGame.DLC) return;
if(!filter_settings_merge || game is Sources.GOG.GOGGame.DLC || game is Sources.EpicGames.EpicGame.DLC) return;
foreach(var src in sources)
{
foreach(var game2 in src.games)
Expand All @@ -524,7 +524,7 @@ namespace GameHub.Data.Adapters

private void merge_game_with_game(GameSource src, Game game, Game game2)
{
if(Game.is_equal(game, game2) || game2 is Sources.GOG.GOGGame.DLC) return;
if(Game.is_equal(game, game2) || game2 is Sources.GOG.GOGGame.DLC || game2 is Sources.EpicGames.EpicGame.DLC) return;

if(Tables.Merges.is_game_merged(game) || Tables.Merges.is_game_merged(game2) || Tables.Merges.is_game_merged_as_primary(game2)) return;

Expand Down
2 changes: 2 additions & 0 deletions src/data/compat/tools/wine/Wine.vala
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ namespace GameHub.Data.Compat.Tools.Wine
var task = runnable.prepare_exec_task(prepare_exec_cmdline(runnable, file, wine_options), args);
if(dir != null) task.dir(dir.get_path());
apply_env(runnable, task, wine_options_local);
if(runnable is Traits.HasExecutableFile) yield runnable.pre_run();
yield task.sync_thread();
if(runnable is Traits.HasExecutableFile) yield runnable.post_run();
}

public virtual File? get_prefix(Traits.SupportsCompatTools runnable, WineOptions? wine_options = null)
Expand Down
10 changes: 10 additions & 0 deletions src/data/db/tables/Games.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using GameHub.Utils;

using GameHub.Data.Runnables;
using GameHub.Data.Sources.Steam;
using GameHub.Data.Sources.EpicGames;
using GameHub.Data.Sources.GOG;
using GameHub.Data.Sources.Humble;
using GameHub.Data.Sources.Itch;
Expand Down Expand Up @@ -154,6 +155,7 @@ namespace GameHub.Data.DB.Tables
}

if(game is Sources.GOG.GOGGame.DLC) return false;
if(game is Sources.EpicGames.EpicGame.DLC) return false;

unowned Sqlite.Database? db = Database.instance.db;
if(db == null) return false;
Expand Down Expand Up @@ -339,6 +341,10 @@ namespace GameHub.Data.DB.Tables
{
g = new SteamGame.from_db((Steam) s, st);
}
else if(s is EpicGames)
{
g = new EpicGame.from_db((EpicGames) s, st);
}
else if(s is GOG)
{
g = new GOGGame.from_db((GOG) s, st);
Expand Down Expand Up @@ -424,6 +430,10 @@ namespace GameHub.Data.DB.Tables
{
g = new SteamGame.from_db((Steam) s, st);
}
else if(s is EpicGames)
{
g = new EpicGame.from_db((EpicGames) s, st);
}
else if(s is GOG)
{
g = new GOGGame.from_db((GOG) s, st);
Expand Down
2 changes: 1 addition & 1 deletion src/data/db/tables/Merges.vala
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace GameHub.Data.DB.Tables

public static bool add(Game first, Game second)
{
if(first is Sources.GOG.GOGGame.DLC || second is Sources.GOG.GOGGame.DLC) return false;
if(first is Sources.GOG.GOGGame.DLC || second is Sources.GOG.GOGGame.DLC || first is Sources.EpicGames.EpicGame.DLC || second is Sources.EpicGames.EpicGame.DLC) return false;

unowned Sqlite.Database? db = Database.instance.db;
if(db == null) return false;
Expand Down
13 changes: 11 additions & 2 deletions src/data/runnables/Game.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ namespace GameHub.Data.Runnables

public string? store_page { get; protected set; default = null; }

/**
* Last launch date in unix time
*/
public int64 last_launch { get; set; default = 0; }
public int64 playtime_source { get; set; default = 0; }

/**
* Tracked playtime in minutes
*
* minutes = {@link GLib.TimeSpan} / 6e7
*/
public int64 playtime_tracked { get; set; default = 0; }
public int64 playtime { get { return playtime_source + playtime_tracked; } }

Expand Down Expand Up @@ -103,7 +112,7 @@ namespace GameHub.Data.Runnables
// Version

private string? _version = null;
public string? version
public virtual string? version
{
get { return _version; }
set
Expand All @@ -123,7 +132,7 @@ namespace GameHub.Data.Runnables
}
}

protected void load_version()
protected virtual void load_version()
{
if(install_dir == null || !install_dir.query_exists()) return;
var file = get_file(@"$(FS.GAMEHUB_DIR)/version");
Expand Down
6 changes: 6 additions & 0 deletions src/data/runnables/tasks/install/InstallTask.vala
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ namespace GameHub.Data.Runnables.Tasks.Install
if(cancelled) return;
if(install_dir_imported)
{
// FIXME: hack to be able to do stuff on import
if(selected_installer.can_import)
{
yield selected_installer.import(this);
}

warning("[InstallTask.install] Installation directory was imported, skipping installation");
return;
}
Expand Down
20 changes: 12 additions & 8 deletions src/data/runnables/tasks/install/Installer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ namespace GameHub.Data.Runnables.Tasks.Install
{
public abstract class Installer: BaseObject
{
public string id { get; protected set; }
public string name { get; protected set; }
public Platform platform { get; protected set; default = Platform.CURRENT; }
public int64 full_size { get; protected set; default = 0; }
public string? version { get; protected set; }
public string? language { get; protected set; }
public string? language_name { get; protected set; }
public string id { get; protected set; }
public string name { get; protected set; }
public Platform platform { get; protected set; default = Platform.CURRENT; }
public int64 full_size { get; protected set; default = 0; }
public string? version { get; protected set; }
public string? language { get; protected set; }
public string? language_name { get; protected set; }

// allow doing something on import
public bool can_import { get; protected set; default = false; }

public bool is_installable
{
Expand All @@ -43,6 +46,7 @@ namespace GameHub.Data.Runnables.Tasks.Install
}

public abstract async bool install(InstallTask task);
public virtual async bool import (InstallTask task) { return false; } // allow doing something on import
}

public abstract class FileInstaller: Installer
Expand Down Expand Up @@ -223,7 +227,7 @@ namespace GameHub.Data.Runnables.Tasks.Install
}
}

if(dirname != null && !(task.runnable is GameHub.Data.Sources.GOG.GOGGame.DLC))
if(dirname != null && !(task.runnable is GameHub.Data.Sources.GOG.GOGGame.DLC) && !(task.runnable is GameHub.Data.Sources.EpicGames.EpicGame.DLC))
{
FS.mv_up(task.install_dir, dirname.replace(" ", "\\ "));
}
Expand Down
4 changes: 2 additions & 2 deletions src/data/runnables/traits/HasExecutableFile.vala
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ namespace GameHub.Data.Runnables.Traits
});
}

protected virtual async void pre_run(){}
protected virtual async void post_run(){}
public virtual async void pre_run(){}
public virtual async void post_run(){}

protected virtual string[] cmdline
{
Expand Down
Loading