mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-01-02 13:53:42 +01:00
Add an option for designs to always force a redraw.
This commit is contained in:
parent
86c871fa81
commit
2713e6f1f6
11 changed files with 52 additions and 6 deletions
|
|
@ -43,6 +43,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
public string Description { get; internal set; } = string.Empty;
|
public string Description { get; internal set; } = string.Empty;
|
||||||
public string[] Tags { get; internal set; } = [];
|
public string[] Tags { get; internal set; } = [];
|
||||||
public int Index { get; internal set; }
|
public int Index { get; internal set; }
|
||||||
|
public bool ForcedRedraw { get; internal set; }
|
||||||
public bool QuickDesign { get; internal set; } = true;
|
public bool QuickDesign { get; internal set; } = true;
|
||||||
public string Color { get; internal set; } = string.Empty;
|
public string Color { get; internal set; } = string.Empty;
|
||||||
public SortedList<Mod, ModSettings> AssociatedMods { get; private set; } = [];
|
public SortedList<Mod, ModSettings> AssociatedMods { get; private set; } = [];
|
||||||
|
|
@ -99,6 +100,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
["LastEdit"] = LastEdit,
|
["LastEdit"] = LastEdit,
|
||||||
["Name"] = Name.Text,
|
["Name"] = Name.Text,
|
||||||
["Description"] = Description,
|
["Description"] = Description,
|
||||||
|
["ForcedRedraw"] = ForcedRedraw,
|
||||||
["Color"] = Color,
|
["Color"] = Color,
|
||||||
["QuickDesign"] = QuickDesign,
|
["QuickDesign"] = QuickDesign,
|
||||||
["Tags"] = JArray.FromObject(Tags),
|
["Tags"] = JArray.FromObject(Tags),
|
||||||
|
|
@ -173,7 +175,8 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
LoadParameters(json["Parameters"], design, design.Name);
|
LoadParameters(json["Parameters"], design, design.Name);
|
||||||
LoadMaterials(json["Materials"], design, design.Name);
|
LoadMaterials(json["Materials"], design, design.Name);
|
||||||
LoadLinks(linkLoader, json["Links"], design);
|
LoadLinks(linkLoader, json["Links"], design);
|
||||||
design.Color = json["Color"]?.ToObject<string>() ?? string.Empty;
|
design.Color = json["Color"]?.ToObject<string>() ?? string.Empty;
|
||||||
|
design.ForcedRedraw = json["ForcedRedraw"]?.ToObject<bool>() ?? false;
|
||||||
return design;
|
return design;
|
||||||
|
|
||||||
static string[] ParseTags(JObject json)
|
static string[] ParseTags(JObject json)
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ public sealed class DesignManager : DesignEditor
|
||||||
DesignChanged.Invoke(DesignChanged.Type.ChangedDescription, design, oldDescription);
|
DesignChanged.Invoke(DesignChanged.Type.ChangedDescription, design, oldDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Change the associated color of a design. </summary>
|
||||||
public void ChangeColor(Design design, string newColor)
|
public void ChangeColor(Design design, string newColor)
|
||||||
{
|
{
|
||||||
var oldColor = design.Color;
|
var oldColor = design.Color;
|
||||||
|
|
@ -311,6 +312,17 @@ public sealed class DesignManager : DesignEditor
|
||||||
|
|
||||||
#region Edit Application Rules
|
#region Edit Application Rules
|
||||||
|
|
||||||
|
public void ChangeForcedRedraw(Design design, bool forcedRedraw)
|
||||||
|
{
|
||||||
|
if (design.ForcedRedraw == forcedRedraw)
|
||||||
|
return;
|
||||||
|
|
||||||
|
design.ForcedRedraw = forcedRedraw;
|
||||||
|
SaveService.QueueSave(design);
|
||||||
|
Glamourer.Log.Debug($"Set {design.Identifier} to {(forcedRedraw ? "not" : string.Empty)} force redraws.");
|
||||||
|
DesignChanged.Invoke(DesignChanged.Type.ForceRedraw, design, null);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Change whether to apply a specific customize value. </summary>
|
/// <summary> Change whether to apply a specific customize value. </summary>
|
||||||
public void ChangeApplyCustomize(Design design, CustomizeIndex idx, bool value)
|
public void ChangeApplyCustomize(Design design, CustomizeIndex idx, bool value)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,6 @@ public interface IDesignStandIn : IEquatable<IDesignStandIn>
|
||||||
public void ParseData(JObject jObj);
|
public void ParseData(JObject jObj);
|
||||||
|
|
||||||
public bool ChangeData(object data);
|
public bool ChangeData(object data);
|
||||||
|
|
||||||
|
public bool ForcedRedraw { get; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,11 @@ public class DesignMerger(
|
||||||
{
|
{
|
||||||
public MergedDesign Merge(LinkContainer designs, in CustomizeArray currentCustomize, in DesignData baseRef, bool respectOwnership,
|
public MergedDesign Merge(LinkContainer designs, in CustomizeArray currentCustomize, in DesignData baseRef, bool respectOwnership,
|
||||||
bool modAssociations)
|
bool modAssociations)
|
||||||
=> Merge(designs.Select(d => ((IDesignStandIn)d.Link, d.Type, JobFlag.All)), currentCustomize, baseRef, respectOwnership, modAssociations);
|
=> Merge(designs.Select(d => ((IDesignStandIn)d.Link, d.Type, JobFlag.All)), currentCustomize, baseRef, respectOwnership,
|
||||||
|
modAssociations);
|
||||||
|
|
||||||
public MergedDesign Merge(IEnumerable<(IDesignStandIn, ApplicationType, JobFlag)> designs, in CustomizeArray currentCustomize, in DesignData baseRef,
|
public MergedDesign Merge(IEnumerable<(IDesignStandIn, ApplicationType, JobFlag)> designs, in CustomizeArray currentCustomize,
|
||||||
|
in DesignData baseRef,
|
||||||
bool respectOwnership, bool modAssociations)
|
bool respectOwnership, bool modAssociations)
|
||||||
{
|
{
|
||||||
var ret = new MergedDesign(designManager);
|
var ret = new MergedDesign(designManager);
|
||||||
|
|
@ -51,6 +53,8 @@ public class DesignMerger(
|
||||||
ReduceMods(design as Design, ret, modAssociations);
|
ReduceMods(design as Design, ret, modAssociations);
|
||||||
if (type.HasFlag(ApplicationType.GearCustomization))
|
if (type.HasFlag(ApplicationType.GearCustomization))
|
||||||
ReduceMaterials(design, ret);
|
ReduceMaterials(design, ret);
|
||||||
|
if (design.ForcedRedraw)
|
||||||
|
ret.ForcedRedraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyFixFlags(ret, fixFlags);
|
ApplyFixFlags(ret, fixFlags);
|
||||||
|
|
@ -189,7 +193,8 @@ public class DesignMerger(
|
||||||
ret.Weapons.TryAdd(weapon.Type, weapon, source, allowedJobs);
|
ret.Weapons.TryAdd(weapon.Type, weapon, source, allowedJobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReduceOffhands(in DesignData design, JobFlag allowedJobs, EquipFlag equipFlags, MergedDesign ret, StateSource source, bool respectOwnership)
|
private void ReduceOffhands(in DesignData design, JobFlag allowedJobs, EquipFlag equipFlags, MergedDesign ret, StateSource source,
|
||||||
|
bool respectOwnership)
|
||||||
{
|
{
|
||||||
if (!equipFlags.HasFlag(EquipFlag.Offhand))
|
if (!equipFlags.HasFlag(EquipFlag.Offhand))
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,8 @@ public sealed class MergedDesign
|
||||||
if (weapon.Valid)
|
if (weapon.Valid)
|
||||||
Weapons.TryAdd(weapon.Type, weapon, StateSource.Manual, JobFlag.All);
|
Weapons.TryAdd(weapon.Type, weapon, StateSource.Manual, JobFlag.All);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ForcedRedraw = design is IDesignStandIn { ForcedRedraw: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
public MergedDesign(Design design)
|
public MergedDesign(Design design)
|
||||||
|
|
@ -101,4 +103,5 @@ public sealed class MergedDesign
|
||||||
public readonly WeaponList Weapons = new();
|
public readonly WeaponList Weapons = new();
|
||||||
public readonly SortedList<Mod, ModSettings> AssociatedMods = [];
|
public readonly SortedList<Mod, ModSettings> AssociatedMods = [];
|
||||||
public StateSources Sources = new();
|
public StateSources Sources = new();
|
||||||
|
public bool ForcedRedraw;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,7 @@ public class QuickSelectedDesign(QuickDesignCombo combo) : IDesignStandIn, IServ
|
||||||
|
|
||||||
public bool ChangeData(object data)
|
public bool ChangeData(object data)
|
||||||
=> false;
|
=> false;
|
||||||
|
|
||||||
|
public bool ForcedRedraw
|
||||||
|
=> combo.Design?.ForcedRedraw ?? false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,4 +78,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
||||||
Predicates = predicates;
|
Predicates = predicates;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ForcedRedraw
|
||||||
|
=> false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,4 +42,7 @@ public class RevertDesign : IDesignStandIn
|
||||||
|
|
||||||
public bool ChangeData(object data)
|
public bool ChangeData(object data)
|
||||||
=> false;
|
=> false;
|
||||||
|
|
||||||
|
public bool ForcedRedraw
|
||||||
|
=> false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,9 @@ public sealed class DesignChanged()
|
||||||
/// <summary> An existing design had an advanced dye rows Revert state changed. Data is the index [MaterialValueIndex]. </summary>
|
/// <summary> An existing design had an advanced dye rows Revert state changed. Data is the index [MaterialValueIndex]. </summary>
|
||||||
MaterialRevert,
|
MaterialRevert,
|
||||||
|
|
||||||
|
/// <summary> An existing design had changed whether it always forces a redraw or not. </summary>
|
||||||
|
ForceRedraw,
|
||||||
|
|
||||||
/// <summary> An existing design changed whether a specific customization is applied. Data is the type of customization [CustomizeIndex]. </summary>
|
/// <summary> An existing design changed whether a specific customization is applied. Data is the type of customization [CustomizeIndex]. </summary>
|
||||||
ApplyCustomize,
|
ApplyCustomize,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,13 @@ public class DesignDetailTab
|
||||||
if (hovered || ImGui.IsItemHovered())
|
if (hovered || ImGui.IsItemHovered())
|
||||||
ImGui.SetTooltip("Display or hide this design in your quick design bar.");
|
ImGui.SetTooltip("Display or hide this design in your quick design bar.");
|
||||||
|
|
||||||
|
var forceRedraw = _selector.Selected!.ForcedRedraw;
|
||||||
|
ImGuiUtil.DrawFrameColumn("Force Redrawing");
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
if (ImGui.Checkbox("##ForceRedraw", ref forceRedraw))
|
||||||
|
_manager.ChangeForcedRedraw(_selector.Selected!, forceRedraw);
|
||||||
|
ImGuiUtil.HoverTooltip("Set this design to always force a redraw when it is applied through any means.");
|
||||||
|
|
||||||
ImGuiUtil.DrawFrameColumn("Color");
|
ImGuiUtil.DrawFrameColumn("Color");
|
||||||
var colorName = _selector.Selected!.Color.Length == 0 ? DesignColors.AutomaticName : _selector.Selected!.Color;
|
var colorName = _selector.Selected!.Color.Length == 0 ? DesignColors.AutomaticName : _selector.Selected!.Color;
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,9 @@ public class StateEditor(
|
||||||
mergedDesign.Design.GetDesignDataRef().GetEquipmentPtr(), settings.Source, out var oldModelId, settings.Key))
|
mergedDesign.Design.GetDesignDataRef().GetEquipmentPtr(), settings.Source, out var oldModelId, settings.Key))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var requiresRedraw = oldModelId != mergedDesign.Design.DesignData.ModelId || !mergedDesign.Design.DesignData.IsHuman;
|
var requiresRedraw = mergedDesign.ForcedRedraw
|
||||||
|
|| oldModelId != mergedDesign.Design.DesignData.ModelId
|
||||||
|
|| !mergedDesign.Design.DesignData.IsHuman;
|
||||||
|
|
||||||
if (state.ModelData.IsHuman)
|
if (state.ModelData.IsHuman)
|
||||||
{
|
{
|
||||||
|
|
@ -402,6 +404,6 @@ public class StateEditor(
|
||||||
|
|
||||||
if (mh is { Type: FullEquipType.Fists } && Items.ItemData.Tertiary.TryGetValue(mh.ItemId, out var gauntlets))
|
if (mh is { Type: FullEquipType.Fists } && Items.ItemData.Tertiary.TryGetValue(mh.ItemId, out var gauntlets))
|
||||||
ChangeEquip(state, EquipSlot.Hands, newMainhand != null ? gauntlets : state.ModelData.Item(EquipSlot.Hands),
|
ChangeEquip(state, EquipSlot.Hands, newMainhand != null ? gauntlets : state.ModelData.Item(EquipSlot.Hands),
|
||||||
stain, settings);
|
stain, settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue