Skip to content

Commit

Permalink
Ability to toggle library status (Enable/Disable Steam, Origin or Upl…
Browse files Browse the repository at this point in the history
…ay libraries) #63
  • Loading branch information
RevoLand committed Aug 2, 2019
1 parent 8c53594 commit d215f51
Show file tree
Hide file tree
Showing 11 changed files with 434 additions and 36 deletions.
Binary file modified Binaries/Steam Library Manager.exe
Binary file not shown.
7 changes: 6 additions & 1 deletion Source/Steam Library Manager/Definitions/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ public static class Steam
public static string RegistryKeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam";

public static string VdfFilePath = System.IO.Path.Combine(Properties.Settings.Default.steamInstallationPath, "config", "config.vdf");

public static bool IsStateChanging;
}

public static class Origin
{
public static string ConfigFilePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "Origin", "local.xml");
public static List<KeyValuePair<string, string>> AppIds = new List<KeyValuePair<string, string>>();

public static bool IsStateChanging;
}

public static class Uplay
{
// AppData\Local\Ubisoft Game Launcher\settings.yml
public static string ConfigFilePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Ubisoft Game Launcher", "settings.yml");

public static bool IsStateChanging;
}
}
}
2 changes: 1 addition & 1 deletion Source/Steam Library Manager/Definitions/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private List<FrameworkElement> GenerateCMenuItems()
var cMenu = new List<FrameworkElement>();
try
{
foreach (var cMenuItem in List.LibraryCMenuItems.ToList().Where(x => x.IsActive && x.AllowedLibraryTypes.Contains(Type)))
foreach (var cMenuItem in List.LibraryCMenuItems.Where(x => x.IsActive && x.AllowedLibraryTypes.Contains(Type)).ToList())
{
if (!cMenuItem.ShowToNormal && IsMain)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/Steam Library Manager/Definitions/SteamLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public override async void UpdateAppListAsync()
// If key doesn't contains a child (value in acf file)
if (keyValReader.Children.Count == 0)
{
if (Definitions.List.IgnoredJunkItems.Contains(acfFile.FullName))
if (List.IgnoredJunkItems.Contains(acfFile.FullName))
{
return;
}
Expand Down Expand Up @@ -371,7 +371,7 @@ public override void UpdateJunks()

if (List.JunkItems.Count(x => x.FSInfo.FullName == junk.FSInfo.FullName) == 0)
{
if (Definitions.List.IgnoredJunkItems.Contains(dirInfo.FullName))
if (List.IgnoredJunkItems.Contains(dirInfo.FullName))
{
continue;
}
Expand Down Expand Up @@ -400,7 +400,7 @@ public override void UpdateJunks()

if (List.JunkItems.Count(x => x.FSInfo.FullName == junk.FSInfo.FullName) == 0)
{
if (Definitions.List.IgnoredJunkItems.Contains(fileDetails.FullName))
if (List.IgnoredJunkItems.Contains(fileDetails.FullName))
{
continue;
}
Expand Down
42 changes: 41 additions & 1 deletion Source/Steam Library Manager/Forms/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,16 @@ private void CreateLibraryButton_Click(object sender, RoutedEventArgs e)
createLibrary_ResultText.Text = $"Selected directory does not exists: \"{libraryPath}\"";
return;
}

switch (_libraryType)
{
case LibraryType.Steam:
if (!Properties.Settings.Default.Steam_IsEnabled)
{
createLibrary_ResultText.Text = "Steam Library support must be enabled for this action.";
return;
}

if (!Functions.Steam.Library.IsLibraryExists(libraryPath))
{
if (Directory.GetDirectoryRoot(libraryPath) != libraryPath)
Expand All @@ -347,6 +354,12 @@ private void CreateLibraryButton_Click(object sender, RoutedEventArgs e)
break;

case LibraryType.SLM:
if (!Properties.Settings.Default.Steam_IsEnabled)
{
createLibrary_ResultText.Text = "Steam Library support must be enabled for this action.";
return;
}

if (!Functions.SLM.Library.IsLibraryExists(libraryPath))
{
if (Directory.GetDirectoryRoot(libraryPath) != libraryPath)
Expand All @@ -366,6 +379,12 @@ private void CreateLibraryButton_Click(object sender, RoutedEventArgs e)
break;

case LibraryType.Origin:
if (!Properties.Settings.Default.Origin_IsEnabled)
{
createLibrary_ResultText.Text = "Origin Library support must be enabled for this action.";
return;
}

if (!Functions.Origin.IsLibraryExists(libraryPath))
{
if (Directory.GetDirectoryRoot(libraryPath) != libraryPath)
Expand All @@ -385,7 +404,28 @@ private void CreateLibraryButton_Click(object sender, RoutedEventArgs e)
break;

case LibraryType.Uplay:
createLibrary_ResultText.Text = "Selected library type is not implemented yet.";
if (!Properties.Settings.Default.Uplay_IsEnabled)
{
createLibrary_ResultText.Text = "Uplay Library support must be enabled for this action.";
return;
}

if (!Functions.Uplay.IsLibraryExists(libraryPath))
{
if (Directory.GetDirectoryRoot(libraryPath) != libraryPath)
{
Functions.Uplay.AddNewLibraryAsync(libraryPath);
createLibraryFlyout.IsOpen = false;
}
else
{
createLibrary_ResultText.Text = Functions.SLM.Translate(nameof(Properties.Resources.CreateLibrary_RootErrorMessage));
}
}
else
{
createLibrary_ResultText.Text = Framework.StringFormat.Format(Functions.SLM.Translate(nameof(Properties.Resources.CreateLibrary_ExistsMessage)), new { LibraryPath = libraryPath });
}
break;
}
}
Expand Down
48 changes: 42 additions & 6 deletions Source/Steam Library Manager/Forms/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
xmlns:Enums="clr-namespace:Steam_Library_Manager.Definitions.Enums"
xmlns:p="clr-namespace:Steam_Library_Manager.Properties"
mc:Ignorable="d">
<Grid>
<GroupBox x:Name="GeneralSettingsGroupBox" Header="{l:Static p:Resources.Forms_Settings_GeneralSettings}" Margin="0,5,360,5">
<UniformGrid Columns="2" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5, 10">
<GroupBox x:Name="GeneralSettingsGroupBox" Header="{l:Static p:Resources.Forms_Settings_GeneralSettings}">
<UniformGrid Columns="2">
<WrapPanel Orientation="Vertical">
<!-- Application sorting method -->
<ComboBox BorderBrush="{DynamicResource AccentColorBrush}" Margin="5" Controls:TextBoxHelper.Watermark="{l:Static p:Resources.Forms_Settings_SortGamesBy}" Controls:TextBoxHelper.UseFloatingWatermark="True" HorizontalAlignment="Left" Height="40"
Expand Down Expand Up @@ -185,7 +185,7 @@
</Controls:ToggleSwitch.ToolTip>
</Controls:ToggleSwitch>
</WrapPanel>
<WrapPanel Orientation="Vertical" Margin="5,0,0,0">
<WrapPanel Orientation="Vertical" Margin="3,0,0,0">
<ComboBox BorderBrush="{DynamicResource AccentColorBrush}" Margin="5" Controls:TextBoxHelper.Watermark="Default Compact Level" Controls:TextBoxHelper.UseFloatingWatermark="True" HorizontalAlignment="Left" Height="40"
VerticalAlignment="Top" Width="240" SelectedItem="{Binding Setting_compactLevel}"
ItemsSource="{Binding Source={SLM:EnumBindingSource EnumType={x:Type Enums:CompactLevel}}}">
Expand Down Expand Up @@ -292,7 +292,8 @@
</WrapPanel>
</UniformGrid>
</GroupBox>
<GroupBox Header="{l:Static p:Resources.Forms_Settings_TaskManagerDefaults}" Margin="0,5,0,5" HorizontalAlignment="Right" Width="355">
<StackPanel Margin="10,0,0,0">
<GroupBox Header="{l:Static p:Resources.Forms_Settings_TaskManagerDefaults}">
<StackPanel>
<!-- Remove Source Files -->
<Controls:ToggleSwitch ThumbIndicatorBrush="{DynamicResource AccentColorBrush}" Margin="5" Header="{l:Static p:Resources.Forms_Settings_RemoveFiles}" OnLabel="{l:Static p:Resources.Forms_Settings_Remove}" OffLabel="{l:Static p:Resources.Forms_Settings_DoNOTRemove}" IsChecked="{SLM:SettingBinding Global_RemoveOldFiles}"
Expand Down Expand Up @@ -373,5 +374,40 @@
</Controls:ToggleSwitch>
</StackPanel>
</GroupBox>
</Grid>
<GroupBox Header="Library Settings" Margin="0,10,0,0">
<StackPanel>
<Controls:ToggleSwitch ThumbIndicatorBrush="{DynamicResource AccentColorBrush}" Margin="5" Header="Steam Library Support" IsChecked="{SLM:SettingBinding Steam_IsEnabled}" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}">
<Controls:ToggleSwitch.ToolTip>
<ToolTip>
<StackPanel>
<TextBlock FontWeight="Bold" Text="Steam Library Support" />
<TextBlock Text="Enables/Disables Steam Library functionality for SLM" />
</StackPanel>
</ToolTip>
</Controls:ToggleSwitch.ToolTip>
</Controls:ToggleSwitch>
<Controls:ToggleSwitch ThumbIndicatorBrush="{DynamicResource AccentColorBrush}" Margin="5" Header="Origin Library Support" IsChecked="{SLM:SettingBinding Origin_IsEnabled}" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}">
<Controls:ToggleSwitch.ToolTip>
<ToolTip>
<StackPanel>
<TextBlock FontWeight="Bold" Text="Origin Library Support" />
<TextBlock Text="Enables/Disables Origin Library functionality for SLM" />
</StackPanel>
</ToolTip>
</Controls:ToggleSwitch.ToolTip>
</Controls:ToggleSwitch>
<Controls:ToggleSwitch ThumbIndicatorBrush="{DynamicResource AccentColorBrush}" Margin="5" Header="Uplay Library Support" IsChecked="{SLM:SettingBinding Uplay_IsEnabled}" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}">
<Controls:ToggleSwitch.ToolTip>
<ToolTip>
<StackPanel>
<TextBlock FontWeight="Bold" Text="Uplay Library Support" />
<TextBlock Text="Enables/Disables Uplay Library functionality for SLM" />
</StackPanel>
</ToolTip>
</Controls:ToggleSwitch.ToolTip>
</Controls:ToggleSwitch>
</StackPanel>
</GroupBox>
</StackPanel>
</StackPanel>
</UserControl>
Loading

0 comments on commit d215f51

Please sign in to comment.