Skip to content

Conversation

@D1yt
Copy link

@D1yt D1yt commented Feb 10, 2023

Checks if workshop link metadata exists and only creates button if it does. Link from metadata is passed to this extension.

I have verified that:

  • These changes work, by building the extension and testing.
  • That the changes comply with the rules indicated in the repository.
  • Pull request is targeting master branch.

Checks if workshop link metadata exists and only creates button if it does.
Link from metadata is passed to this extension.
Comment on lines -31 to 42
$menuItem13 = New-Object Playnite.SDK.Plugins.ScriptGameMenuItem
$menuItem13.Description = [Playnite.SDK.ResourceProvider]::GetString("LOCSteam_Viewer_MenuItemComponentScreenshotsDescription")
$menuItem13.FunctionName = "Start-ComponentScreenshots"
$menuItem13.Description = [Playnite.SDK.ResourceProvider]::GetString("LOCSteam_Viewer_MenuItemComponentNewsDescription")
$menuItem13.FunctionName = "Start-ComponentNews"
$menuItem13.MenuSection = "$extensionName|$subSection"

$menuItem14 = New-Object Playnite.SDK.Plugins.ScriptGameMenuItem
$menuItem14.Description = [Playnite.SDK.ResourceProvider]::GetString("LOCSteam_Viewer_MenuItemComponentSettingsDescription")
$menuItem14.FunctionName = "Start-ComponentSettings"
$menuItem14.Description = [Playnite.SDK.ResourceProvider]::GetString("LOCSteam_Viewer_MenuItemComponentScreenshotsDescription")
$menuItem14.FunctionName = "Start-ComponentScreenshots"
$menuItem14.MenuSection = "$extensionName|$subSection"

$menuItem15 = New-Object Playnite.SDK.Plugins.ScriptGameMenuItem
$menuItem15.Description = [Playnite.SDK.ResourceProvider]::GetString("LOCSteam_Viewer_MenuItemComponentSettingsDescription")
$menuItem15.FunctionName = "Start-ComponentSettings"
$menuItem15.MenuSection = "$extensionName|$subSection"

$game = $scriptGameMenuItemActionArgs.Games | Select-Object -last 1
if ([Playnite.SDK.BuiltinExtensions]::GetExtensionFromId($game.PluginId) -eq "SteamLibrary")
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new menu item should be added last to prevent modifying all other ones. Also helps to maintain consistency in items placement

Comment on lines +84 to +86
$workshopLink = $game.Links | Where-Object { $_.Name -eq "Workshop" }
if ($workshopLink)
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'd be better if the link search was done by the url instead of name as it would prevent false positives or work in cases where the link name was changed for any reason
  2. I'd prefer if the link search was done in a loop that breaks upon finding, to prevent having to loop through all the links

)
$game = $scriptGameMenuItemActionArgs.Games | Select-Object -last 1
#get workshop link
$workshopLink = $game.Links | Where-Object { $_.Name -eq "Workshop" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also should be done as a loop and via url

Comment on lines +207 to +208
$url = $workshopLink.Url
$uri = "steam://openurl/{0}" -f $url
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be done in a single line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants