Skip to content

Commit f2456ef

Browse files
committed
Slight popup refactoring
1 parent cc122c6 commit f2456ef

File tree

6 files changed

+53
-23
lines changed

6 files changed

+53
-23
lines changed

CustomizePlus/Core/Services/FantasiaPlusDetectService.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ public FantasiaPlusDetectService(DalamudPluginInterface pluginInterface, PopupSy
2929
_popupSystem = popupSystem;
3030
_logger = logger;
3131

32-
_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+.");
33-
3432
if (CheckFantasiaPlusPresence())
3533
{
36-
_popupSystem.ShowPopup("fantasia_detected_warn");
34+
_popupSystem.ShowPopup(PopupSystem.Messages.FantasiaPlusDetected);
3735
_logger.Error("Fantasia+ detected during startup, plugin will be locked");
3836
}
3937
else
@@ -62,7 +60,7 @@ private void CheckTimerOnElapsed(object? sender, ElapsedEventArgs e)
6260
{
6361
if (CheckFantasiaPlusPresence())
6462
{
65-
_popupSystem.ShowPopup("fantasia_detected_warn");
63+
_popupSystem.ShowPopup(PopupSystem.Messages.FantasiaPlusDetected);
6664
_checkTimer!.Stop();
6765
_checkTimer?.Dispose();
6866
_logger.Error("Fantasia+ detected by timer, plugin will be locked");

CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ public IPCTestTab(
5151
_gameObjectService = gameObjectService;
5252
_actorManager = actorManager;
5353

54-
_popupSystem.RegisterPopup("ipc_v4_profile_remembered", "Current profile has been copied into memory");
55-
_popupSystem.RegisterPopup("ipc_get_profile_from_character_remembered", "GetProfileFromCharacter result has been copied into memory");
56-
_popupSystem.RegisterPopup("ipc_set_profile_to_character_done", "SetProfileToCharacter has been called with data from memory");
57-
_popupSystem.RegisterPopup("ipc_revert_done", "Revert has been called");
58-
5954
_getApiVersion = pluginInterface.GetIpcSubscriber<(int, int)>("CustomizePlus.GetApiVersion");
6055
_apiVersion = _getApiVersion.InvokeFunc();
6156

@@ -105,7 +100,7 @@ public unsafe void Draw()
105100
return;
106101

107102
_rememberedProfileJson = JsonConvert.SerializeObject(V4ProfileToV3Converter.Convert(profile));
108-
_popupSystem.ShowPopup("ipc_v4_profile_remembered");
103+
_popupSystem.ShowPopup(PopupSystem.Messages.IPCV4ProfileRemembered);
109104
}
110105

111106
if (ImGui.Button("GetProfileFromCharacter into memory"))
@@ -115,7 +110,7 @@ public unsafe void Draw()
115110
return;
116111

117112
_rememberedProfileJson = _getProfileFromCharacter!.InvokeFunc(FindCharacterByAddress(actors[0].Item2.Address));
118-
_popupSystem.ShowPopup("ipc_get_profile_from_character_remembered");
113+
_popupSystem.ShowPopup(PopupSystem.Messages.IPCGetProfileFromChrRemembered);
119114
}
120115

121116
using (var disabled = ImRaii.Disabled(_rememberedProfileJson == null))
@@ -127,7 +122,7 @@ public unsafe void Draw()
127122
return;
128123

129124
_setCharacterProfile!.InvokeAction(_rememberedProfileJson, FindCharacterByAddress(actors[0].Item2.Address));
130-
_popupSystem.ShowPopup("ipc_set_profile_to_character_done");
125+
_popupSystem.ShowPopup(PopupSystem.Messages.IPCSetProfileToChrDone);
131126
}
132127
}
133128

@@ -138,7 +133,7 @@ public unsafe void Draw()
138133
return;
139134

140135
_revertCharacter!.InvokeAction(FindCharacterByAddress(actors[0].Item2.Address));
141-
_popupSystem.ShowPopup("ipc_revert_done");
136+
_popupSystem.ShowPopup(PopupSystem.Messages.IPCRevertDone);
142137
}
143138
}
144139

CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ public TemplateFileSystemSelector(
9494
_logger = logger;
9595
_popupSystem = popupSystem;
9696

97-
_popupSystem.RegisterPopup("template_editor_active_warn", "You need to stop bone editing before doing this action"/*, false, new Vector2(5, 12)*/);
98-
_popupSystem.RegisterPopup("clipboard_data_unsupported_version", "Clipboard data you are trying to use cannot be used in this version of Customize+.");
9997

10098
_templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.TemplateFileSystemSelector);
10199
_profileChangedEvent.Subscribe(OnProfileChange, ProfileChanged.Priority.TemplateFileSystemSelector);
@@ -157,7 +155,7 @@ protected override void DrawPopups()
157155

158156
private void ShowEditorWarningPopup()
159157
{
160-
_popupSystem.ShowPopup("template_editor_active_warn");
158+
_popupSystem.ShowPopup(PopupSystem.Messages.TemplateEditorActiveWarning);
161159
}
162160

