mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Fix PR.
This commit is contained in:
parent
ef96dadba5
commit
cca2bf645f
13 changed files with 65 additions and 64 deletions
|
|
@ -287,8 +287,7 @@ public sealed class AutoDesignApplier : IDisposable
|
||||||
set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))),
|
set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design.AllLinks.Select(l => (l.Design, l.Flags & d.Type, d.Jobs.Flags))),
|
||||||
state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods);
|
state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods);
|
||||||
|
|
||||||
var resetMaterials = mergedDesign.ResetMaterials;
|
_state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, false));
|
||||||
_state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, resetMaterials));
|
|
||||||
forcedRedraw = mergedDesign.ForcedRedraw;
|
forcedRedraw = mergedDesign.ForcedRedraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,19 +37,19 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
// Metadata
|
// Metadata
|
||||||
public new const int FileVersion = 2;
|
public new const int FileVersion = 2;
|
||||||
|
|
||||||
public Guid Identifier { get; internal init; }
|
public Guid Identifier { get; internal init; }
|
||||||
public DateTimeOffset CreationDate { get; internal init; }
|
public DateTimeOffset CreationDate { get; internal init; }
|
||||||
public DateTimeOffset LastEdit { get; internal set; }
|
public DateTimeOffset LastEdit { get; internal set; }
|
||||||
public LowerString Name { get; internal set; } = LowerString.Empty;
|
public LowerString Name { get; internal set; } = LowerString.Empty;
|
||||||
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 ForcedRedraw { get; internal set; }
|
||||||
public bool ResetMaterials { get; internal set; }
|
public bool ResetAdvancedDyes { 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; } = [];
|
||||||
public LinkContainer Links { get; private set; } = [];
|
public LinkContainer Links { get; private set; } = [];
|
||||||
|
|
||||||
public string Incognito
|
public string Incognito
|
||||||
=> Identifier.ToString()[..8];
|
=> Identifier.ToString()[..8];
|
||||||
|
|
@ -96,25 +96,25 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
{
|
{
|
||||||
var ret = new JObject()
|
var ret = new JObject()
|
||||||
{
|
{
|
||||||
["FileVersion"] = FileVersion,
|
["FileVersion"] = FileVersion,
|
||||||
["Identifier"] = Identifier,
|
["Identifier"] = Identifier,
|
||||||
["CreationDate"] = CreationDate,
|
["CreationDate"] = CreationDate,
|
||||||
["LastEdit"] = LastEdit,
|
["LastEdit"] = LastEdit,
|
||||||
["Name"] = Name.Text,
|
["Name"] = Name.Text,
|
||||||
["Description"] = Description,
|
["Description"] = Description,
|
||||||
["ForcedRedraw"] = ForcedRedraw,
|
["ForcedRedraw"] = ForcedRedraw,
|
||||||
["ResetMaterials"] = ResetMaterials,
|
["ResetAdvancedDyes"] = ResetAdvancedDyes,
|
||||||
["Color"] = Color,
|
["Color"] = Color,
|
||||||
["QuickDesign"] = QuickDesign,
|
["QuickDesign"] = QuickDesign,
|
||||||
["Tags"] = JArray.FromObject(Tags),
|
["Tags"] = JArray.FromObject(Tags),
|
||||||
["WriteProtected"] = WriteProtected(),
|
["WriteProtected"] = WriteProtected(),
|
||||||
["Equipment"] = SerializeEquipment(),
|
["Equipment"] = SerializeEquipment(),
|
||||||
["Bonus"] = SerializeBonusItems(),
|
["Bonus"] = SerializeBonusItems(),
|
||||||
["Customize"] = SerializeCustomize(),
|
["Customize"] = SerializeCustomize(),
|
||||||
["Parameters"] = SerializeParameters(),
|
["Parameters"] = SerializeParameters(),
|
||||||
["Materials"] = SerializeMaterials(),
|
["Materials"] = SerializeMaterials(),
|
||||||
["Mods"] = SerializeMods(),
|
["Mods"] = SerializeMods(),
|
||||||
["Links"] = Links.Serialize(),
|
["Links"] = Links.Serialize(),
|
||||||
};
|
};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +146,8 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
|
|
||||||
#region Deserialization
|
#region Deserialization
|
||||||
|
|
||||||
public static Design LoadDesign(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json)
|
public static Design LoadDesign(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader,
|
||||||
|
JObject json)
|
||||||
{
|
{
|
||||||
var version = json["FileVersion"]?.ToObject<int>() ?? 0;
|
var version = json["FileVersion"]?.ToObject<int>() ?? 0;
|
||||||
return version switch
|
return version switch
|
||||||
|
|
@ -158,7 +159,8 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> The values for gloss and specular strength were switched. Swap them for all appropriate designs. </summary>
|
/// <summary> The values for gloss and specular strength were switched. Swap them for all appropriate designs. </summary>
|
||||||
private static Design LoadDesignV1(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader, JObject json)
|
private static Design LoadDesignV1(SaveService saveService, CustomizeService customizations, ItemManager items, DesignLinkLoader linkLoader,
|
||||||
|
JObject json)
|
||||||
{
|
{
|
||||||
var design = LoadDesignV2(customizations, items, linkLoader, json);
|
var design = LoadDesignV2(customizations, items, linkLoader, json);
|
||||||
var materialDesignData = design.GetMaterialDataRef();
|
var materialDesignData = design.GetMaterialDataRef();
|
||||||
|
|
@ -216,7 +218,7 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
|
||||||
Glamourer.Messager.AddMessage(new Notification(
|
Glamourer.Messager.AddMessage(new Notification(
|
||||||
$"Swapped Gloss and Specular Strength in {materialDesignData.Values.Count} Rows in design {design.Incognito} {reason}",
|
$"Swapped Gloss and Specular Strength in {materialDesignData.Values.Count} Rows in design {design.Incognito} {reason}",
|
||||||
NotificationType.Info));
|
NotificationType.Info));
|
||||||
saveService.Save(SaveType.ImmediateSync,design);
|
saveService.Save(SaveType.ImmediateSync, design);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,9 +246,9 @@ 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;
|
design.ForcedRedraw = json["ForcedRedraw"]?.ToObject<bool>() ?? false;
|
||||||
design.ResetMaterials = json["ResetMaterials"]?.ToObject<bool>() ?? false;
|
design.ResetAdvancedDyes = json["ResetAdvancedDyes"]?.ToObject<bool>() ?? false;
|
||||||
return design;
|
return design;
|
||||||
|
|
||||||
static string[] ParseTags(JObject json)
|
static string[] ParseTags(JObject json)
|
||||||
|
|
|
||||||
|
|
@ -304,8 +304,8 @@ public class DesignEditor(
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void ApplyDesign(object data, MergedDesign other, ApplySettings _ = default)
|
public void ApplyDesign(object data, MergedDesign other, ApplySettings settings = default)
|
||||||
=> ApplyDesign(data, other.Design);
|
=> ApplyDesign(data, other.Design, settings);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void ApplyDesign(object data, DesignBase other, ApplySettings _ = default)
|
public void ApplyDesign(object data, DesignBase other, ApplySettings _ = default)
|
||||||
|
|
|
||||||
|
|
@ -334,15 +334,15 @@ public sealed class DesignManager : DesignEditor
|
||||||
DesignChanged.Invoke(DesignChanged.Type.ForceRedraw, design, null);
|
DesignChanged.Invoke(DesignChanged.Type.ForceRedraw, design, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeResetMaterials(Design design, bool resetMaterials)
|
public void ChangeResetAdvancedDyes(Design design, bool resetAdvancedDyes)
|
||||||
{
|
{
|
||||||
if (design.ResetMaterials == resetMaterials)
|
if (design.ResetAdvancedDyes == resetAdvancedDyes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
design.ResetMaterials = resetMaterials;
|
design.ResetAdvancedDyes = resetAdvancedDyes;
|
||||||
SaveService.QueueSave(design);
|
SaveService.QueueSave(design);
|
||||||
Glamourer.Log.Debug($"Set {design.Identifier} to {(resetMaterials ? "not" : string.Empty)} reset materials.");
|
Glamourer.Log.Debug($"Set {design.Identifier} to {(resetAdvancedDyes ? "not" : string.Empty)} reset advanced dyes.");
|
||||||
DesignChanged.Invoke(DesignChanged.Type.ResetMaterials, design, null);
|
DesignChanged.Invoke(DesignChanged.Type.ResetAdvancedDyes, design, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Change whether to apply a specific customize value. </summary>
|
/// <summary> Change whether to apply a specific customize value. </summary>
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,5 @@ public interface IDesignStandIn : IEquatable<IDesignStandIn>
|
||||||
|
|
||||||
public bool ForcedRedraw { get; }
|
public bool ForcedRedraw { get; }
|
||||||
|
|
||||||
public bool ResetMaterials { get; }
|
public bool ResetAdvancedDyes { get; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ public class DesignMerger(
|
||||||
ReduceMaterials(design, ret);
|
ReduceMaterials(design, ret);
|
||||||
if (design.ForcedRedraw)
|
if (design.ForcedRedraw)
|
||||||
ret.ForcedRedraw = true;
|
ret.ForcedRedraw = true;
|
||||||
if (design.ResetMaterials)
|
if (design.ResetAdvancedDyes)
|
||||||
ret.ResetMaterials = true;
|
ret.ResetAdvancedDyes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyFixFlags(ret, fixFlags);
|
ApplyFixFlags(ret, fixFlags);
|
||||||
|
|
|
||||||
|
|
@ -100,5 +100,5 @@ public sealed class MergedDesign
|
||||||
public readonly SortedList<Mod, ModSettings> AssociatedMods = [];
|
public readonly SortedList<Mod, ModSettings> AssociatedMods = [];
|
||||||
public StateSources Sources = new();
|
public StateSources Sources = new();
|
||||||
public bool ForcedRedraw;
|
public bool ForcedRedraw;
|
||||||
public bool ResetMaterials;
|
public bool ResetAdvancedDyes;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,6 @@ public class QuickSelectedDesign(QuickDesignCombo combo) : IDesignStandIn, IServ
|
||||||
public bool ForcedRedraw
|
public bool ForcedRedraw
|
||||||
=> combo.Design?.ForcedRedraw ?? false;
|
=> combo.Design?.ForcedRedraw ?? false;
|
||||||
|
|
||||||
public bool ResetMaterials
|
public bool ResetAdvancedDyes
|
||||||
=> combo.Design?.ResetMaterials ?? false;
|
=> combo.Design?.ResetAdvancedDyes ?? false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,6 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
||||||
public bool ForcedRedraw
|
public bool ForcedRedraw
|
||||||
=> false;
|
=> false;
|
||||||
|
|
||||||
public bool ResetMaterials
|
public bool ResetAdvancedDyes
|
||||||
=> false;
|
=> false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,6 @@ public class RevertDesign : IDesignStandIn
|
||||||
public bool ForcedRedraw
|
public bool ForcedRedraw
|
||||||
=> false;
|
=> false;
|
||||||
|
|
||||||
public bool ResetMaterials
|
public bool ResetAdvancedDyes
|
||||||
=> false;
|
=> true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,8 @@ public sealed class DesignChanged()
|
||||||
/// <summary> An existing design had changed whether it always forces a redraw or not. </summary>
|
/// <summary> An existing design had changed whether it always forces a redraw or not. </summary>
|
||||||
ForceRedraw,
|
ForceRedraw,
|
||||||
|
|
||||||
/// <summary> An existing design had changed whether it always reset materials or not. </summary>
|
/// <summary> An existing design had changed whether it always resets advanced dyes or not. </summary>
|
||||||
ResetMaterials,
|
ResetAdvancedDyes,
|
||||||
|
|
||||||
/// <summary> An existing design changed whether a specific customization is applied. </summary>
|
/// <summary> An existing design changed whether a specific customization is applied. </summary>
|
||||||
ApplyCustomize,
|
ApplyCustomize,
|
||||||
|
|
|
||||||
|
|
@ -143,12 +143,12 @@ public class DesignDetailTab
|
||||||
_manager.ChangeForcedRedraw(_selector.Selected!, forceRedraw);
|
_manager.ChangeForcedRedraw(_selector.Selected!, forceRedraw);
|
||||||
ImGuiUtil.HoverTooltip("Set this design to always force a redraw when it is applied through any means.");
|
ImGuiUtil.HoverTooltip("Set this design to always force a redraw when it is applied through any means.");
|
||||||
|
|
||||||
var resetMaterials = _selector.Selected!.ResetMaterials;
|
var resetMaterials = _selector.Selected!.ResetAdvancedDyes;
|
||||||
ImGuiUtil.DrawFrameColumn("Reset Materials");
|
ImGuiUtil.DrawFrameColumn("Reset Advanced Dyes");
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (ImGui.Checkbox("##ResetMaterials", ref resetMaterials))
|
if (ImGui.Checkbox("##ResetAdvancedDyes", ref resetMaterials))
|
||||||
_manager.ChangeResetMaterials(_selector.Selected!, resetMaterials);
|
_manager.ChangeResetAdvancedDyes(_selector.Selected!, resetMaterials);
|
||||||
ImGuiUtil.HoverTooltip("Set this design to reset materials when it is applied through any means.");
|
ImGuiUtil.HoverTooltip("Set this design to reset any previously applied advanced dyes 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;
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ public class StateEditor(
|
||||||
Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key);
|
Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.ResetMaterials)
|
if (settings.ResetMaterials || mergedDesign.ResetAdvancedDyes)
|
||||||
state.Materials.Clear();
|
state.Materials.Clear();
|
||||||
|
|
||||||
foreach (var (key, value) in mergedDesign.Design.Materials)
|
foreach (var (key, value) in mergedDesign.Design.Materials)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue