Compare commits

..

No commits in common. "master" and "2.3.0" have entirely different histories.

28 changed files with 236 additions and 1992 deletions

8
.gitignore vendored
View File

@ -262,10 +262,4 @@ paket-files/
# Python Tools for Visual Studio (PTVS) # Python Tools for Visual Studio (PTVS)
__pycache__/ __pycache__/
*.pyc *.pyc
# Advanced Installer
./Setup/UWPHook setup.exe
./Setup/Setup-cache
Setup/UWPHook.exe
*.exe

View File

@ -1,82 +1,47 @@
# UWPHook # UWPHook
[![](http://imgur.com/gWwR02D.png)](https://briano.dev/UWPHook/) ![](http://imgur.com/gWwR02D.png)
Small project to link UWP games and XboxGamePass to Steam Small project to link UWP games to Steam
If you want to add Windows Store or Xbox Game Pass Games to Steam, you need to do a bit of a workaround because Steam can't see UWP apps, and there's a chance Steam won't show it on your "Currently playing" status. This app aims to simplify a little bit the process where it is possible by automating the scripting and launching of Windows Store apps and Xbox Game Pass games. If you want to add Windows Store Games to Steamyou need to do a bit of a warkaround because Steam can't see UWP apps, and there's a chance Steam won't show it on your "Currently playing" status. This app aims to simplify a little bit the process where it is possible by automating the scripting and launching of Windows Store apps and games.
# To add UWP or XGP games to Steam # # To add UWP games to Steam #
[Download the latest version of UWPHook](https://github.com/BrianLima/UWPHook/releases) and store it somewhere on your PC. [Download the latest version of UWPHook](https://github.com/BrianLima/UWPHook/releases) and store it somewhere on your PC.
Click on the 🔄 to load installed UWP Apps, we will find every UWP app and Xbox Game Pass game installed on your PC. ![](http://i.imgur.com/wOV8QwD.png)
![](https://i.imgur.com/pjGfGHe.png) Click "load installed UWP Apps", we will find every UWP app installed on your PC.
Select every app you want to add to Steam, you can change the name by double clicking the "name" collumn, press "Export selected apps to Steam" and 🎉, every app you selected will be added to Steam. ![](http://i.imgur.com/ppivtS5.png)
![](https://i.imgur.com/on46CMQ.png) Select every app you want to add to Steam, change the name by doubleclicking the "name" collumn, press "Export selected apps to Steam" and boom, every app you selected will be added to Steam.
Close UWPHook, restart Steam if prompted, click play on your UWP game, and Steam will show your current game on your status as long as you are playing it! Close UWPHook, restart Steam, click play on your UWP game, and Steam will show your current game on your status as long as you are playing it!
---------- ----------
# SteamGridDB #
Since v2.8, UWPHook can automatically import grid, icons and hero images from [SteamGridDB](https://www.steamgriddb.com)
On your first usage, the app will ask you if you want it to download images, redirecting you to the settings page.
![](https://i.imgur.com/K0Cm4IL.png)
By adding a API Key obtained in the SteamGridDB preferences, UWPHook will try to find matching images for any exported games, giving you the following result:
![](https://i.imgur.com/mlvVdwb.png)
You can refine the images by using filters for animated images, blurred, no logo or memes for example, but it will always pick the first it finds for the filters automatically.
Special thanks to @FusRoDah061 for implementing the base feature!
# Troubleshooting # # Troubleshooting #
- **Steam's Overlay isn't working!** - **Steam's Overlay isn't working!**
- Unfortunately, it's a Steam limitation, Valve has to update it in order to work properly with UWP, DXTory is a recommended overlay for UWP games. - Unfortunately, it's a Steam limitation, Valve has to update it in order to work properly with UWP, DXTory is a recommended overlay for UWP games.
- **Using Steam Link**
- Check the option "Streaming" mode inside the settings screen - **Steam Link launches the game but input doesn't work!**
- **Steam Deck?** - Unfortunately, another limitation by Steam, i have some ideas as to why it isn't working, but i can't give an ETA for when i can fix this, or even if it's fixable on my end, since Valve didn't released the Link in Brazil and i can't get one to test.
- This app is not compatible with the Steam Deck in any way.
- **Steam Controller isn't working**
- Another limitation by Steam, some people reported it works with "Desktop Mode" configuration, but i can't verify this.
If you are facing an error of any kind, please check the contents of the file
- **I have shortcuts from other application that broke when i used UWPHook**
- You can find a backup of your `shortcuts.vdf` file in `%appdata%\Roaming\Briano\UWPHook\backups`, each file in this directory is a backup of the original `shortcuts.vdf` before manipulation by UWPHook, the files are renamed `{userid}_{timestamp}_shortcut.vdf`, you can restore these files to their original location for usage.
- **My question isn't listed here!** - **My question isn't listed here!**
- Drop by our subreddit and ask a question over there, maybe someone will help you, i surely will as soon as i can: - Drop by our subreddit and ask a question over there, maybe someone will help you, i surely will as soon as i can
**[https://www.reddit.com/r/uwphook](https://www.reddit.com/r/uwphook)** **[https://www.reddit.com/r/uwphook](https://www.reddit.com/r/uwphook)**
- Please also paste the contents of the file `%appdata%Roaming\Briano\UWPHook\application.log` so i can try to understand better the problem.
----------
# Building
- Clone project or forked project.
- Install Visual Studio 2022 with .NET Framework 4.8.
- Install [SharpSteam by BrianLima](https://github.com/BrianLima/SharpSteam/releases/) and [VDFParser](https://github.com/brianlima/VDFParser) and build.
- If the project asks for the references for VDFParser and Sharpsteam, point it to the most recent build.
- Press run!
## Installer
The installer is built with [NSIS](https://nsis.sourceforge.io/Download), just run the script `UWPHook.nsi` and things **should** work. Modify any hardcoded paths to suit your setup.
The installation consists of zipping the application and creating some of the paths for the user, since the application is mostly static/dynamic and does not depend a lot on where it is installed, the installer is made for convenience.
---------- ----------
# About # About #
This software is open-source under the MIT License. This software is open-source under the MIT License.
It will mostly likely break withouth any heads up, since any API, file format, script and many other things used by it may be changed by Valve or Microsoft withouth prior notice.
I am not responsible if anything breaks.
If you like what i did with it and want to suport me, you can cheer me up at my [Twitter](http://www.twitter.com/brianostorm "Twitter") or [pay me a coffee via Paypal, it will help me to continue to build amazing open source tools for you!"](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9YPV3FHEFRAUQ) If you like what i did with it and want to suport me, you can cheer me up at my [Twitter](http://www.twitter.com/brianostorm "Twitter") or [pay me a coffee via Paypal, it will help me to continue to build amazing open source tools for you!"](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9YPV3FHEFRAUQ)

View File

@ -1,220 +0,0 @@
############################################################################################
# NSIS Installation Script created by NSIS Quick Setup Script Generator v1.09.18
# Entirely Edited with NullSoft Scriptable Installation System
# by Vlasis K. Barkas aka Red Wine red_wine@freemail.gr Sep 2006
############################################################################################
#
# Edited by Briano 🤔
#
############################################################################################
!define APP_NAME "UWPHook"
!define COMP_NAME "Briano"
!define WEB_SITE "https://briano.dev"
!define VERSION "2.14.00.00"
!define COPYRIGHT "Briano <20> 2020 2021 2022"
!define DESCRIPTION "The easy way to add UWP and XGP games to Steam"
!define LICENSE_TXT "C:\Users\Brian\Documents\GitHub\UWPHook\README.md"
!define INSTALLER_NAME "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook.exe"
!define MAIN_APP_EXE "UWPHook.exe"
!define INSTALL_TYPE "SetShellVarContext current"
!define REG_ROOT "HKCU"
!define REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${MAIN_APP_EXE}"
!define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
!define REG_START_MENU "Start Menu Folder"
var SM_Folder
######################################################################
VIProductVersion "${VERSION}"
VIAddVersionKey "ProductName" "${APP_NAME}"
VIAddVersionKey "CompanyName" "${COMP_NAME}"
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
VIAddVersionKey "FileDescription" "${DESCRIPTION}"
VIAddVersionKey "FileVersion" "${VERSION}"
######################################################################
SetCompressor ZLIB
Name "${APP_NAME}"
Caption "${APP_NAME}"
OutFile "${INSTALLER_NAME}"
BrandingText "${APP_NAME}"
XPStyle on
InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" ""
InstallDir "$APPDATA\Briano\UWPHook"
######################################################################
!include "MUI.nsh"
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!ifdef LICENSE_TXT
!insertmacro MUI_PAGE_LICENSE "${LICENSE_TXT}"
!endif
!insertmacro MUI_PAGE_DIRECTORY
!ifdef REG_START_MENU
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "UWPHook"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
!endif
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAIN_APP_EXE}"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
######################################################################
Section -MainProgram
${INSTALL_TYPE}
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Crc32.NET.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\MaterialDesignColors.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\MaterialDesignThemes.Wpf.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Microsoft.Xaml.Behaviors.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Newtonsoft.Json.Bson.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Newtonsoft.Json.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Serilog.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Serilog.Sinks.Console.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Serilog.Sinks.File.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\SharpSteam.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Buffers.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Diagnostics.DiagnosticSource.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Management.Automation.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Memory.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Net.Http.Formatting.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Numerics.Vectors.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Runtime.CompilerServices.Unsafe.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\System.Threading.Tasks.Extensions.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\VDFParser.dll"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\UWPHook.exe"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\UWPHook.exe.config"
CreateDirectory "$INSTDIR\Resources"
SetOutPath "$INSTDIR\Resources"
File "C:\Users\Brian\Documents\GitHub\UWPHook\UWPHook\bin\Release\Resources\KnownApps.json"
SectionEnd
######################################################################
Section -Icons_Reg
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\uninstall.exe"
!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$SM_Folder"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk" "$INSTDIR\${APP_NAME} website.url"
!endif
!insertmacro MUI_STARTMENU_WRITE_END
!endif
!ifndef REG_START_MENU
CreateDirectory "$SMPROGRAMS\UWPHook"
CreateShortCut "$SMPROGRAMS\UWPHook\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\UWPHook\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
CreateShortCut "$SMPROGRAMS\UWPHook\${APP_NAME} Website.lnk" "$INSTDIR\${APP_NAME} website.url"
!endif
!endif
WriteRegStr ${REG_ROOT} "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "${APP_NAME}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayIcon" "$INSTDIR\${MAIN_APP_EXE}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "${VERSION}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "${COMP_NAME}"
!ifdef WEB_SITE
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "${WEB_SITE}"
!endif
SectionEnd
######################################################################
Section Uninstall
${INSTALL_TYPE}
Delete "$INSTDIR\MaterialDesignColors.dll"
Delete "$INSTDIR\MaterialDesignThemes.Wpf.dll"
Delete "$INSTDIR\MaterialDesignThemes.Wpf.xml"
Delete "$INSTDIR\Microsoft.Management.Infrastructure.dll"
Delete "$INSTDIR\SharpSteam.dll"
Delete "$INSTDIR\System.Management.Automation.dll"
Delete "$INSTDIR\System.Management.Automation.xml"
Delete "$INSTDIR\UWPHook.exe"
Delete "$INSTDIR\UWPHook.exe.config"
Delete "$INSTDIR\VDFParser.dll"
Delete "$INSTDIR\Crc32.NET.dll"
Delete "$INSTDIR\Crc32.NET.xml"
Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\System.Net.Http.Formatting.dll"
Delete "$INSTDIR\Newtonsoft.Json.dll"
Delete "$INSTDIR\System.dll"
Delete "$INSTDIR\Resources\KnownApps.json"
!ifdef WEB_SITE
Delete "$INSTDIR\${APP_NAME} website.url"
!endif
RmDir /r "$APPDATA\Briano"
RmDir "$INSTDIR\Resources"
RmDir "$INSTDIR"
!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $SM_Folder
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk"
!endif
Delete "$DESKTOP\${APP_NAME}.lnk"
RmDir "$SMPROGRAMS\$SM_Folder"
!endif
!ifndef REG_START_MENU
Delete "$SMPROGRAMS\UWPHook\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\UWPHook\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\UWPHook\${APP_NAME} Website.lnk"
!endif
Delete "$DESKTOP\${APP_NAME}.lnk"
RmDir "$SMPROGRAMS\UWPHook"
!endif
DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
SectionEnd
######################################################################

View File

@ -1,28 +1,22 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 14
VisualStudioVersion = 15.0.27703.1 VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPHook", "UWPHook\UWPHook.csproj", "{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPHook", "UWPHook\UWPHook.csproj", "{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
DefaultBuild|Any CPU = DefaultBuild|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU
{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU
{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Release|Any CPU.Build.0 = Release|Any CPU {AFE09BCF-28A4-48EE-876B-FEF080D04D5F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8F60407F-0197-459E-B674-3CDDF6EF79A1}
EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="UWPHook.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="UWPHook.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> </configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<userSettings> <userSettings>
<UWPHook.Properties.Settings> <UWPHook.Properties.Settings>
@ -22,87 +22,6 @@
<setting name="StreamMode" serializeAs="String"> <setting name="StreamMode" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="SteamGridDbApiKey" serializeAs="String">
<value />
</setting>
<setting name="SelectedSteamGridDB_Style" serializeAs="String">
<value>0</value>
</setting>
<setting name="SelectedSteamGridDB_Type" serializeAs="String">
<value>0</value>
</setting>
<setting name="SelectedSteamGridDB_nfsw" serializeAs="String">
<value>0</value>
</setting>
<setting name="SelectedSteamGridDB_Humor" serializeAs="String">
<value>0</value>
</setting>
<setting name="OfferedSteamGridDB" serializeAs="String">
<value>False</value>
</setting>
<setting name="Tags" serializeAs="String">
<value>READY TO PLAY,XBOX</value>
</setting>
<setting name="SteamGridDB_Style" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<string>any</string>
<string>alternate</string>
<string>blurred</string>
<string>white_logo</string>
<string>material</string>
<string>no_logo </string>
</ArrayOfString>
</value>
</setting>
<setting name="SteamGridDB_Type" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<string>any</string>
<string>static</string>
<string>animated</string>
</ArrayOfString>
</value>
</setting>
<setting name="SteamGridDB_nfsw" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<string>false</string>
<string>any</string>
<string>true</string>
</ArrayOfString>
</value>
</setting>
<setting name="SteamGridDB_Humor" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<string>false</string>
<string>any</string>
<string>true</string>
</ArrayOfString>
</value>
</setting>
<setting name="LogLevel" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<string>ERROR</string>
<string>DEBUG</string>
<string>TRACE</string>
</ArrayOfString>
</value>
</setting>
<setting name="SelectedLogLevel" serializeAs="String">
<value>0</value>
</setting>
</UWPHook.Properties.Settings> </UWPHook.Properties.Settings>
</userSettings> </userSettings>
<runtime> </configuration>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,15 +1,15 @@
<Application x:Class="UWPHook.App" <Application x:Class="UWPHook.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UWPHook" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:UWPHook"
StartupUri="GamesWindow.xaml"> StartupUri="GamesWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<materialDesign:CustomColorTheme BaseTheme="Light" PrimaryColor="Blue" SecondaryColor="MediumPurple" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml"/> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml"/> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml"/> <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.deeppurple.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

View File

@ -2,7 +2,6 @@
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace UWPHook namespace UWPHook
@ -35,16 +34,6 @@ public string Name
set { _name = value; } set { _name = value; }
} }
private string _executable;
/// <summary>
/// Gets or sets the executable of the application
/// </summary>
public string Executable
{
get { return _executable; }
set { _executable = value; }
}
private string _aumid; private string _aumid;
/// <summary> /// <summary>
/// Gets or sets the aumid of the application /// Gets or sets the aumid of the application
@ -84,19 +73,8 @@ public string widestSquareIcon()
Size size = new Size(0, 0); Size size = new Size(0, 0);
List<string> images = new List<string>(); List<string> images = new List<string>();
//Get every png in this directory, Steam only allows for .png's
try images.AddRange(Directory.GetFiles(_icon_path, "*.png"));
{
//Get every png, jpg or jpeg in this directory, Steam only allows for .png's but jpgs work too
images.AddRange(Directory.GetFiles(_icon_path, "*.png"));
images.AddRange(Directory.GetFiles(_icon_path, "*.jpg"));
images.AddRange(Directory.GetFiles(_icon_path, "*.jpeg"));
}
catch (DirectoryNotFoundException)
{
// Issue #56
return string.Empty;
}
//Decide which is the largest //Decide which is the largest
foreach (string image in images) foreach (string image in images)
@ -128,26 +106,11 @@ public string widestSquareIcon()
return result; return result;
} }
public string isKnownApp()
{
if(AppManager.IsKnownApp(_aumid, out string name))
{
return name;
}
return "Name not found, double click here to edit";
}
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
public override string ToString()
{
return $"{Name} ({Aumid})";
}
} }
} }

View File

@ -1,16 +1,11 @@
using Serilog; using System;
using Serilog.Core;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Management;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using UWPHook.Properties;
namespace UWPHook namespace UWPHook
{ {
@ -19,43 +14,28 @@ namespace UWPHook
/// </summary> /// </summary>
static class AppManager static class AppManager
{ {
private static int runningProcessId; private static int id;
private static bool isLauncherProcess;
private static string executablePath;
/// <summary> /// <summary>
/// Launch a UWP App using a ApplicationActivationManager and sets a internal id to launched proccess id /// Launch a UWP App using a ApplicationActivationManager and sets a internal id to launched proccess id
/// </summary> /// </summary>
/// <param name="aumid">The AUMID of the app to launch</param> /// <param name="aumid">The AUMID of the app to launch</param>
public static void LaunchUWPApp(string[] args) public static void LaunchUWPApp(string aumid)
{ {
// We receive the args from Steam,
// 0 is application location,
// 1 is the aumid,
// 2 is the executable, the rest are extras
string aumid = args[1];
executablePath = args[2].Contains("/") ? args[2].Replace('/', '\\') : args[2];
Log.Verbose("Arguments => " + String.Join("/", args));
var mgr = new ApplicationActivationManager(); var mgr = new ApplicationActivationManager();
uint processId; uint processId;
string extra_args = String.Join(" ", args.Skip(3)
.Take(args.Length - 3)
.Select(eachElement => eachElement.Clone()
).ToArray());
try try
{ {
mgr.ActivateApplication(aumid, extra_args, ActivateOptions.None, out processId); mgr.ActivateApplication(aumid, null, ActivateOptions.None, out processId);
runningProcessId = (int) processId;
Log.Verbose("Process ID => " + runningProcessId.ToString());
//Bring the launched app to the foreground, this fixes in-home streaming //Bring the launched app to the foreground, this fixes in-home streaming
id = (int)processId;
BringProcess(); BringProcess();
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error("Error while trying to launch your app." + Environment.NewLine + e.Message);
throw new Exception("Error while trying to launch your app." + Environment.NewLine + e.Message); throw new Exception("Error while trying to launch your app." + Environment.NewLine + e.Message);
} }
} }
@ -66,91 +46,25 @@ public static void LaunchUWPApp(string[] args)
/// <returns>True if the perviously launched app is running, false otherwise</returns> /// <returns>True if the perviously launched app is running, false otherwise</returns>
public static Boolean IsRunning() public static Boolean IsRunning()
{ {
//If 0, no app was launched most probably
if (id == 0)
{
return false;
}
try try
{ {
Log.Debug("Checking PID => " + runningProcessId.ToString()); Process.GetProcessById(id);
// PID 0 means an error during launch for the game
// (Example : Game no more available on gamepass or problem with installation) so instant exit in this case
if (runningProcessId == 0)
{
Log.Debug("PID is 0");
return false;
}
Process.GetProcessById(runningProcessId);
Log.Debug("Process is running");
return true;
} }
catch catch (Exception)
{ {
// Check only at launch if started by a launcher return false;
if (!isLauncherProcess)
{
Log.Debug("initial PID is not running anymore, checking other possible process runing before stop");
bool secondCheck = false;
do
{
// Handle process running by some launcher by checking their executable path and name
var processes = GetProcess();
foreach (var process in processes)
{
string executableFile = executablePath.Contains('\\') ? executablePath.Substring(executablePath.LastIndexOf('\\') + 1) : executablePath;
Log.Verbose("Process " + process.Value.Path + " contains " + executablePath + " ? : " + process.Value.Path.Contains(executablePath).ToString());
Log.Verbose("Process " + process.Key + " contains " + executableFile + " ? : " + process.Key.Contains(executableFile).ToString());
if (process.Value.Path.Contains(executablePath) || process.Key.Contains(executableFile))
{
int pid = process.Value.Pid;
Log.Verbose($"Launcher opened child process ({runningProcessId}->{pid}), using new process as target");
runningProcessId = pid;
isLauncherProcess = true;
//bring the "real" launched process
BringProcess();
return true;
}
}
// Handle the last chance if process was not found due to slow running like Farming Simulator 2022 or Halo MCC
secondCheck = !secondCheck;
if (secondCheck)
{
Log.Debug("Process has not been found. Last chance to find it !");
Thread.Sleep(Settings.Default.Seconds * 5000);
}
} while (secondCheck);
}
} }
return false; return true;
} }
/// <summary> /// <summary>
/// Find process path with their dedicated pid /// Gets a list of installed UWP Apps on the system, containing each app name + AUMID, separated by '|'
/// </summary>
/// <returns>Map of processes to their path and pid. Any process in this object may have already terminated</returns>
private static Dictionary<string, (string Path, int Pid)> GetProcess()
{
var result = new Dictionary<string, (string Path, int Pid)>();
using (var searcher = new ManagementObjectSearcher("select processid, Name, ExecutablePath from win32_process"))
{
foreach (var process in searcher.Get())
{
string processName = Convert.ToString(process.Properties["Name"].Value);
int processId = Convert.ToInt32(process.Properties["processid"].Value);
string processPath = Convert.ToString(process.Properties["ExecutablePath"].Value);
if (String.IsNullOrWhiteSpace(processName) || result.ContainsKey(processName)) continue;
result.Add(processName, (processPath, processId));
}
}
return result;
}
/// <summary>
/// Gets a list of installed UWP Apps on the system, containing each app name + AUMID + executable path, separated by '|'
/// </summary> /// </summary>
/// <returns>List of installed UWP Apps</returns> /// <returns>List of installed UWP Apps</returns>
public static List<String> GetInstalledApps() public static List<String> GetInstalledApps()
@ -158,7 +72,7 @@ public static List<String> GetInstalledApps()
List<String> result = null; List<String> result = null;
var assembly = Assembly.GetExecutingAssembly(); var assembly = Assembly.GetExecutingAssembly();
//Load the powershell script to get installed apps //Load the powershell script to get installed apps
var resourceName = "UWPHook.Resources.GetAUMIDScript.ps1"; var resourceName = "UWPHook.Resources.GetAUMIDScript.txt";
try try
{ {
using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (Stream stream = assembly.GetManifestResourceStream(resourceName))
@ -172,37 +86,12 @@ public static List<String> GetInstalledApps()
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error("Error trying to get installed apps on your PC " + Environment.NewLine + e.Message, e.InnerException);
throw new Exception("Error trying to get installed apps on your PC " + Environment.NewLine + e.Message, e.InnerException); throw new Exception("Error trying to get installed apps on your PC " + Environment.NewLine + e.Message, e.InnerException);
} }
return result; return result;
} }
/// <summary>
/// Try to convert an aumid into a human-readable app name
/// </summary>
/// <param name="appName">Application user model ID (aumid)</param>
/// <param name="readableName">User-friendly app name</param>
/// <returns>Whether this is a known app</returns>
public static bool IsKnownApp(string appName, out string readableName)
{
string appsJson = File.ReadAllText(@"Resources\KnownApps.json");
var apps = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(appsJson);
foreach (var kvp in apps)
{
if (appName.StartsWith(kvp.Key + "_"))
{
readableName = kvp.Value;
return true;
}
}
readableName = null;
return false;
}
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern private static extern
bool SetForegroundWindow(IntPtr hWnd); bool SetForegroundWindow(IntPtr hWnd);
@ -225,7 +114,8 @@ public static void BringProcess()
        const int SW_SHOWDEFAULT = 10;         const int SW_SHOWDEFAULT = 10;
        */         */
var arrProcesses = Process.GetProcessById(runningProcessId); var me = Process.GetCurrentProcess();
var arrProcesses = Process.GetProcessById(id);
// get the window handle // get the window handle
IntPtr hWnd = arrProcesses.MainWindowHandle; IntPtr hWnd = arrProcesses.MainWindowHandle;

View File

@ -1,45 +0,0 @@
<Window x:Class="UWPHook.FullScreenLauncher"
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"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:UWPHook"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
Background="{DynamicResource MaterialDesignPaper}"
TextElement.FontWeight="Medium"
TextElement.FontSize="14"
FontFamily="Segoe UI Light"
mc:Ignorable="d"
WindowStyle="None"
WindowState="Maximized"
Title="UWPHook" Height="600" Width="800" Icon="/Resources/hook2.ico">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="29*"/>
<RowDefinition Height="147*"/>
<RowDefinition Height="65.6"/>
</Grid.RowDefinitions>
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.Darken="True" Mode="PrimaryMid" Height="80" Margin="0,0,-0.4,0">
<Label x:Name="label1" Content="Welcome to UWPHook, the easier way to add UWP games and apps to Steam!" HorizontalAlignment="Left" Margin="172,-14,0,0" VerticalAlignment="Top" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone>
<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.8,9.6,0" Grid.Row="1" Height="421" VerticalAlignment="Top">
<ProgressBar
IsIndeterminate="True"
Style="{StaticResource MaterialDesignCircularProgressBar}"
Value="50" Height="100" Width="100"/>
</Grid>
<TextBlock x:Name="textLaunch" Margin="10,72.8,9.6,0" Grid.Row="1" TextWrapping="Wrap" Text="" VerticalAlignment="Top" TextAlignment="Center" FontSize="24" Height="32"/>
<TextBlock HorizontalAlignment="Left" Margin="10,9,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Made for you with &lt;3, code and coffee by Brian Lima @brianostorm, do you like my work? Support me by downloading my other projects or by paying me a coffee via paypal!" VerticalAlignment="Top" Width="633" Height="47" TextAlignment="Justify"/>
<materialDesign:Chip Content="Paypal donate"
IconBackground="{DynamicResource PrimaryHueDarkBrush}"
IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Margin="0,12,9.6,18.6" Click="Chip2_Click" HorizontalAlignment="Right" Height="Auto" Grid.Row="2" Width="136">
<materialDesign:Chip.Icon>
<materialDesign:PackIcon Kind="Coffee"></materialDesign:PackIcon>
</materialDesign:Chip.Icon>
</materialDesign:Chip>
</Grid>
</Window>

View File

@ -1,75 +0,0 @@
using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace UWPHook
{
/// <summary>
/// Interaction logic for FullScreenLauncher.xaml
/// </summary>
public partial class FullScreenLauncher : Window
{
public PaletteHelper pallet;
public FullScreenLauncher()
{
InitializeComponent();
textLaunch.Text = GetLauncherText();
pallet = new PaletteHelper();
BaseTheme darkTheme = BaseTheme.Dark;
var theme = Theme.Create(darkTheme,
SwatchHelper.Lookup[(MaterialDesignColor)PrimaryColor.DeepPurple],
SwatchHelper.Lookup[(MaterialDesignColor)SecondaryColor.Lime]);
pallet.SetTheme(theme);
}
private void Chip2_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9YPV3FHEFRAUQ");
}
string GetLauncherText()
{
int n = DateTime.Now.Second;
if (n >= 0 && n <= 10)
{
return "Hold on, i'm making your stream full screen!";
}
else if (n > 10 && n <= 20)
{
return "Waiting Steam in-home Streaming to catch up";
}
else if (n > 20 && n <= 30)
{
return "Starting Stream in a few seconds!";
}
else if (n > 30 && n <= 40)
{
return "Let's get this game started!";
}
else if (n > 40 && n <= 50)
{
return "Don't forget to check for updates at github.com/brianlima";
}
else
{
return "Good game, enjoy!";
}
}
}
}

View File

@ -11,18 +11,18 @@
TextElement.FontSize="14" TextElement.FontSize="14"
FontFamily="Segoe UI Light" FontFamily="Segoe UI Light"
mc:Ignorable="d" mc:Ignorable="d"
Title="UWPHook" Height="600" Width="800" Icon="/Resources/hook2.ico" Loaded="Window_Loaded"> Title="UWPHook" Height="600" Width="800" Icon="/Resources/hook2.ico">
<Grid x:Name="grid"> <Grid x:Name="grid">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="28*"/> <RowDefinition Height="28*"/>
<RowDefinition Height="144*"/> <RowDefinition Height="144*"/>
<RowDefinition Height="19*"/> <RowDefinition Height="19*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.Darken="True" Mode="PrimaryMid" Height="80"> <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" Height="80">
<Label x:Name="label1" Content="Welcome to UWPHook, the easier way to add UWP apps and XGP games and apps to Steam!" HorizontalAlignment="Left" Margin="172,-14,0,0" VerticalAlignment="Top" Foreground="#DDFFFFFF"/> <Label x:Name="label1" Content="Welcome to UWPHook, the easier way to add UWP games and apps to Steam!" HorizontalAlignment="Left" Margin="172,-14,0,0" VerticalAlignment="Top" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone> </materialDesign:ColorZone>
<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!"/> <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!"/>
<Button x:Name="settingsButton" Click="SettingsButton_Click" Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}" <Button Click="HelpButton_Click" Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
Margin="0,6,10,0" HorizontalAlignment="Right" Margin="0,6,10,0" HorizontalAlignment="Right"
ToolTip="Settings/About" VerticalAlignment="Top"> ToolTip="Settings/About" VerticalAlignment="Top">
<materialDesign:PackIcon Kind="Settings" Height="24" Width="24" /> <materialDesign:PackIcon Kind="Settings" Height="24" Width="24" />
@ -35,11 +35,11 @@
<Grid Margin="10" Grid.Row="1"> <Grid Margin="10" Grid.Row="1">
<DataGrid x:Name="listGames" Margin="0,25,0,0" CanUserSortColumns="True" CanUserAddRows="False" <DataGrid x:Name="listGames" Margin="0,25,0,0" CanUserSortColumns="True" CanUserAddRows="False"
materialDesign:DataGridAssist.CellPadding="4 2 2 2" materialDesign:DataGridAssist.ColumnHeaderPadding="4 2 2 2"/> materialDesign:DataGridAssist.CellPadding="4 2 2 2" materialDesign:DataGridAssist.ColumnHeaderPadding="4 2 2 2"/>
<Label x:Name="label" Content="Press 'Load installed apps' to get a list of installed titles." HorizontalAlignment="Left" Margin="0,-10,0,0" VerticalAlignment="Top"/> <Label x:Name="label" Content="Press 'Load installed apps' to get a list of installed apps on your system." HorizontalAlignment="Left" Margin="0,-10,0,0" VerticalAlignment="Top"/>
</Grid> </Grid>
<Button Content="Export selected apps to Steam" Click="ExportButton_Click" HorizontalAlignment="Right" Margin="0,0,10,10" Grid.Row="2" VerticalAlignment="Bottom" Width="227"/> <Button Content="Export selected apps to Steam" Click="ExportButton_Click" HorizontalAlignment="Right" Margin="0,0,10,10" Grid.Row="2" VerticalAlignment="Bottom" Width="227"/>
<ProgressBar Visibility="Collapsed" x:Name="progressBar" Margin="10,215,10,174" Grid.Row="1" IsIndeterminate="True" /> <ProgressBar Visibility="Collapsed" x:Name="progressBar" Margin="10,215,10,174" Grid.Row="1" IsIndeterminate="True" />
<Label Content="Filter:" HorizontalAlignment="Left" Margin="5,16,0,0" Grid.Row="2" VerticalAlignment="Top"/> <Label Content="Filter AUMIDS:" HorizontalAlignment="Left" Margin="5,16,0,0" Grid.Row="2" VerticalAlignment="Top"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="25" Margin="50,17,0,0" Grid.Row="2" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="271" TextChanged="textBox_TextChanged"/> <TextBox x:Name="textBox" HorizontalAlignment="Left" Height="25" Margin="104,17,0,0" Grid.Row="2" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="217" TextChanged="textBox_TextChanged"/>
</Grid> </Grid>
</Window> </Window>

View File

@ -1,23 +1,12 @@
using Force.Crc32; using SharpSteam;
using Serilog;
using Serilog.Core;
using SharpSteam;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using UWPHook.Properties;
using UWPHook.SteamGridDb;
using VDFParser; using VDFParser;
using VDFParser.Models; using VDFParser.Models;
@ -29,72 +18,36 @@ namespace UWPHook
public partial class GamesWindow : Window public partial class GamesWindow : Window
{ {
AppEntryModel Apps; AppEntryModel Apps;
BackgroundWorker bwrLoad; BackgroundWorker bwrLoad, bwrSave;
static LoggingLevelSwitch levelSwitch = new LoggingLevelSwitch();
public GamesWindow() public GamesWindow()
{ {
InitializeComponent(); InitializeComponent();
Log.Debug("Init GamesWindow");
Apps = new AppEntryModel(); Apps = new AppEntryModel();
var args = Environment.GetCommandLineArgs();
// Init log file to AppData\Roaming\Briano\UWPHook directory with size rotation on 10Mb with max 5 files //If null or 1, the app was launched normally
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); if (Environment.GetCommandLineArgs() != null)
FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
string loggerFilePath = String.Join("\\", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), fvi.CompanyName, fvi.ProductName, "application.log");
Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.WriteTo.File(path: loggerFilePath, rollOnFileSizeLimit: true, fileSizeLimitBytes: 10485760, retainedFileCountLimit: 5)
.WriteTo.Console()
.CreateLogger();
// Switch to Info by default to inform logger level in log file and switch to the correct log level
levelSwitch.MinimumLevel = Serilog.Events.LogEventLevel.Information;
SetLogLevel();
// If null or 1, the app was launched normally
if (args?.Length > 1)
{ {
// When length is 1, the only argument is the path where the app is installed //When length is 1, the only argument is the path where the app is installed
_ = LauncherAsync(args); // Launches the requested game if (Environment.GetCommandLineArgs().Length > 1)
} {
else Launcher();
{ }
//auto refresh on load
LoadButton_Click(null, null);
} }
} }
/// <summary> private void Launcher()
/// We have to wait a little untill Steam catches up, otherwise it will stream a black screen
/// </summary>
/// <returns></returns>
async Task LaunchDelay()
{ {
await Task.Delay(10000);
}
/// <summary>
/// Main task that launches a game
/// Usually invoked by steam
/// </summary>
/// <param name="args">launch args received from the program execution</param>
/// <returns></returns>
private async Task LauncherAsync(string[] args)
{
FullScreenLauncher launcher = null;
//So, for some reason, Steam is now stopping in-home streaming if the launched app is minimized, so not hiding UWPHook's window is doing the trick for now //So, for some reason, Steam is now stopping in-home streaming if the launched app is minimized, so not hiding UWPHook's window is doing the trick for now
if (Settings.Default.StreamMode) if (Properties.Settings.Default.StreamMode)
{ {
this.Hide(); this.Show();
launcher = new FullScreenLauncher(); this.WindowStyle = WindowStyle.None;
launcher.Show(); this.WindowState = WindowState.Maximized;
this.Title = "UWPHook: Streaming a game";
this.label.Content = "UWPHook is streaming your game, fasten your seatbelts.";
await LaunchDelay(); Thread.Sleep(10000);
launcher.Close();
} }
else else
{ {
@ -109,18 +62,18 @@ private async Task LauncherAsync(string[] args)
{ {
//Some apps have their language locked to the UI language of the system, so overriding it might change the language of the game //Some apps have their language locked to the UI language of the system, so overriding it might change the language of the game
//I my self couldn't get this to work on neither Forza Horizon 3 or Halo 5 Forge, @AbGedreht reported it works tho //I my self couldn't get this to work on neither Forza Horizon 3 or Halo 5 Forge, @AbGedreht reported it works tho
if (Settings.Default.ChangeLanguage && !String.IsNullOrEmpty(Settings.Default.TargetLanguage)) if (Properties.Settings.Default.ChangeLanguage && !String.IsNullOrEmpty(Properties.Settings.Default.TargetLanguage))
{ {
ScriptManager.RunScript("Set-WinUILanguageOverride " + Properties.Settings.Default.TargetLanguage); ScriptManager.RunScript("Set-WinUILanguageOverride " + Properties.Settings.Default.TargetLanguage);
} }
//The only other parameter Steam will send is the app AUMID //The only other parameter Steam will send is the app AUMID
AppManager.LaunchUWPApp(args); AppManager.LaunchUWPApp(Environment.GetCommandLineArgs()[1]);
//While the current launched app is running, sleep for n seconds and then check again //While the current launched app is running, sleep for n seconds and then check again
while (AppManager.IsRunning()) while (AppManager.IsRunning())
{ {
Thread.Sleep(Settings.Default.Seconds * 1000); Thread.Sleep(Properties.Settings.Default.Seconds * 1000);
} }
} }
catch (Exception e) catch (Exception e)
@ -130,9 +83,9 @@ private async Task LauncherAsync(string[] args)
} }
finally finally
{ {
if (Settings.Default.ChangeLanguage && !String.IsNullOrEmpty(Settings.Default.TargetLanguage)) if (Properties.Settings.Default.ChangeLanguage && !String.IsNullOrEmpty(Properties.Settings.Default.TargetLanguage))
{ {
ScriptManager.RunScript("Set-WinUILanguageOverride " + currentLanguage); ScriptManager.RunScript("Set - WinUILanguageOverride " + currentLanguage);
} }
//The user has probably finished using the app, so let's close UWPHook to keep the experience clean //The user has probably finished using the app, so let's close UWPHook to keep the experience clean
@ -140,275 +93,38 @@ private async Task LauncherAsync(string[] args)
} }
} }
/// <summary> private void ExportButton_Click(object sender, RoutedEventArgs e)
/// Generates a CRC32 hash expected by Steam to link an image with a game in the library
/// See https://blog.yo1.dog/calculate-id-for-non-steam-games-js/ for an example
/// </summary>
/// <param name="appName">The name of the executable to be displayed</param>
/// <param name="appTarget">The executable target path</param>
/// <returns></returns>
private UInt64 GenerateSteamGridAppId(string appName, string appTarget)
{
byte[] nameTargetBytes = Encoding.UTF8.GetBytes(appTarget + appName + "");
UInt64 crc = Crc32Algorithm.Compute(nameTargetBytes);
UInt64 gameId = crc | 0x80000000;
return gameId;
}
/// <summary>
/// Task responsible for triggering the export, blocks the UI, and shows a message
/// once the task is finished, unlocking the UI
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void ExportButton_Click(object sender, RoutedEventArgs e)
{ {
bwrSave = new BackgroundWorker();
bwrSave.DoWork += BwrSave_DoWork;
bwrSave.RunWorkerCompleted += BwrSave_RunWorkerCompleted;
grid.IsEnabled = false; grid.IsEnabled = false;
progressBar.Visibility = Visibility.Visible; progressBar.Visibility = Visibility.Visible;
bool result = false, restartSteam = true; bwrSave.RunWorkerAsync();
string msg = String.Empty; }
try
{
await ExportGames();
await RestartSteam(restartSteam);
msg = "Your apps were successfuly exported!";
if (!restartSteam)
{
msg += " Please restart Steam in order to see them.";
}
else if (result)
{
msg += " Steam has been restarted.";
}
}
catch (TaskCanceledException exception)
{
Log.Error(exception.Message);
msg = exception.Message;
}
private void BwrSave_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
grid.IsEnabled = true; grid.IsEnabled = true;
progressBar.Visibility = Visibility.Collapsed; progressBar.Visibility = Visibility.Collapsed;
MessageBox.Show("Your apps were successfuly exported, please restart Steam in order to see your apps in it.", "UWPHook", MessageBoxButton.OK, MessageBoxImage.Information);
MessageBox.Show(msg, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Information);
} }
/// <summary> private void BwrSave_DoWork(object sender, DoWorkEventArgs e)
/// Downloads the given image in the url to a given path in a given format
/// </summary>
/// <param name="imageUrl">The url for the image</param>
/// <param name="destinationFilename">Path to store the image</param>
/// <param name="format"></param>
/// <returns></returns>
private async Task SaveImage(string imageUrl, string destinationFilename, ImageFormat format)
{ {
await Task.Run(() =>
{
WebClient client = new WebClient();
Stream stream = null;
try
{
stream = client.OpenRead(imageUrl);
}
catch (Exception exception)
{
Log.Error(exception.Message);
//Image with error?
//Skip for now
}
if (stream != null)
{
Bitmap bitmap; bitmap = new Bitmap(stream);
bitmap.Save(destinationFilename, format);
stream.Flush();
stream.Close();
client.Dispose();
}
});
}
/// <summary>
/// Copies all temporary images to the given user
/// </summary>
/// <param name="user">The user path to copy images to</param>
private void CopyTempGridImagesToSteamUser(string user)
{
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
string userGridDirectory = user + "\\config\\grid\\";
// No images were downloaded, maybe the key is invalid or no app had an image
if (!Directory.Exists(tmpGridDirectory))
{
return;
}
string[] images = Directory.GetFiles(tmpGridDirectory);
if (!Directory.Exists(userGridDirectory))
{
Directory.CreateDirectory(userGridDirectory);
}
foreach (string image in images)
{
string destFile = userGridDirectory + Path.GetFileName(image);
File.Copy(image, destFile, true);
}
}
private void RemoveTempGridImages()
{
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
if (Directory.Exists(tmpGridDirectory))
{
Directory.Delete(tmpGridDirectory, true);
}
}
/// <summary>
/// Task responsible for downloading grid images to a temporary location,
/// generates the steam ID for the game based in the receiving parameters,
/// Throws TaskCanceledException if cannot communicate with SteamGridDB properly
/// </summary>
/// <param name="appName">The name of the app</param>
/// <param name="appTarget">The target path of the executable</param>
/// <returns></returns>
private async Task DownloadTempGridImages(string appName, string appTarget)
{
SteamGridDbApi api = new SteamGridDbApi(Properties.Settings.Default.SteamGridDbApiKey);
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
GameResponse[] games = null;
try
{
games = await api.SearchGame(appName);
}
catch (TaskCanceledException exception)
{
Log.Error(exception.Message);
}
if (games != null)
{
var game = games[0];
Log.Verbose("Detected Game: " + game.ToString());
UInt64 gameId = GenerateSteamGridAppId(appName, appTarget);
SafellyCreateTmpGridDirectory(tmpGridDirectory);
var gameGridsVertical = api.GetGameGrids(game.Id, "600x900,342x482,660x930");
var gameGridsHorizontal = api.GetGameGrids(game.Id, "460x215,920x430");
var gameHeroes = api.GetGameHeroes(game.Id);
var gameLogos = api.GetGameLogos(game.Id);
Log.Verbose("Game ID: " + game.Id);
await Task.WhenAll(
gameGridsVertical,
gameGridsHorizontal,
gameHeroes,
gameLogos
);
var gridsVertical = await gameGridsVertical;
var gridsHorizontal = await gameGridsHorizontal;
var heroes = await gameHeroes;
var logos = await gameLogos;
List<Task> saveImagesTasks = new List<Task>();
if (gridsHorizontal != null && gridsHorizontal.Length > 0)
{
var grid = gridsHorizontal[0];
saveImagesTasks.Add(SaveImage(grid.Url, $"{tmpGridDirectory}\\{gameId}.png", ImageFormat.Png));
}
if (gridsVertical != null && gridsVertical.Length > 0)
{
var grid = gridsVertical[0];
saveImagesTasks.Add(SaveImage(grid.Url, $"{tmpGridDirectory}\\{gameId}p.png", ImageFormat.Png));
}
if (heroes != null && heroes.Length > 0)
{
var hero = heroes[0];
saveImagesTasks.Add(SaveImage(hero.Url, $"{tmpGridDirectory}\\{gameId}_hero.png", ImageFormat.Png));
}
if (logos != null && logos.Length > 0)
{
var logo = logos[0];
saveImagesTasks.Add(SaveImage(logo.Url, $"{tmpGridDirectory}\\{gameId}_logo.png", ImageFormat.Png));
}
await Task.WhenAll(saveImagesTasks);
}
}
private void SafellyCreateTmpGridDirectory(string tmpGridDirectory)
{
if (!Directory.Exists(tmpGridDirectory))
{
try
{
Directory.CreateDirectory(tmpGridDirectory);
Log.Information("Created directory: " + tmpGridDirectory);
}
catch (Exception exception)
{
Log.Error(exception.Message);
Log.Error(exception.StackTrace);
throw new Exception("UWPHook was not able to create the tmp directory for some reason." + Environment.NewLine +
"You may solve this by manually creating the following folder:" + Environment.NewLine +
tmpGridDirectory);
}
}
}
/// <summary>
/// Main Task to export the selected games to steam
/// </summary>
/// <param name="restartSteam"></param>
/// <returns></returns>
private async Task<bool> ExportGames()
{
string[] tags = Settings.Default.Tags.Split(',');
string steam_folder = SteamManager.GetSteamFolder(); string steam_folder = SteamManager.GetSteamFolder();
if (!String.IsNullOrEmpty(steam_folder))
if (Directory.Exists(steam_folder))
{ {
var users = SteamManager.GetUsers(steam_folder); var users = SteamManager.GetUsers(steam_folder);
var selected_apps = Apps.Entries.Where(app => app.Selected); var selected_apps = Apps.Entries.Where(app => app.Selected);
var exePath = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @"""";
var exeDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
List<Task> gridImagesDownloadTasks = new List<Task>();
bool downloadGridImages = !String.IsNullOrEmpty(Properties.Settings.Default.SteamGridDbApiKey);
//To make things faster, decide icons and download grid images before looping users
Log.Verbose("downloadGridImages: " + (downloadGridImages));
//To make things faster, decide icons before looping users
foreach (var app in selected_apps) foreach (var app in selected_apps)
{ {
app.Icon = app.widestSquareIcon(); app.Icon = app.widestSquareIcon();
if (downloadGridImages)
{
Log.Verbose("Downloading grid images for app " + app.Name);
gridImagesDownloadTasks.Add(DownloadTempGridImages(app.Name, exePath));
}
} }
await Task.WhenAll(gridImagesDownloadTasks);
// Export the selected apps and the downloaded images to each user
// in the steam folder by modifying it's VDF file
foreach (var user in users) foreach (var user in users)
{ {
try try
@ -423,8 +139,7 @@ private async Task<bool> ExportGames()
//If it's a short VDF, let's just overwrite it //If it's a short VDF, let's just overwrite it
if (ex.GetType() != typeof(VDFTooShortException)) if (ex.GetType() != typeof(VDFTooShortException))
{ {
Log.Error("Error: Program failed to load existing Steam shortcuts." + Environment.NewLine + ex.Message); throw new Exception("Error trying to load existing Steam shortcuts." + Environment.NewLine + ex.Message);
throw new Exception("Error: Program failed to load existing Steam shortcuts." + Environment.NewLine + ex.Message);
} }
} }
@ -432,272 +147,44 @@ private async Task<bool> ExportGames()
{ {
foreach (var app in selected_apps) foreach (var app in selected_apps)
{ {
try
{
app.Icon = PersistAppIcon(app);
Log.Verbose("Defaulting to app.Icon for app " + app.Name);
}
catch (System.IO.IOException)
{
Log.Verbose("Using backup icon for app " + app.Name);
await Task.Run(() =>
{
string tmpGridDirectory = Path.GetTempPath() + "UWPHook\\tmp_grid\\";
SafellyCreateTmpGridDirectory(tmpGridDirectory);
string[] images = Directory.GetFiles(tmpGridDirectory);
UInt64 gameId = GenerateSteamGridAppId(app.Name, exePath);
app.Icon = PersistAppIcon(app, tmpGridDirectory + gameId + "_logo.png");
});
}
VDFEntry newApp = new VDFEntry() VDFEntry newApp = new VDFEntry()
{ {
appid = ((int)GenerateSteamGridAppId(app.Name, exePath)),
AppName = app.Name, AppName = app.Name,
Exe = exePath, Exe = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @""" " + app.Aumid,
StartDir = exeDir, StartDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
LaunchOptions = app.Aumid + " " + app.Executable,
AllowDesktopConfig = 1, AllowDesktopConfig = 1,
AllowOverlay = 1,
Icon = app.Icon, Icon = app.Icon,
Index = shortcuts.Length, Index = shortcuts.Length,
IsHidden = 0, IsHidden = 0,
OpenVR = 0, OpenVR = 0,
ShortcutPath = "", ShortcutPath = "",
Tags = tags, Tags = new string[0]
Devkit = 0,
DevkitGameID = "",
LastPlayTime = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
}; };
Boolean shortcutAlreadyExists = false;
for (int i = 0; i < shortcuts.Length; i++)
{
Log.Verbose(shortcuts[i].ToString());
if (shortcuts[i].AppName == app.Name && shortcuts[i].Exe == exePath) //Resize this array so it fits the new entries
{ Array.Resize(ref shortcuts, shortcuts.Length + 1);
shortcutAlreadyExists = true; shortcuts[shortcuts.Length - 1] = newApp;
Log.Verbose(app.Name + " already added to Steam. Updating existing shortcut.");
shortcuts[i] = newApp;
}
}
if (!shortcutAlreadyExists)
{
//Resize this array so it fits the new entries
Array.Resize(ref shortcuts, shortcuts.Length + 1);
shortcuts[shortcuts.Length - 1] = newApp;
}
} }
try try
{ {
if (!Directory.Exists(user + @"\\config\\"))
{
Directory.CreateDirectory(user + @"\\config\\");
}
BackupShortcutsVDF(user, @"\\config\\shortcuts.vdf");
//Write the file with all the shortcuts //Write the file with all the shortcuts
File.WriteAllBytes(user + @"\\config\\shortcuts.vdf", VDFSerializer.Serialize(shortcuts)); File.WriteAllBytes(user + @"\\config\\shortcuts.vdf", VDFSerializer.Serialize(shortcuts));
Log.Debug("Shortcuts written to " + user + @"\\config\\shortcuts.vdf");
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.InnerException + ex.StackTrace); throw new Exception("Error while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
throw new Exception("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error("Error: Program failed exporting your games:" + Environment.NewLine + ex.Message + ex.StackTrace); MessageBox.Show("Error exporting your games:" + Environment.NewLine + ex.Message + ex.StackTrace);
MessageBox.Show("Error: Program failed exporting your games:" + Environment.NewLine + ex.Message + ex.StackTrace);
} }
} }
if (gridImagesDownloadTasks.Count > 0)
{
await Task.WhenAll(gridImagesDownloadTasks);
await Task.Run(() =>
{
foreach (var user in users)
{
CopyTempGridImagesToSteamUser(user);
}
RemoveTempGridImages();
});
}
}
return true;
}
private void BackupShortcutsVDF(string userPath, string vdfSubPath)
{
string backupFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Briano", "UWPHook", "backups");
if (!Directory.Exists(backupFolder))
{
Directory.CreateDirectory(backupFolder);
Log.Debug("Created backup folder: " + backupFolder);
}
string user_id = userPath.Split('\\').Last();
string sourceFilePath = Path.Combine(userPath, "config", "shortcuts.vdf");
string destinationFileName = Path.Combine(backupFolder, $"{user_id}_{DateTime.Now.ToString("yyyyMMddHHmmss")}_shortcuts.vdf");
File.Copy(sourceFilePath, destinationFileName);
Log.Debug("Backup created: " + destinationFileName);
}
/// <summary>
/// Copies an apps icon to a intermediate location
/// Due to some apps changing the icon location when they update, which causes icons to be "lost"
/// </summary>
/// <param name="app">App to copy the icon to</param>
/// <param name="forcedIcon">Overwrites the app.icon to be copied</param>
/// <returns>string, the path to the usable and persisted icon</returns>
private string PersistAppIcon(AppEntry app, string forcedIcon = "")
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string icons_path = path + @"\Briano\UWPHook\icons\";
// If we do not have an specific icon to copy, copy app.icon, if we do, copy the specified icon
string icon_to_copy = String.IsNullOrEmpty(forcedIcon) ? app.Icon : forcedIcon;
if (!Directory.Exists(icons_path))
{
Directory.CreateDirectory(icons_path);
}
string dest_file = String.Join(String.Empty, icons_path, app.Aumid + Path.GetFileName(icon_to_copy));
try
{
if (File.Exists(icon_to_copy))
{
File.Copy(icon_to_copy, dest_file, true);
}
else
{
dest_file = app.Icon;
}
}
catch (System.IO.IOException e)
{
Log.Warning(e, "Could not copy icon " + app.Icon);
throw e;
}
return dest_file;
}
/// <summary>
/// Restarts the Steam.exe process
/// </summary>
/// <param name="restartSteam"></param>
/// <returns></returns>
private async Task<bool> RestartSteam(bool restartSteam)
{
Func<Process> getSteam = () => Process.GetProcessesByName("steam").SingleOrDefault();
Process steam = getSteam();
if (steam != null)
{
string steamExe = steam.MainModule.FileName;
//we always ask politely
Log.Debug("Requesting Steam shutdown");
Process.Start(steamExe, "-exitsteam");
bool restarted = false;
Stopwatch watch = new Stopwatch();
watch.Start();
//give it N seconds to sort itself out
int waitSeconds = 8;
while (!restarted || watch.Elapsed.TotalSeconds < waitSeconds)
{
await Task.Delay(TimeSpan.FromSeconds(0.5f));
if (getSteam() == null)
{
Log.Debug("Restarting Steam");
Process.Start(steamExe);
restarted = true;
break;
}
}
if (!restarted)
{
Log.Debug("Steam instance not restarted");
MessageBox.Show("Failed to restart Steam, please launch it manually", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
}
else
{
Log.Debug("Steam instance not found to be restarted");
}
return true;
}
public static void ClearAllShortcuts()
{
Log.Debug("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)
{
Log.Error("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
throw new Exception("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
}
}
catch (Exception ex)
{
Log.Error("Error: Program failed while trying to clear your Steam shortcuts:" + Environment.NewLine + ex.Message + ex.StackTrace);
MessageBox.Show("Error: Program failed while trying to clear your Steam shortcuts:" + Environment.NewLine + ex.Message + ex.StackTrace);
}
}
MessageBox.Show("All non-Steam shortcuts has been cleared.");
} }
} }
/// <summary>
/// Fires the Bwr_DoWork, to load the apps installed at the machine
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LoadButton_Click(object sender, RoutedEventArgs e) private void LoadButton_Click(object sender, RoutedEventArgs e)
{ {
bwrLoad = new BackgroundWorker(); bwrLoad = new BackgroundWorker();
@ -705,19 +192,12 @@ private void LoadButton_Click(object sender, RoutedEventArgs e)
bwrLoad.RunWorkerCompleted += Bwr_RunWorkerCompleted; bwrLoad.RunWorkerCompleted += Bwr_RunWorkerCompleted;
grid.IsEnabled = false; grid.IsEnabled = false;
label.Content = "Loading your installed apps";
progressBar.Visibility = Visibility.Visible; progressBar.Visibility = Visibility.Visible;
Apps.Entries = new System.Collections.ObjectModel.ObservableCollection<AppEntry>(); Apps.Entries = new System.Collections.ObjectModel.ObservableCollection<AppEntry>();
bwrLoad.RunWorkerAsync(); bwrLoad.RunWorkerAsync();
} }
/// <summary>
/// Callback for restoring the grid list interactivity
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Bwr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) private void Bwr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{ {
listGames.ItemsSource = Apps.Entries; listGames.ItemsSource = Apps.Entries;
@ -730,11 +210,6 @@ private void Bwr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e
label.Content = "Installed Apps"; label.Content = "Installed Apps";
} }
/// <summary>
/// Worker responsible for loading the apps installed in the machine
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Bwr_DoWork(object sender, DoWorkEventArgs e) private void Bwr_DoWork(object sender, DoWorkEventArgs e)
{ {
try try
@ -758,27 +233,20 @@ private void Bwr_DoWork(object sender, DoWorkEventArgs e)
{ {
//Remove end lines from the String and split both values, I split the appname and the AUMID using | //Remove end lines from the String and split both values, I split the appname and the AUMID using |
//I hope no apps have that in their name. Ever. //I hope no apps have that in their name. Ever.
var values = app.Replace("\r\n", "").Split('|'); var valor = app.Replace("\r\n", "").Split('|');
if (!String.IsNullOrWhiteSpace(valor[0]))
if (values.Length >= 3 && AppManager.IsKnownApp(values[2], out string readableName))
{
values[0] = readableName;
}
if (!String.IsNullOrWhiteSpace(values[0]))
{ {
//We get the default square tile to find where the app stores it's icons, then we resolve which one is the widest //We get the default square tile to find where the app stores it's icons, then we resolve which one is the widest
string logosPath = Path.GetDirectoryName(values[1]); string logosPath = Path.GetDirectoryName(valor[1]);
Application.Current.Dispatcher.BeginInvoke((Action)delegate () Application.Current.Dispatcher.BeginInvoke((Action)delegate ()
{ {
Apps.Entries.Add(new AppEntry() { Name = values[0], Executable = values[3], IconPath = logosPath, Aumid = values[2], Selected = false }); Apps.Entries.Add(new AppEntry() { Name = valor[0], IconPath = logosPath, Aumid = valor[2], Selected = false });
}); });
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.Message);
MessageBox.Show(ex.Message, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show(ex.Message, "UWPHook", MessageBoxButton.OK, MessageBoxImage.Error);
} }
} }
@ -801,55 +269,14 @@ private void textBox_TextChanged(object sender, System.Windows.Controls.TextChan
public bool Contains(object o) public bool Contains(object o)
{ {
AppEntry appEntry = o as AppEntry; AppEntry appEntry = o as AppEntry;
return (appEntry.Aumid.ToLower().Contains(textBox.Text.ToLower()) || appEntry.Name.ToLower().Contains(textBox.Text.ToLower())); //Return members whose Orders have not been filled
return (appEntry.Aumid.ToLower().Contains(textBox.Text.ToLower()));
} }
private void SettingsButton_Click(object sender, RoutedEventArgs e) private void HelpButton_Click(object sender, RoutedEventArgs e)
{ {
SettingsWindow window = new SettingsWindow(); SettingsWindow window = new SettingsWindow();
window.ShowDialog(); window.ShowDialog();
} }
/// <summary>
/// Function that executes when the Games Window is loaded
/// Will inform the user of the possibility of using the SteamGridDB API
/// redirecting him to the settings page if he wishes to use the functionality
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
if (!Settings.Default.OfferedSteamGridDB)
{
Settings.Default.SteamGridDbApiKey = "";
Settings.Default.OfferedSteamGridDB = true;
Settings.Default.Save();
var boxResult = MessageBox.Show("Do you want to automatically import grid images for imported games?", "UWPHook", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (boxResult == MessageBoxResult.Yes)
{
SettingsButton_Click(this, null);
}
}
}
public static void SetLogLevel()
{
switch (Settings.Default.SelectedLogLevel)
{
case 1:
Log.Information("Init log with DEBUG level.");
levelSwitch.MinimumLevel = Serilog.Events.LogEventLevel.Debug;
break;
case 2:
Log.Information("Init log with TRACE level.");
levelSwitch.MinimumLevel = Serilog.Events.LogEventLevel.Verbose;
break;
default:
Log.Information("Init log with ERROR level.");
levelSwitch.MinimumLevel = Serilog.Events.LogEventLevel.Error;
break;
}
}
} }
} }

View File

@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Briano")] [assembly: AssemblyCompany("Briano")]
[assembly: AssemblyProduct("UWPHook")] [assembly: AssemblyProduct("UWPHook")]
[assembly: AssemblyCopyright("Copyright Brian Lima © 2020 2021 2022")] [assembly: AssemblyCopyright("Copyright Brian Lima © 2016")]
[assembly: AssemblyTrademark("Briano")] [assembly: AssemblyTrademark("Briano")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -51,6 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.14.0.0")] [assembly: AssemblyVersion("2.3.0.0")]
[assembly: AssemblyFileVersion("2.14.0.0")] [assembly: AssemblyFileVersion("2.3.0.0")]
[assembly: NeutralResourcesLanguage("en")]

View File

@ -19,7 +19,7 @@ namespace UWPHook.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources { public class Resources {
@ -61,12 +61,22 @@ internal Resources() {
} }
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Byte[]. /// Looks up a localized string similar to $installedapps = get-AppxPackage
///
///$aumidList = @()
///foreach ($app in $installedapps)
///{
///    foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id)
///    {
///        $aumidList += $app.name + &quot;|&quot; + $app.packagefamilyname + &quot;!&quot; + $id + &quot;;&quot;
///    }
///}
///
///$aumidList.
/// </summary> /// </summary>
public static byte[] GetAUMIDScript { public static string GetAUMIDScript {
get { get {
object obj = ResourceManager.GetObject("GetAUMIDScript", resourceCulture); return ResourceManager.GetString("GetAUMIDScript", resourceCulture);
return ((byte[])(obj));
} }
} }
} }

View File

@ -119,6 +119,6 @@
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="GetAUMIDScript" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="GetAUMIDScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GetAUMIDScript.ps1;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>..\Resources\GetAUMIDScript.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data> </data>
</root> </root>

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Ce code a été généré par un outil. // This code was generated by a tool.
// Version du runtime :4.0.30319.42000 // Runtime Version:4.0.30319.42000
// //
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si // Changes to this file may cause incorrect behavior and will be lost if
// le code est régénéré. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -12,7 +12,7 @@ namespace UWPHook.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -70,181 +70,5 @@ public bool StreamMode {
this["StreamMode"] = value; this["StreamMode"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string SteamGridDbApiKey {
get {
return ((string)(this["SteamGridDbApiKey"]));
}
set {
this["SteamGridDbApiKey"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int SelectedSteamGridDB_Style {
get {
return ((int)(this["SelectedSteamGridDB_Style"]));
}
set {
this["SelectedSteamGridDB_Style"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int SelectedSteamGridDB_Type {
get {
return ((int)(this["SelectedSteamGridDB_Type"]));
}
set {
this["SelectedSteamGridDB_Type"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int SelectedSteamGridDB_nfsw {
get {
return ((int)(this["SelectedSteamGridDB_nfsw"]));
}
set {
this["SelectedSteamGridDB_nfsw"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int SelectedSteamGridDB_Humor {
get {
return ((int)(this["SelectedSteamGridDB_Humor"]));
}
set {
this["SelectedSteamGridDB_Humor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool OfferedSteamGridDB {
get {
return ((bool)(this["OfferedSteamGridDB"]));
}
set {
this["OfferedSteamGridDB"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("READY TO PLAY,XBOX")]
public string Tags {
get {
return ((string)(this["Tags"]));
}
set {
this["Tags"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(@"<?xml version=""1.0"" encoding=""utf-16""?>
<ArrayOfString xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
<string>any</string>
<string>alternate</string>
<string>blurred</string>
<string>white_logo</string>
<string>material</string>
<string>no_logo </string>
</ArrayOfString>")]
public global::System.Collections.Specialized.StringCollection SteamGridDB_Style {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["SteamGridDB_Style"]));
}
set {
this["SteamGridDB_Style"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <s" +
"tring>any</string>\r\n <string>static</string>\r\n <string>animated</string>\r\n</Ar" +
"rayOfString>")]
public global::System.Collections.Specialized.StringCollection SteamGridDB_Type {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["SteamGridDB_Type"]));
}
set {
this["SteamGridDB_Type"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <s" +
"tring>false</string>\r\n <string>any</string>\r\n <string>true</string>\r\n</ArrayOf" +
"String>")]
public global::System.Collections.Specialized.StringCollection SteamGridDB_nfsw {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["SteamGridDB_nfsw"]));
}
set {
this["SteamGridDB_nfsw"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <s" +
"tring>false</string>\r\n <string>any</string>\r\n <string>true</string>\r\n</ArrayOf" +
"String>")]
public global::System.Collections.Specialized.StringCollection SteamGridDB_Humor {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["SteamGridDB_Humor"]));
}
set {
this["SteamGridDB_Humor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <s" +
"tring>ERROR</string>\r\n <string>DEBUG</string>\r\n <string>TRACE</string>\r\n</Arra" +
"yOfString>")]
public global::System.Collections.Specialized.StringCollection LogLevel {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["LogLevel"]));
}
set {
this["LogLevel"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int SelectedLogLevel {
get {
return ((int)(this["SelectedLogLevel"]));
}
set {
this["SelectedLogLevel"] = value;
}
}
} }
} }

View File

@ -14,72 +14,5 @@
<Setting Name="StreamMode" Type="System.Boolean" Scope="User"> <Setting Name="StreamMode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="SteamGridDbApiKey" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SelectedSteamGridDB_Style" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="SelectedSteamGridDB_Type" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="SelectedSteamGridDB_nfsw" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="SelectedSteamGridDB_Humor" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="OfferedSteamGridDB" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="Tags" Type="System.String" Scope="User">
<Value Profile="(Default)">READY TO PLAY,XBOX</Value>
</Setting>
<Setting Name="SteamGridDB_Style" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;string&gt;any&lt;/string&gt;
&lt;string&gt;alternate&lt;/string&gt;
&lt;string&gt;blurred&lt;/string&gt;
&lt;string&gt;white_logo&lt;/string&gt;
&lt;string&gt;material&lt;/string&gt;
&lt;string&gt;no_logo &lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="SteamGridDB_Type" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;string&gt;any&lt;/string&gt;
&lt;string&gt;static&lt;/string&gt;
&lt;string&gt;animated&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="SteamGridDB_nfsw" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;string&gt;false&lt;/string&gt;
&lt;string&gt;any&lt;/string&gt;
&lt;string&gt;true&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="SteamGridDB_Humor" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;string&gt;false&lt;/string&gt;
&lt;string&gt;any&lt;/string&gt;
&lt;string&gt;true&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="LogLevel" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;string&gt;ERROR&lt;/string&gt;
&lt;string&gt;DEBUG&lt;/string&gt;
&lt;string&gt;TRACE&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="SelectedLogLevel" Type="System.String" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -1,63 +0,0 @@
$installedapps = get-AppxPackage
$invalidNames = '*ms-resource*', '*DisplayName*'
$aumidList = @()
foreach ($app in $installedapps)
{
try {
if(-not $app.IsFramework){
foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id)
{
$appx = Get-AppxPackageManifest $app;
$name = $appx.Package.Properties.DisplayName;
$executable = $appx.Package.Applications.Application.Executable;
# Handle app running with microsoft launcher or which doesn't have an executable in the manifest
if([string]::IsNullOrWhitespace($executable) -or $executable -eq "GameLaunchHelper.exe") {
if(Test-Path -Path ($app.InstallLocation + "\MicrosoftGame.Config")) {
[xml]$msconfig = Get-Content ($app.InstallLocation + "\MicrosoftGame.Config");
$executable = $msconfig.Game.ExecutableList.Executable.Name;
}
else {
# Cannot handle app which doesn't have any configuration to read
continue;
}
}
# Convert object to ensure is the String of execuble (cf Halo Master Chief Collection example below)
# mcclauncher.exe
# MCC\Binaries\Win64\MCCWinStore-Win64-Shipping.exe
if($executable -is [Object[]]) { $executable = $executable[1].ToString() }
# Exclude apps without a name acceptable
if($name -like '*DisplayName*' -or $name -like '*ms-resource*')
{
continue;
}
$logo = $app.InstallLocation + "\" + $appx.Package.Applications.Application.VisualElements.Square150x150Logo;
# Check for possible duplicate game like Halo MCC which have two version (one with AC and one witohut AC)
$duplicate = $false;
foreach($item in $aumidList) {
#Write-host $item - $name
if($item.StartsWith($name)) {
$duplicate = $true;
break;
}
}
# Insert if not duplicated
if(!$duplicate) {
$aumidList += $name + "|" + $logo + "|" + $app.packagefamilyname + "!" + $id + "|" + $executable + ";"
}
}
}
}
catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
}
}
$aumidList;

View File

@ -0,0 +1,37 @@
$installedapps = get-AppxPackage
$invalidNames = '*ms-resource*', '*DisplayName*'
$aumidList = @()
foreach ($app in $installedapps)
{
try {
if(-not $app.IsFramework){
foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id)
{
$appx = Get-AppxPackageManifest $app;
$name = $appx.Package.Properties.DisplayName;
if($name -like '*DisplayName*' -or $name -like '*ms-resource*')
{
$name = $appx.Package.Applications.Application.VisualElements.DisplayName;
}
if($name -like '*DisplayName*' -or $name -like '*ms-resource*')
{
$name = "App name not found, double click here to edit it";
}
$logo = $app.InstallLocation + "\" + $appx.Package.Applications.Application.VisualElements.Square150x150Logo;
$aumidList += $name + "|" + $logo + "|" +
$app.packagefamilyname + "!" + $id+ ";"
}
}
}
catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
}
}
$aumidList;

View File

@ -1,7 +0,0 @@
{
"Microsoft.SeaofThieves": "Sea of Thieves",
"Microsoft.DeltaPC": "Gears of War: Ultimate Edition",
"MotionTwin.DeadCellsWin10": "Dead Cells",
"SystemEraSoftworks.29415440E1269": "ASTRONEER",
"NAMCOBANDAIGamesInc.TTablet": "Taiko no Tatsujin: The Drum Master!"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 KiB

View File

@ -11,154 +11,87 @@
TextElement.FontWeight="Medium" TextElement.FontWeight="Medium"
TextElement.FontSize="14" TextElement.FontSize="14"
FontFamily="Segoe UI Light" FontFamily="Segoe UI Light"
Title="Settings" Height="750" Width="800" Icon="Resources/hook2.ico"> Title="Settings" Height="600" Width="800" Icon="Resources/hook2.ico">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="27*"/> <ColumnDefinition Width="27*"/>
<ColumnDefinition Width="17*"/> <ColumnDefinition Width="17*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="80"/> <RowDefinition Height="83*"/>
<RowDefinition Height="179*"/> <RowDefinition Height="490*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<materialDesign:ColorZone Padding="16" Mode="PrimaryMid" VerticalAlignment="Top" Height="80" Grid.ColumnSpan="2" Margin="0,0,-0.4,0"/> <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="80" Grid.ColumnSpan="2"/>
<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!"/> <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,10,10,10" Grid.RowSpan="1" Grid.Row="1"> <Grid Margin="10" Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"/> <RowDefinition Height="93*"/>
<RowDefinition Height="44*"/> <RowDefinition Height="49*"/>
<RowDefinition Height="44*"/> <RowDefinition Height="325*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="30"/>
<RowDefinition Height="40*"/>
<RowDefinition Height="40*"/>
<RowDefinition Height="40*"/>
<RowDefinition Height="40*"/>
<RowDefinition Height="40*"/>
<RowDefinition Height="80"/>
<RowDefinition Height="50*"/>
<RowDefinition Height="50*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="62*"/> <ColumnDefinition Width="52*"/>
<ColumnDefinition Width="167*"/> <ColumnDefinition Width="177*"/>
<ColumnDefinition Width="124*"/> <ColumnDefinition Width="124*"/>
<ColumnDefinition Width="113*"/> <ColumnDefinition Width="113*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Settings Section --> <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="27" Grid.ColumnSpan="4">
<materialDesign:ColorZone Padding="16" Mode="PrimaryMid" VerticalAlignment="Top" Height="30" Grid.ColumnSpan="4" Grid.Row="0">
<Label Content="Settings" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/> <Label Content="Settings" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone> </materialDesign:ColorZone>
<ToggleButton x:Name="language_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" RenderTransformOrigin="0.304,0.444" Grid.Row="1" Margin="5,3,6,4" /> <ToggleButton x:Name="language_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="4,56,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" />
<Label ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="label_cultures" Content="Set system language when launching an app*" VerticalAlignment="Center" Height="29" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"/> <Label ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="label1" Content="Set system language when launching an app*" Margin="5,48,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2"/>
<ComboBox ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="cultures_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="3" HorizontalAlignment="Right" Width="92" Grid.Row="1"/> <ComboBox ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="cultures_comboBox" Margin="0,48,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93"/>
<Label x:Name="label_seconds" ToolTip="If 0, UWPHook will not run in the background and will not update the in-game status" Content="Check if the launched app is running every" VerticalAlignment="Center" Height="29" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2"/> <Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" Margin="0,42,10,0" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="3" Grid.Row="2"/>
<ComboBox x:Name="seconds_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="3" HorizontalAlignment="Right" Width="92" Grid.Row="2"/> <Label x:Name="label3" Content="Check if the launched app is running every" Margin="5,0,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"/>
<ToggleButton x:Name="streaming_toggle" Style="{DynamicResource MaterialDesignSwitchToggleButton}" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Grid.Row="3" Margin="6,3,5,4" /> <ComboBox x:Name="seconds_comboBox" Margin="0,10,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93" Grid.Row="1"/>
<Label ToolTip="This fixes Steam in-home Streaming, set this in the host computer." x:Name="label_streaming" Content="Enable streaming mode" VerticalAlignment="Center" Height="29" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3"/> <Button x:Name="update_button" Click="update_button_Click" Content="Check for updates" Grid.Column="1" Margin="0,0,5,10" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="162"/>
<ToggleButton x:Name="change_resolution_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Change host resolution on streaming mode" IsChecked="False" Grid.Row="4" Width="NaN" Margin="5,3,6,3" /> <Button x:Name="help_button" Click="help_button_Click" Content="Get help at our Reddit" Grid.Column="2" Margin="8,0,0,10" Grid.Row="2" VerticalAlignment="Bottom" Grid.ColumnSpan="2" HorizontalAlignment="Left" Width="163"/>
<Label ToolTip="Change the host computer resolution on launch, return to previous after." x:Name="label_resolution" Content="Change host resolution to:" VerticalAlignment="Center" Height="29" Grid.Column="1" Grid.Row="4"/> <ToggleButton x:Name="streaming_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="0,17,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" Grid.Row="2" />
<ComboBox x:Name="resolution_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="2" Width="220" Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Right"/> <Label ToolTip="This fixes Steam in-home Streaming, set this in the host computer." x:Name="label1_Copy" Content="Enable streaming mode" Margin="5,10,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2"/>
<Label ToolTip="Add these tags to exported games, use comma separated values" x:Name="label_tags" Content="Export with these tags:" Margin="0,0,8,0" VerticalAlignment="Center" Height="29" Grid.Column="1" Grid.Row="5"/>
<TextBox x:Name="tags_textBox" Grid.Column="2" Height="32" Margin="0,0,10,0" Grid.Row="5" TextWrapping="Wrap" VerticalAlignment="Center" Grid.ColumnSpan="2" Width="220" HorizontalAlignment="Right"/>
<Label x:Name="label_logLevel" Content="Define log severity level" VerticalAlignment="Center" Height="29" Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="2"/>
<ComboBox x:Name="logLevel_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="3" Width="92" Grid.Row="6" SelectedIndex="0" HorizontalAlignment="Right" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Padding="10,0,0,0">
<ComboBoxItem Content="ERROR"/>
<ComboBoxItem Content="DEBUG"/>
<ComboBoxItem Content="TRACE"/>
</ComboBox>
<!-- SteamGrid Section -->
<materialDesign:ColorZone Padding="16" Mode="PrimaryMid" VerticalAlignment="Top" Height="30" Grid.ColumnSpan="4" Grid.Row="7">
<Label Content="SteamGrid" HorizontalAlignment="Left" Margin="-10,-15,0,-17" FontFamily="Segoe UI Semibold" FontSize="14" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone>
<Button x:Name="key_Button" Content="{materialDesign:PackIcon Key}" ToolTip="Go to SteamGridDB.com to generate a new key" Grid.Row="8" Height="Auto" Click="key_Button_Click" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Label ToolTip="SteamGridDB API key used to download Steam's library artwork. Leave it blank if you don't want to download artwork." x:Name="label_apiKey" Content="Api Key" VerticalAlignment="Center" Height="29" Grid.Row="8" Grid.Column="1"/>
<TextBox x:Name="steamgriddb_api_key" Grid.Column="2" Height="32" Grid.Row="8" TextWrapping="Wrap" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="0,0,10,0" Width="220" HorizontalAlignment="Right"/>
<Label ToolTip="The main style of the artwork." x:Name="label_artworkStyle" Content="Artwork Style" VerticalAlignment="Center" Height="29" Grid.Row="9" Grid.Column="1"/>
<ComboBox x:Name="style_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="2" Width="220" Grid.Row="9" Grid.ColumnSpan="2" HorizontalAlignment="Right">
<ComboBoxItem Content="Any"/>
<ComboBoxItem Content="Alternate"/>
<ComboBoxItem Content="Blurred"/>
<ComboBoxItem Content="White Logo"/>
<ComboBoxItem Content="Material"/>
<ComboBoxItem Content="No Logo"/>
</ComboBox>
<Label ToolTip="Type of the artwork, animated, static or both." x:Name="label_artworkType" Content="Artwork Type" VerticalAlignment="Center" Height="29" Grid.Row="10" Grid.Column="1"/>
<ComboBox x:Name="type_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="2" Width="220" Grid.Row="10" Grid.ColumnSpan="2" HorizontalAlignment="Right">
<ComboBoxItem Content="Any"/>
<ComboBoxItem Content="Static"/>
<ComboBoxItem Content="Animated"/>
</ComboBox>
<Label ToolTip="Consider NSFW artwork?" x:Name="label_artworkNSFW" Content="Artwork nsfw" VerticalAlignment="Center" Height="29" Grid.Row="11" Grid.Column="1"/>
<ComboBox x:Name="nfsw_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="2" Width="220" Grid.Row="11" Grid.ColumnSpan="2" HorizontalAlignment="Right">
<ComboBoxItem Content="No"/>
<ComboBoxItem Content="Any"/>
<ComboBoxItem Content="Yes"/>
</ComboBox>
<Label ToolTip="Consider meme and humorous artwork?" x:Name="label_artworkHumor" Content="Artwork humorous" VerticalAlignment="Center" Height="29" Grid.Row="12" Grid.Column="1"/>
<ComboBox x:Name="humor_comboBox" Margin="0,0,10,0" VerticalAlignment="Center" Height="32" Grid.Column="2" Width="220" Grid.Row="12" Grid.ColumnSpan="2" HorizontalAlignment="Right">
<ComboBoxItem Content="No"/>
<ComboBoxItem Content="Any"/>
<ComboBoxItem Content="Yes"/>
</ComboBox>
<!-- Bottom Section -->
<Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="3" Grid.Row="13" Grid.ColumnSpan="1" Height="32" Margin="0,5,10,0"/>
<Button x:Name="update_button" Click="update_button_Click" Content="Check for updates" Margin="0,0,10,0" Grid.Row="14" VerticalAlignment="Center" HorizontalAlignment="Right" Width="165" Grid.ColumnSpan="2" Grid.Column="0" Height="32"/>
<Button x:Name="help_button" Click="help_button_Click" Content="Get help at our Reddit" Grid.Column="2" Grid.Row="14" VerticalAlignment="Center" Grid.ColumnSpan="2" HorizontalAlignment="Left" Width="165" Height="32" Margin="10,0,0,0"/>
<Button x:Name="clearAll_button" Click="clearAll_button_Click" Content="Debug: Clear shortcuts.vdf" Grid.Row="18" VerticalAlignment="Center" HorizontalAlignment="Center" Width="200" Grid.Column="1" Grid.ColumnSpan="2" Height="32"/>
</Grid> </Grid>
<!-- Sidebar --> <Grid Margin="10,10,10,0" Grid.Column="1" Grid.Row="1">
<Grid Margin="10,10,10,10" Grid.Column="1" Grid.RowSpan="1" Grid.Row="1">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="290*"/> <ColumnDefinition Width="63*"/>
<ColumnDefinition Width="164*"/>
<ColumnDefinition Width="59*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"/> <RowDefinition Height="278*"/>
<RowDefinition Height="150"/> <RowDefinition Height="47*"/>
<RowDefinition Height="80"/> <RowDefinition Height="49*"/>
<RowDefinition Height="40"/> <RowDefinition Height="47*"/>
<RowDefinition Height="40"/> <RowDefinition Height="59*"/>
<RowDefinition Height="40"/>
<RowDefinition Height="60*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<materialDesign:ColorZone Padding="16" Mode="PrimaryMid" VerticalAlignment="Top" Height="30" Grid.ColumnSpan="3">
<Label Content="About" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone>
<Image x:Name="image2" Height="150" VerticalAlignment="Center" Source="Resources/briano.png" Stretch="UniformToFill" HorizontalAlignment="Center" Width="150" Grid.Column="0" Grid.Row="1"/>
<TextBlock TextWrapping="WrapWithOverflow" x:Name="textBlock" Text="Developed by Brian Lima, @brianostorm, if you like my work cheer me up at my Twitter or pay me a coffee via Paypal, this way i can keep building amazing open-source tools for you!" TextAlignment="Justify" VerticalAlignment="Center" Grid.ColumnSpan="1" Grid.RowSpan="1" Grid.Row="2" HorizontalAlignment="Center"/>
<materialDesign:Chip Content="Projects @ GitHub" <materialDesign:Chip Content="Projects @ GitHub"
IconBackground="{DynamicResource PrimaryHueDarkBrush}" IconBackground="{DynamicResource PrimaryHueDarkBrush}"
IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}" IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Margin="0,0,0,0" Click="Chip1_Click" HorizontalAlignment="Center" Height="32" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Width="160"> Margin="8,3,0,4" Click="Chip1_Click" HorizontalAlignment="Stretch" Height="Auto" Grid.Row="1" Grid.Column="1">
<materialDesign:Chip.Icon> <materialDesign:Chip.Icon>
<materialDesign:PackIcon Kind="Github" Foreground="{DynamicResource MaterialDesign.Brush.Primary.Dark}"/> <materialDesign:PackIcon Kind="GithubCircle"></materialDesign:PackIcon>
</materialDesign:Chip.Icon> </materialDesign:Chip.Icon>
</materialDesign:Chip> </materialDesign:Chip>
<materialDesign:Chip Content="Paypal donate" <materialDesign:Chip Content="Paypal donate"
IconBackground="{DynamicResource PrimaryHueDarkBrush}" IconBackground="{DynamicResource PrimaryHueDarkBrush}"
IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}" IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Margin="0,0,0,0" Click="Chip2_Click" HorizontalAlignment="Center" Height="32" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Width="160"> Margin="8,4,0,5" Click="Chip2_Click" HorizontalAlignment="Stretch" Height="Auto" Grid.Row="2" Grid.Column="1">
<materialDesign:Chip.Icon> <materialDesign:Chip.Icon>
<materialDesign:PackIcon Kind="Coffee" Foreground="{DynamicResource MaterialDesign.Brush.Primary.Dark}"></materialDesign:PackIcon> <materialDesign:PackIcon Kind="Coffee"></materialDesign:PackIcon>
</materialDesign:Chip.Icon> </materialDesign:Chip.Icon>
</materialDesign:Chip> </materialDesign:Chip>
<materialDesign:Chip Content="@brianostorm" <materialDesign:Chip Content="@brianostorm"
IconBackground="{DynamicResource PrimaryHueDarkBrush}" IconBackground="{DynamicResource PrimaryHueDarkBrush}"
IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}" IconForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Margin="0,0,0,0" Click="Chip_Click" HorizontalAlignment="Center" Height="32" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" Width="160"> Margin="8,4,0,3" Click="Chip_Click" HorizontalAlignment="Stretch" Height="Auto" Grid.Row="3" Grid.Column="1">
<materialDesign:Chip.Icon> <materialDesign:Chip.Icon>
<materialDesign:PackIcon Kind="Twitter" Foreground="{DynamicResource MaterialDesign.Brush.Primary.Dark}" /> <materialDesign:PackIcon Kind="Twitter" />
</materialDesign:Chip.Icon> </materialDesign:Chip.Icon>
</materialDesign:Chip> </materialDesign:Chip>
<TextBlock TextWrapping="WrapWithOverflow" x:Name="textBlock_Copy" Height="59" TextAlignment="Justify" Grid.Row="6" Grid.ColumnSpan="1" VerticalAlignment="Top" Margin="0,10,0,0"><Run Text="Special thanks to /r/Forza and /r/Steam communities at Reddit"/><Run Text=", and to all the "/><Hyperlink NavigateUri="https://github.com/BrianLima/UWPHook/graphs/contributors"> contributors </Hyperlink><Run Text=" who have dealt with my bad code"/><Run Text="."/><Run Text=" "/><Run Text=":)"/></TextBlock> <TextBlock TextWrapping="WrapWithOverflow" x:Name="textBlock" Margin="0,185,0,0" Text="Developed by Brian Lima, @brianostorm, if you like my work cheer me up at my Twitter or pay me a coffee via Paypal, this way i can keep building amazing open-source tools for you!" TextAlignment="Justify" Height="91" VerticalAlignment="Top" Grid.ColumnSpan="3"/>
</Grid> <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="27" Grid.ColumnSpan="3">
<Grid Margin="10,9.8,10.2,0.4" Grid.Row="2" Visibility="Hidden"> <Label Content="About" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/>
<Image HorizontalAlignment="Left" Height="111" VerticalAlignment="Top" Width="111" Source="Resources/square.png"/> </materialDesign:ColorZone>
<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"/> <Image x:Name="image2" Height="150" VerticalAlignment="Top" Source="Resources/briano.png" Stretch="UniformToFill" Margin="8,32,0,0" HorizontalAlignment="Left" Width="150" Grid.Column="1"/>
<Button x:Name="update_button_Copy" Click="update_button_Click" Content="Get OverFy!" Margin="206,0,0,10" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="162"/> <TextBlock TextWrapping="WrapWithOverflow" x:Name="textBlock_Copy" VerticalAlignment="Top" Height="59" Text="This project uses the MaterialDesignXAMLToolkit. Special thanks to /r/Forza and /r/Steam communities at Reddit." TextAlignment="Justify" Grid.Row="3" Grid.ColumnSpan="3" Margin="0,44,0,0" Grid.RowSpan="2"/>
</Grid> </Grid>
</Grid> </Grid>
</Window> </Window>

View File

@ -19,26 +19,19 @@ public SettingsWindow()
{ {
cultures_comboBox.Items.Add(culture.TextInfo.CultureName); cultures_comboBox.Items.Add(culture.TextInfo.CultureName);
} }
for (int i = 0; i < 10; i++) for (int i = 1; i < 10; i++)
{ {
seconds_comboBox.Items.Add(i + " seconds"); seconds_comboBox.Items.Add(i + " seconds");
if (i == Properties.Settings.Default.Seconds) if (i == Properties.Settings.Default.Seconds)
{ {
seconds_comboBox.SelectedIndex = i; seconds_comboBox.SelectedIndex = i - 1;
} }
} }
cultures_comboBox.SelectedItem = Properties.Settings.Default.TargetLanguage; cultures_comboBox.SelectedItem = Properties.Settings.Default.TargetLanguage;
language_toggle.IsChecked = Properties.Settings.Default.ChangeLanguage; language_toggle.IsChecked = Properties.Settings.Default.ChangeLanguage;
streaming_toggle.IsChecked = Properties.Settings.Default.StreamMode; streaming_toggle.IsChecked = Properties.Settings.Default.StreamMode;
logLevel_comboBox.SelectedIndex = Properties.Settings.Default.SelectedLogLevel;
steamgriddb_api_key.Text = Properties.Settings.Default.SteamGridDbApiKey;
style_comboBox.SelectedIndex = Properties.Settings.Default.SelectedSteamGridDB_Style;
type_comboBox.SelectedIndex = Properties.Settings.Default.SelectedSteamGridDB_Type;
nfsw_comboBox.SelectedIndex = Properties.Settings.Default.SelectedSteamGridDB_nfsw;
humor_comboBox.SelectedIndex = Properties.Settings.Default.SelectedSteamGridDB_Humor;
tags_textBox.Text = Properties.Settings.Default.Tags;
} }
private void saveButton_Click(object sender, RoutedEventArgs e) private void saveButton_Click(object sender, RoutedEventArgs e)
@ -47,15 +40,7 @@ private void saveButton_Click(object sender, RoutedEventArgs e)
Properties.Settings.Default.TargetLanguage = cultures_comboBox.SelectedItem.ToString(); Properties.Settings.Default.TargetLanguage = cultures_comboBox.SelectedItem.ToString();
Properties.Settings.Default.Seconds = Int32.Parse(seconds_comboBox.SelectedItem.ToString().Substring(0, 1)); Properties.Settings.Default.Seconds = Int32.Parse(seconds_comboBox.SelectedItem.ToString().Substring(0, 1));
Properties.Settings.Default.StreamMode = (bool)streaming_toggle.IsChecked; Properties.Settings.Default.StreamMode = (bool)streaming_toggle.IsChecked;
Properties.Settings.Default.SelectedLogLevel = logLevel_comboBox.SelectedIndex;
Properties.Settings.Default.SteamGridDbApiKey = steamgriddb_api_key.Text.Trim('\r', '\n');
Properties.Settings.Default.SelectedSteamGridDB_Style = style_comboBox.SelectedIndex;
Properties.Settings.Default.SelectedSteamGridDB_Type = type_comboBox.SelectedIndex;
Properties.Settings.Default.SelectedSteamGridDB_nfsw = nfsw_comboBox.SelectedIndex;
Properties.Settings.Default.SelectedSteamGridDB_Humor = humor_comboBox.SelectedIndex;
Properties.Settings.Default.Tags = tags_textBox.Text;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
GamesWindow.SetLogLevel();
this.Close(); this.Close();
} }
@ -83,21 +68,5 @@ private void help_button_Click(object sender, RoutedEventArgs e)
{ {
System.Diagnostics.Process.Start("https://reddit.com/r/UWPHook/"); System.Diagnostics.Process.Start("https://reddit.com/r/UWPHook/");
} }
private void clearAll_button_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show("This action will remove ALL shortcuts from non-Steam games." + Environment.NewLine + " Are you sure you want to continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
{
GamesWindow.ClearAllShortcuts();
}
}
private void key_Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(messageBoxText: "You are being redirected to SteamGridDB website!\r\n" +
"Log-in, or create your account, go to your profile preferences and click 'Generate API Key', then paste the key back on UWPHook.", "Attention!", MessageBoxButton.OK, MessageBoxImage.Information );
System.Diagnostics.Process.Start("https://www.steamgriddb.com/profile/preferences/api");
}
} }
} }

