-
-
Notifications
You must be signed in to change notification settings - Fork 31
News Viewer
Adds support to display news for Steam games in compatible themes and adds a sidebar button to open the Steam news page in Playnite
Full integration tutorial for theme developers is available in the Playnite documentation: https://playnite.link/docs/devel/tutorials/themes/extensionIntegration.html
Example:
[...]
<Grid Visibility="{PluginStatus Plugin=NewsViewer_15e03ffe-90f6-4e8e-bd4d-94514777481d, Status=Installed}">
[...]
It can also be used to return a bool
value if used in another property.
<ContentControl x:Name="NewsViewer_NewsViewerControl" />
The source name of the plugin is NewsViewer
Setting | Type | Default | Description |
---|---|---|---|
IsControlVisible | bool | false | Indicates if the News Viewer control is visible |
Binding example:
[...]
<StackPanel>
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{PluginSettings Plugin=NewsViewer, Path=ReviewsAvailable, FallbackValue=False}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
[...]
This control by default only contains a button with the number of players in-game on Steam as Content. It is intended that the theme styles the button layout to their preference by creating a button template, for example:
<Style TargetType="{x:Type Button}" x:Key="PlayersCountButtonStyle">
<Setter Property="Background" Value="Red"/>
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="BorderBrush" Value="Yellow"/>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeSmall}" />
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Padding" Value="6,2,6,2" />
<Setter Property="Margin" Value="10,0,0,0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}" VerticalAlignment="{TemplateBinding VerticalAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}">
<StackPanel Orientation="Horizontal">
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalAlignment}" />
<TextBlock Foreground="{TemplateBinding Foreground}"
FontSize="{TemplateBinding FontSize}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Tag="{DynamicResource LOC_NewsViewer_PlayersInGameViewerControl_InGameCountLabel}"
Text="{Binding Path=Tag, RelativeSource={RelativeSource Self}, StringFormat=' {0}'}"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Afterwards, the created button style can be added to the ContentControl
resources to apply it to the control button. If needed, button properties can be changed in the style:
<ContentControl x:Name="NewsViewer_PlayersInGameViewerControl">
<ContentControl.Resources>
<Style TargetType="Button" BasedOn="{StaticResource PlayersCountButtonStyle}">
<Setter Property="Foreground" Value="Green"/>
</Style>
</ContentControl.Resources>
</ContentControl>
The extension contains localization strings intended to be used in the button definition:
Resource Key | String Value |
---|---|
LOC_NewsViewer_PlayersInGameViewerControl_InGameCountLabel | In-Game |
LOC_NewsViewer_PlayersInGameViewerControl_OnlineNowCountLabel | Online now |
The source name of the plugin is NewsViewer
Setting | Type | Default | Description |
---|---|---|---|
PlayersCountAvailable | bool | false | Indicates if data of current players for the current game has been obtained and the control is visible |
Binding example:
[...]
<StackPanel>
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{PluginSettings Plugin=NewsViewer, Path=PlayersCountAvailable, FallbackValue=False}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
[...]