From 092e0ee30e8d7d2fdca163f74f046fbfbf244c9e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 18 Jan 2024 00:59:53 +0100 Subject: [PATCH] Make it not use clipboard because duh. --- Glamourer/GameData/CustomizeParameterValue.cs | 26 ------------------- .../Customization/CustomizeParameterDrawer.cs | 24 +++++------------ 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/Glamourer/GameData/CustomizeParameterValue.cs b/Glamourer/GameData/CustomizeParameterValue.cs index 0e2df8e..e1e0943 100644 --- a/Glamourer/GameData/CustomizeParameterValue.cs +++ b/Glamourer/GameData/CustomizeParameterValue.cs @@ -49,30 +49,4 @@ public readonly struct CustomizeParameterValue public override string ToString() => _data.ToString(); - - public string ToJson() - { - try - { - return JsonConvert.SerializeObject(_data, Formatting.None); - } - catch - { - return string.Empty; - } - } - - public static bool FromJson(string input, out CustomizeParameterValue value) - { - try - { - value = new CustomizeParameterValue(JsonConvert.DeserializeObject(input)); - return true; - } - catch - { - value = default; - return false; - } - } } diff --git a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs index 387780b..414398e 100644 --- a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs @@ -17,6 +17,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import private CustomizeParameterData _data; private CustomizeParameterFlag _flags; private float _width; + private CustomizeParameterValue? _copy; public void Draw(DesignManager designManager, Design design) { @@ -301,25 +302,14 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import return ImRaii.ItemWidth(_width); } - private static void DrawCopyPasteButtons(in CustomizeParameterDrawData data, bool locked) + private void DrawCopyPasteButtons(in CustomizeParameterDrawData data, bool locked) { if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Copy.ToIconString(), new Vector2(ImGui.GetFrameHeight()), - "Copy this color to clipboard.", false, true)) - ImGui.SetClipboardText(data.CurrentValue.ToJson()); + "Copy this color for later use.", false, true)) + _copy = data.CurrentValue; ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); - if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), new Vector2(ImGui.GetFrameHeight()), - "Try to paste this color from clipboard", locked, true)) - return; - - try - { - var text = ImGui.GetClipboardText(); - if (CustomizeParameterValue.FromJson(text, out var v)) - data.ValueSetter(v); - } - catch - { - // ignored - } + if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), new Vector2(ImGui.GetFrameHeight()), + _copy.HasValue ? "Paste the currently copied value." : "No value copied yet.", locked || !_copy.HasValue, true)) + data.ValueSetter(_copy!.Value); } }