Skip to content

Commit 90277a2

Browse files
committed
Remove ExecutablePath from IGame
1 parent 72ea9ee commit 90277a2

File tree

19 files changed

+64
-128
lines changed

19 files changed

+64
-128
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ All notable changes to this project will be documented in this file.
66

77
## [1.3.1] - 2022-11-09
88
### Fixed
9-
- Activate parallel processing of installed games
9+
- Activate parallel processing of installed games for Battle.net and Rockstar Games
1010

1111
### Deleted
1212
- Remove "ExecutablePath" from ILauncher interface
13+
- Remove "ExecutablePath" from IGame interface
1314

1415
### Changed
1516
- "Executable" on ILauncher interface returns the executable including the path
17+
- "Executable" on IGame interface returns the executable including the path
1618

1719

1820
## [1.3.0] - 2022-11-09

GameLib.Core/IGame.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public interface IGame
2727
/// <summary>
2828
/// Executable name including the full Path
2929
/// </summary>
30-
public string ExecutablePath { get; }
31-
32-
/// <summary>
33-
/// Just the executable name
34-
/// </summary>
3530
public string Executable { get; }
3631

3732
/// <summary>

GameLib.Demo/GameLib.Demo.Wpf/ViewModels/GameViewModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public void RefreshGameIsRunning()
9494
OnPropertyChanged(nameof(SelectedGame));
9595
}
9696

97-
9897
[RelayCommand]
9998
public static void RunGame(IGame? game)
10099
{
@@ -114,9 +113,8 @@ public static void RunGame(IGame? game)
114113
Process.Start(new ProcessStartInfo()
115114
{
116115
UseShellExecute = true,
117-
FileName = game.ExecutablePath,
116+
FileName = game.Executable,
118117
WorkingDirectory = game.WorkingDir
119-
120118
});
121119
}
122120
catch { /* ignore */ }
@@ -173,5 +171,4 @@ public static void CopyToClipboard(string? text)
173171

174172
Clipboard.SetText(text);
175173
}
176-
177174
}

GameLib.Demo/GameLib.Demo.Wpf/Views/GameView.xaml

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -389,18 +389,18 @@
389389
</StackPanel>
390390
<!--#endregion-->
391391

392-
<!--#region Executable path-->
392+
<!--#region Executable-->
393393
<TextBlock
394394
Grid.Row="13"
395395
Grid.Column="0"
396396
HorizontalAlignment="Right"
397397
VerticalAlignment="Center"
398-
Text="Executable path: " />
398+
Text="Executable: " />
399399
<TextBox
400400
Grid.Row="13"
401401
Grid.Column="2"
402402
VerticalAlignment="Center"
403-
Text="{Binding SelectedGame.ExecutablePath, Mode=OneWay}" />
403+
Text="{Binding SelectedGame.Executable, Mode=OneWay}" />
404404
<StackPanel
405405
Grid.Row="13"
406406
Grid.Column="4"
@@ -409,7 +409,7 @@
409409
Orientation="Horizontal">
410410
<Button
411411
Command="{Binding CopyToClipboardCommand}"
412-
CommandParameter="{Binding SelectedGame.ExecutablePath}"
412+
CommandParameter="{Binding SelectedGame.Executable}"
413413
ToolTip="Copy to clipboard">
414414
<Image
415415
Width="20"
@@ -420,7 +420,7 @@
420420
<Button
421421
Margin="5,0,0,0"
422422
Command="{Binding OpenPathCommand}"
423-
CommandParameter="{Binding SelectedGame.ExecutablePath}"
423+
CommandParameter="{Binding SelectedGame.Executable}"
424424
ToolTip="Open in explorer">
425425
<Image
426426
Width="20"
@@ -441,51 +441,20 @@
441441
</StackPanel>
442442
<!--#endregion-->
443443

