Skip to content

Commit

Permalink
Humble Bundle support
Browse files Browse the repository at this point in the history
0.3.0 release


Former-commit-id: 89968b4
  • Loading branch information
tkashkin committed Jun 17, 2018
1 parent dd210e9 commit df0d8a8
Show file tree
Hide file tree
Showing 27 changed files with 603 additions and 105 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ GameHub can support multiple game sources and services
__Currently supported sources:__
* Steam
* GOG.com
* Humble Bundle

## Features
__Implemented:__
Expand Down
5 changes: 5 additions & 0 deletions data/com.github.tkashkin.gamehub.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
</screenshots>

<releases>
<release version="0.3.0" date="2018-06-17">
<description>
<p>Humble Bundle support</p>
</description>
</release>
<release version="0.2.5" date="2018-06-12">
<description>
<p>Bug fixes</p>
Expand Down
12 changes: 12 additions & 0 deletions data/com.github.tkashkin.gamehub.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,24 @@
</key>
</schema>

<schema path="/com/github/tkashkin/gamehub/auth/humble/" id="com.github.tkashkin.gamehub.auth.humble" gettext-domain="com.github.tkashkin.gamehub">
<key name="authenticated" type="b">
<default>false</default>
</key>
<key name="access-token" type="s">
<default>''</default>
</key>
</schema>

<schema path="/com/github/tkashkin/gamehub/paths/" id="com.github.tkashkin.gamehub.paths" gettext-domain="com.github.tkashkin.gamehub">
<key name="steam-home" type="s">
<default>'~/.steam'</default>
</key>
<key name="gog-games" type="s">
<default>'~/Games/GOG'</default>
</key>
<key name="humble-games" type="s">
<default>'~/Games/HumbleBundle'</default>
</key>
</schema>
</schemalist>
1 change: 1 addition & 0 deletions data/icons/humble-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/icons/humble.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions data/icons/icons.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<gresource prefix="/com/github/tkashkin/gamehub/icons">
<file alias="steam.svg" compressed="true" preprocess="xml-stripblanks">steam.svg</file>
<file alias="gog.svg" compressed="true" preprocess="xml-stripblanks">gog.svg</file>
<file alias="humble.svg" compressed="true" preprocess="xml-stripblanks">humble.svg</file>

<file alias="steam-white.svg" compressed="true" preprocess="xml-stripblanks">steam-white.svg</file>
<file alias="gog-white.svg" compressed="true" preprocess="xml-stripblanks">gog-white.svg</file>
<file alias="humble-white.svg" compressed="true" preprocess="xml-stripblanks">humble-white.svg</file>
</gresource>
</gresources>
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
com.github.tkashkin.gamehub (0.3.0) xenial; urgency=low

* Humble Bundle support

-- tkashkin <[email protected]> Sun, 17 Jun 2018 04:57:12 +0300

com.github.tkashkin.gamehub (0.2.5) xenial; urgency=low

* Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.2.5')
project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.3.0')

i18n = import('i18n')
gnome = import('gnome')
Expand Down
9 changes: 6 additions & 3 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ src/data/GameSource.vala
src/data/sources/steam/Steam.vala
src/data/sources/steam/SteamGame.vala

src/data/GamesDB.vala

src/data/sources/gog/GOG.vala
src/data/sources/gog/GOGGame.vala

src/data/sources/humble/Humble.vala
src/data/sources/humble/HumbleGame.vala

src/data/GamesDB.vala

src/ui/windows/MainWindow.vala
src/ui/windows/WebAuthWindow.vala

src/ui/dialogs/SettingsDialog.vala
src/ui/dialogs/GOGGameInstallDialog.vala
src/ui/dialogs/GameInstallDialog.vala

src/ui/views/BaseView.vala
src/ui/views/WelcomeView.vala
Expand Down
29 changes: 21 additions & 8 deletions po/com.github.tkashkin.gamehub.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: com.github.tkashkin.gamehub\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-02 05:53+0300\n"
"POT-Creation-Date: 2018-06-17 04:53+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -50,6 +50,19 @@ msgstr ""
msgid "Your SteamID will be read from Steam configuration file"
msgstr ""

#: src/data/sources/humble/HumbleGame.vala:163
msgid "Select main executable of the game"
msgstr ""

#: src/data/sources/humble/HumbleGame.vala:164
#: src/ui/dialogs/GameInstallDialog.vala:75
msgid "Cancel"
msgstr ""

#: src/data/sources/humble/HumbleGame.vala:164
msgid "Select"
msgstr ""

#: src/ui/dialogs/SettingsDialog.vala:27
msgid "Use dark theme"
msgstr ""
Expand All @@ -74,19 +87,19 @@ msgstr ""
msgid "GOG games directory"
msgstr ""

