Reintroduced holding Ctrl or Shift to apply only gear or customization for things.

This commit is contained in:
Ottermandias 2023-09-27 23:23:05 +02:00
parent 550c0c756e
commit 3b28c21c7d
4 changed files with 45 additions and 17 deletions

View file

@ -49,8 +49,11 @@ public class DesignConverter
=> ShareBackwardCompatible(ShareJObject(design), design); => ShareBackwardCompatible(ShareJObject(design), design);
public string ShareBase64(ActorState state) public string ShareBase64(ActorState state)
=> ShareBase64(state, EquipFlagExtensions.All, CustomizeFlagExtensions.All);
public string ShareBase64(ActorState state, EquipFlag equipFlags, CustomizeFlag customizeFlags)
{ {
var design = Convert(state, EquipFlagExtensions.All, CustomizeFlagExtensions.All); var design = Convert(state, equipFlags, customizeFlags);
return ShareBackwardCompatible(ShareJObject(design), design); return ShareBackwardCompatible(ShareJObject(design), design);
} }

View file

@ -15,7 +15,6 @@ using Glamourer.Interop;
using Glamourer.Interop.Structs; using Glamourer.Interop.Structs;
using Glamourer.Services; using Glamourer.Services;
using Glamourer.State; using Glamourer.State;
using Glamourer.Structs;
using ImGuiNET; using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Raii; using OtterGui.Raii;
@ -281,7 +280,7 @@ public class ActorPanel
private HeaderDrawer.Button SetFromClipboardButton() private HeaderDrawer.Button SetFromClipboardButton()
=> new() => new()
{ {
Description = "Try to apply a design from your clipboard.", Description = "Try to apply a design from your clipboard.\nHold Control to only apply gear.\nHold Shift to only apply customizations.",
Icon = FontAwesomeIcon.Clipboard, Icon = FontAwesomeIcon.Clipboard,
OnClick = SetFromClipboard, OnClick = SetFromClipboard,
Visible = _state != null, Visible = _state != null,
@ -291,7 +290,7 @@ public class ActorPanel
private HeaderDrawer.Button ExportToClipboardButton() private HeaderDrawer.Button ExportToClipboardButton()
=> new() => new()
{ {
Description = "Copy the current design to your clipboard.", Description = "Copy the current design to your clipboard.\nHold Control to disable applying of customizations for the copied design.\nHold Shift to disable applying of gear for the copied design.",
Icon = FontAwesomeIcon.Copy, Icon = FontAwesomeIcon.Copy,
OnClick = ExportToClipboard, OnClick = ExportToClipboard,
Visible = _state?.ModelData.ModelId == 0, Visible = _state?.ModelData.ModelId == 0,
@ -300,7 +299,7 @@ public class ActorPanel
private HeaderDrawer.Button SaveAsDesignButton() private HeaderDrawer.Button SaveAsDesignButton()
=> new() => new()
{ {
Description = "Save the current state as a design.", Description = "Save the current state as a design.\nHold Control to disable applying of customizations for the saved design.\nHold Shift to disable applying of gear for the saved design.",
Icon = FontAwesomeIcon.Save, Icon = FontAwesomeIcon.Save,
OnClick = SaveDesignOpen, OnClick = SaveDesignOpen,
Visible = _state?.ModelData.ModelId == 0, Visible = _state?.ModelData.ModelId == 0,
@ -325,7 +324,8 @@ public class ActorPanel
{ {
ImGui.OpenPopup("Save as Design"); ImGui.OpenPopup("Save as Design");
_newName = _state!.Identifier.ToName(); _newName = _state!.Identifier.ToName();
_newDesign = _converter.Convert(_state, EquipFlagExtensions.All, CustomizeFlagExtensions.All); var (applyGear, applyCustomize) = UiHelpers.ConvertKeysToFlags();
_newDesign = _converter.Convert(_state, applyGear, applyCustomize);
} }
private void SaveDesignDrawPopup() private void SaveDesignDrawPopup()
@ -343,8 +343,9 @@ public class ActorPanel
{ {
try try
{ {
var (applyGear, applyCustomize) = UiHelpers.ConvertKeysToBool();
var text = ImGui.GetClipboardText(); var text = ImGui.GetClipboardText();
var design = _converter.FromBase64(text, true, true, out _) ?? throw new Exception("The clipboard did not contain valid data."); var design = _converter.FromBase64(text, applyCustomize, applyGear, out _) ?? throw new Exception("The clipboard did not contain valid data.");
_stateManager.ApplyDesign(design, _state!, StateChanged.Source.Manual); _stateManager.ApplyDesign(design, _state!, StateChanged.Source.Manual);
} }
catch (Exception ex) catch (Exception ex)
@ -358,7 +359,8 @@ public class ActorPanel
{ {
try try
{ {
var text = _converter.ShareBase64(_state!); var (applyGear, applyCustomize) = UiHelpers.ConvertKeysToFlags();
var text = _converter.ShareBase64(_state!, applyGear, applyCustomize);
ImGui.SetClipboardText(text); ImGui.SetClipboardText(text);
} }
catch (Exception ex) catch (Exception ex)
@ -392,12 +394,13 @@ public class ActorPanel
private void DrawApplyToSelf() private void DrawApplyToSelf()
{ {
var (id, data) = _objects.PlayerData; var (id, data) = _objects.PlayerData;
if (!ImGuiUtil.DrawDisabledButton("Apply to Yourself", Vector2.Zero, "Apply the current state to your own character.", if (!ImGuiUtil.DrawDisabledButton("Apply to Yourself", Vector2.Zero, "Apply the current state to your own character.\nHold Control to only apply gear.\nHold Shift to only apply customizations.",
!data.Valid || id == _identifier || _state!.ModelData.ModelId != 0)) !data.Valid || id == _identifier || _state!.ModelData.ModelId != 0))
return; return;
var (applyGear, applyCustomize) = UiHelpers.ConvertKeysToFlags();
if (_stateManager.GetOrCreate(id, data.Objects[0], out var state)) if (_stateManager.GetOrCreate(id, data.Objects[0], out var state))
_stateManager.ApplyDesign(_converter.Convert(_state!, EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant), state, _stateManager.ApplyDesign(_converter.Convert(_state!, applyGear, applyCustomize), state,
StateChanged.Source.Manual); StateChanged.Source.Manual);
} }
@ -406,15 +409,16 @@ public class ActorPanel
var (id, data) = _objects.TargetData; var (id, data) = _objects.TargetData;
var tt = id.IsValid var tt = id.IsValid
? data.Valid ? data.Valid
? "Apply the current state to your current target." ? "Apply the current state to your current target.\nHold Control to only apply gear.\nHold Shift to only apply customizations."
: "The current target can not be manipulated." : "The current target can not be manipulated."
: "No valid target selected."; : "No valid target selected.";
if (!ImGuiUtil.DrawDisabledButton("Apply to Target", Vector2.Zero, tt, if (!ImGuiUtil.DrawDisabledButton("Apply to Target", Vector2.Zero, tt,
!data.Valid || id == _identifier || _state!.ModelData.ModelId != 0 || _objects.IsInGPose)) !data.Valid || id == _identifier || _state!.ModelData.ModelId != 0 || _objects.IsInGPose))
return; return;
var (applyGear, applyCustomize) = UiHelpers.ConvertKeysToFlags();
if (_stateManager.GetOrCreate(id, data.Objects[0], out var state)) if (_stateManager.GetOrCreate(id, data.Objects[0], out var state))
_stateManager.ApplyDesign(_converter.Convert(_state!, EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant), state, _stateManager.ApplyDesign(_converter.Convert(_state!, applyGear, applyCustomize), state,
StateChanged.Source.Manual); StateChanged.Source.Manual);
} }
} }

View file

@ -75,7 +75,7 @@ public class DesignPanel
private HeaderDrawer.Button SetFromClipboardButton() private HeaderDrawer.Button SetFromClipboardButton()
=> new() => new()
{ {
Description = "Try to apply a design from your clipboard over this design.", Description = "Try to apply a design from your clipboard over this design.\nHold Control to only apply gear.\nHold Shift to only apply customizations.",
Icon = FontAwesomeIcon.Clipboard, Icon = FontAwesomeIcon.Clipboard,
OnClick = SetFromClipboard, OnClick = SetFromClipboard,
Visible = _selector.Selected != null, Visible = _selector.Selected != null,
@ -395,7 +395,8 @@ public class DesignPanel
try try
{ {
var text = ImGui.GetClipboardText(); var text = ImGui.GetClipboardText();
var design = _converter.FromBase64(text, true, true, out _) ?? throw new Exception("The clipboard did not contain valid data."); var (applyEquip, applyCustomize) = UiHelpers.ConvertKeysToBool();
var design = _converter.FromBase64(text, applyEquip, applyCustomize, out _) ?? throw new Exception("The clipboard did not contain valid data.");
_manager.ApplyDesign(_selector.Selected!, design); _manager.ApplyDesign(_selector.Selected!, design);
} }
catch (Exception ex) catch (Exception ex)

View file

@ -1,7 +1,9 @@
using System; using System;
using System.Numerics; using System.Numerics;
using Dalamud.Interface; using Dalamud.Interface;
using Glamourer.Customization;
using Glamourer.Services; using Glamourer.Services;
using Glamourer.Structs;
using ImGuiNET; using ImGuiNET;
using Lumina.Misc; using Lumina.Misc;
using OtterGui; using OtterGui;
@ -99,4 +101,22 @@ public static class UiHelpers
newApply = currentApply; newApply = currentApply;
return DataChange.None; return DataChange.None;
} }
public static (EquipFlag, CustomizeFlag) ConvertKeysToFlags()
=> (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch
{
(false, false) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant),
(true, true) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant),
(true, false) => (EquipFlagExtensions.All, (CustomizeFlag)0),
(false, true) => ((EquipFlag)0, CustomizeFlagExtensions.AllRelevant),
};
public static (bool, bool) ConvertKeysToBool()
=> (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch
{
(false, false) => (true, true),
(true, true) => (true, true),
(true, false) => (true, false),
(false, true) => (false, true),
};
} }