forked from Lacro59/playnite-isthereanydeal-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIsThereAnyDealSettings.cs
99 lines (79 loc) · 3.77 KB
/
IsThereAnyDealSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using IsThereAnyDeal.Models;
using Newtonsoft.Json;
using Playnite.SDK;
using System.Collections.Generic;
namespace IsThereAnyDeal
{
public class IsThereAnyDealSettings : ISettings
{
private readonly IsThereAnyDeal plugin;
public string Region { get; set; } = "us";
public string Country { get; set; } = "US";
public string CurrencySign { get; set; } = "$";
public List<ItadStore> Stores { get; set; } = new List<ItadStore>();
public bool EnableSteam { get; set; } = false;
public bool EnableGog { get; set; } = false;
public bool EnableHumble { get; set; } = false;
public bool EnableEpic { get; set; } = false;
public bool EnableNotification { get; set; } = false;
public bool EnableNotificationGiveaways { get; set; } = false;
public int LimitNotification { get; set; } = 50;
public string HumbleKey { get; set; } = "";
public bool EnableCheckVersion { get; set; } = true;
// Playnite serializes settings object to a JSON object and saves it as text file.
// If you want to exclude some property from being saved then use `JsonIgnore` ignore attribute.
[JsonIgnore]
public bool OptionThatWontBeSaved { get; set; } = false;
// Parameterless constructor must exist if you want to use LoadPluginSettings method.
public IsThereAnyDealSettings()
{
}
public IsThereAnyDealSettings(IsThereAnyDeal plugin)
{
// Injecting your plugin instance is required for Save/Load method because Playnite saves data to a location based on what plugin requested the operation.
this.plugin = plugin;
// Load saved settings.
var savedSettings = plugin.LoadPluginSettings<IsThereAnyDealSettings>();
// LoadPluginSettings returns null if not saved data is available.
if (savedSettings != null)
{
Region = savedSettings.Region;
Country = savedSettings.Country;
CurrencySign = savedSettings.CurrencySign;
Stores = savedSettings.Stores;
EnableSteam = savedSettings.EnableSteam;
EnableGog = savedSettings.EnableGog;
EnableHumble = savedSettings.EnableHumble;
EnableEpic = savedSettings.EnableEpic;
EnableNotification = savedSettings.EnableNotification;
EnableNotificationGiveaways = savedSettings.EnableNotificationGiveaways;
LimitNotification = savedSettings.LimitNotification;
HumbleKey = savedSettings.HumbleKey;
EnableCheckVersion = savedSettings.EnableCheckVersion;
}
}
public void BeginEdit()
{
// Code executed when settings view is opened and user starts editing values.
}
public void CancelEdit()
{
// Code executed when user decides to cancel any changes made since BeginEdit was called.
// This method should revert any changes made to Option1 and Option2.
}
public void EndEdit()
{
// Code executed when user decides to confirm changes made since BeginEdit was called.
// This method should save settings made to Option1 and Option2.
plugin.SavePluginSettings(this);
}
public bool VerifySettings(out List<string> errors)
{
// Code execute when user decides to confirm changes made since BeginEdit was called.
// Executed before EndEdit is called and EndEdit is not called if false is returned.
// List of errors is presented to user if verification fails.
errors = new List<string>();
return true;
}
}
}