Merge pull request #70 from EnumC/feat.duplicateDetect

pull/75/head
Brian Lima 3 years ago committed by GitHub
commit fa51d9d40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -55,6 +55,16 @@ Special thanks to @FusRoDah061 for implementing the base feature!
----------
# Building #
- Clone project or forked project.
- Install Visual Studio 2019 with .NET Framework 4.6.2.
- Install [SharpSteam by BrianLima](https://github.com/BrianLima/SharpSteam/releases/) and [VDFParser by heyvito](https://github.com/heyvito/VDFParser).
- Add the above two dll to the project in Visual Studio Reference Manager.
- Press run!
----------
# About #
This software is open-source under the MIT License.

@ -17,6 +17,7 @@ using UWPHook.Properties;
using UWPHook.SteamGridDb;
using VDFParser;
using VDFParser.Models;
using System.Diagnostics;
namespace UWPHook
{
@ -31,6 +32,7 @@ namespace UWPHook
public GamesWindow()
{
InitializeComponent();
Debug.WriteLine("Init GamesWindow");
Apps = new AppEntryModel();
var args = Environment.GetCommandLineArgs();
@ -324,10 +326,27 @@ namespace UWPHook
DevkitGameID = "",
LastPlayTime = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
};
Boolean isFound = false;
for (int i = 0; i < shortcuts.Length; i++)
{
Debug.WriteLine(shortcuts[i].ToString());
if (shortcuts[i].AppName == app.Name)
{
isFound = true;
Debug.WriteLine(app.Name + " already added to Steam. Updating existing shortcut.");
shortcuts[i] = newApp;
}
}
//Resize this array so it fits the new entries
Array.Resize(ref shortcuts, shortcuts.Length + 1);
shortcuts[shortcuts.Length - 1] = newApp;
if (!isFound)
{
//Resize this array so it fits the new entries
Array.Resize(ref shortcuts, shortcuts.Length + 1);
shortcuts[shortcuts.Length - 1] = newApp;
}
}
try
@ -368,6 +387,47 @@ namespace UWPHook
}
}
public static void ClearAllShortcuts()
{
Debug.WriteLine("DBG: Clearing all elements in shortcuts.vdf");
string[] tags = Settings.Default.Tags.Split(',');
string steam_folder = SteamManager.GetSteamFolder();
if (Directory.Exists(steam_folder))
{
var users = SteamManager.GetUsers(steam_folder);
var exePath = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @"""";
var exeDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
foreach (var user in users)
{
try
{
VDFEntry[] shortcuts = new VDFEntry[0];
try
{
if (!Directory.Exists(user + @"\\config\\"))
{
Directory.CreateDirectory(user + @"\\config\\");
}
//Write the file with all the shortcuts
File.WriteAllBytes(user + @"\\config\\shortcuts.vdf", VDFSerializer.Serialize(shortcuts));
}
catch (Exception ex)
{
throw new Exception("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Program failed while trying to clear your Steam shurtcuts:" + Environment.NewLine + ex.Message + ex.StackTrace);
}
}
MessageBox.Show("All non-Steam shortcuts has been cleared.");
}
}
private void LoadButton_Click(object sender, RoutedEventArgs e)
{
bwrLoad = new BackgroundWorker();

@ -1,4 +1,4 @@
<Window x:Class="UWPHook.SettingsWindow"
<Window x:Class="UWPHook.SettingsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -24,7 +24,7 @@
</Grid.RowDefinitions>
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="80" Grid.ColumnSpan="2" Margin="0,0,-0.4,0"/>
<Image x:Name="image" HorizontalAlignment="Left" Width="178" Height="80" VerticalAlignment="Top" Source="Resources/WhiteTransparent.png" Stretch="UniformToFill" ToolTip="Welcome to UWPHook, add your UWP apps and games to Steam!"/>
<Grid Margin="10,9.4,10.2,10.2" Grid.Row="1">
<Grid Margin="10,88,10,44" Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="62"/>
<RowDefinition Height="40"/>
@ -88,7 +88,7 @@
<Label ToolTip="Add these tags to exported games, use comma separated values" x:Name="label1_Copy6" Content="Export with these tags" Margin="5,35,8,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.Row="2"/>
<TextBox x:Name="tags_textBox" Grid.Column="2" Height="29" Margin="5,35,10,0" Grid.Row="2" TextWrapping="Wrap" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
</Grid>
<Grid Margin="10,9,9,1" Grid.Column="1" Grid.Row="1">
<Grid Margin="10,88,9,35" Grid.Column="1" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="63*"/>
<ColumnDefinition Width="164*"/>
@ -135,7 +135,8 @@
<Grid Margin="10,9.8,10.2,0.4" Grid.Row="2" Visibility="Hidden">
<Image HorizontalAlignment="Left" Height="111" VerticalAlignment="Top" Width="111" Source="Resources/square.png"/>
<TextBlock Margin="116,0,0,0" TextWrapping="Wrap" Text="Checkout OverFy, my new app, it add Spotify's now playing status into Rivatuner/MSI Afterburner overlay, Free and Open Source!" VerticalAlignment="Top" Height="63" TextAlignment="Justify" HorizontalAlignment="Left" Width="341"/>
<Button x:Name="update_button_Copy" Click="update_button_Copy_Click" Content="Get OverFy!" Margin="206,0,0,10" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="162"/>
<Button x:Name="update_button_Copy" Click="update_button_Click" Content="Get OverFy!" Margin="206,0,0,10" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="162"/>
</Grid>
<Button x:Name="clearAll_button" Click="clearAll_button_Click" Content="Debug: Clear shortcuts.vdf" Margin="0,0,156,12" Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="191"/>
</Grid>
</Window>

@ -81,9 +81,9 @@ namespace UWPHook
System.Diagnostics.Process.Start("https://reddit.com/r/UWPHook/");
}
private void update_button_Copy_Click(object sender, RoutedEventArgs e)
private void clearAll_button_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/BrianLima/OverFy/releases");
GamesWindow.ClearAllShortcuts();
}
private void key_Button_Click(object sender, RoutedEventArgs e)

Loading…
Cancel
Save