Config: Few JsonRequired attributes

This commit is contained in:
Liza 2023-02-15 14:35:11 +01:00
parent e7c2cd426b
commit faa35feade
4 changed files with 87 additions and 5 deletions

View File

@ -41,6 +41,7 @@ namespace Pal.Client.Configuration
}
[JsonInclude]
[JsonRequired]
public EFormat Format { get; private set; } = EFormat.Unencrypted;
/// <summary>
@ -48,11 +49,13 @@ namespace Pal.Client.Configuration
/// </summary>
[JsonPropertyName("Id")]
[JsonInclude]
[JsonRequired]
public string EncryptedId { get; private set; } = null!;
[JsonInclude]
public byte[]? Entropy { get; private set; }
[JsonRequired]
public string Server { get; init; } = null!;
[JsonIgnore] public bool IsUsable => DecryptAccountId() != null;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Numerics;
using ImGuiNET;
using Newtonsoft.Json;
namespace Pal.Client.Configuration
{
@ -59,8 +60,12 @@ namespace Pal.Client.Configuration
public class MarkerConfiguration
{
[JsonRequired]
public bool Show { get; set; }
[JsonRequired]
public uint Color { get; set; }
public bool OnlyVisibleAfterPomander { get; set; }
public bool Fill { get; set; }
}

View File

@ -0,0 +1,73 @@
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Plugin;
using Microsoft.Extensions.DependencyInjection;
using Pal.Client.Properties;
namespace Pal.Client.DependencyInjection
{
/// <summary>
/// DI-aware Plugin.
/// </summary>
internal sealed class DIPlugin : IDalamudPlugin
{
private ServiceProvider? _serviceProvider;
public string Name => Localization.Palace_Pal;
public DIPlugin(DalamudPluginInterface pluginInterface,
ClientState clientState,
GameGui gameGui,
ChatGui chatGui,
ObjectTable objectTable,
Framework framework,
Condition condition,
CommandManager commandManager,
DataManager dataManager)
{
IServiceCollection services = new ServiceCollection();
// dalamud
services.AddSingleton<IDalamudPlugin>(this);
services.AddSingleton(pluginInterface);
services.AddSingleton(gameGui);
services.AddSingleton(chatGui);
services.AddSingleton(objectTable);
services.AddSingleton(framework);
services.AddSingleton(condition);
services.AddSingleton(commandManager);
services.AddSingleton(dataManager);
// palace pal
services.AddSingleton<Plugin>();
// build
_serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions
{
ValidateOnBuild = true,
ValidateScopes = true,
});
// initialize plugin
_serviceProvider.GetRequiredService<Plugin>();
}
public void Dispose()
{
// ensure we're not calling dispose recursively on ourselves
if (_serviceProvider != null)
{
ServiceProvider serviceProvider = _serviceProvider;
_serviceProvider = null;
serviceProvider.Dispose();
}
}
}
}

View File

@ -33,9 +33,10 @@ using Pal.Client.Net;
namespace Pal.Client
{
public class Plugin : IDalamudPlugin
public class Plugin : IDisposable
{
internal const uint ColorInvisible = 0;
private readonly IDalamudPlugin _dalamudPlugin;
private LocalizedChatMessages _localizedChatMessages = new();
@ -51,10 +52,10 @@ namespace Pal.Client
internal ConcurrentQueue<nint> NextUpdateObjects { get; } = new();
internal IRenderer Renderer { get; private set; } = null!;
public string Name => Localization.Palace_Pal;
public Plugin(DalamudPluginInterface pluginInterface, ChatGui chat)
public Plugin(DalamudPluginInterface pluginInterface, ChatGui chat, IDalamudPlugin dalamudPlugin)
{
_dalamudPlugin = dalamudPlugin;
LanguageChanged(pluginInterface.UiLanguage);
PluginLog.Information($"Install source: {pluginInterface.SourceRepository}");
@ -669,7 +670,7 @@ namespace Pal.Client
disposable.Dispose();
if (Service.Configuration.Renderer.SelectedRenderer == ERenderer.Splatoon)
Renderer = new SplatoonRenderer(Service.PluginInterface, this);
Renderer = new SplatoonRenderer(Service.PluginInterface, _dalamudPlugin);
else
Renderer = new SimpleRenderer();
}