Skip to content

Commit

Permalink
All or nothing?
Browse files Browse the repository at this point in the history
* Check all DLCs
* Check all (DLCs+SDLs)
  • Loading branch information
hawkeye116477 committed Jan 9, 2024
1 parent e8ed44a commit 25f2bd6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 14 deletions.
31 changes: 18 additions & 13 deletions src/LegendaryGameInstaller.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,24 @@
</StackPanel>
<Border Grid.Row="4" Grid.Column="0" BorderThickness="2" Style="{DynamicResource HighlightBorder}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Name="ExtraContentBrd" Visibility="Collapsed" Margin="0,0,0,5">
<Expander Header="{DynamicResource LOCLegendaryExtraContent}" Margin="2,2,5,2" HorizontalAlignment="Left">
<ListBox BorderThickness="0" Name="ExtraContentLB" SelectionMode="Multiple" SelectionChanged="ExtraContentLB_SelectionChanged" Margin="5,0,5,5">
<ListBox.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<CheckBox Content="{Binding Value.Name}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" ToolTip="{Binding Value.Description}" Margin="0,5,0,0"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Resources>
</ListBox>
<StackPanel Orientation="Vertical">
<ListBox BorderThickness="0" Name="ExtraContentLB" SelectionMode="Multiple" SelectionChanged="ExtraContentLB_SelectionChanged" Margin="5,0,5,5">
<ListBox.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<CheckBox Content="{Binding Value.Name}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" ToolTip="{Binding Value.Description}" Tag="{Binding Value.Is_dlc}" Margin="0,5,0,0" Name="ExtraContentLBChk" Unchecked="ExtraContentLBChk_Unchecked"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Resources>
</ListBox>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Background="{DynamicResource PanelSeparatorBrush}" Margin="7,0,0,5" />
<CheckBox Margin="7,0,0,5" Content="{DynamicResource LOCLegendaryCheckAllDlcs}" x:Name="AllDlcsChk" Checked="AllDlcsChk_Checked" Unchecked="AllDlcsChk_Unchecked" Visibility="Collapsed"/>
<CheckBox Margin="7,0,0,5" Content="{DynamicResource LOCLegendaryCheckAllContent}" x:Name="AllOrNothingChk" Checked="AllOrNothingChk_Checked" Unchecked="AllOrNothingChk_Unchecked" />
</StackPanel>
</Expander>
</Border>
<Border Grid.Row="5" Grid.Column="0" BorderThickness="2" Style="{DynamicResource HighlightBorder}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.ColumnSpan="2">
Expand Down
53 changes: 52 additions & 1 deletion src/LegendaryGameInstaller.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public partial class LegendaryGameInstaller : UserControl
public double downloadSizeNumber;
public double installSizeNumber;
private LegendaryGameInfo.Rootobject manifest;
public bool uncheckedByUser = true;

public LegendaryGameInstaller()
{
Expand Down Expand Up @@ -99,7 +100,7 @@ private async void InstallBtn_Click(object sender, RoutedEventArgs e)
selectedExtraContent.AddMissing("");
foreach (var selectedOption in ExtraContentLB.SelectedItems.Cast<KeyValuePair<string, LegendarySDLInfo>>().ToList())
{
if (selectedOption.Value.Is_dlc == false)
if (!selectedOption.Value.Is_dlc)
{
foreach (var tag in selectedOption.Value.Tags)
{
Expand Down Expand Up @@ -407,6 +408,7 @@ private async void LegendaryGameInstallerUC_Loaded(object sender, RoutedEventArg
}
}
}
AllDlcsChk.Visibility = Visibility.Visible;
}
if (extraContentInfo.Keys.Count > 0)
{
Expand Down Expand Up @@ -625,5 +627,54 @@ private async void RepairBtn_Click(object sender, RoutedEventArgs e)
await downloadManager.EnqueueJob(GameID, InstallerWindow.Title, downloadSize, installSize, downloadProperties);
}
}

private void AllDlcsChk_Checked(object sender, RoutedEventArgs e)
{
var dlcs = ExtraContentLB.Items.Cast<KeyValuePair<string, LegendarySDLInfo>>().Where(x => x.Value.Is_dlc).ToList();
foreach (var dlc in dlcs)
{
ExtraContentLB.SelectedItems.Add(dlc);
}
}

private void AllDlcsChk_Unchecked(object sender, RoutedEventArgs e)
{
if (uncheckedByUser)
{
var dlcs = ExtraContentLB.SelectedItems.Cast<KeyValuePair<string, LegendarySDLInfo>>().Where(x => x.Value.Is_dlc).ToList();
foreach (var dlc in dlcs)
{
ExtraContentLB.SelectedItems.Remove(dlc);
}
}
}

private void ExtraContentLBChk_Unchecked(object sender, RoutedEventArgs e)
{
uncheckedByUser = false;
if (AllOrNothingChk.IsChecked == true)
{
AllOrNothingChk.IsChecked = false;
}
var extraCheckbox = sender as CheckBox;
if (AllDlcsChk.IsChecked == true && (bool)extraCheckbox.Tag)
{
AllDlcsChk.IsChecked = false;
}
uncheckedByUser = true;
}

private void AllOrNothingChk_Checked(object sender, RoutedEventArgs e)
{
ExtraContentLB.SelectAll();
}

private void AllOrNothingChk_Unchecked(object sender, RoutedEventArgs e)
{
if (uncheckedByUser)
{
ExtraContentLB.SelectedItems.Clear();
}
}
}
}
2 changes: 2 additions & 0 deletions src/Localization/en_US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,6 @@
<sys:String x:Key="LOCLegendaryAlternativeExe">Alternative executable file</sys:String>
<sys:String x:Key="LOCLegendaryCloudSaves">Cloud saves</sys:String>
<sys:String x:Key="LOCLegendaryDisplayDownloadSpeedInBits">Display download speed in bits per second</sys:String>
<sys:String x:Key="LOCLegendaryCheckAllDlcs">Check all DLCs</sys:String>
<sys:String x:Key="LOCLegendaryCheckAllContent">Check all</sys:String>
</ResourceDictionary>
8 changes: 8 additions & 0 deletions src/LocalizationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,5 +577,13 @@ public static class LOC
/// Display download speed in bits per second
/// </summary>
public const string LegendaryDisplayDownloadSpeedInBits = "LOCLegendaryDisplayDownloadSpeedInBits";
/// <summary>
/// Check all DLCs
/// </summary>
public const string LegendaryCheckAllDlcs = "LOCLegendaryCheckAllDlcs";
/// <summary>
/// Check all
/// </summary>
public const string LegendaryCheckAllContent = "LOCLegendaryCheckAllContent";
}
}

0 comments on commit 25f2bd6

Please sign in to comment.