2023-01-05 01:23:32 +00:00
|
|
|
|
using Playnite.SDK;
|
|
|
|
|
using Playnite.SDK.Data;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2023-01-08 18:09:57 +00:00
|
|
|
|
namespace LANCommander.PlaynitePlugin
|
2023-01-05 01:23:32 +00:00
|
|
|
|
{
|
2023-01-14 21:16:13 +00:00
|
|
|
|
public class LANCommanderSettingsViewModel : ObservableObject, ISettings
|
2023-01-05 01:23:32 +00:00
|
|
|
|
{
|
2023-01-14 21:15:31 +00:00
|
|
|
|
private readonly LANCommanderLibraryPlugin Plugin;
|
2023-01-05 01:23:32 +00:00
|
|
|
|
|
2023-01-07 18:34:12 +00:00
|
|
|
|
public string ServerAddress { get; set; } = String.Empty;
|
2023-01-05 07:07:17 +00:00
|
|
|
|
public string AccessToken { get; set; } = String.Empty;
|
|
|
|
|
public string RefreshToken { get; set; } = String.Empty;
|
2023-01-12 02:48:39 +00:00
|
|
|
|
public string InstallDirectory { get; set; } = String.Empty;
|
2023-01-16 17:31:38 +00:00
|
|
|
|
public string PlayerName { get; set; } = String.Empty;
|
2023-01-05 07:07:17 +00:00
|
|
|
|
|
2023-01-14 21:16:13 +00:00
|
|
|
|
public LANCommanderSettingsViewModel() { }
|
2023-01-05 07:07:17 +00:00
|
|
|
|
|
2023-01-14 21:16:13 +00:00
|
|
|
|
public LANCommanderSettingsViewModel(LANCommanderLibraryPlugin plugin)
|
2023-01-05 01:23:32 +00:00
|
|
|
|
{
|
|
|
|
|
Plugin = plugin;
|
|
|
|
|
|
2023-01-14 21:16:13 +00:00
|
|
|
|
var settings = Plugin.LoadPluginSettings<LANCommanderSettingsViewModel>();
|
2023-01-12 02:48:39 +00:00
|
|
|
|
|
2023-01-26 03:08:05 +00:00
|
|
|
|
if (settings != null)
|
|
|
|
|
{
|
|
|
|
|
ServerAddress = settings.ServerAddress;
|
|
|
|
|
AccessToken = settings.AccessToken;
|
|
|
|
|
RefreshToken = settings.RefreshToken;
|
|
|
|
|
InstallDirectory = settings.InstallDirectory;
|
|
|
|
|
PlayerName = settings.PlayerName;
|
|
|
|
|
}
|
2023-01-05 01:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BeginEdit()
|
|
|
|
|
{
|
2023-01-12 02:48:39 +00:00
|
|
|
|
|
2023-01-05 01:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CancelEdit()
|
|
|
|
|
{
|
2023-01-12 02:48:39 +00:00
|
|
|
|
|
2023-01-05 01:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void EndEdit()
|
|
|
|
|
{
|
2023-01-12 02:48:39 +00:00
|
|
|
|
Plugin.SavePluginSettings(this);
|
2023-01-05 01:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool VerifySettings(out List<string> errors)
|
|
|
|
|
{
|
|
|
|
|
errors = new List<string>();
|
|
|
|
|
|
2023-01-12 02:48:39 +00:00
|
|
|
|
if (String.IsNullOrWhiteSpace(InstallDirectory))
|
|
|
|
|
errors.Add("An install directory needs to be set!");
|
|
|
|
|
|
|
|
|
|
return errors.Count == 0;
|
2023-01-05 01:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|