444-
<!--#region Executable name-->
445-
<TextBlock
446-
Grid.Row="15"
447-
Grid.Column="0"
448-
HorizontalAlignment="Right"
449-
VerticalAlignment="Center"
450-
Text="Executable: " />
451-
<TextBox
452-
Grid.Row="15"
453-
Grid.Column="2"
454-
VerticalAlignment="Center"
455-
Text="{Binding SelectedGame.Executable, Mode=OneWay}" />
456-
<StackPanel
457-
Grid.Row="15"
458-
Grid.Column="4"
459-
HorizontalAlignment="Left"
460-
VerticalAlignment="Center"
461-
Orientation="Horizontal">
462-
<Button
463-
Command="{Binding CopyToClipboardCommand}"
464-
CommandParameter="{Binding SelectedGame.Executable}"
465-
ToolTip="Copy to clipboard">
466-
<Image
467-
Width="20"
468-
Height="20"
469-
Margin="2"
470-
Source="/Resources/copy-white.png" />
471-
</Button>
472-
</StackPanel>
473-
<!--#endregion-->
474-
475444
<!--#region Working directory-->
476445
<TextBlock
477-
Grid.Row="17"
446+
Grid.Row="15"
478447
Grid.Column="0"
479448
HorizontalAlignment="Right"
480449
VerticalAlignment="Center"
481450
Text="Working directory: " />
482451
<TextBox
483-
Grid.Row="17"
452+
Grid.Row="15"
484453
Grid.Column="2"
485454
VerticalAlignment="Center"
486455
Text="{Binding SelectedGame.WorkingDir, Mode=OneWay}" />
487456
<StackPanel
488-
Grid.Row="17"
457+
Grid.Row="15"
489458
Grid.Column="4"
490459
HorizontalAlignment="Left"
491460
VerticalAlignment="Center"
@@ -516,18 +485,18 @@
516485

517486
<!--#region Launch string-->
518487
<TextBlock
519-
Grid.Row="19"
488+
Grid.Row="17"
520489
Grid.Column="0"
521490
HorizontalAlignment="Right"
522491
VerticalAlignment="Center"
523492
Text="Launch string: " />
524493
<TextBox
525-
Grid.Row="19"
494+
Grid.Row="17"
526495
Grid.Column="2"
527496
VerticalAlignment="Center"
528497
Text="{Binding SelectedGame.LaunchString, Mode=OneWay}" />
529498
<StackPanel
530-
Grid.Row="19"
499+
Grid.Row="17"
531500
Grid.Column="4"
532501
HorizontalAlignment="Left"
533502
VerticalAlignment="Center"
@@ -557,22 +526,22 @@
557526

558527
<!--#region IsRunning-->
559528
<TextBlock
560-
Grid.Row="21"
529+
Grid.Row="19"
561530
Grid.Column="0"
562531
HorizontalAlignment="Right"
563532
VerticalAlignment="Center"
564533
Text="Is running: " />
565534

566535
<Image
567-
Grid.Row="21"
536+
Grid.Row="19"
568537
Grid.Column="2"
569538
Width="24"
570539
Height="24"
571540
HorizontalAlignment="Left"
572541
Source="{Binding IsRunningLogo}" />
573542

574543
<StackPanel
575-
Grid.Row="21"
544+
Grid.Row="19"
576545
Grid.Column="4"
577546
HorizontalAlignment="Left"
578547
VerticalAlignment="Center"

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@
292292
Background="#373737"
293293
Command="{Binding CopyToClipboardCommand}"
294294
CommandParameter="{Binding SelectedLauncher.InstallDir}"
295-
ToolTip="Copy to clipboard">
295+
ToolTip="Copy to clipboard"
296+
Visibility="{Binding SelectedLauncher.IsInstalled, Converter={StaticResource BooleanToVisibilityConverter}}">
296297
<Image
297298
Width="20"
298299
Height="20"
@@ -304,7 +305,8 @@
304305
Background="#373737"
305306
Command="{Binding OpenPathCommand}"
306307
CommandParameter="{Binding SelectedLauncher}"
307-
ToolTip="Open in explorer">
308+
ToolTip="Open in explorer"
309+
Visibility="{Binding SelectedLauncher.IsInstalled, Converter={StaticResource BooleanToVisibilityConverter}}">
308310
<Image
309311
Width="20"
310312
Height="20"
@@ -336,7 +338,8 @@
336338
Background="#373737"
337339
Command="{Binding CopyToClipboardCommand}"
338340
CommandParameter="{Binding SelectedLauncher.Executable}"
339-
ToolTip="Copy to clipboard">
341+
ToolTip="Copy to clipboard"
342+
Visibility="{Binding SelectedLauncher.IsInstalled, Converter={StaticResource BooleanToVisibilityConverter}}">
340343
<Image
341344
Width="20"
342345
Height="20"
@@ -398,7 +401,8 @@
398401
<Button
399402
Background="#373737"
400403
Command="{Binding RefreshLauncherIsRunningCommand}"
401-
ToolTip="Refresh">
404+
ToolTip="Refresh"
405+
Visibility="{Binding SelectedLauncher.IsInstalled, Converter={StaticResource BooleanToVisibilityConverter}}">
402406
<Image
403407
Width="20"
404408
Height="20"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ private static BattleNetGame AddCatalogData(ILauncher launcher, BattleNetGame ga
122122
game.LaunchString = $"\"{launcher.Executable}\" --exec=\"launch {game.ProductCode}\"";
123123
}
124124

