Skip to content
Open
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
19 changes: 19 additions & 0 deletions data/com.github.tkashkin.gamehub.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,21 @@
</key>
</schema>

<schema path="@SCHEMA_PATH@/auth/epic/" id="@[email protected]">
<key name="enabled" type="b">
<default>true</default>
<summary>Is Epic enabled</summary>
</key>
<key name="authenticated" type="b">
<default>false</default>
<summary>Did user get authentication code</summary>
</key>
<key name="auth-code" type="s">
<default>'@PREF_AUTH_CODE_EPIC@'</default>
<summary>Epic AUTH CODE</summary>
</key>
</schema>

<!-- Paths -->
<schema path="@SCHEMA_PATH@/paths/" id="@[email protected]">
<key name="steam-home" type="s">
Expand All @@ -221,6 +236,10 @@
<default>'~/Games/itch'</default>
<summary>itch.io games directory</summary>
</key>
<key name="epic-games" type="s">
<default>'~/Games/epic'</default>
<summary>Epic games directory</summary>
</key>
</schema>

<!-- Paths / Collection -->
Expand Down
1 change: 1 addition & 0 deletions data/icons/icons.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<gresource prefix="/com/github/tkashkin/gamehub/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 data/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.Sources.Steam;
using GameHub.Data.Sources.GOG;
using GameHub.Data.Sources.EpicGames;

namespace GameHub.Data
{
Expand Down
9 changes: 9 additions & 0 deletions src/data/db/tables/Games.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using Sqlite;
using GameHub.Utils;

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 @@ -311,6 +312,10 @@ namespace GameHub.Data.DB.Tables
{
g = new SteamGame.from_db((Steam) s, st);
}
else if(s is EpicGames)
{
g = new EpicGamesGame.from_db((EpicGames) s, st);
}
else if(s is GOG)
{
g = new GOGGame.from_db((GOG) s, st);
Expand Down Expand Up @@ -396,6 +401,10 @@ namespace GameHub.Data.DB.Tables
{
g = new SteamGame.from_db((Steam) s, st);
}
else if(s is EpicGames)
{
g = new EpicGamesGame.from_db((EpicGames) s, st);
}
else if(s is GOG)
{
g = new GOGGame.from_db((GOG) s, st);
Expand Down
1 change: 1 addition & 0 deletions src/data/db/tables/IGDBData.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using GameHub.Utils;
using GameHub.Data.Sources.Steam;
using GameHub.Data.Sources.GOG;
using GameHub.Data.Sources.Humble;
using GameHub.Data.Sources.EpicGames;

namespace GameHub.Data.DB.Tables
{
Expand Down
1 change: 1 addition & 0 deletions src/data/db/tables/Tags.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using Sqlite;
using GameHub.Utils;

using GameHub.Data.Sources.Steam;
using GameHub.Data.Sources.EpicGames;
using GameHub.Data.Sources.GOG;
using GameHub.Data.Sources.Humble;

Expand Down
185 changes: 185 additions & 0 deletions src/data/sources/epicgames/EpicGames.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
This file is part of GameHub.
Copyright (C) 2018-2019 Anatoliy Kashkin
Copyright (C) 2020 Adam Jordanek

GameHub is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

GameHub is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GameHub. If not, see <https://www.gnu.org/licenses/>.
*/

using Gee;
using GameHub.Data.DB;
using GameHub.Utils;

namespace GameHub.Data.Sources.EpicGames
{
public class EpicGames: GameSource
{
public static EpicGames instance;

private bool? installed = null;
public File? legendary_executable = null;

public override string id { get { return "epicgames"; } }
public override string name { get { return "EpicGames"; } }
public override string icon { get { return "source-epicgames-symbolic"; } }

private Regex regex = /\*\s*([^(]*)\s\(App\sname:\s([a-zA-Z0-9]+),\sversion:\s([^)]*)\)/;

private bool enable = true;
public override bool enabled
{
get { return enable; }
set { enable = value; }
}


public LegendaryWrapper? legendary_wrapper { get; private set; }

public string? user_id { get; protected set; }
public string? user_name { get; protected set; }

public EpicGames()
{
instance = this;
legendary_wrapper = new LegendaryWrapper();
}

public override bool is_installed(bool refresh)
{
/*
Epic games depends on
*/
if(installed != null && !refresh)
{
return (!) installed;
}

//check if legendary exists
var legendary = Utils.find_executable("legendary");

if(legendary == null || !legendary.query_exists())
{
debug("[EpicGames] is_installed: Legendary not found");

}
else
{
debug("[EpicGames] is_installed: LegendaryYES");
}

legendary_executable = legendary;

installed = legendary_executable != null && legendary_executable.query_exists();

return (!) installed;

}

public override async bool install()
{
debug("[EpicGames] install: NOT IMPLEMENTED");
return true;
}

public override async bool authenticate()
{
debug("[EpicGames] authenticate: NOT IMPLEMENTED");
return true;
}

public override bool is_authenticated()
{
debug("[EpicGames] is_authenticated: NOT IMPLEMENTED");
return true;
}

public override bool can_authenticate_automatically()
{
debug("[EpicGames] can_authenticate_automatically: NOT IMPLEMENTED");
return true;
}

public async bool refresh_token()
{
debug("[EpicGames] refresh_token: NOT IMPLEMENTED");
return true;
}

private ArrayList<Game> _games = new ArrayList<Game>(Game.is_equal);

public override ArrayList<Game> games { get { return _games; } }

public override async ArrayList<Game> load_games(Utils.FutureResult2<Game, bool>? game_loaded=null, Utils.Future? cache_loaded=null)
{
if(_games.size > 0)
{
return _games;
}

debug("[EpicGames] Load games");

Utils.thread("EpicGamesLoading", () => {
_games.clear();

games_count = 0;

var cached = Tables.Games.get_all(this);
if(cached.size > 0)
{
foreach(var g in cached)
{
if(!Settings.UI.Behavior.instance.merge_games || !Tables.Merges.is_game_merged(g))
{
_games.add(g);
if(game_loaded != null)
{
game_loaded(g, true);
}
}
games_count++;
}
}

if(cache_loaded != null)
{
cache_loaded();
}

var games = legendary_wrapper.getGames();
foreach(var game in games)
{
var g = new EpicGamesGame(this, game.name, game.id);
bool is_new_game = !_games.contains(g);
if(is_new_game) {
g.save();
if(game_loaded != null)
{
game_loaded(g, true);
}
_games.add(g);
games_count++;
} else {
var index = _games.index_of(g);
_games.get(index).update_status();
}
}
Idle.add(load_games.callback);
});
yield;
return _games;
}


}
}
Loading