Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance steam shortcut creation #366

Merged
merged 3 commits into from
Apr 15, 2020
Merged
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
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