Skip to content

Commit c0db3cf

Browse files
Merge pull request #51 from KrystianLesniak/develop
Release: 1.9.0
2 parents 81d9435 + ea3370f commit c0db3cf

9 files changed

Lines changed: 160 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ GamesLauncher is a plugin for [Flow launcher](https://github.com/Flow-Launcher/F
1616
* Steam
1717
* Epic Games Launcher
1818
* Xbox
19+
* GOG Galaxy
1920
* EA app
2021
* Ubisoft Connect
2122
* Amazon Games

src/GamesLauncher.Common/Settings/MainSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public class MainSettings
88
public bool SynchronizeAmazon { get; set; } = true;
99
public bool SynchronizeUbisoft { get; set; } = true;
1010
public bool SynchronizeEaApp { get; set; } = true;
11+
public bool SynchronizeGogGalaxy { get; set; } = true;
1112
}
1213
}

src/GamesLauncher.Platforms/GamesLauncher.Platforms.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20+
<PackageReference Include="GameFinder.StoreHandlers.GOG" Version="4.0.0" />
2021
<PackageReference Include="GameFinder.StoreHandlers.Steam" Version="4.0.0" />
2122
<PackageReference Include="GameFinder.StoreHandlers.Xbox" Version="4.0.0" />
2223
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" />

src/GamesLauncher.Platforms/PlatformsManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using GamesLauncher.Platforms.SyncEngines.Common.Interfaces;
66
using GamesLauncher.Platforms.SyncEngines.EaApp;
77
using GamesLauncher.Platforms.SyncEngines.Epic;
8+
using GamesLauncher.Platforms.SyncEngines.Gog;
89
using GamesLauncher.Platforms.SyncEngines.Steam;
910
using GamesLauncher.Platforms.SyncEngines.Ubisoft;
1011
using System.Diagnostics;
@@ -74,6 +75,9 @@ private IEnumerable<ISyncEngine> InitializeEngines(MainSettings settings)
7475
if (settings.SynchronizeEaApp)
7576
engines.Add(new EaAppSyncEngine(publicApi));
7677

78+
if(settings.SynchronizeGogGalaxy)
79+
engines.Add(new GogSyncEngine(publicApi));
80+
7781
engines.Add(new ShortcutsSyncEngine(publicApi));
7882

7983
return engines;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using GamesLauncher.Platforms.SyncEngines.Common.ControlPanelUninstall;
2+
3+
namespace GamesLauncher.Platforms.SyncEngines.Gog
4+
{
5+
internal class GogGalaxyClient
6+
{
7+
internal string IconPath { get; private set; } = string.Empty;
8+
internal string ExePath { get; private set; } = string.Empty;
9+
10+
internal static async Task<GogGalaxyClient?> GetIfInstalled()
11+
{
12+
var gogUninstall = (await ControlPanelUninstall.GetPrograms()).Where(x => x.DisplayName == "GOG GALAXY").FirstOrDefault();
13+
14+
if (gogUninstall is null)
15+
return null;
16+
17+
var clientExeLocation = Path.Combine(gogUninstall.InstallLocation, "GalaxyClient.exe");
18+
19+
if (!File.Exists(clientExeLocation))
20+
return null;
21+
22+
return new GogGalaxyClient
23+
{
24+
ExePath = clientExeLocation,
25+
IconPath = Path.Combine(gogUninstall.InstallLocation, "Icons", "default.ico")
26+
};
27+
}
28+
}
29+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using Flow.Launcher.Plugin;
2+
using GameFinder.Common;
3+
using GameFinder.RegistryUtils;
4+
using GameFinder.StoreHandlers.GOG;
5+
using GamesLauncher.Platforms.SyncEngines.Common.Interfaces;
6+
using NexusMods.Paths;
7+
8+
namespace GamesLauncher.Platforms.SyncEngines.Gog
9+
{
10+
internal class GogSyncEngine : ISyncEngine
11+
{
12+
public string PlatformName => "GOG Galaxy";
13+
public IEnumerable<Game> SynchronizedGames { get; private set; } = Array.Empty<Game>();
14+
15+
16+
private readonly GOGHandler handler = new (WindowsRegistry.Shared, FileSystem.Shared);
17+
private readonly IPublicAPI publicApi;
18+
19+
public GogSyncEngine(IPublicAPI publicApi)
20+
{
21+
this.publicApi = publicApi;
22+
}
23+
24+
public async Task SynchronizeGames()
25+
{
26+
var gogClient = await GogGalaxyClient.GetIfInstalled();
27+
if (gogClient is null)
28+
return;
29+
30+
var games = handler.FindAllGames().Where(x => x.IsGame()).Select(x => x.AsGame());
31+
var syncedGames = new List<Game>();
32+
33+
foreach (var game in games)
34+
{
35+
syncedGames.Add(MapGogGameToGame(game, gogClient));
36+
}
37+
38+
SynchronizedGames = syncedGames;
39+
}
40+
41+
private Game MapGogGameToGame(GOGGame gogGame, GogGalaxyClient gogClient)
42+
{
43+
return new Game(
44+
title: gogGame.Name,
45+
runTask: GetGameRunTask(gogGame, gogClient),
46+
iconPath: GetIconPath(gogGame, gogClient),
47+
platform: PlatformName,
48+
iconDelegate: null,
49+
uninstallAction: GetGogUninstallTask(gogGame)
50+
);
51+
}
52+
53+
private Func<Task> GetGameRunTask(GOGGame gogGame, GogGalaxyClient gogClient)
54+
{
55+
var argString = $"/command=runGame /gameId={gogGame.Id} /path=\"{gogGame.Path}\"";
56+
57+
return async () =>
58+
{
59+
publicApi.ShellRun(argString, gogClient.ExePath);
60+
await Task.CompletedTask;
61+
};
62+
}
63+
private static string GetIconPath(GOGGame gogGame, GogGalaxyClient gogClient)
64+
{
65+
var icoPath = Path.Combine(gogGame.Path.ToString(), $"goggame-{gogGame.Id}.ico");
66+
67+
if (File.Exists(icoPath))
68+
return icoPath;
69+
else
70+
return gogClient.IconPath;
71+
}
72+
73+
private UninstallAction? GetGogUninstallTask(GOGGame gogGame)
74+
{
75+
var uninstallExe = Path.Combine(gogGame.Path.ToString(), "unins000.exe");
76+
77+
if (!File.Exists(uninstallExe))
78+
return null;
79+
80+
return new UninstallAction(async () =>
81+
{
82+
var directory = Path.GetDirectoryName(uninstallExe);
83+
var uninstallFileExe = Path.GetFileName(uninstallExe);
84+
publicApi.ShellRun($"cd /d \"{directory}\" && start \"\" \"{uninstallFileExe}\"");
85+
86+
for (int i = 0; i < 12; i++)
87+
{
88+
var game = handler.FindAllGames().Where(x => x.IsGame()).Select(x => x.AsGame()).FirstOrDefault(x=> x.Id == gogGame.Id);
89+
90+
if (game is null)
91+
break;
92+
93+
await Task.Delay(TimeSpan.FromSeconds(5));
94+
}
95+
96+
await SynchronizeGames();
97+
});
98+
}
99+
}
100+
}

src/GamesLauncher/Views/SettingsView.xaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<RowDefinition />
2222
<RowDefinition />
2323
<RowDefinition />
24+
<RowDefinition />
2425
</Grid.RowDefinitions>
2526
<TextBlock
2627
Grid.Row="0"
@@ -46,26 +47,32 @@
4647
HorizontalAlignment="Left"
4748
Content="Xbox" />
4849
<CheckBox
49-
x:Name="SynchronizeEaApp"
50+
x:Name="SynchronizeGogGalaxy"
5051
Grid.Row="4"
5152
Margin="10,5,5,5"
5253
HorizontalAlignment="Left"
54+
Content="GOG Galaxy" />
55+
<CheckBox
56+
x:Name="SynchronizeEaApp"
57+
Grid.Row="5"
58+
Margin="10,5,5,5"
59+
HorizontalAlignment="Left"
5360
Content="EA app" />
5461
<CheckBox
5562
x:Name="SynchronizeUbisoft"
56-
Grid.Row="5"
63+
Grid.Row="6"
5764
Margin="10,5,5,5"
5865
HorizontalAlignment="Left"
5966
Content="Ubisoft Connect" />
6067
<CheckBox
6168
x:Name="SynchronizeAmazon"
62-
Grid.Row="6"
69+
Grid.Row="7"
6370
Margin="10,5,5,5"
6471
HorizontalAlignment="Left"
6572
Content="Amazon Games" />
6673
<Button
6774
Click="BtnOpenCustomShortcutsDirectory_Click"
68-
Grid.Row="7"
75+
Grid.Row="8"
6976
Margin="10,5,5,5"
7077
Padding="20,10,20,10"
7178
HorizontalAlignment="Left"
@@ -76,7 +83,7 @@
7683
</Button>
7784
<Button
7885
Click="BtnShowHiddenGames_Click"
79-
Grid.Row="8"
86+
Grid.Row="9"
8087
Margin="10,5,5,5"
8188
Padding="20,10,20,10"
8289
HorizontalAlignment="Left"
@@ -85,7 +92,7 @@
8592
<StackPanel
8693
Name="HiddenGamesStackPanel"
8794
Visibility="Collapsed"
88-
Grid.Row="9">
95+
Grid.Row="10">
8996
<ListView
9097
Name="HiddenGames"
9198
Height="auto"

src/GamesLauncher/Views/SettingsView.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private void SettingsView_OnLoaded(object sender, RoutedEventArgs re)
3030
SynchronizeSteam.IsChecked = _settings.SynchronizeSteam;
3131
SyncrhonizeEpic.IsChecked = _settings.SynchronizeEpicGamesStore;
3232
SynchronizeXbox.IsChecked = _settings.SynchronizeXbox;
33+
SynchronizeGogGalaxy.IsChecked = _settings.SynchronizeGogGalaxy;
3334
SynchronizeEaApp.IsChecked = _settings.SynchronizeEaApp;
3435
SynchronizeUbisoft.IsChecked = _settings.SynchronizeUbisoft;
3536
SynchronizeAmazon.IsChecked = _settings.SynchronizeAmazon;
@@ -61,6 +62,15 @@ private void SettingsView_OnLoaded(object sender, RoutedEventArgs re)
6162
_settings.SynchronizeXbox = false;
6263
};
6364

65+
SynchronizeGogGalaxy.Checked += (o, e) =>
66+
{
67+
_settings.SynchronizeGogGalaxy = true;
68+
};
69+
SynchronizeGogGalaxy.Unchecked += (o, e) =>
70+
{
71+
_settings.SynchronizeGogGalaxy = false;
72+
};
73+
6474
SynchronizeEaApp.Checked += (o, e) =>
6575
{
6676
_settings.SynchronizeEaApp = true;

src/GamesLauncher/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "GamesLauncher",
55
"Description": "Search and launch games from multiple platforms like Steam, Epic Games, Xbox etc.",
66
"Author": "KrystianLesniak",
7-
"Version": "1.8.0",
7+
"Version": "1.9.0",
88
"Language": "csharp",
99
"Website": "https://github.com/KrystianLesniak/Flow.Launcher.Plugin.GamesLauncher",
1010
"IcoPath": "icon.png",

0 commit comments

Comments
 (0)