From f2456ef9205f4be5d812aea4e7980bd98cbf0cd2 Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Sun, 4 Feb 2024 23:36:59 +0300 Subject: [PATCH] Slight popup refactoring --- .../Services/FantasiaPlusDetectService.cs | 6 +-- .../MainWindow/Tabs/Debug/IPCTestTab.cs | 13 ++---- .../Templates/TemplateFileSystemSelector.cs | 8 ++-- .../Tabs/Templates/TemplatePanel.cs | 5 +-- .../UI/Windows/PopupSystem.Messages.cs | 40 +++++++++++++++++++ CustomizePlus/UI/Windows/PopupSystem.cs | 4 +- 6 files changed, 53 insertions(+), 23 deletions(-) create mode 100644 CustomizePlus/UI/Windows/PopupSystem.Messages.cs diff --git a/CustomizePlus/Core/Services/FantasiaPlusDetectService.cs b/CustomizePlus/Core/Services/FantasiaPlusDetectService.cs index 36113f7..35a242d 100644 --- a/CustomizePlus/Core/Services/FantasiaPlusDetectService.cs +++ b/CustomizePlus/Core/Services/FantasiaPlusDetectService.cs @@ -29,11 +29,9 @@ public class FantasiaPlusDetectService : IDisposable _popupSystem = popupSystem; _logger = logger; - _popupSystem.RegisterPopup("fantasia_detected_warn", "Customize+ detected that you have Fantasia+ installed.\nPlease delete or turn it off and restart your game to use Customize+."); - if (CheckFantasiaPlusPresence()) { - _popupSystem.ShowPopup("fantasia_detected_warn"); + _popupSystem.ShowPopup(PopupSystem.Messages.FantasiaPlusDetected); _logger.Error("Fantasia+ detected during startup, plugin will be locked"); } else @@ -62,7 +60,7 @@ public class FantasiaPlusDetectService : IDisposable { if (CheckFantasiaPlusPresence()) { - _popupSystem.ShowPopup("fantasia_detected_warn"); + _popupSystem.ShowPopup(PopupSystem.Messages.FantasiaPlusDetected); _checkTimer!.Stop(); _checkTimer?.Dispose(); _logger.Error("Fantasia+ detected by timer, plugin will be locked"); diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs index d20e9c7..6d2b2a1 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs @@ -51,11 +51,6 @@ public class IPCTestTab //: IDisposable _gameObjectService = gameObjectService; _actorManager = actorManager; - _popupSystem.RegisterPopup("ipc_v4_profile_remembered", "Current profile has been copied into memory"); - _popupSystem.RegisterPopup("ipc_get_profile_from_character_remembered", "GetProfileFromCharacter result has been copied into memory"); - _popupSystem.RegisterPopup("ipc_set_profile_to_character_done", "SetProfileToCharacter has been called with data from memory"); - _popupSystem.RegisterPopup("ipc_revert_done", "Revert has been called"); - _getApiVersion = pluginInterface.GetIpcSubscriber<(int, int)>("CustomizePlus.GetApiVersion"); _apiVersion = _getApiVersion.InvokeFunc(); @@ -105,7 +100,7 @@ public class IPCTestTab //: IDisposable return; _rememberedProfileJson = JsonConvert.SerializeObject(V4ProfileToV3Converter.Convert(profile)); - _popupSystem.ShowPopup("ipc_v4_profile_remembered"); + _popupSystem.ShowPopup(PopupSystem.Messages.IPCV4ProfileRemembered); } if (ImGui.Button("GetProfileFromCharacter into memory")) @@ -115,7 +110,7 @@ public class IPCTestTab //: IDisposable return; _rememberedProfileJson = _getProfileFromCharacter!.InvokeFunc(FindCharacterByAddress(actors[0].Item2.Address)); - _popupSystem.ShowPopup("ipc_get_profile_from_character_remembered"); + _popupSystem.ShowPopup(PopupSystem.Messages.IPCGetProfileFromChrRemembered); } using (var disabled = ImRaii.Disabled(_rememberedProfileJson == null)) @@ -127,7 +122,7 @@ public class IPCTestTab //: IDisposable return; _setCharacterProfile!.InvokeAction(_rememberedProfileJson, FindCharacterByAddress(actors[0].Item2.Address)); - _popupSystem.ShowPopup("ipc_set_profile_to_character_done"); + _popupSystem.ShowPopup(PopupSystem.Messages.IPCSetProfileToChrDone); } } @@ -138,7 +133,7 @@ public class IPCTestTab //: IDisposable return; _revertCharacter!.InvokeAction(FindCharacterByAddress(actors[0].Item2.Address)); - _popupSystem.ShowPopup("ipc_revert_done"); + _popupSystem.ShowPopup(PopupSystem.Messages.IPCRevertDone); } } diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs index ed4dcdd..4ca4497 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs @@ -94,8 +94,6 @@ public class TemplateFileSystemSelector : FileSystemSelector