Skip to content

Commit af1075e

Browse files
committed
started adding settings/options
1 parent 7fa5529 commit af1075e

File tree

6 files changed

+149
-5
lines changed

6 files changed

+149
-5
lines changed

BonusSettings.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Playnite.SDK;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace BonusTools
9+
{
10+
public class BonusSettings : ISettings
11+
{
12+
public string Option1 { get; set; } = string.Empty;
13+
14+
public bool Option2 { get; set; } = false;
15+
16+
public void BeginEdit()
17+
{
18+
// Code executed when settings view is opened and user starts editing values.
19+
}
20+
21+
public void CancelEdit()
22+
{
23+
// Code executed when user decides to cancel any changes made since BeginEdit was called.
24+
// This method should revert any changes made to Option1 and Option2.
25+
}
26+
27+
public void EndEdit()
28+
{
29+
// Code executed when user decides to confirm changes made since BeginEdit was called.
30+
// This method should save settings made to Option1 and Option2.
31+
}
32+
33+
public bool VerifySettings(out List<string> errors)
34+
{
35+
// Code execute when user decides to confirm changes made since BeginEdit was called.
36+
// Executed before EndEdit is called and EndEdit is not called if false is returned.
37+
// List of errors is presented to user if verification fails.
38+
errors = new List<string>();
39+
return true;
40+
}
41+
}
42+
}

BonusSettingsView.xaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<UserControl x:Class="BonusTools.BonusSettingsView"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:BonusTools"
7+
mc:Ignorable="d"
8+
d:DesignHeight="850" d:DesignWidth="800">
9+
<StackPanel>
10+
<StackPanel Margin="5">
11+
<Label FontWeight="Bold">SensCritique</Label>
12+
<TextBlock Text="Minimum game name similarity (min 60% recommended):" />
13+
<TextBox Text="{Binding Option1}" MinWidth="100" HorizontalAlignment="Left"/>
14+
<TextBlock Text="Sleep time between requests (to avoid http error 429 Too Many Requests) :" />
15+
<TextBox Text="{Binding Option1}" MinWidth="100" HorizontalAlignment="Left"/>
16+
<TextBlock Text="Release Year must match" />
17+
<CheckBox IsChecked="{Binding Option2}" />
18+
<TextBlock Text="Platform must match (e.g : PlayStation 5)" />
19+
<CheckBox IsChecked="{Binding Option2}" />
20+
<TextBlock Text="Populate Playnite.PlayCount with SensCritique.ReviewCount" />
21+
<CheckBox IsChecked="{Binding Option2}" />
22+
<TextBlock Text="Add a link to SensCritique" />
23+
<CheckBox IsChecked="{Binding Option2}" />
24+
</StackPanel>
25+
<StackPanel Margin="5">
26+
<Label FontWeight="Bold">Steam</Label>
27+
<TextBlock Text="Populate Playnite.PlayCount with Steam.ReviewCount" />
28+
<CheckBox IsChecked="{Binding Option2}" />
29+
<TextBlock Text="Populate Community Score" />
30+
<CheckBox IsChecked="{Binding Option2}" />
31+
</StackPanel>
32+
<StackPanel Margin="5">
33+
<Label FontWeight="Bold">IGDB</Label>
34+
<TextBlock Text="CLIENT_ID:" />
35+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
36+
<TextBlock Text="CLIENT_SECRET :" />
37+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
38+
</StackPanel>
39+
<StackPanel Margin="5">
40+
<Label FontWeight="Bold">Custom Spreadsheet</Label>
41+
<TextBlock Text="File Path:" />
42+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
43+
</StackPanel>
44+
<StackPanel Margin="5">
45+
<Label FontWeight="Bold">PlayStation</Label>
46+
<TextBlock Text="File Path Master List (.xlsx):" />
47+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
48+
<TextBlock Text="File Path Transaction Details (.xlsx):" />
49+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
50+
</StackPanel>
51+
<StackPanel Margin="5">
52+
<Label FontWeight="Bold">Nintendo</Label>
53+
<TextBlock Text="NX-Activity-Log File Path (.json):" />
54+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
55+
<TextBlock Text="Import PlayCount (not recommended) :" />
56+
<CheckBox IsChecked="{Binding Option2}" />
57+
<TextBlock Text="Yuzu File Path (.xlsx):" />
58+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
59+
<TextBlock Text="Ryujinx File Path (.xlsx):" />
60+
<TextBox Text="{Binding Option1}" MinWidth="200" HorizontalAlignment="Left"/>
61+
</StackPanel>
62+
</StackPanel>
63+
</UserControl>

BonusSettingsView.xaml.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace BonusTools
17+
{
18+
public partial class BonusSettingsView : UserControl
19+
{
20+
public BonusSettingsView()
21+
{
22+
InitializeComponent();
23+
}
24+
}
25+
}

BonusTools.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Playnite.SDK.Plugins;
66
using System;
77
using System.Collections.Generic;
8+
using System.Runtime;
9+
using System.Web.UI;
810
using Game = Playnite.SDK.Models.Game;
911

1012

@@ -14,6 +16,7 @@ public class BonusTools : GenericPlugin
1416
{
1517
private static readonly ILogger logger = LogManager.GetLogger();
1618
private string steamApiLanguage;
19+
private BonusSettings settings { get; set; }
1720

1821
public override Guid Id { get; } = Guid.Parse("ca24e37a-76d9-49bf-89ab-d3cba4a54bd2");
1922

@@ -127,7 +130,15 @@ public void RefreshGameData(List<Game> games)
127130
return;
128131
}
129132

133+
public override ISettings GetSettings(bool firstRunSettings)
134+
{
135+
return settings;
136+
}
130137

138+
public override System.Windows.Controls.UserControl GetSettingsView(bool firstRunSettings)
139+
{
140+
return new BonusSettingsView();
141+
}
131142

132143

133144
}

BonusTools.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@
267267
<Compile Include="JP\Models\PsGame.cs" />
268268
<Compile Include="BonusTools.cs" />
269269
<Compile Include="Properties\AssemblyInfo.cs" />
270+
<Compile Include="BonusSettings.cs" />
271+
<Compile Include="BonusSettingsView.xaml.cs">
272+
<DependentUpon>BonusSettingsView.xaml</DependentUpon>
273+
</Compile>
270274
<Compile Include="SteamSearch.cs" />
271275
</ItemGroup>
272276
<ItemGroup>
@@ -290,6 +294,10 @@
290294
<SubType>Designer</SubType>
291295
<Generator>MSBuild:Compile</Generator>
292296
</Page>
297+
<Page Include="BonusSettingsView.xaml">
298+
<SubType>Designer</SubType>
299+
<Generator>MSBuild:Compile</Generator>
300+
</Page>
293301
</ItemGroup>
294302
<ItemGroup>
295303
<None Include="icon.png">

JP/Popularity/Steam.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ public static async void Update(Game game, IPlayniteAPI PlayniteApi, string stea
8888
gameToUpdate.PlayCount = (ulong)TotalReviewsAvailable;
8989
gameToUpdate.CommunityScore = CalculateCommunityScore(reviews);
9090
}
91-
92-
// TODO : find an alternative to playerCount
93-
94-
//int playerCount = await PlayersInGameCount(steamId);
95-
//gameToUpdate.PlayCount = (ulong)playerCount;
9691

9792
PlayniteApi.Database.Games.Update(gameToUpdate);
9893
}

0 commit comments

Comments
 (0)