#: src/ui/dialogs/SettingsDialog.vala:50
msgid "Close"
#: src/ui/dialogs/SettingsDialog.vala:41
msgid "Humble Bundle games directory"
msgstr ""

#: src/ui/dialogs/GOGGameInstallDialog.vala:47
msgid "Select game language"
#: src/ui/dialogs/SettingsDialog.vala:54
msgid "Close"
msgstr ""

#: src/ui/dialogs/GOGGameInstallDialog.vala:69
msgid "Cancel"
#: src/ui/dialogs/GameInstallDialog.vala:48
msgid "Select game installer"
msgstr ""

#: src/ui/dialogs/GOGGameInstallDialog.vala:70
#: src/ui/dialogs/GameInstallDialog.vala:76
msgid "Install"
msgstr ""

Expand Down
39 changes: 23 additions & 16 deletions po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: com.github.tkashkin.gamehub\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-02 05:53+0300\n"
"POT-Creation-Date: 2018-06-17 04:53+0300\n"
"PO-Revision-Date: 2018-05-27 03:39+0300\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand All @@ -18,12 +18,6 @@ msgstr ""
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"

#: data/com.github.tkashkin.gamehub.appdata.xml.in:8
#: data/com.github.tkashkin.gamehub.desktop.in:3
#: data/com.github.tkashkin.gamehub.desktop.in:4
msgid "GameHub"
msgstr ""

#: data/com.github.tkashkin.gamehub.appdata.xml.in:9
#: data/com.github.tkashkin.gamehub.desktop.in:5
#: src/ui/views/WelcomeView.vala:32
Expand All @@ -38,6 +32,19 @@ msgstr "Управляйте играми из Steam и GOG в одном мес
msgid "Your SteamID will be read from Steam configuration file"
msgstr "Ваш SteamID будет прочитан из файла конфигурации Steam"

#: src/data/sources/humble/HumbleGame.vala:163
msgid "Select main executable of the game"
msgstr "Выберите исполняемый файл игры"

#: src/data/sources/humble/HumbleGame.vala:164
#: src/ui/dialogs/GameInstallDialog.vala:75
msgid "Cancel"
msgstr "Отмена"

#: src/data/sources/humble/HumbleGame.vala:164
msgid "Select"
msgstr "Выбрать"

#: src/ui/dialogs/SettingsDialog.vala:27
msgid "Use dark theme"
msgstr "Использовать тёмную тему"
Expand All @@ -62,19 +69,19 @@ msgstr "Папка установки Steam"
msgid "GOG games directory"
msgstr "Папка игр GOG"

#: src/ui/dialogs/SettingsDialog.vala:50
#: src/ui/dialogs/SettingsDialog.vala:41
msgid "Humble Bundle games directory"
msgstr "Папка игр Humble Bundle"

#: src/ui/dialogs/SettingsDialog.vala:54
msgid "Close"
msgstr "Закрыть"

#: src/ui/dialogs/GOGGameInstallDialog.vala:47
msgid "Select game language"
msgstr "Выберите язык игры"

#: src/ui/dialogs/GOGGameInstallDialog.vala:69
msgid "Cancel"
msgstr "Отмена"
#: src/ui/dialogs/GameInstallDialog.vala:48
msgid "Select game installer"
msgstr "Выберите установочный файл игры"

#: src/ui/dialogs/GOGGameInstallDialog.vala:70
#: src/ui/dialogs/GameInstallDialog.vala:76
msgid "Install"
msgstr "Установить"

Expand Down
3 changes: 2 additions & 1 deletion src/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Granite;
using GameHub.Data;
using GameHub.Data.Sources.Steam;
using GameHub.Data.Sources.GOG;
using GameHub.Data.Sources.Humble;
using GameHub.Utils;

namespace GameHub
Expand Down Expand Up @@ -42,7 +43,7 @@ namespace GameHub

GamesDB.init();

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

var app = new Application();
return app.run(args);
Expand Down
11 changes: 10 additions & 1 deletion src/data/Game.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace GameHub.Data
public string icon { get; protected set; }
public string image { get; protected set; }

public string playtime { get; protected set; default = ""; }
public string custom_info { get; protected set; default = ""; }

public virtual async bool is_for_linux(){ return true; }

Expand All @@ -25,5 +25,14 @@ namespace GameHub.Data
{
return first == second || (first.source == second.source && first.id == second.id);
}

public abstract class Installer
{
public string id { get; protected set; }
public string os { get; protected set; }
public string file { get; protected set; }

public virtual string name { get { return id; } }
}
}
}
17 changes: 14 additions & 3 deletions src/data/GamesDB.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using GameHub.Utils;

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