View File

@ -1,15 +0,0 @@
namespace UWPHook.SteamGridDb
{
class GameResponse
{
/// <summary>
/// SteamGridDB id of the game
/// </summary>
public int Id { get; set; }
/// <summary>
/// Name of the game in SteamgridDB
/// </summary>
public string Name { get; set; }
}
}

View File

@ -1,10 +0,0 @@
namespace UWPHook.SteamGridDb
{
/// <summary>
/// Represents an image from SteamGridDB
/// </summary>
public class ImageResponse
{
public string Url { get; set; }
}
}

View File

@ -1,145 +0,0 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using UWPHook.Properties;
using System.Diagnostics;
using Serilog;
namespace UWPHook.SteamGridDb
{
class SteamGridDbApi
{
private const string BASE_URL = "https://www.steamgriddb.com/api/v2/";
private HttpClient httpClient;
private Settings settings;
/// <summary>
/// Constructor
/// </summary>
/// <param name="apiKey"> An SteamGridDB api key retrieved from https://www.steamgriddb.com/profile/preferences </param>
public SteamGridDbApi(string apiKey)
{
settings = Settings.Default;
httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(BASE_URL);
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
}
/// <summary>
/// Search SteamGridDB for a game
/// </summary>
/// <param name="gameName" type="String">Name of the game</param>
/// <returns>Array of games corresponding to the provided name</returns>
public async Task<GameResponse[]> SearchGame(string gameName)
{
string path = $"search/autocomplete/{gameName}";
GameResponse[] games = null;
HttpResponseMessage response = await httpClient.GetAsync(path);
if (response.IsSuccessStatusCode)
{
var parsedResponse = await response.Content.ReadAsAsync<ResponseWrapper<GameResponse>>();
games = parsedResponse.Data;
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
Log.Verbose("ERROR RESPONSE: " + response.ToString());
settings.SteamGridDbApiKey = String.Empty;
settings.Save();
Log.Error("Warning: SteamGrid API Key Invalid. Please generate a new key and add it to settings.");
throw new TaskCanceledException("Warning: SteamGrid API Key Invalid. Please generate a new key and add it to settings.");
}
return games;
}
/// <summary>
/// Method responsible for transforming user selected settings
/// into a suitable parameter list for SteamGridDB requests
/// </summary>
/// <param name="dimensions">Comma separated list of resolutions, see https://www.steamgriddb.com/api/v2#tag/GRIDS</param>
/// <returns>A String with the formatted parameters</returns>
public string BuildParameters(string dimensions)
{
String result = String.Empty;
var style = settings.SteamGridDB_Style[settings.SelectedSteamGridDB_Style];
var type = settings.SteamGridDB_Type[settings.SelectedSteamGridDB_Type];
var nsfw = settings.SteamGridDB_nfsw[settings.SelectedSteamGridDB_nfsw];
var humor = settings.SteamGridDB_Humor[settings.SelectedSteamGridDB_Humor];
if (!String.IsNullOrEmpty(dimensions))
result += $"dimensions={dimensions}&";
if (type != "any")
result += $"types={type}&";
if (style != "any")
result += $"styles={style}&";
if (nsfw != "any")
result += $"nsfw={nsfw}&";
if (humor != "any")
result += $"humor={humor}&";
return result;
}
/// <summary>
/// Performs a request on a given url
/// </summary>
/// <param name="url">The url to perform the request</param>
/// <returns>An array of ImageResponse with their urls</returns>
public async Task<ImageResponse[]> getResponse(string url)
{
HttpResponseMessage response = await httpClient.GetAsync(url);
ImageResponse[] images = null;
if (response.IsSuccessStatusCode)
{
var parsedResponse = await response.Content.ReadAsAsync<ResponseWrapper<ImageResponse>>();
if (parsedResponse != null)
{
if (parsedResponse.Success)
{
images = parsedResponse.Data;
}
}
}
return images;
}
public async Task<ImageResponse[]> GetGameGrids(int gameId, string dimensions = null)
{
string path = $"grids/game/{gameId}?{BuildParameters(dimensions)}";
return await getResponse(path);
}
public async Task<ImageResponse[]> GetGameHeroes(int gameId, string dimensions = null)
{
string path = $"heroes/game/{gameId}?{BuildParameters(dimensions)}";
return await getResponse(path);
}
public async Task<ImageResponse[]> GetGameLogos(int gameId, string dimensions = null)
{
string path = $"logos/game/{gameId}?{BuildParameters(dimensions)}";
return await getResponse(path);
}
private class ResponseWrapper<T>
{
public bool Success { get; set; }
public T[] Data { get; set; }
}
}
}

