mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Add Shift/Ctrl modifiers to Apply Design buttons.
This commit is contained in:
parent
5cd7d607ef
commit
49768e797d
2 changed files with 48 additions and 10 deletions
|
|
@ -157,6 +157,31 @@ public class DesignBase
|
|||
public void FixCustomizeApplication(CustomizationSet set, CustomizeFlag flags)
|
||||
=> ApplyCustomize = flags.FixApplication(set);
|
||||
|
||||
internal FlagRestrictionResetter TemporarilyRestrictApplication(EquipFlag equipFlags, CustomizeFlag customizeFlags)
|
||||
=> new(this, equipFlags, customizeFlags);
|
||||
|
||||
internal readonly struct FlagRestrictionResetter : IDisposable
|
||||
{
|
||||
private readonly DesignBase _design;
|
||||
private readonly EquipFlag _oldEquipFlags;
|
||||
private readonly CustomizeFlag _oldCustomizeFlags;
|
||||
|
||||
public FlagRestrictionResetter(DesignBase d, EquipFlag equipFlags, CustomizeFlag customizeFlags)
|
||||
{
|
||||
_design = d;
|
||||
_oldEquipFlags = d.ApplyEquip;
|
||||
_oldCustomizeFlags = d.ApplyCustomize;
|
||||
d.ApplyEquip &= equipFlags;
|
||||
d.ApplyCustomize &= customizeFlags;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_design.ApplyEquip = _oldEquipFlags;
|
||||
_design.ApplyCustomize = _oldCustomizeFlags;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Serialization
|
||||
|
|
@ -349,7 +374,9 @@ public class DesignBase
|
|||
void PrintWarning(string msg)
|
||||
{
|
||||
if (msg.Length > 0)
|
||||
Glamourer.Chat.NotificationMessage($"{msg} ({name})\n\nThis change is not saved automatically. If you want this replacement to stick and the warning to stop appearing, please save the design manually once by changing something in it.", "Warning", NotificationType.Warning);
|
||||
Glamourer.Chat.NotificationMessage(
|
||||
$"{msg} ({name})\n\nThis change is not saved automatically. If you want this replacement to stick and the warning to stop appearing, please save the design manually once by changing something in it.",
|
||||
"Warning", NotificationType.Warning);
|
||||
}
|
||||
|
||||
var wetness = QuadBool.FromJObject(json["Wetness"], "Value", "Apply", QuadBool.NullFalse);
|
||||
|
|
|
|||
|
|
@ -75,11 +75,12 @@ public class DesignPanel
|
|||
private HeaderDrawer.Button SetFromClipboardButton()
|
||||
=> new()
|
||||
{
|
||||
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,
|
||||
OnClick = SetFromClipboard,
|
||||
Visible = _selector.Selected != null,
|
||||
Disabled = _selector.Selected?.WriteProtected() ?? true,
|
||||
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,
|
||||
OnClick = SetFromClipboard,
|
||||
Visible = _selector.Selected != null,
|
||||
Disabled = _selector.Selected?.WriteProtected() ?? true,
|
||||
};
|
||||
|
||||
private HeaderDrawer.Button ExportToClipboardButton()
|
||||
|
|
@ -396,9 +397,10 @@ public class DesignPanel
|
|||
{
|
||||
try
|
||||
{
|
||||
var text = ImGui.GetClipboardText();
|
||||
var text = ImGui.GetClipboardText();
|
||||
var (applyEquip, applyCustomize) = UiHelpers.ConvertKeysToBool();
|
||||
var design = _converter.FromBase64(text, applyEquip, applyCustomize, out _) ?? throw new Exception("The clipboard did not contain valid data.");
|
||||
var design = _converter.FromBase64(text, applyEquip, applyCustomize, out _)
|
||||
?? throw new Exception("The clipboard did not contain valid data.");
|
||||
_manager.ApplyDesign(_selector.Selected!, design);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -425,12 +427,17 @@ public class DesignPanel
|
|||
private void DrawApplyToSelf()
|
||||
{
|
||||
var (id, data) = _objects.PlayerData;
|
||||
if (!ImGuiUtil.DrawDisabledButton("Apply to Yourself", Vector2.Zero, "Apply the current design with its settings to your character.",
|
||||
if (!ImGuiUtil.DrawDisabledButton("Apply to Yourself", Vector2.Zero,
|
||||
"Apply the current design with its settings to your character.\nHold Control to only apply gear.\nHold Shift to only apply customizations.",
|
||||
!data.Valid))
|
||||
return;
|
||||
|
||||
if (_state.GetOrCreate(id, data.Objects[0], out var state))
|
||||
{
|
||||
var (applyGear, applyCustomize) = UiHelpers.ConvertKeysToFlags();
|
||||
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize);
|
||||
_state.ApplyDesign(_selector.Selected!, state, StateChanged.Source.Manual);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawApplyToTarget()
|
||||
|
|
@ -438,14 +445,18 @@ public class DesignPanel
|
|||
var (id, data) = _objects.TargetData;
|
||||
var tt = id.IsValid
|
||||
? data.Valid
|
||||
? "Apply the current design with its settings to your current target."
|
||||
? "Apply the current design with its settings to your current target.\nHold Control to only apply gear.\nHold Shift to only apply customizations."
|
||||
: "The current target can not be manipulated."
|
||||
: "No valid target selected.";
|
||||
if (!ImGuiUtil.DrawDisabledButton("Apply to Target", Vector2.Zero, tt, !data.Valid || _objects.IsInGPose))
|
||||
return;
|
||||
|
||||
if (_state.GetOrCreate(id, data.Objects[0], out var state))
|
||||
{
|
||||
var (applyGear, applyCustomize) = UiHelpers.ConvertKeysToFlags();
|
||||
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize);
|
||||
_state.ApplyDesign(_selector.Selected!, state, StateChanged.Source.Manual);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSaveToDat()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue