DTR entry: Click to open main UI (#62)
This commit is contained in:
@@ -73,7 +73,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
clientState, objectTable, framework, gameGui, condition, gameData,
|
clientState, objectTable, framework, gameGui, condition, gameData,
|
||||||
s.GetRequiredService<MareMediator>(), s.GetRequiredService<PerformanceCollectorService>()));
|
s.GetRequiredService<MareMediator>(), s.GetRequiredService<PerformanceCollectorService>()));
|
||||||
collection.AddSingleton((s) => new DtrEntry(s.GetRequiredService<ILogger<DtrEntry>>(), dtrBar, s.GetRequiredService<MareConfigService>(),
|
collection.AddSingleton((s) => new DtrEntry(s.GetRequiredService<ILogger<DtrEntry>>(), dtrBar, s.GetRequiredService<MareConfigService>(),
|
||||||
s.GetRequiredService<PairManager>(), s.GetRequiredService<ApiController>()));
|
s.GetRequiredService<MareMediator>(), s.GetRequiredService<PairManager>(), s.GetRequiredService<ApiController>()));
|
||||||
collection.AddSingleton((s) => new IpcManager(s.GetRequiredService<ILogger<IpcManager>>(),
|
collection.AddSingleton((s) => new IpcManager(s.GetRequiredService<ILogger<IpcManager>>(),
|
||||||
pluginInterface, s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<MareMediator>()));
|
pluginInterface, s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<MareMediator>()));
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Dalamud.Plugin.Services;
|
|||||||
using MareSynchronos.MareConfiguration;
|
using MareSynchronos.MareConfiguration;
|
||||||
using MareSynchronos.MareConfiguration.Configurations;
|
using MareSynchronos.MareConfiguration.Configurations;
|
||||||
using MareSynchronos.PlayerData.Pairs;
|
using MareSynchronos.PlayerData.Pairs;
|
||||||
|
using MareSynchronos.Services.Mediator;
|
||||||
using MareSynchronos.WebAPI;
|
using MareSynchronos.WebAPI;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -16,17 +17,19 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
|||||||
private readonly ILogger<DtrEntry> _logger;
|
private readonly ILogger<DtrEntry> _logger;
|
||||||
private readonly IDtrBar _dtrBar;
|
private readonly IDtrBar _dtrBar;
|
||||||
private readonly ConfigurationServiceBase<MareConfig> _configService;
|
private readonly ConfigurationServiceBase<MareConfig> _configService;
|
||||||
|
private readonly MareMediator _mareMediator;
|
||||||
private Lazy<DtrBarEntry> _entry;
|
private Lazy<DtrBarEntry> _entry;
|
||||||
private readonly PairManager _pairManager;
|
private readonly PairManager _pairManager;
|
||||||
private Task? _runTask;
|
private Task? _runTask;
|
||||||
private string? _text;
|
private string? _text;
|
||||||
|
|
||||||
public DtrEntry(ILogger<DtrEntry> logger, IDtrBar dtrBar, ConfigurationServiceBase<MareConfig> configService, PairManager pairManager, ApiController apiController)
|
public DtrEntry(ILogger<DtrEntry> logger, IDtrBar dtrBar, ConfigurationServiceBase<MareConfig> configService, MareMediator mareMediator, PairManager pairManager, ApiController apiController)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_dtrBar = dtrBar;
|
_dtrBar = dtrBar;
|
||||||
_entry = new(() => _dtrBar.Get("Mare Synchronos"));
|
_entry = new(CreateEntry);
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
|
_mareMediator = mareMediator;
|
||||||
_pairManager = pairManager;
|
_pairManager = pairManager;
|
||||||
_apiController = apiController;
|
_apiController = apiController;
|
||||||
}
|
}
|
||||||
@@ -63,6 +66,14 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DtrBarEntry CreateEntry()
|
||||||
|
{
|
||||||
|
var entry = _dtrBar.Get("Mare Synchronos");
|
||||||
|
entry.OnClick = () => _mareMediator.Publish(new UiToggleMessage(typeof(CompactUi)));
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
private void Clear()
|
private void Clear()
|
||||||
{
|
{
|
||||||
if (!_entry.IsValueCreated) return;
|
if (!_entry.IsValueCreated) return;
|
||||||
@@ -72,7 +83,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
|||||||
_entry.Value.Shown = false;
|
_entry.Value.Shown = false;
|
||||||
_entry.Value.Text = null;
|
_entry.Value.Text = null;
|
||||||
_entry.Value.Dispose();
|
_entry.Value.Dispose();
|
||||||
_entry = new(() => _dtrBar.Get("Mare Synchronos"));
|
_entry = new(CreateEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunAsync()
|
private async Task RunAsync()
|
||||||
@@ -87,7 +98,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (!_configService.Current.EnableDtrEntry)
|
if (!_configService.Current.EnableDtrEntry || !_configService.Current.HasValidSetup())
|
||||||
{
|
{
|
||||||
if (_entry.IsValueCreated && _entry.Value.Shown)
|
if (_entry.IsValueCreated && _entry.Value.Shown)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user