Skip to content

Commit

Permalink
Add possibility to update EOS Overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye116477 committed Feb 4, 2024
1 parent a84d741 commit fc05452
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 43 deletions.
94 changes: 54 additions & 40 deletions src/LegendaryDownloadManager.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,55 +195,69 @@ public static async Task WaitUntilLegendaryCloses()
public async Task Install(string gameID, string gameTitle, string downloadSize, DownloadProperties downloadProperties)
{
await WaitUntilLegendaryCloses();
var installCommand = new List<string>() { "-y", "install", gameID };
if (downloadProperties.installPath != "")
{
installCommand.AddRange(new[] { "--base-path", downloadProperties.installPath });
}
var installCommand = new List<string>();
var settings = LegendaryLibrary.GetSettings();
if (settings.PreferredCDN != "")
{
installCommand.AddRange(new[] { "--preferred-cdn", settings.PreferredCDN });
}
if (settings.NoHttps)
{
installCommand.Add("--no-https");
}
if (downloadProperties.maxWorkers != 0)
{
installCommand.AddRange(new[] { "--max-workers", downloadProperties.maxWorkers.ToString() });
}
if (downloadProperties.maxSharedMemory != 0)
{
installCommand.AddRange(new[] { "--max-shared-memory", downloadProperties.maxSharedMemory.ToString() });
}
if (downloadProperties.enableReordering)
{
installCommand.Add("--enable-reordering");
}
if (downloadProperties.downloadAction == DownloadAction.Repair)
{
installCommand.Add("--repair");
}
if (downloadProperties.downloadAction == DownloadAction.Update)
if (gameID == "eos-overlay")
{
installCommand.Add("--update-only");
installCommand = new List<string>() { "-y", "eos-overlay" };
if (downloadProperties.downloadAction == DownloadAction.Update)
{

installCommand.Add("update");
}
else
{
installCommand.AddRange(new[] { "install", "--path", Path.Combine(downloadProperties.installPath, ".overlay") });
}
}
if (downloadProperties.extraContent != null)
else
{
if (downloadProperties.extraContent.Count > 0)
installCommand = new List<string>() { "-y", "install", gameID };
if (downloadProperties.installPath != "")
{
foreach (var singleSelectedContent in downloadProperties.extraContent)
installCommand.AddRange(new[] { "--base-path", downloadProperties.installPath });
}
if (settings.PreferredCDN != "")
{
installCommand.AddRange(new[] { "--preferred-cdn", settings.PreferredCDN });
}
if (settings.NoHttps)
{
installCommand.Add("--no-https");
}
if (downloadProperties.maxWorkers != 0)
{
installCommand.AddRange(new[] { "--max-workers", downloadProperties.maxWorkers.ToString() });
}
if (downloadProperties.maxSharedMemory != 0)
{
installCommand.AddRange(new[] { "--max-shared-memory", downloadProperties.maxSharedMemory.ToString() });
}
if (downloadProperties.enableReordering)
{
installCommand.Add("--enable-reordering");
}
if (downloadProperties.downloadAction == DownloadAction.Repair)
{
installCommand.Add("--repair");
}
if (downloadProperties.downloadAction == DownloadAction.Update)
{
installCommand.Add("--update-only");
}
if (downloadProperties.extraContent != null)
{
if (downloadProperties.extraContent.Count > 0)
{
installCommand.Add("--install-tag=" + singleSelectedContent);
foreach (var singleSelectedContent in downloadProperties.extraContent)
{
installCommand.Add("--install-tag=" + singleSelectedContent);
}
}
}
installCommand.Add("--skip-dlcs");
}
installCommand.Add("--skip-dlcs");
if (gameID == "eos-overlay")
{
installCommand = new List<string>() { "-y", "eos-overlay", "install", "--path", Path.Combine(downloadProperties.installPath, ".overlay") };
}

forcefulInstallerCTS = new CancellationTokenSource();
gracefulInstallerCTS = new CancellationTokenSource();
try
Expand Down
6 changes: 4 additions & 2 deletions src/LegendaryLibrarySettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@
<Button Content="{DynamicResource LOCLegendary3P_PlayniteInstallGame}" Grid.Row="0"
Grid.Column="0" Margin="5,0,0,0" Name="EOSOInstallBtn" Visibility="Collapsed"
Click="EOSOInstallBtn_Click" HorizontalAlignment="Left"></Button>
<Button x:Name="EOSOCheckForUpdatesBtn" Grid.Column="0" Grid.Row="0" Margin="5,0,0,0" HorizontalAlignment="Left"
Content="{DynamicResource LOCLegendary3P_PlayniteCheckForUpdates}" Click="EOSOCheckForUpdatesBtn_Click" />
<Button Content="{DynamicResource LOCLegendaryDisable}" Grid.Row="0"
Grid.Column="0" Margin="10,0,0,0" Name="EOSOToggleBtn"
Grid.Column="1" Margin="10,0,0,0" Name="EOSOToggleBtn"
Click="EOSOToggleBtn_Click" HorizontalAlignment="Left"/>
<Button Content="{DynamicResource LOCLegendary3P_PlayniteUninstallGame}" Name="EOSOUninstallBtn"
Grid.Row="0" Grid.Column="1" Margin="10,0,0,0"
Grid.Row="0" Grid.Column="2" Margin="10,0,0,0"
Click="EOSOUninstallBtn_Click" HorizontalAlignment="Left"></Button>
</Grid>
</StackPanel>
Expand Down
51 changes: 51 additions & 0 deletions src/LegendaryLibrarySettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private async void EOSOUninstallBtn_Click(object sender, RoutedEventArgs e)
EOSOInstallBtn.Visibility = Visibility.Visible;
EOSOUninstallBtn.Visibility = Visibility.Collapsed;
EOSOToggleBtn.Visibility = Visibility.Collapsed;
EOSOCheckForUpdatesBtn.Visibility = Visibility.Collapsed;
playniteAPI.Dialogs.ShowMessage(ResourceProvider.GetString(LOC.LegendaryUninstallSuccess).Format(ResourceProvider.GetString(LOC.LegendaryEOSOverlay)));
}
}
Expand Down Expand Up @@ -103,6 +104,7 @@ private void EOSOInstallBtn_Click(object sender, RoutedEventArgs e)
EOSOUninstallBtn.Visibility = Visibility.Visible;
EOSOToggleBtn.Content = ResourceProvider.GetString(LOC.LegendaryDisable);
EOSOToggleBtn.Visibility = Visibility.Visible;
EOSOCheckForUpdatesBtn.Visibility = Visibility.Visible;
}
}
}
Expand Down Expand Up @@ -615,5 +617,54 @@ private void OpenLogFilesPathBtn_Click(object sender, RoutedEventArgs e)
{
ProcessStarter.StartProcess("explorer.exe", playniteAPI.Paths.ConfigurationPath);
}

private async void EOSOCheckForUpdatesBtn_Click(object sender, RoutedEventArgs e)
{
var cmd = await Cli.Wrap(LegendaryLauncher.ClientExecPath)
.WithArguments(new[] { "eos-overlay", "update" })
.WithStandardInputPipe(PipeSource.FromString("n"))
.WithEnvironmentVariables(LegendaryLauncher.DefaultEnvironmentVariables)
.WithValidation(CommandResultValidation.None)
.ExecuteBufferedAsync();
if (cmd.StandardError.Contains("is up to date"))
{
playniteAPI.Dialogs.ShowMessage(ResourceProvider.GetString(LOC.LegendaryNoUpdatesAvailable), ResourceProvider.GetString(LOC.LegendaryEOSOverlay));
}
else
{
var options = new List<MessageBoxOption>
{
new MessageBoxOption(ResourceProvider.GetString(LOC.Legendary3P_PlayniteUpdaterInstallUpdate)),
new MessageBoxOption(ResourceProvider.GetString(LOC.Legendary3P_PlayniteOKLabel)),
};
var result = playniteAPI.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString(LOC.LegendaryNewVersionAvailable), ResourceProvider.GetString(LOC.LegendaryEOSOverlay), ""), ResourceProvider.GetString(LOC.Legendary3P_PlayniteUpdaterWindowTitle), MessageBoxImage.Information, options);
if (result == options[0])
{
LegendaryDownloadManager downloadManager = LegendaryLibrary.GetLegendaryDownloadManager();
var wantedItem = downloadManager.downloadManagerData.downloads.FirstOrDefault(item => item.gameID == "eos-overlay");
if (wantedItem != null)
{
if (wantedItem.status == DownloadStatus.Completed)
{
downloadManager.downloadManagerData.downloads.Remove(wantedItem);
downloadManager.SaveData();
wantedItem = null;
}
}
if (wantedItem != null)
{
playniteAPI.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString(LOC.LegendaryDownloadAlreadyExists), wantedItem.name), "", MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
DownloadProperties downloadProperties = new DownloadProperties()
{
downloadAction = DownloadAction.Update,
};
downloadManager.EnqueueJob("eos-overlay", ResourceProvider.GetString(LOC.LegendaryEOSOverlay), "", "", downloadProperties);
}
}
}
}
}
}
1 change: 0 additions & 1 deletion src/LegendaryUpdater.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace LegendaryLibraryNS
public partial class LegendaryUpdater : UserControl
{
public Dictionary<string, Installed> UpdatesList => (Dictionary<string, Installed>)DataContext;
private IPlayniteAPI playniteAPI = API.Instance;
public LegendaryUpdater()
{
InitializeComponent();
Expand Down

0 comments on commit fc05452

Please sign in to comment.