namespace GameHub.Data
{
Expand All @@ -28,22 +29,28 @@ namespace GameHub.Data

public void create_tables() requires (db != null)
{
db.exec("CREATE TABLE IF NOT EXISTS `games`(`source` string not null, `id` string not null, `name` string not null, `icon` string, `image` string, `playtime` string, PRIMARY KEY(`source`, `id`))");
Statement stmt;
if(db.prepare_v2("SELECT `playtime` FROM `games`", -1, out stmt) == Sqlite.OK) // migrate from v1
{
db.exec("DROP TABLE `games`");
}

db.exec("CREATE TABLE IF NOT EXISTS `games`(`source` string not null, `id` string not null, `name` string not null, `icon` string, `image` string, `custom_info` string, PRIMARY KEY(`source`, `id`))");
db.exec("CREATE TABLE IF NOT EXISTS `unsupported_games`(`source` string not null, `id` string not null, PRIMARY KEY(`source`, `id`))");
}

public bool add_game(Game game) requires (db != null)
{
Statement stmt;
int res = db.prepare_v2("INSERT OR REPLACE INTO `games`(`source`, `id`, `name`, `icon`, `image`, `playtime`) VALUES (?, ?, ?, ?, ?, ?)", -1, out stmt);
int res = db.prepare_v2("INSERT OR REPLACE INTO `games`(`source`, `id`, `name`, `icon`, `image`, `custom_info`) VALUES (?, ?, ?, ?, ?, ?)", -1, out stmt);
assert(res == Sqlite.OK);

stmt.bind_text(1, game.source.name);
stmt.bind_text(2, game.id);
stmt.bind_text(3, game.name);
stmt.bind_text(4, game.icon);
stmt.bind_text(5, game.image);
stmt.bind_text(6, game.playtime);
stmt.bind_text(6, game.custom_info);

res = stmt.step();

Expand Down Expand Up @@ -95,6 +102,10 @@ namespace GameHub.Data
{
games.add(new GOGGame.from_db((GOG) s, stmt));
}
else if(s is Humble)
{
games.add(new HumbleGame.from_db((Humble) s, stmt));
}
}

return games;
Expand Down
11 changes: 6 additions & 5 deletions src/data/sources/gog/GOG.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace GameHub.Data.Sources.GOG

public override async bool authenticate()
{
Settings.Auth.GOG.get_instance().authenticated = true;
settings.authenticated = true;

if(token_needs_refresh && user_refresh_token != null)
{
Expand All @@ -65,7 +65,7 @@ namespace GameHub.Data.Sources.GOG

public override bool can_authenticate_automatically()
{
return user_refresh_token != null && Settings.Auth.GOG.get_instance().authenticated;
return user_refresh_token != null && settings.authenticated;
}

private async bool get_auth_code()
Expand Down Expand Up @@ -102,7 +102,7 @@ namespace GameHub.Data.Sources.GOG
}

var url = @"https://auth.gog.com/token?client_id=$(CLIENT_ID)&client_secret=$(CLIENT_SECRET)&grant_type=authorization_code&redirect_uri=$(REDIRECT)&code=$(user_auth_code)";
var root = yield Parser.parse_remote_json_file_async(url);
var root = (yield Parser.parse_remote_json_file_async(url)).get_object();
user_token = root.get_string_member("access_token");
user_refresh_token = root.get_string_member("refresh_token");
user_id = root.get_string_member("user_id");
Expand All @@ -121,7 +121,7 @@ namespace GameHub.Data.Sources.GOG
}

var url = @"https://auth.gog.com/token?client_id=$(CLIENT_ID)&client_secret=$(CLIENT_SECRET)&grant_type=refresh_token&refresh_token=$(user_refresh_token)";
var root = yield Parser.parse_remote_json_file_async(url);
var root = (yield Parser.parse_remote_json_file_async(url)).get_object();
user_token = root.get_string_member("access_token");
user_refresh_token = root.get_string_member("refresh_token");
user_id = root.get_string_member("user_id");
Expand Down Expand Up @@ -156,9 +156,10 @@ namespace GameHub.Data.Sources.GOG
}
}
}
games_count = games.size;

var url = @"https://embed.gog.com/account/getFilteredProducts?mediaType=1";
var root = yield Parser.parse_remote_json_file_async(url, "GET", user_token);
var root = (yield Parser.parse_remote_json_file_async(url, "GET", user_token)).get_object();

var products = root.get_array_member("products");

Expand Down
Loading

0 comments on commit df0d8a8

Please sign in to comment.