Skip to content

Commit

Permalink
Merge pull request #366 from Lucki/issue-#319
Browse files Browse the repository at this point in the history
Enhance steam shortcut creation
  • Loading branch information
tkashkin authored Apr 15, 2020
2 parents 7724323 + 28a577f commit 57b25a7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/data/sources/steam/Steam.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ along with GameHub. If not, see <https://www.gnu.org/licenses/>.
using Gee;
using GameHub.Data.DB;
using GameHub.Utils;
using ZLib.Utility;

namespace GameHub.Data.Sources.Steam
{
Expand Down Expand Up @@ -446,10 +447,14 @@ namespace GameHub.Data.Sources.Steam

var root_node = vdf.read() as BinaryVDF.ListNode;

if(root_node == null)
if(root_node.get("shortcuts") == null)
{
root_node = new BinaryVDF.ListNode.node("shortcuts");
}
else
{
root_node = root_node.get("shortcuts") as BinaryVDF.ListNode;
}

var game_node = new BinaryVDF.ListNode.node(root_node.nodes.size.to_string());

Expand All @@ -470,8 +475,30 @@ namespace GameHub.Data.Sources.Steam
game_node.add_node(new BinaryVDF.StringNode.node("icon", cached.get_path()));
}

if(game.image_vertical != null)
{
try
{
var cached = ImageCache.local_file(game.image_vertical, @"games/$(game.source.id)/$(game.id)/images/");
// https://github.com/boppreh/steamgrid/blob/master/games.go#L120
uint64 id = crc32(0, (ProjectConfig.PROJECT_NAME + game.name).data) | 0x80000000;
var dest = FSUtils.file(get_userdata_dir().get_child("config").get_child("grid").get_path(), id.to_string() + "p.png");
cached.copy(dest, NONE);
}
catch (Error e) {}
}

var tags_node = new BinaryVDF.ListNode.node("tags");
tags_node.add_node(new BinaryVDF.StringNode.node("0", "GameHub"));

foreach(var tag in game.tags)
{
if(tag.removable)
{
tags_node.add_node(new BinaryVDF.StringNode.node((game.tags.index_of(tag) + 1).to_string(), tag.name));
}
}

game_node.add_node(tags_node);

root_node.add_node(game_node);
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ deps = [
dependency('sqlite3'),
dependency('libxml-2.0'),
dependency('gio-unix-2.0'),
dependency('zlib'),
meson.get_compiler('vala').find_library('posix'),
meson.get_compiler('vala').find_library('linux')
]
Expand Down

0 comments on commit 57b25a7

Please sign in to comment.