Add some buttons to set design application rules to some presets.

This commit is contained in:
Ottermandias 2025-03-03 17:55:38 +01:00
parent 6e685b96d1
commit b9e4c144c2
3 changed files with 119 additions and 1 deletions

View file

@ -3,6 +3,7 @@ using Glamourer.Designs.History;
using Glamourer.Designs.Links; using Glamourer.Designs.Links;
using Glamourer.Events; using Glamourer.Events;
using Glamourer.GameData; using Glamourer.GameData;
using Glamourer.Interop.Material;
using Glamourer.Interop.Penumbra; using Glamourer.Interop.Penumbra;
using Glamourer.Services; using Glamourer.Services;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -448,6 +449,39 @@ public sealed class DesignManager : DesignEditor
DesignChanged.Invoke(DesignChanged.Type.ApplyParameter, design, new ApplicationTransaction(flag, !value, value)); DesignChanged.Invoke(DesignChanged.Type.ApplyParameter, design, new ApplicationTransaction(flag, !value, value));
} }
/// <summary> Change multiple application values at once. </summary>
public void ChangeApplyMulti(Design design, bool? equipment, bool? customization, bool? bonus, bool? parameters, bool? meta, bool? stains,
bool? materials, bool? crest)
{
if (equipment is { } e)
foreach (var f in EquipSlotExtensions.FullSlots)
ChangeApplyItem(design, f, e);
if (stains is { } s)
foreach (var f in EquipSlotExtensions.FullSlots)
ChangeApplyStains(design, f, s);
if (customization is { } c)
foreach (var f in CustomizationExtensions.All.Where(design.CustomizeSet.IsAvailable).Prepend(CustomizeIndex.Clan)
.Prepend(CustomizeIndex.Gender))
ChangeApplyCustomize(design, f, c);
if (bonus is { } b)
foreach (var f in BonusExtensions.AllFlags)
ChangeApplyBonusItem(design, f, b);
if (meta is { } m)
foreach (var f in MetaExtensions.AllRelevant)
ChangeApplyMeta(design, f, m);
if (crest is { } cr)
foreach (var f in CrestExtensions.AllRelevantSet)
ChangeApplyCrest(design, f, cr);
if (parameters is { } p)
foreach (var f in CustomizeParameterExtensions.AllFlags)
ChangeApplyParameter(design, f, p);
if (materials is { } ma)
foreach (var (key, _) in design.GetMaterialData())
ChangeApplyMaterialValue(design, MaterialValueIndex.FromKey(key), ma);
}
#endregion #endregion
public void UndoDesignChange(Design design) public void UndoDesignChange(Design design)

View file

@ -44,7 +44,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
private void DrawName(MaterialValueIndex index) private void DrawName(MaterialValueIndex index)
{ {
using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0.05f, 0.5f));
ImUtf8.TextFramed(index.ToString(), 0, new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0), ImUtf8.TextFramed(index.ToString(), 0, new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0),
borderColor: ImGui.GetColorU32(ImGuiCol.Text)); borderColor: ImGui.GetColorU32(ImGuiCol.Text));
} }

View file

@ -254,6 +254,8 @@ public class DesignPanel
using var disabled = ImRaii.Disabled(_selector.Selected!.WriteProtected()); using var disabled = ImRaii.Disabled(_selector.Selected!.WriteProtected());
DrawAllButtons();
using (var _ = ImUtf8.Group()) using (var _ = ImUtf8.Group())
{ {
DrawCustomizeApplication(); DrawCustomizeApplication();
@ -310,6 +312,88 @@ public class DesignPanel
} }
} }
private void DrawAllButtons()
{
var enabled = _config.DeleteDesignModifier.IsActive();
bool? equip = null;
bool? customize = null;
var size = new Vector2(200 * ImUtf8.GlobalScale, 0);
if (ImUtf8.ButtonEx("Disable Everything"u8,
"Disable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness."u8, size,
!enabled))
{
equip = false;
customize = false;
}
if (!enabled)
ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking.");
ImGui.SameLine();
if (ImUtf8.ButtonEx("Enable Everything"u8,
"Enable application of everything, including any existing advanced dyes, advanced customizations, crests and wetness."u8, size,
!enabled))
{
equip = true;
customize = true;
}
if (!enabled)
ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking.");
if (ImUtf8.ButtonEx("Equipment Only"u8,
"Enable application of anything related to gear, disable anything that is not related to gear."u8, size,
!enabled))
{
equip = true;
customize = false;
}
if (!enabled)
ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking.");
ImGui.SameLine();
if (ImUtf8.ButtonEx("Customization Only"u8,
"Enable application of anything related to customization, disable anything that is not related to customization."u8, size,
!enabled))
{
equip = false;
customize = true;
}
if (ImUtf8.ButtonEx("Default Application"u8,
"Set the application rules to the default values as if the design was newly created, without any advanced features or wetness."u8,
size,
!enabled))
{
_manager.ChangeApplyMulti(_selector.Selected!, true, true, true, false, true, true, false, true);
_manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.Wetness, false);
}
ImGui.SameLine();
if (ImUtf8.ButtonEx("Disable Advanced"u8, "Disable all advanced dyes and customizations but keep everything else as is."u8,
size,
!enabled))
_manager.ChangeApplyMulti(_selector.Selected!, null, null, null, false, null, null, false, null);
if (!enabled)
ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteDesignModifier} while clicking.");
if (equip is null && customize is null)
return;
_manager.ChangeApplyMulti(_selector.Selected!, equip, customize, equip, customize, null, equip, equip, equip);
if (equip.HasValue)
{
_manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.HatState, equip.Value);
_manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.VisorState, equip.Value);
_manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.WeaponState, equip.Value);
}
if (customize.HasValue)
_manager.ChangeApplyMeta(_selector.Selected!, MetaIndex.Wetness, customize.Value);
}
private static readonly IReadOnlyList<string> MetaLabels = private static readonly IReadOnlyList<string> MetaLabels =
[ [
"Apply Wetness", "Apply Wetness",