125-
game.Executable = catalogItem.Executables.FirstOrDefault(defaultValue: string.Empty);
126-
if (!string.IsNullOrEmpty(game.Executable))
125+
var executable = catalogItem.Executables.FirstOrDefault(defaultValue: string.Empty);
126+
if (!string.IsNullOrEmpty(executable))
127127
{
128-
game.ExecutablePath = Path.Combine(game.InstallDir, game.Executable);
128+
game.Executable = Path.Combine(game.InstallDir, executable);
129129
}
130130

131131
return game;

GameLib.Plugin/GameLib.Plugin.BattleNet/Model/BattleNetGame.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ public class BattleNetGame : IGame
1515

1616
public string InstallDir { get; internal set; } = string.Empty;
1717

18-
public string ExecutablePath { get; internal set; } = string.Empty;
19-
2018
public string Executable { get; internal set; } = string.Empty;
2119

22-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
20+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
2321

2422
public string WorkingDir { get; internal set; } = string.Empty;
2523

GameLib.Plugin/GameLib.Plugin.Epic/EpicGameFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private static EpicGame AddLauncherId(ILauncher launcher, EpicGame game)
8383

8484
var game = deserializedEpicGame.EpicGameBuilder();
8585

86-
game.ExecutablePath = Path.Combine(PathUtil.Sanitize(game.InstallDir)!, game.Executable);
86+
game.Executable = Path.Combine(PathUtil.Sanitize(game.InstallDir)!, game.Executable);
8787
game.LaunchString = $"com.epicgames.launcher://apps/{game.Id}?action=launch&silent=true";
8888
game.InstallDate = PathUtil.GetCreationTime(game.InstallDir) ?? DateTime.MinValue;
8989

GameLib.Plugin/GameLib.Plugin.Epic/Model/EpicGame.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ public class EpicGame : IGame
1111
public Guid LauncherId { get; internal set; } = Guid.Empty;
1212
public string Name { get; internal set; } = string.Empty;
1313
public string InstallDir { get; internal set; } = string.Empty;
14-
public string ExecutablePath { get; internal set; } = string.Empty;
1514
public string Executable { get; internal set; } = string.Empty;
16-
public Icon? ExecutableIcon => PathUtil.GetFileIcon(ExecutablePath);
15+
public Icon? ExecutableIcon => PathUtil.GetFileIcon(Executable);
1716
public string WorkingDir { get; internal set; } = string.Empty;
1817
public string LaunchString { get; internal set; } = string.Empty;
1918
public DateTime InstallDate { get; internal set; } = DateTime.MinValue;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ private static GogGame AddLauncherId(ILauncher launcher, GogGame game)
5353
{
5454
Id = (string)regKey.GetValue("gameID", string.Empty)!,
5555
Name = (string)regKey.GetValue("gameName", string.Empty)!,
56-
ExecutablePath = (string)regKey.GetValue("exe", string.Empty)!,
57-
Executable = (string)regKey.GetValue("exeFile", string.Empty)!,
56+
Executable = (string)regKey.GetValue("exe", string.Empty)!,
5857
WorkingDir = (string)regKey.GetValue("workingDir", string.Empty)!,
5958
InstallDate = DateTime.TryParseExact(
6059
(string)regKey.GetValue("INSTALLDATE", string.Empty)!, "yyyy-MM-dd HH:mm:ss",
@@ -83,7 +82,7 @@ private static GogGame AddLauncherId(ILauncher launcher, GogGame game)
8382
return null;
8483
}
8584

86-
game.InstallDir = Path.GetDirectoryName(game.ExecutablePath) ?? string.Empty;
85+
game.InstallDir = Path.GetDirectoryName(game.Executable) ?? string.Empty;
8786
game.LaunchString = $"\"{launcher.Executable}\" /command=runGame /gameId={game.Id}";
8887
if (!string.IsNullOrEmpty(game.WorkingDir))
8988
{

0 commit comments

Comments
 (0)