mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Some more changes regarding unavailable customization options.
This commit is contained in:
parent
8e881ceba1
commit
59e75b2346
7 changed files with 48 additions and 22 deletions
|
|
@ -49,7 +49,12 @@ public static class CustomizeFlagExtensions
|
|||
{
|
||||
public const CustomizeFlag All = (CustomizeFlag)(((ulong)CustomizeFlag.FacePaintColor << 1) - 1ul);
|
||||
public const CustomizeFlag AllRelevant = All & ~CustomizeFlag.BodyType & ~CustomizeFlag.Race;
|
||||
public const CustomizeFlag RedrawRequired = CustomizeFlag.Race | CustomizeFlag.Clan | CustomizeFlag.Gender | CustomizeFlag.Face | CustomizeFlag.BodyType;
|
||||
|
||||
public const CustomizeFlag RedrawRequired =
|
||||
CustomizeFlag.Race | CustomizeFlag.Clan | CustomizeFlag.Gender | CustomizeFlag.Face | CustomizeFlag.BodyType;
|
||||
|
||||
public static CustomizeFlag FixApplication(this CustomizeFlag flag, CustomizationSet set)
|
||||
=> flag & (set.SettingAvailable | CustomizeFlag.Clan | CustomizeFlag.Gender);
|
||||
|
||||
public static bool RequiresRedraw(this CustomizeFlag flags)
|
||||
=> (flags & RedrawRequired) != 0;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ namespace Glamourer.Designs;
|
|||
public sealed class Design : DesignBase, ISavable
|
||||
{
|
||||
#region Data
|
||||
internal Design(ItemManager items)
|
||||
: base(items)
|
||||
internal Design(CustomizationService customize, ItemManager items)
|
||||
: base(customize, items)
|
||||
{ }
|
||||
|
||||
internal Design(DesignBase other)
|
||||
|
|
@ -116,7 +116,7 @@ public sealed class Design : DesignBase, ISavable
|
|||
|
||||
var creationDate = json["CreationDate"]?.ToObject<DateTimeOffset>() ?? throw new ArgumentNullException("CreationDate");
|
||||
|
||||
var design = new Design(items)
|
||||
var design = new Design(customizations, items)
|
||||
{
|
||||
CreationDate = creationDate,
|
||||
Identifier = json["Identifier"]?.ToObject<Guid>() ?? throw new ArgumentNullException("Identifier"),
|
||||
|
|
|
|||
|
|
@ -16,15 +16,16 @@ public class DesignBase
|
|||
{
|
||||
public const int FileVersion = 1;
|
||||
|
||||
internal DesignBase(ItemManager items)
|
||||
internal DesignBase(CustomizationService customize, ItemManager items)
|
||||
{
|
||||
DesignData.SetDefaultEquipment(items);
|
||||
FixCustomizeApplication(customize);
|
||||
}
|
||||
|
||||
internal DesignBase(DesignBase clone)
|
||||
{
|
||||
DesignData = clone.DesignData;
|
||||
ApplyCustomize = clone.ApplyCustomize & CustomizeFlagExtensions.All;
|
||||
ApplyCustomize = clone.ApplyCustomize & CustomizeFlagExtensions.AllRelevant;
|
||||
ApplyEquip = clone.ApplyEquip & EquipFlagExtensions.All;
|
||||
_designFlags = clone._designFlags & (DesignFlags)0x0F;
|
||||
}
|
||||
|
|
@ -43,7 +44,7 @@ public class DesignBase
|
|||
WriteProtected = 0x10,
|
||||
}
|
||||
|
||||
internal CustomizeFlag ApplyCustomize = CustomizeFlagExtensions.All;
|
||||
internal CustomizeFlag ApplyCustomize = CustomizeFlagExtensions.AllRelevant;
|
||||
internal EquipFlag ApplyEquip = EquipFlagExtensions.All;
|
||||
private DesignFlags _designFlags = DesignFlags.ApplyHatVisible | DesignFlags.ApplyVisorState | DesignFlags.ApplyWeaponVisible;
|
||||
|
||||
|
|
@ -151,6 +152,18 @@ public class DesignBase
|
|||
return true;
|
||||
}
|
||||
|
||||
public void FixCustomizeApplication(CustomizationService service)
|
||||
=> FixCustomizeApplication(service, ApplyCustomize);
|
||||
|
||||
public void FixCustomizeApplication(CustomizationSet set)
|
||||
=> FixCustomizeApplication(set, ApplyCustomize);
|
||||
|
||||
public void FixCustomizeApplication(CustomizationService service, CustomizeFlag flags)
|
||||
=> FixCustomizeApplication(service.AwaitedService.GetList(DesignData.Customize.Clan, DesignData.Customize.Gender), flags);
|
||||
|
||||
public void FixCustomizeApplication(CustomizationSet set, CustomizeFlag flags)
|
||||
=> ApplyCustomize = flags.FixApplication(set);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Serialization
|
||||
|
|
@ -244,7 +257,7 @@ public class DesignBase
|
|||
|
||||
private static DesignBase LoadDesignV1Base(CustomizationService customizations, ItemManager items, JObject json)
|
||||
{
|
||||
var ret = new DesignBase(items);
|
||||
var ret = new DesignBase(customizations, items);
|
||||
LoadCustomize(customizations, json["Customize"], ret, "Temporary Design", false, true);
|
||||
LoadEquip(items, json["Equipment"], ret, "Temporary Design", true);
|
||||
return ret;
|
||||
|
|
@ -398,7 +411,7 @@ public class DesignBase
|
|||
}
|
||||
}
|
||||
|
||||
design.ApplyCustomize &= set.SettingAvailable | CustomizeFlag.Gender | CustomizeFlag.Clan;
|
||||
design.FixCustomizeApplication(set);
|
||||
}
|
||||
|
||||
public void MigrateBase64(ItemManager items, HumanModelList humans, string base64)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class DesignConverter
|
|||
{
|
||||
var design = _designs.CreateTemporary();
|
||||
design.ApplyEquip = equipFlags & EquipFlagExtensions.All;
|
||||
design.ApplyCustomize = customizeFlags & CustomizeFlagExtensions.All;
|
||||
design.FixCustomizeApplication(_customize, customizeFlags);
|
||||
design.SetApplyHatVisible(design.DoApplyEquip(EquipSlot.Head));
|
||||
design.SetApplyVisorToggle(design.DoApplyEquip(EquipSlot.Head));
|
||||
design.SetApplyWeaponVisible(design.DoApplyEquip(EquipSlot.MainHand) || design.DoApplyEquip(EquipSlot.OffHand));
|
||||
|
|
@ -127,6 +127,10 @@ public class DesignConverter
|
|||
ret.ApplyCustomize = 0;
|
||||
ret.SetApplyWetness(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.FixCustomizeApplication(_customize);
|
||||
}
|
||||
|
||||
if (!equip)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ public class DesignManager
|
|||
|
||||
/// <summary> Create a new temporary design without adding it to the manager. </summary>
|
||||
public DesignBase CreateTemporary()
|
||||
=> new(_items);
|
||||
=> new(_customizations, _items);
|
||||
|
||||
/// <summary> Create a new design of a given name. </summary>
|
||||
public Design CreateEmpty(string name, bool handlePath)
|
||||
{
|
||||
var (actualName, path) = ParseName(name, handlePath);
|
||||
var design = new Design(_items)
|
||||
var design = new Design(_customizations, _items)
|
||||
{
|
||||
CreationDate = DateTimeOffset.UtcNow,
|
||||
LastEdit = DateTimeOffset.UtcNow,
|
||||
|
|
@ -522,7 +522,7 @@ public class DesignManager
|
|||
try
|
||||
{
|
||||
var actualName = Path.GetFileName(name);
|
||||
var design = new Design(_items)
|
||||
var design = new Design(_customizations, _items)
|
||||
{
|
||||
CreationDate = File.GetCreationTimeUtc(_saveService.FileNames.MigrationDesignFile),
|
||||
LastEdit = File.GetLastWriteTimeUtc(_saveService.FileNames.MigrationDesignFile),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Linq;
|
||||
using Dalamud.Interface;
|
||||
using Glamourer.Automation;
|
||||
using Glamourer.Customization;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Events;
|
||||
using Glamourer.Services;
|
||||
|
|
@ -22,8 +23,8 @@ public sealed class DesignCombo : FilterComboCache<(Design, string)>
|
|||
private float _innerWidth;
|
||||
|
||||
public DesignCombo(AutoDesignManager manager, DesignManager designs, DesignFileSystem fileSystem, TabSelected tabSelected,
|
||||
ItemManager items)
|
||||
: this(manager, designs, fileSystem, tabSelected, CreateRevertDesign(items))
|
||||
ItemManager items, CustomizationService customize)
|
||||
: this(manager, designs, fileSystem, tabSelected, CreateRevertDesign(customize, items))
|
||||
{ }
|
||||
|
||||
private DesignCombo(AutoDesignManager manager, DesignManager designs, DesignFileSystem fileSystem, TabSelected tabSelected,
|
||||
|
|
@ -97,10 +98,11 @@ public sealed class DesignCombo : FilterComboCache<(Design, string)>
|
|||
return filter.IsContained(path) || design.Name.Lower.Contains(filter.Lower);
|
||||
}
|
||||
|
||||
private static Design CreateRevertDesign(ItemManager items)
|
||||
=> new(items)
|
||||
private static Design CreateRevertDesign(CustomizationService customize, ItemManager items)
|
||||
=> new(customize, items)
|
||||
{
|
||||
Index = RevertDesignIndex,
|
||||
Name = AutoDesign.RevertName,
|
||||
ApplyCustomize = CustomizeFlagExtensions.AllRelevant,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ public sealed class CustomizationService : AsyncServiceWrapper<ICustomizationMan
|
|||
applied |= CustomizeFlag.Gender;
|
||||
}
|
||||
|
||||
|
||||
var set = AwaitedService.GetList(ret.Clan, ret.Gender);
|
||||
applyWhich &= set.SettingAvailable | CustomizeFlag.Gender | CustomizeFlag.Clan;
|
||||
applyWhich = applyWhich.FixApplication(set);
|
||||
foreach (var index in CustomizationExtensions.AllBasic)
|
||||
{
|
||||
var flag = index.ToFlag();
|
||||
|
|
@ -118,7 +119,8 @@ public sealed class CustomizationService : AsyncServiceWrapper<ICustomizationMan
|
|||
|
||||
/// <summary> Returns whether a customization value is valid for a given clan/gender set and face. </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static bool IsCustomizationValid(CustomizationSet set, CustomizeValue face, CustomizeIndex type, CustomizeValue value, out CustomizeData? data)
|
||||
public static bool IsCustomizationValid(CustomizationSet set, CustomizeValue face, CustomizeIndex type, CustomizeValue value,
|
||||
out CustomizeData? data)
|
||||
=> set.Validate(type, value, out data, face);
|
||||
|
||||
/// <summary> Returns whether a customization value is valid for a given clan, gender and face. </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue