Skip to content

Commit 72ea9ee

Browse files
committedSep 11, 2022
Remove ExecutablePath from ILauncher
1 parent 693382f commit 72ea9ee

File tree

14 files changed

+87
-145
lines changed

14 files changed

+87
-145
lines changed
 

‎CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44
## [Unreleased]
55

66

7+
## [1.3.1] - 2022-11-09
8+
### Fixed
9+
- Activate parallel processing of installed games
10+
11+
### Deleted
12+
- Remove "ExecutablePath" from ILauncher interface
13+
14+
### Changed
15+
- "Executable" on ILauncher interface returns the executable including the path
16+
17+
718
## [1.3.0] - 2022-11-09
819
### Added
920
- Add Rockstar Games plugin for interacting with Rockstar Games launcher and games

‎GameLib.Core/ILauncher.cs

-6
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ public interface ILauncher
4646
/// The executable including the path of the Launcher<br/>
4747
/// <see langword="string.Empty"/> if not (properly) installed
4848
/// </summary>
49-
public string ExecutablePath { get; }
50-
51-
/// <summary>
52-
/// The executable name of the Launcher<br/>
53-
/// <see langword="string.Empty"/> if not (properly) installed
54-
/// </summary>
5549
public string Executable { get; }
5650

5751
/// <summary>

‎GameLib.Demo/GameLib.Demo.Wpf/ViewModels/LauncherViewModel.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public partial class LauncherViewModel : ViewModelBase
3636
[ObservableProperty]
3737
private string _isRunningLogo = CrossImagePath;
3838

39-
4039
public LauncherViewModel(LauncherManager launcherManager)
4140
{
4241
LoadData(launcherManager);
@@ -111,7 +110,7 @@ public static void RunLauncher(ILauncher? launcher)
111110
Process.Start(new ProcessStartInfo()
112111
{
113112
UseShellExecute = true,
114-
FileName = launcher.ExecutablePath
113+
FileName = launcher.Executable
115114
});
116115
}
117116
catch { /* ignore */ }
@@ -122,8 +121,8 @@ public static void OpenPath(ILauncher? launcher)
122121
{
123122
switch (launcher)
124123
{
125-
case not null when !string.IsNullOrEmpty(launcher.ExecutablePath):
126-
Process.Start("explorer.exe", $"/select,\"{launcher.ExecutablePath}\"");
124+
case not null when !string.IsNullOrEmpty(launcher.Executable):
125+
Process.Start("explorer.exe", $"/select,\"{launcher.Executable}\"");
127126
break;
128127

129128
case not null when !string.IsNullOrEmpty(launcher.InstallDir):

‎GameLib.Demo/GameLib.Demo.Wpf/Views/LauncherView.xaml

+11-43
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,18 @@
314314
</StackPanel>
315315
<!--#endregion-->
316316

317-
<!--#region Executable path-->
317+
<!--#region Executable-->
318318
<TextBlock
319319
Grid.Row="9"
320320
Grid.Column="0"
321321
HorizontalAlignment="Right"
322322
VerticalAlignment="Center"
323-
Text="Executable path: " />
323+
Text="Executable: " />
324324
<TextBox
325325
Grid.Row="9"
326326
Grid.Column="2"
327327
VerticalAlignment="Center"
328-
Text="{Binding SelectedLauncher.ExecutablePath, Mode=OneWay}" />
328+
Text="{Binding SelectedLauncher.Executable, Mode=OneWay}" />
329329
<StackPanel
330330
Grid.Row="9"
331331
Grid.Column="4"
@@ -335,7 +335,7 @@
335335
<Button
336336
Background="#373737"
337337
Command="{Binding CopyToClipboardCommand}"
338-
CommandParameter="{Binding SelectedLauncher.ExecutablePath}"
338+
CommandParameter="{Binding SelectedLauncher.Executable}"
339339
ToolTip="Copy to clipboard">
340340
<Image
341341
Width="20"
@@ -359,47 +359,15 @@
359359
</StackPanel>
360360
<!--#endregion-->
361361

362-
<!--#region Executable-->
363-
<TextBlock
364-
Grid.Row="11"
365-
Grid.Column="0"
366-
HorizontalAlignment="Right"
367-
VerticalAlignment="Center"
368-
Text="Executable: " />
369-
<TextBox
370-
Grid.Row="11"
371-
Grid.Column="2"
372-
VerticalAlignment="Center"
373-
Text="{Binding SelectedLauncher.Executable, Mode=OneWay}" />
374-
<StackPanel
375-
Grid.Row="11"
376-
Grid.Column="4"
377-
HorizontalAlignment="Left"
378-
VerticalAlignment="Center"
379-
Orientation="Horizontal">
380-
<Button
381-
Background="#373737"
382-
Command="{Binding CopyToClipboardCommand}"
383-
CommandParameter="{Binding SelectedLauncher.Executable}"
384-
ToolTip="Copy to clipboard">
385-
<Image
386-
Width="20"
387-
Height="20"
388-
Margin="2"
389-
Source="/Resources/copy-white.png" />
390-
</Button>
391-
</StackPanel>
392-
<!--#endregion-->
393-
394362
<!--#region IsInstalled-->
395363
<TextBlock
396-
Grid.Row="13"
364+
Grid.Row="11"
397365
Grid.Column="0"
398366
HorizontalAlignment="Right"
399367
VerticalAlignment="Center"
400368
Text="Is installed: " />
401369
<Image
402-
Grid.Row="13"
370+
Grid.Row="11"
403371
Grid.Column="2"
404372
Width="24"
405373
Height="24"
@@ -409,20 +377,20 @@
409377

410378
<!--#region IsRunning-->
411379
<TextBlock
412-
Grid.Row="15"
380+
Grid.Row="13"
413381
Grid.Column="0"
414382
HorizontalAlignment="Right"
415383
VerticalAlignment="Center"
416384
Text="Is running: " />
417385
<Image
418-
Grid.Row="15"
386+
Grid.Row="13"
419387
Grid.Column="2"
420388
Width="24"
421389
Height="24"
422390
HorizontalAlignment="Left"
423391
Source="{Binding IsRunningLogo}" />
424392
<StackPanel
425-
Grid.Row="15"
393+
Grid.Row="13"
426394
Grid.Column="4"
427395
HorizontalAlignment="Left"
428396
VerticalAlignment="Center"
@@ -442,13 +410,13 @@
442410

443411
<!--#region Installed games-->
444412
<TextBlock
445-
Grid.Row="17"
413+
Grid.Row="15"
446414
Grid.Column="0"
447415
HorizontalAlignment="Right"
448416
VerticalAlignment="Center"
449417
Text="Installed games: " />
450418
<TextBlock
451-
Grid.Row="17"
419+
Grid.Row="15"
452420
Grid.Column="2"
453421
HorizontalAlignment="Left"
454422
VerticalAlignment="Center"

‎GameLib.Plugin/GameLib.Plugin.BattleNet/BattleNetGameFactory.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public static IEnumerable<BattleNetGame> GetGames(ILauncher launcher, Cancellati
1313
var catalog = GetCatalog();
1414

1515
return DeserializeProductInstalls()
16-
//.AsParallel()
17-
//.WithCancellation(cancellationToken)
16+
.AsParallel()
17+
.WithCancellation(cancellationToken)
1818
.Select(product => BattleNetGameBuiler(launcher, product))
1919
.Where(game => game is not null)
2020
.Select(game => AddLauncherId(launcher, game))
@@ -90,7 +90,7 @@ private static BattleNetGame BattleNetGameBuiler(ILauncher launcher, ProductInst
9090
InstallDir = PathUtil.Sanitize(productInstall.Settings.installPath) ?? string.Empty,
9191
WorkingDir = PathUtil.Sanitize(productInstall.Settings.installPath) ?? string.Empty,
9292
InstallDate = PathUtil.GetCreationTime(productInstall.Settings.installPath) ?? DateTime.MinValue,
93-
LaunchString = $"\"{launcher.ExecutablePath}\" --game={productInstall.productCode.ToUpper()}",
93+
LaunchString = $"\"{launcher.Executable}\" --game={productInstall.productCode.ToUpper()}",
9494
ProductCode = productInstall.productCode ?? string.Empty,
9595
PlayRegion = productInstall.Settings.playRegion ?? string.Empty,
9696
SpeechLanguage = productInstall.Settings.selectedSpeechLanguage ?? string.Empty,
@@ -119,7 +119,7 @@ private static BattleNetGame AddCatalogData(ILauncher launcher, BattleNetGame ga
119119
if (!string.IsNullOrEmpty(catalogItem.ProductId))
120120
{
121121
game.ProductCode = catalogItem.ProductId;
122-
game.LaunchString = $"\"{launcher.ExecutablePath}\" --exec=\"launch {game.ProductCode}\"";
122+
game.LaunchString = $"\"{launcher.Executable}\" --exec=\"launch {game.ProductCode}\"";
123123
}
124124

125125
game.Executable = catalogItem.Executables.FirstOrDefault(defaultValue: string.Empty);
@@ -130,6 +130,4 @@ private static BattleNetGame AddCatalogData(ILauncher launcher, BattleNetGame ga
130130

131131
return game;
132132
}
133-
134-
135133
}

‎GameLib.Plugin/GameLib.Plugin.BattleNet/BattleNetLauncher.cs

+8-12
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,39 @@ public BattleNetLauncher(LauncherOptions? launcherOptions)
2828

2929
public bool IsInstalled { get; private set; }
3030

31-
public bool IsRunning => ProcessUtil.IsProcessRunning(ExecutablePath);
31+
public bool IsRunning => ProcessUtil.IsProcessRunning(Executable);
3232

3333
public string InstallDir { get; private set; } = string.Empty;
3434

35-
public string ExecutablePath { get; private set; } = string.Empty;
36-
3735
public string Executable { get; private set; } = string.Empty;
3836

39-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
37+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
4038

4139
public IEnumerable<IGame> Games { get; private set; } = Enumerable.Empty<IGame>();
4240

4341
public void Refresh(CancellationToken cancellationToken = default)
4442
{
45-
ExecutablePath = string.Empty;
4643
Executable = string.Empty;
4744
InstallDir = string.Empty;
4845
IsInstalled = false;
4946
Games = Enumerable.Empty<IGame>();
5047

51-
ExecutablePath = GetExecutable() ?? string.Empty;
52-
if (!string.IsNullOrEmpty(ExecutablePath))
48+
Executable = GetExecutable() ?? string.Empty;
49+
if (!string.IsNullOrEmpty(Executable))
5350
{
54-
Executable = Path.GetFileName(ExecutablePath);
55-
InstallDir = Path.GetDirectoryName(ExecutablePath) ?? string.Empty;
56-
IsInstalled = File.Exists(ExecutablePath);
51+
InstallDir = Path.GetDirectoryName(Executable) ?? string.Empty;
52+
IsInstalled = File.Exists(Executable);
5753
Games = BattleNetGameFactory.GetGames(this, cancellationToken);
5854
}
5955
}
6056

61-
public bool Start() => IsRunning || ProcessUtil.StartProcess(ExecutablePath);
57+
public bool Start() => IsRunning || ProcessUtil.StartProcess(Executable);
6258

6359
public void Stop()
6460
{
6561
if (IsRunning)
6662
{
67-
Process.Start(ExecutablePath, "--exec=shutdown");
63+
Process.Start(Executable, "--exec=shutdown");
6864
}
6965
}
7066
#endregion

‎GameLib.Plugin/GameLib.Plugin.Epic/EpicLauncher.cs

+8-12
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,38 @@ public EpicLauncher(LauncherOptions? launcherOptions)
2828

2929
public bool IsInstalled { get; private set; }
3030

31-
public bool IsRunning => ProcessUtil.IsProcessRunning(ExecutablePath);
31+
public bool IsRunning => ProcessUtil.IsProcessRunning(Executable);
3232

3333
public string InstallDir { get; private set; } = string.Empty;
3434

35-
public string ExecutablePath { get; private set; } = string.Empty;
36-
3735
public string Executable { get; private set; } = string.Empty;
3836

39-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
37+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
4038

4139
public IEnumerable<IGame> Games { get; private set; } = Enumerable.Empty<IGame>();
4240

43-
public bool Start() => IsRunning || ProcessUtil.StartProcess(ExecutablePath);
41+
public bool Start() => IsRunning || ProcessUtil.StartProcess(Executable);
4442

4543
public void Stop()
4644
{
4745
if (IsRunning)
4846
{
49-
ProcessUtil.StopProcess(ExecutablePath);
47+
ProcessUtil.StopProcess(Executable);
5048
}
5149
}
5250

5351
public void Refresh(CancellationToken cancellationToken = default)
5452
{
55-
ExecutablePath = string.Empty;
5653
Executable = string.Empty;
5754
InstallDir = string.Empty;
5855
IsInstalled = false;
5956
Games = Enumerable.Empty<IGame>();
6057

61-
ExecutablePath = GetExecutable() ?? string.Empty;
62-
if (!string.IsNullOrEmpty(ExecutablePath))
58+
Executable = GetExecutable() ?? string.Empty;
59+
if (!string.IsNullOrEmpty(Executable))
6360
{
64-
Executable = Path.GetFileName(ExecutablePath);
65-
InstallDir = Path.GetDirectoryName(ExecutablePath) ?? string.Empty;
66-
IsInstalled = File.Exists(ExecutablePath);
61+
InstallDir = Path.GetDirectoryName(Executable) ?? string.Empty;
62+
IsInstalled = File.Exists(Executable);
6763
Games = EpicGameFactory.GetGames(this, cancellationToken);
6864
}
6965
}

‎GameLib.Plugin/GameLib.Plugin.Gog/GogGameFactory.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static IEnumerable<GogGame> GetGames(ILauncher launcher, CancellationToke
2323
return regKey.GetSubKeyNames()
2424
.AsParallel()
2525
.WithCancellation(cancellationToken)
26-
.Select(gameId => LoadFromRegistry(launcher.ExecutablePath, gameId))
26+
.Select(gameId => LoadFromRegistry(launcher, gameId))
2727
.Where(game => game is not null)
2828
.Select(game => AddLauncherId(launcher, game!))
2929
.ToList()!;
@@ -41,7 +41,7 @@ private static GogGame AddLauncherId(ILauncher launcher, GogGame game)
4141
/// <summary>
4242
/// Load the GoG game registry entry into a <see cref="GogGame"/> object
4343
/// </summary>
44-
private static GogGame? LoadFromRegistry(string launcherExecutable, string gameId)
44+
private static GogGame? LoadFromRegistry(ILauncher launcher, string gameId)
4545
{
4646
using var regKey = RegistryUtil.GetKey(RegistryHive.LocalMachine, $@"SOFTWARE\GOG.com\Games\{gameId}");
4747
if (regKey is null)
@@ -84,7 +84,7 @@ private static GogGame AddLauncherId(ILauncher launcher, GogGame game)
8484
}
8585

8686
game.InstallDir = Path.GetDirectoryName(game.ExecutablePath) ?? string.Empty;
87-
game.LaunchString = $"\"{launcherExecutable}\" /command=runGame /gameId={game.Id}";
87+
game.LaunchString = $"\"{launcher.Executable}\" /command=runGame /gameId={game.Id}";
8888
if (!string.IsNullOrEmpty(game.WorkingDir))
8989
{
9090
game.LaunchString += $" /path=\"{game.WorkingDir}\"";

‎GameLib.Plugin/GameLib.Plugin.Gog/GogLauncher.cs

+7-11
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,35 @@ public GogLauncher(LauncherOptions? launcherOptions)
3333

3434
public string InstallDir { get; private set; } = string.Empty;
3535

36-
public string ExecutablePath { get; private set; } = string.Empty;
37-
3836
public string Executable { get; private set; } = string.Empty;
3937

40-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
38+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
4139

4240
public IEnumerable<IGame> Games { get; private set; } = Enumerable.Empty<IGame>();
4341

4442
public void Refresh(CancellationToken cancellationToken = default)
4543
{
46-
ExecutablePath = string.Empty;
4744
Executable = string.Empty;
4845
InstallDir = string.Empty;
4946
IsInstalled = false;
5047
Games = Enumerable.Empty<IGame>();
5148

52-
ExecutablePath = GetExecutable() ?? string.Empty;
53-
if (!string.IsNullOrEmpty(ExecutablePath))
49+
Executable = GetExecutable() ?? string.Empty;
50+
if (!string.IsNullOrEmpty(Executable))
5451
{
55-
Executable = Path.GetFileName(ExecutablePath);
56-
InstallDir = Path.GetDirectoryName(ExecutablePath) ?? string.Empty;
57-
IsInstalled = File.Exists(ExecutablePath);
52+
InstallDir = Path.GetDirectoryName(Executable) ?? string.Empty;
53+
IsInstalled = File.Exists(Executable);
5854
Games = GogGameFactory.GetGames(this, cancellationToken);
5955
}
6056
}
6157

62-
public bool Start() => IsRunning || ProcessUtil.StartProcess(ExecutablePath);
58+
public bool Start() => IsRunning || ProcessUtil.StartProcess(Executable);
6359

6460
public void Stop()
6561
{
6662
if (IsRunning)
6763
{
68-
Process.Start(ExecutablePath, "/command=shutdown");
64+
Process.Start(Executable, "/command=shutdown");
6965
}
7066
}
7167
#endregion

‎GameLib.Plugin/GameLib.Plugin.Origin/OriginLauncher.cs

+8-12
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,38 @@ public OriginLauncher(LauncherOptions? launcherOptions)
2828

2929
public bool IsInstalled { get; private set; }
3030

31-
public bool IsRunning => ProcessUtil.IsProcessRunning(ExecutablePath);
31+
public bool IsRunning => ProcessUtil.IsProcessRunning(Executable);
3232

3333
public string InstallDir { get; private set; } = string.Empty;
3434

35-
public string ExecutablePath { get; private set; } = string.Empty;
36-
3735
public string Executable { get; private set; } = string.Empty;
3836

39-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
37+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
4038

4139
public IEnumerable<IGame> Games { get; private set; } = Enumerable.Empty<IGame>();
4240

43-
public bool Start() => IsRunning || ProcessUtil.StartProcess(ExecutablePath);
41+
public bool Start() => IsRunning || ProcessUtil.StartProcess(Executable);
4442

4543
public void Stop()
4644
{
4745
if (IsRunning)
4846
{
49-
ProcessUtil.StopProcess(ExecutablePath);
47+
ProcessUtil.StopProcess(Executable);
5048
}
5149
}
5250

5351
public void Refresh(CancellationToken cancellationToken = default)
5452
{
55-
ExecutablePath = string.Empty;
5653
Executable = string.Empty;
5754
InstallDir = string.Empty;
5855
IsInstalled = false;
5956
Games = Enumerable.Empty<IGame>();
6057

61-
ExecutablePath = GetExecutable() ?? string.Empty;
62-
if (!string.IsNullOrEmpty(ExecutablePath))
58+
Executable = GetExecutable() ?? string.Empty;
59+
if (!string.IsNullOrEmpty(Executable))
6360
{
64-
Executable = Path.GetFileName(ExecutablePath);
65-
InstallDir = Path.GetDirectoryName(ExecutablePath) ?? string.Empty;
66-
IsInstalled = File.Exists(ExecutablePath);
61+
InstallDir = Path.GetDirectoryName(Executable) ?? string.Empty;
62+
IsInstalled = File.Exists(Executable);
6763
Games = OriginGameFactory.GetGames(this, cancellationToken);
6864
}
6965
}

‎GameLib.Plugin/GameLib.Plugin.Rockstar/RockstarGameFactory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static RockstarGame AddLauncherId(ILauncher launcher, RockstarGame game)
7777
game.Executable = Path.GetFileName(game.ExecutablePath);
7878
}
7979

80-
game.LaunchString = $"\"{launcher.ExecutablePath}\" -launchTitleInFolder \"{game.InstallDir}\"";
80+
game.LaunchString = $"\"{launcher.Executable}\" -launchTitleInFolder \"{game.InstallDir}\"";
8181

8282
return game;
8383
}

‎GameLib.Plugin/GameLib.Plugin.Rockstar/RockstarLauncher.cs

+8-12
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,32 @@ public RockstarLauncher(LauncherOptions? launcherOptions)
2828

2929
public bool IsInstalled { get; private set; }
3030

31-
public bool IsRunning => ProcessUtil.IsProcessRunning(ExecutablePath);
31+
public bool IsRunning => ProcessUtil.IsProcessRunning(Executable);
3232

3333
public string InstallDir { get; private set; } = string.Empty;
3434

35-
public string ExecutablePath { get; private set; } = string.Empty;
36-
3735
public string Executable { get; private set; } = string.Empty;
3836

39-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
37+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
4038

4139
public IEnumerable<IGame> Games { get; private set; } = Enumerable.Empty<IGame>();
4240

43-
public bool Start() => IsRunning || ProcessUtil.StartProcess(ExecutablePath);
41+
public bool Start() => IsRunning || ProcessUtil.StartProcess(Executable);
4442

45-
public void Stop() => ProcessUtil.StopProcess(ExecutablePath);
43+
public void Stop() => ProcessUtil.StopProcess(Executable);
4644

4745
public void Refresh(CancellationToken cancellationToken = default)
4846
{
49-
ExecutablePath = string.Empty;
5047
Executable = string.Empty;
5148
InstallDir = string.Empty;
5249
IsInstalled = false;
5350
Games = Enumerable.Empty<IGame>();
5451

55-
ExecutablePath = GetExecutable() ?? string.Empty;
56-
if (!string.IsNullOrEmpty(ExecutablePath))
52+
Executable = GetExecutable() ?? string.Empty;
53+
if (!string.IsNullOrEmpty(Executable))
5754
{
58-
Executable = Path.GetFileName(ExecutablePath);
59-
InstallDir = Path.GetDirectoryName(ExecutablePath) ?? string.Empty;
60-
IsInstalled = File.Exists(ExecutablePath);
55+
InstallDir = Path.GetDirectoryName(Executable) ?? string.Empty;
56+
IsInstalled = File.Exists(Executable);
6157
Games = RockstarGameFactory.GetGames(this, cancellationToken);
6258
}
6359
}

‎GameLib.Plugin/GameLib.Plugin.Steam/SteamLauncher.cs

+8-12
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,39 @@ public SteamLauncher(LauncherOptions? launcherOptions)
3030

3131
public bool IsInstalled { get; private set; }
3232

33-
public bool IsRunning => ProcessUtil.IsProcessRunning(ExecutablePath);
33+
public bool IsRunning => ProcessUtil.IsProcessRunning(Executable);
3434

3535
public string InstallDir { get; private set; } = string.Empty;
3636

37-
public string ExecutablePath { get; private set; } = string.Empty;
38-
3937
public string Executable { get; private set; } = string.Empty;
4038

41-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
39+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
4240

4341
public IEnumerable<IGame> Games { get; private set; } = Enumerable.Empty<IGame>();
4442

45-
public bool Start() => IsRunning || ProcessUtil.StartProcess(ExecutablePath);
43+
public bool Start() => IsRunning || ProcessUtil.StartProcess(Executable);
4644

4745
public void Stop()
4846
{
4947
if (IsRunning)
5048
{
51-
Process.Start(ExecutablePath, "-shutdown");
49+
Process.Start(Executable, "-shutdown");
5250
}
5351
}
5452

5553
public void Refresh(CancellationToken cancellationToken = default)
5654
{
57-
ExecutablePath = string.Empty;
5855
Executable = string.Empty;
5956
InstallDir = string.Empty;
6057
IsInstalled = false;
6158
Libraries = Enumerable.Empty<SteamLibrary>();
6259
Games = Enumerable.Empty<IGame>();
6360

64-
ExecutablePath = GetExecutable() ?? string.Empty;
65-
if (!string.IsNullOrEmpty(ExecutablePath))
61+
Executable = GetExecutable() ?? string.Empty;
62+
if (!string.IsNullOrEmpty(Executable))
6663
{
67-
Executable = Path.GetFileName(ExecutablePath);
68-
InstallDir = Path.GetDirectoryName(ExecutablePath) ?? string.Empty;
69-
IsInstalled = File.Exists(ExecutablePath);
64+
InstallDir = Path.GetDirectoryName(Executable) ?? string.Empty;
65+
IsInstalled = File.Exists(Executable);
7066
Libraries = SteamLibraryFactory.GetLibraries(InstallDir);
7167
Games = SteamGameFactory.GetGames(this, Libraries);
7268
}

‎GameLib.Plugin/GameLib.Plugin.Ubisoft/UbisoftLauncher.cs

+7-11
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,31 @@ public UbisoftLauncher(LauncherOptions? launcherOptions)
3232

3333
public string InstallDir { get; private set; } = string.Empty;
3434

35-
public string ExecutablePath { get; private set; } = string.Empty;
36-
3735
public string Executable { get; private set; } = string.Empty;
3836

39-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
37+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
4038

4139
public IEnumerable<IGame> Games { get; private set; } = Enumerable.Empty<IGame>();
4240

4341
public void Refresh(CancellationToken cancellationToken = default)
4442
{
45-
ExecutablePath = string.Empty;
4643
Executable = string.Empty;
4744
InstallDir = string.Empty;
4845
IsInstalled = false;
4946
Games = Enumerable.Empty<IGame>();
5047

51-
ExecutablePath = GetExecutable() ?? string.Empty;
52-
if (!string.IsNullOrEmpty(ExecutablePath))
48+
Executable = GetExecutable() ?? string.Empty;
49+
if (!string.IsNullOrEmpty(Executable))
5350
{
54-
Executable = Path.GetFileName(ExecutablePath);
55-
InstallDir = Path.GetDirectoryName(ExecutablePath) ?? string.Empty;
56-
IsInstalled = File.Exists(ExecutablePath);
51+
InstallDir = Path.GetDirectoryName(Executable) ?? string.Empty;
52+
IsInstalled = File.Exists(Executable);
5753
Games = UbisoftGameFactory.GetGames(this, cancellationToken);
5854
}
5955
}
6056

61-
public bool Start() => IsRunning || ProcessUtil.StartProcess(ExecutablePath);
57+
public bool Start() => IsRunning || ProcessUtil.StartProcess(Executable);
6258

63-
public void Stop() => ProcessUtil.StopProcess(ExecutablePath);
59+
public void Stop() => ProcessUtil.StopProcess(Executable);
6460
#endregion
6561

6662
#region Private methods

0 commit comments

Comments
 (0)
Please sign in to comment.