Clipboard data warning

This commit is contained in:
RisaDev
2024-02-04 22:32:51 +03:00
parent 695375d93c
commit 82e064dc29
2 changed files with 13 additions and 4 deletions

View File

@@ -95,7 +95,6 @@ public class TemplateFileSystemSelector : FileSystemSelector<Template, TemplateS
_popupSystem = popupSystem; _popupSystem = popupSystem;
_popupSystem.RegisterPopup("template_editor_active_warn", "You need to stop bone editing before doing this action"/*, false, new Vector2(5, 12)*/); _popupSystem.RegisterPopup("template_editor_active_warn", "You need to stop bone editing before doing this action"/*, false, new Vector2(5, 12)*/);
_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 clipboard data between different Customize+ is not guaranteed."/*, false, new Vector2(5, 12)*/);
_popupSystem.RegisterPopup("clipboard_data_unsupported_version", "Clipboard data you are trying to use cannot be used in this version of Customize+."); _popupSystem.RegisterPopup("clipboard_data_unsupported_version", "Clipboard data you are trying to use cannot be used in this version of Customize+.");
_templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.TemplateFileSystemSelector); _templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.TemplateFileSystemSelector);

View File

@@ -14,6 +14,7 @@ using CustomizePlus.Templates;
using CustomizePlus.Configuration.Data; using CustomizePlus.Configuration.Data;
using CustomizePlus.Core.Helpers; using CustomizePlus.Core.Helpers;
using CustomizePlus.Templates.Data; using CustomizePlus.Templates.Data;
using OtterGui.Log;
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Templates; namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Templates;
@@ -25,6 +26,8 @@ public class TemplatePanel
private readonly BoneEditorPanel _boneEditor; private readonly BoneEditorPanel _boneEditor;
private readonly PluginConfiguration _configuration; private readonly PluginConfiguration _configuration;
private readonly MessageService _messageService; private readonly MessageService _messageService;
private readonly PopupSystem _popupSystem;
private readonly Logger _logger;
private string? _newName; private string? _newName;
private Template? _changedTemplate; private Template? _changedTemplate;
@@ -38,7 +41,9 @@ public class TemplatePanel
GameStateService gameStateService, GameStateService gameStateService,
BoneEditorPanel boneEditor, BoneEditorPanel boneEditor,
PluginConfiguration configuration, PluginConfiguration configuration,
MessageService messageService) MessageService messageService,
PopupSystem popupSystem,
Logger logger)
{ {
_selector = selector; _selector = selector;
_manager = manager; _manager = manager;
@@ -46,6 +51,10 @@ public class TemplatePanel
_boneEditor = boneEditor; _boneEditor = boneEditor;
_configuration = configuration; _configuration = configuration;
_messageService = messageService; _messageService = messageService;
_popupSystem = popupSystem;
_logger = logger;
_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));
} }
public void Draw() public void Draw()
@@ -219,11 +228,12 @@ public class TemplatePanel
try try
{ {
Clipboard.SetText(Base64Helper.ExportToBase64(_selector.Selected!, Constants.ConfigurationVersion)); Clipboard.SetText(Base64Helper.ExportToBase64(_selector.Selected!, Constants.ConfigurationVersion));
_popupSystem.ShowPopup("clipboard_data_not_longterm");
} }
catch (Exception ex) catch (Exception ex)
{ {
_messageService.NotificationMessage(ex, $"Could not copy {_selector.Selected!.Name} data to clipboard.", _logger.Error($"Could not copy data from template {_selector.Selected!.UniqueId} to clipboard: {ex}");
$"Could not copy data from template {_selector.Selected!.UniqueId} to clipboard", NotificationType.Error, false); _popupSystem.ShowPopup("action_error");
} }
} }
} }