163161
private void DrawNewTemplatePopup()
@@ -181,7 +179,7 @@ private void DrawNewTemplatePopup()
181179
if (template is Template tpl && tpl != null)
182180
_templateManager.Clone(tpl, _newName, true);
183181
else
184-
_popupSystem.ShowPopup("clipboard_data_unsupported_version");
182+
_popupSystem.ShowPopup(PopupSystem.Messages.ClipboardDataUnsupported);
185183
}
186184
else if (_cloneTemplate != null)
187185
{
@@ -195,7 +193,7 @@ private void DrawNewTemplatePopup()
195193
catch(Exception ex)
196194
{
197195
_logger.Error($"Error while performing clipboard/clone/create template action: {ex}");
198-
_popupSystem.ShowPopup("action_error");
196+
_popupSystem.ShowPopup(PopupSystem.Messages.ActionError);
199197
}
200198
finally
201199
{

CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplatePanel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public TemplatePanel(
5151
_popupSystem = popupSystem;
5252
_logger = logger;
5353

54-
_popupSystem.RegisterPopup("clipboard_data_not_longterm", "Warning: clipboard data is not designed to be used as long-term way of storing your templates.\nCompatibility of copied data between different Customize+ versions is not guaranteed.", true, new Vector2(5, 10));
5554
}
5655

5756
public void Draw()
@@ -225,12 +224,12 @@ private void ExportToClipboard()
225224
try
226225
{
227226
Clipboard.SetText(Base64Helper.ExportToBase64(_selector.Selected!, Constants.ConfigurationVersion));
228-
_popupSystem.ShowPopup("clipboard_data_not_longterm");
227+
_popupSystem.ShowPopup(PopupSystem.Messages.ClipboardDataNotLongTerm);
229228
}
230229
catch (Exception ex)
231230
{
232231
_logger.Error($"Could not copy data from template {_selector.Selected!.UniqueId} to clipboard: {ex}");
233-
_popupSystem.ShowPopup("action_error");
232+
_popupSystem.ShowPopup(PopupSystem.Messages.ActionError);
234233
}
235234
}
236235
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Numerics;
2+
3+
namespace CustomizePlus.UI.Windows;
4+
5+
public partial class PopupSystem
6+
{
7+
public static class Messages
8+
{
9+
public const string ActionError = "action_error";
10+
11+
public const string FantasiaPlusDetected = "fantasia_detected_warn";
12+
13+
public const string IPCV4ProfileRemembered = "ipc_v4_profile_remembered";
14+
public const string IPCGetProfileFromChrRemembered = "ipc_get_profile_from_character_remembered";
15+
public const string IPCSetProfileToChrDone = "ipc_set_profile_to_character_done";
16+
public const string IPCRevertDone = "ipc_revert_done";
17+
18+
public const string TemplateEditorActiveWarning = "template_editor_active_warn";
19+
public const string ClipboardDataUnsupported = "clipboard_data_unsupported_version";
20+
21+
public const string ClipboardDataNotLongTerm = "clipboard_data_not_longterm";
22+
}
23+
24+
private void RegisterMessages()
25+
{
26+
RegisterPopup(Messages.ActionError, "Error while performing selected action.\nDetails have been printed to Dalamud log (/xllog in chat).");
27+
28+
RegisterPopup(Messages.FantasiaPlusDetected, "Customize+ detected that you have Fantasia+ installed.\nPlease delete or turn it off and restart your game to use Customize+.");
29+
30+
RegisterPopup(Messages.IPCV4ProfileRemembered, "Current profile has been copied into memory");
31+
RegisterPopup(Messages.IPCGetProfileFromChrRemembered, "GetProfileFromCharacter result has been copied into memory");
32+
RegisterPopup(Messages.IPCSetProfileToChrDone, "SetProfileToCharacter has been called with data from memory");
33+
RegisterPopup(Messages.IPCRevertDone, "Revert has been called");
34+
35+
RegisterPopup(Messages.TemplateEditorActiveWarning, "You need to stop bone editing before doing this action");
36+
RegisterPopup(Messages.ClipboardDataUnsupported, "Clipboard data you are trying to use cannot be used in this version of Customize+.");
37+
38+
RegisterPopup(Messages.ClipboardDataNotLongTerm, "Warning: clipboard data is not designed to be used as long-term way of storing your templates.\nCompatibility of copied data between different Customize+ versions is not guaranteed.", true, new Vector2(5, 10));
39+
}
40+
}

CustomizePlus/UI/Windows/PopupSystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace CustomizePlus.UI.Windows;
1212

13-
public class PopupSystem
13+
public partial class PopupSystem
1414
{
1515
private readonly Logger _logger;
1616
private readonly PluginConfiguration _configuration;
@@ -23,7 +23,7 @@ public PopupSystem(Logger logger, PluginConfiguration configuration)
2323
_logger = logger;
2424
_configuration = configuration;
2525

26-
RegisterPopup("action_error", "Error while performing selected action.\nDetails have been printed to Dalamud log (/xllog in chat).");
26+
RegisterMessages();
2727
}
2828

2929
public void RegisterPopup(string name, string text, bool displayOnce = false, Vector2? sizeDividers = null)

0 commit comments

Comments
 (0)