Skip to content

Commit

Permalink
Implement Humble Trove support (tkashkin#32)
Browse files Browse the repository at this point in the history
Former-commit-id: 9e3dc15
  • Loading branch information
tkashkin committed Sep 15, 2018
1 parent d631bc4 commit db088d0
Show file tree
Hide file tree
Showing 18 changed files with 405 additions and 106 deletions.
3 changes: 3 additions & 0 deletions data/com.github.tkashkin.gamehub.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<key name="access-token" type="s">
<default>''</default>
</key>
<key name="load-trove-games" type="b">
<default>true</default>
</key>
</schema>

<schema path="/com/github/tkashkin/gamehub/paths/" id="com.github.tkashkin.gamehub.paths" gettext-domain="com.github.tkashkin.gamehub">
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 @@ -5,6 +5,7 @@
<file alias="scalable/actions/source-steam-symbolic.svg">symbolic/sources/steam.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>

<file alias="scalable/actions/platform-linux-symbolic.svg">symbolic/platforms/linux.svg</file>
<file alias="scalable/actions/platform-windows-symbolic.svg">symbolic/platforms/windows.svg</file>
Expand Down
4 changes: 4 additions & 0 deletions data/icons/symbolic/sources/humble-trove.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions data/icons/symbolic/sources/sources-all.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ namespace GameHub
protected override void activate()
{
info("Distro: %s", Utils.get_distro());

FSUtils.make_dirs();

Database.create();

Platforms = { Platform.LINUX, Platform.WINDOWS, Platform.MACOS };
CurrentPlatform = Platform.LINUX;

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

CompatTool[] tools = { new Compat.Innoextract() };
foreach(var appid in Compat.Proton.APPIDS)
Expand Down
1 change: 1 addition & 0 deletions src/data/db/tables/Games.vala
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace GameHub.Data.DB.Tables
public static bool add(Game game)
{
if(game is Sources.GOG.GOGGame.DLC) return false;
//if(game is Sources.Humble.HumbleGame && ((Sources.Humble.HumbleGame) game).order_id == Sources.Humble.Trove.FAKE_ORDER) return false;

unowned Sqlite.Database? db = Database.instance.db;
if(db == null) return false;
Expand Down
56 changes: 35 additions & 21 deletions src/data/sources/humble/HumbleGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace GameHub.Data.Sources.Humble
{
public class HumbleGame: Game
{
private string order_id;
public string order_id;

private bool game_info_updated = false;

Expand All @@ -27,14 +27,17 @@ namespace GameHub.Data.Sources.Humble
info = Json.to_string(json_node, false);

platforms.clear();
foreach(var dl in json_obj.get_array_member("downloads").get_elements())
if(json_obj.has_member("downloads") && json_obj.get_member("downloads").get_node_type() == Json.NodeType.ARRAY)
{
var pl = dl.get_object().get_string_member("platform");
foreach(var p in Platforms)
foreach(var dl in json_obj.get_array_member("downloads").get_elements())
{
if(pl == p.id())
var pl = dl.get_object().get_string_member("platform");
foreach(var p in Platforms)
{
platforms.add(p);
if(pl == p.id())
{
platforms.add(p);
}
}
}
}
Expand All @@ -54,7 +57,7 @@ namespace GameHub.Data.Sources.Humble
info_detailed = Tables.Games.INFO_DETAILED.get(s);
icon = Tables.Games.ICON.get(s);
image = Tables.Games.IMAGE.get(s);
install_dir = FSUtils.file(Tables.Games.INSTALL_PATH.get(s)) ?? FSUtils.file(FSUtils.Paths.GOG.Games, escaped_name);
install_dir = FSUtils.file(Tables.Games.INSTALL_PATH.get(s)) ?? FSUtils.file(FSUtils.Paths.Humble.Games, escaped_name);
executable = FSUtils.file(Tables.Games.EXECUTABLE.get(s)) ?? FSUtils.file(install_dir.get_path(), "start.sh");
compat_tool = Tables.Games.COMPAT_TOOL.get(s);
compat_tool_settings = Tables.Games.COMPAT_TOOL_SETTINGS.get(s);
Expand Down Expand Up @@ -143,25 +146,36 @@ namespace GameHub.Data.Sources.Humble
var product = Parser.parse_json(info).get_object();
if(product == null) return;

foreach(var dl_node in product.get_array_member("downloads").get_elements())
if(product.has_member("_gamehub_description"))
{
var dl = dl_node.get_object();
var id = dl.get_string_member("machine_name");
var os = dl.get_string_member("platform");
var platform = CurrentPlatform;
foreach(var p in Platforms)
description = product.get_string_member("_gamehub_description");
}

if(product.has_member("downloads") && product.get_member("downloads").get_node_type() == Json.NodeType.ARRAY)
{
foreach(var dl_node in product.get_array_member("downloads").get_elements())
{
if(os == p.id())
var dl = dl_node.get_object();
var id = dl.get_string_member("machine_name");
var os = dl.get_string_member("platform");
var platform = CurrentPlatform;
foreach(var p in Platforms)
{
platform = p;
break;
if(os == p.id())
{
platform = p;
break;
}
}
}

foreach(var dls_node in dl.get_array_member("download_struct").get_elements())
{
var installer = new Installer(id, platform, dls_node.get_object());
installers.add(installer);
if(dl.has_member("download_struct") && dl.get_member("download_struct").get_node_type() == Json.NodeType.ARRAY)
{
foreach(var dls_node in dl.get_array_member("download_struct").get_elements())
{
var installer = new Installer(id, platform, dls_node.get_object());
installers.add(installer);
}
}
}
}

Expand Down
Loading

0 comments on commit db088d0

Please sign in to comment.