rework service disposal
This commit is contained in:
@@ -21,12 +21,11 @@ using MareSynchronos.WebAPI;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
public class CompactUi : Window, IDisposable
|
||||
public class CompactUi : WindowMediatorSubscriberBase, IDisposable
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly ConfigurationService _configService;
|
||||
private readonly TagHandler _tagHandler;
|
||||
public readonly Dictionary<string, bool> ShowUidForEntry = new(StringComparer.Ordinal);
|
||||
@@ -58,7 +57,7 @@ public class CompactUi : Window, IDisposable
|
||||
|
||||
public CompactUi(WindowSystem windowSystem,
|
||||
UiShared uiShared, ConfigurationService configService, ApiController apiController, PairManager pairManager,
|
||||
ServerConfigurationManager serverManager, MareMediator mediator) : base("###MareSynchronosMainUI")
|
||||
ServerConfigurationManager serverManager, MareMediator mediator) : base(mediator, "###MareSynchronosMainUI")
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
@@ -89,7 +88,6 @@ public class CompactUi : Window, IDisposable
|
||||
_apiController = apiController;
|
||||
_pairManager = pairManager;
|
||||
_serverManager = serverManager;
|
||||
_mediator = mediator;
|
||||
_tagHandler = new(_serverManager);
|
||||
|
||||
_groupPanel = new(this, uiShared, _pairManager, _serverManager, _configService);
|
||||
@@ -97,10 +95,10 @@ public class CompactUi : Window, IDisposable
|
||||
_selectPairsForGroupUi = new(_tagHandler);
|
||||
_pairGroupsUi = new(_tagHandler, DrawPairedClient, apiController, _selectPairsForGroupUi);
|
||||
|
||||
_mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = true);
|
||||
_mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = false);
|
||||
_mediator.Subscribe<GposeStartMessage>(this, (_) => UiShared_GposeStart());
|
||||
_mediator.Subscribe<GposeEndMessage>(this, (_) => UiShared_GposeEnd());
|
||||
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = true);
|
||||
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = false);
|
||||
Mediator.Subscribe<GposeStartMessage>(this, (_) => UiShared_GposeStart());
|
||||
Mediator.Subscribe<GposeEndMessage>(this, (_) => UiShared_GposeEnd());
|
||||
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
@@ -122,9 +120,9 @@ public class CompactUi : Window, IDisposable
|
||||
IsOpen = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public override void Dispose()
|
||||
{
|
||||
Logger.Verbose("Disposing " + nameof(CompactUi));
|
||||
base.Dispose();
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
|
||||
@@ -701,7 +699,7 @@ public class CompactUi : Window, IDisposable
|
||||
ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2);
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Cog))
|
||||
{
|
||||
_mediator.Publish(new OpenSettingsUiMessage());
|
||||
Mediator.Publish(new OpenSettingsUiMessage());
|
||||
}
|
||||
UiShared.AttachToolTip("Open the Mare Synchronos Settings");
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DownloadUi : Window, IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.Verbose("Disposing " + nameof(DownloadUi));
|
||||
Logger.Verbose($"Disposing {GetType()}");
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,27 +10,25 @@ using MareSynchronos.Utils;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
public class GposeUi : Window, IDisposable
|
||||
public class GposeUi : WindowMediatorSubscriberBase, IDisposable
|
||||
{
|
||||
private readonly WindowSystem _windowSystem;
|
||||
private readonly MareCharaFileManager _mareCharaFileManager;
|
||||
private readonly DalamudUtil _dalamudUtil;
|
||||
private readonly FileDialogManager _fileDialogManager;
|
||||
private readonly ConfigurationService _configService;
|
||||
private readonly MareMediator _mediator;
|
||||
|
||||
public GposeUi(WindowSystem windowSystem, MareCharaFileManager mareCharaFileManager,
|
||||
DalamudUtil dalamudUtil, FileDialogManager fileDialogManager, ConfigurationService configService,
|
||||
MareMediator mediator) : base("Mare Synchronos Gpose Import UI###MareSynchronosGposeUI")
|
||||
MareMediator mediator) : base(mediator, "Mare Synchronos Gpose Import UI###MareSynchronosGposeUI")
|
||||
{
|
||||
_windowSystem = windowSystem;
|
||||
_mareCharaFileManager = mareCharaFileManager;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_fileDialogManager = fileDialogManager;
|
||||
_configService = configService;
|
||||
_mediator = mediator;
|
||||
_mediator.Subscribe<GposeStartMessage>(this, (_) => StartGpose());
|
||||
_mediator.Subscribe<GposeEndMessage>(this, (_) => EndGpose());
|
||||
Mediator.Subscribe<GposeStartMessage>(this, (_) => StartGpose());
|
||||
Mediator.Subscribe<GposeEndMessage>(this, (_) => EndGpose());
|
||||
IsOpen = _dalamudUtil.IsInGpose;
|
||||
Flags = ImGuiWindowFlags.AlwaysAutoResize;
|
||||
_windowSystem.AddWindow(this);
|
||||
@@ -47,8 +45,9 @@ public class GposeUi : Window, IDisposable
|
||||
IsOpen = _configService.Current.OpenGposeImportOnGposeStart;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,12 @@ using MareSynchronos.Mediator;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
internal class IntroUi : Window, IDisposable
|
||||
internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
|
||||
{
|
||||
private readonly UiShared _uiShared;
|
||||
private readonly ConfigurationService _configService;
|
||||
private readonly PeriodicFileScanner _fileCacheManager;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly WindowSystem _windowSystem;
|
||||
private bool _readFirstPage;
|
||||
|
||||
@@ -31,15 +30,14 @@ internal class IntroUi : Window, IDisposable
|
||||
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
|
||||
private int _currentLanguage;
|
||||
|
||||
public void Dispose()
|
||||
public override void Dispose()
|
||||
{
|
||||
Logger.Verbose("Disposing " + nameof(IntroUi));
|
||||
|
||||
base.Dispose();
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
|
||||
public IntroUi(WindowSystem windowSystem, UiShared uiShared, ConfigurationService configService,
|
||||
PeriodicFileScanner fileCacheManager, ServerConfigurationManager serverConfigurationManager, MareMediator mareMediator) : base("Mare Synchronos Setup")
|
||||
PeriodicFileScanner fileCacheManager, ServerConfigurationManager serverConfigurationManager, MareMediator mareMediator) : base(mareMediator, "Mare Synchronos Setup")
|
||||
{
|
||||
Logger.Verbose("Creating " + nameof(IntroUi));
|
||||
|
||||
@@ -47,7 +45,6 @@ internal class IntroUi : Window, IDisposable
|
||||
_configService = configService;
|
||||
_fileCacheManager = fileCacheManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_mareMediator = mareMediator;
|
||||
_windowSystem = windowSystem;
|
||||
IsOpen = false;
|
||||
|
||||
@@ -59,8 +56,8 @@ internal class IntroUi : Window, IDisposable
|
||||
|
||||
GetToSLocalization();
|
||||
|
||||
_mareMediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = false);
|
||||
_mareMediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = true);
|
||||
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = false);
|
||||
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = true);
|
||||
|
||||
_windowSystem.AddWindow(this);
|
||||
}
|
||||
@@ -242,7 +239,7 @@ internal class IntroUi : Window, IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
_mareMediator.Publish(new SwitchToMainUiMessage());
|
||||
Mediator.Publish(new SwitchToMainUiMessage());
|
||||
IsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,10 @@ using MareSynchronos.Managers;
|
||||
using MareSynchronos.API.Data.Comparer;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Mediator;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
public class SettingsUi : Window, IDisposable
|
||||
public class SettingsUi : WindowMediatorSubscriberBase, IDisposable
|
||||
{
|
||||
private readonly ConfigurationService _configService;
|
||||
private readonly WindowSystem _windowSystem;
|
||||
@@ -27,7 +25,6 @@ public class SettingsUi : Window, IDisposable
|
||||
private readonly MareCharaFileManager _mareCharaFileManager;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly UiShared _uiShared;
|
||||
public CharacterData? LastCreatedCharacterData { private get; set; }
|
||||
|
||||
@@ -39,7 +36,7 @@ public class SettingsUi : Window, IDisposable
|
||||
public SettingsUi(WindowSystem windowSystem,
|
||||
UiShared uiShared, ConfigurationService configService,
|
||||
MareCharaFileManager mareCharaFileManager, PairManager pairManager,
|
||||
ServerConfigurationManager serverConfigurationManager, MareMediator mediator) : base("Mare Synchronos Settings")
|
||||
ServerConfigurationManager serverConfigurationManager, MareMediator mediator) : base(mediator, "Mare Synchronos Settings")
|
||||
{
|
||||
Logger.Verbose("Creating " + nameof(SettingsUi));
|
||||
|
||||
@@ -54,15 +51,13 @@ public class SettingsUi : Window, IDisposable
|
||||
_mareCharaFileManager = mareCharaFileManager;
|
||||
_pairManager = pairManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_mediator = mediator;
|
||||
_uiShared = uiShared;
|
||||
|
||||
|
||||
_mediator.Subscribe<OpenSettingsUiMessage>(this, (_) => Toggle());
|
||||
_mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = false);
|
||||
_mediator.Subscribe<GposeStartMessage>(this, (_) => UiShared_GposeStart());
|
||||
_mediator.Subscribe<GposeEndMessage>(this, (_) => UiShared_GposeEnd());
|
||||
_mediator.Subscribe<PlayerChangedMessage>(this, (msg) => LastCreatedCharacterData = ((PlayerChangedMessage)msg).Data);
|
||||
Mediator.Subscribe<OpenSettingsUiMessage>(this, (_) => Toggle());
|
||||
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = false);
|
||||
Mediator.Subscribe<GposeStartMessage>(this, (_) => UiShared_GposeStart());
|
||||
Mediator.Subscribe<GposeEndMessage>(this, (_) => UiShared_GposeEnd());
|
||||
Mediator.Subscribe<PlayerChangedMessage>(this, (msg) => LastCreatedCharacterData = ((PlayerChangedMessage)msg).Data);
|
||||
|
||||
windowSystem.AddWindow(this);
|
||||
}
|
||||
@@ -78,10 +73,9 @@ public class SettingsUi : Window, IDisposable
|
||||
IsOpen = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public override void Dispose()
|
||||
{
|
||||
Logger.Verbose("Disposing " + nameof(SettingsUi));
|
||||
|
||||
base.Dispose();
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
|
||||
@@ -215,7 +209,7 @@ public class SettingsUi : Window, IDisposable
|
||||
{
|
||||
Task.Run(() => ApiController.UserDelete());
|
||||
_deleteAccountPopupModalShown = false;
|
||||
_mediator.Publish(new SwitchToIntroUiMessage());
|
||||
Mediator.Publish(new SwitchToIntroUiMessage());
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
@@ -656,6 +656,7 @@ public partial class UiShared : IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.Verbose($"Disposing {GetType()}");
|
||||
_pluginInterface.UiBuilder.BuildFonts -= BuildFont;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user