Skip to content

Commit

Permalink
Epic games support
Browse files Browse the repository at this point in the history
  • Loading branch information
dotevo committed Jun 23, 2020
1 parent aac7b8f commit 4446b93
Show file tree
Hide file tree
Showing 14 changed files with 553 additions and 3 deletions.
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
157 changes: 157 additions & 0 deletions src/data/sources/epicgames/EpicGames.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
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;

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)
{
debug("[EpicGames] is_installed: NOT IMPLEMENTED");
return true;
}

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

0 comments on commit 4446b93

Please sign in to comment.