View File

@ -9,15 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UWPHook</RootNamespace> <RootNamespace>UWPHook</RootNamespace>
<AssemblyName>UWPHook</AssemblyName> <AssemblyName>UWPHook</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
@ -30,6 +26,7 @@
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
@ -59,18 +56,23 @@
<StartupObject>UWPHook.App</StartupObject> <StartupObject>UWPHook.App</StartupObject>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MaterialDesignColors, Version=1.1.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaterialDesignThemes.Wpf, Version=2.1.0.657, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignThemes.2.1.0.657\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpSteam"> <Reference Include="SharpSteam">
<HintPath>..\..\SharpSteam\SharpSteam\bin\Release\SharpSteam.dll</HintPath> <HintPath>..\..\SharpSteam\SharpSteam\bin\Release\SharpSteam.dll</HintPath>
</Reference> </Reference>
<Reference Include="System"> <Reference Include="System" />
<HintPath>..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll</HintPath>
</Reference>
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Management" /> <Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\packages\System.Management.Automation.6.1.7601.17515\lib\net45\System.Management.Automation.dll</HintPath>
<HintPath>..\..\..\..\..\..\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll</HintPath> <Private>True</Private>
<SpecificVersion>False</SpecificVersion>
</Reference> </Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -95,9 +97,6 @@
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="AppEntry.cs" /> <Compile Include="AppEntry.cs" />
<Compile Include="AppEntryModel.cs" /> <Compile Include="AppEntryModel.cs" />
<Compile Include="FullScreenLauncher.xaml.cs">
<DependentUpon>FullScreenLauncher.xaml</DependentUpon>
</Compile>
<Compile Include="GamesWindow.xaml.cs"> <Compile Include="GamesWindow.xaml.cs">
<DependentUpon>GamesWindow.xaml</DependentUpon> <DependentUpon>GamesWindow.xaml</DependentUpon>
</Compile> </Compile>
@ -106,12 +105,6 @@
<Compile Include="SettingsWindow.xaml.cs"> <Compile Include="SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon> <DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="SteamGridDb\GameResponse.cs" />
<Compile Include="SteamGridDb\ImageResponse.cs" />
<Compile Include="SteamGridDb\SteamGridDbApi.cs" />
<Page Include="FullScreenLauncher.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GamesWindow.xaml"> <Page Include="GamesWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -145,15 +138,12 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<None Include="bin\Release\_Resources\KnownApps.json" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>PublicSettingsSingleFileGenerator</Generator> <Generator>PublicSettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<AppDesigner Include="Properties\" /> <AppDesigner Include="Properties\" />
<EmbeddedResource Include="Resources\KnownApps.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
@ -171,7 +161,7 @@
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\GetAUMIDScript.ps1" /> <EmbeddedResource Include="Resources\GetAUMIDScript.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Resources\WhiteTransparent.png" /> <Resource Include="Resources\WhiteTransparent.png" />
@ -194,35 +184,6 @@
<ItemGroup> <ItemGroup>
<Resource Include="Resources\hook2.ico" /> <Resource Include="Resources\hook2.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Resources\square.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crc32.NET">
<Version>1.2.0</Version>
</PackageReference>
<PackageReference Include="MaterialDesignColors">
<Version>3.0.0</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">
<Version>5.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNet.WebApi.Client">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="Serilog">
<Version>3.1.1</Version>
</PackageReference>
<PackageReference Include="Serilog.Sinks.Console">
<Version>5.0.1</Version>
</PackageReference>
<PackageReference Include="Serilog.Sinks.File">
<Version>5.0.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

6
UWPHook/packages.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MaterialDesignColors" version="1.1.3" targetFramework="net461" />
<package id="MaterialDesignThemes" version="2.1.0.657" targetFramework="net461" />
<package id="System.Management.Automation" version="6.1.7601.17515" targetFramework="net461" />
</packages>