mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-02-18 13:37:44 +01:00
.
This commit is contained in:
parent
80ab57e96d
commit
d1d369a56b
31 changed files with 1637 additions and 80 deletions
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Gauge;
|
||||
using Glamourer.Customization;
|
||||
using Glamourer.Services;
|
||||
using Penumbra.GameData.Enums;
|
||||
|
|
@ -161,7 +159,7 @@ public unsafe struct DesignData
|
|||
}
|
||||
|
||||
public readonly bool IsWeaponVisible()
|
||||
=> (_states & 0x08) == 0x09;
|
||||
=> (_states & 0x08) == 0x08;
|
||||
|
||||
public bool SetWeaponVisible(bool value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public sealed class DesignFileSystem : FileSystem<Design>, IDisposable, ISavable
|
|||
_designManager = designManager;
|
||||
_saveService = saveService;
|
||||
_designChanged = designChanged;
|
||||
_designChanged.Subscribe(OnDataChange, DesignChanged.Priority.DesignFileSystem);
|
||||
_designChanged.Subscribe(OnDesignChange, DesignChanged.Priority.DesignFileSystem);
|
||||
Changed += OnChange;
|
||||
Reload();
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ public sealed class DesignFileSystem : FileSystem<Design>, IDisposable, ISavable
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
_designChanged.Unsubscribe(OnDataChange);
|
||||
_designChanged.Unsubscribe(OnDesignChange);
|
||||
}
|
||||
|
||||
public struct CreationDate : ISortMode<Design>
|
||||
|
|
@ -96,7 +96,7 @@ public sealed class DesignFileSystem : FileSystem<Design>, IDisposable, ISavable
|
|||
_saveService.QueueSave(this);
|
||||
}
|
||||
|
||||
private void OnDataChange(DesignChanged.Type type, Design design, object? data)
|
||||
private void OnDesignChange(DesignChanged.Type type, Design design, object? data)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -202,7 +202,9 @@ public class DesignManager
|
|||
|
||||
break;
|
||||
default:
|
||||
if (!design.DesignData.Customize.Set(idx, value))
|
||||
if (!_customizations.IsCustomizationValid(design.DesignData.Customize.Clan, design.DesignData.Customize.Gender,
|
||||
design.DesignData.Customize.Face, idx, value)
|
||||
|| !design.DesignData.Customize.Set(idx, value))
|
||||
return;
|
||||
|
||||
break;
|
||||
|
|
@ -228,7 +230,7 @@ public class DesignManager
|
|||
/// <summary> Change a non-weapon equipment piece. </summary>
|
||||
public void ChangeEquip(Design design, EquipSlot slot, EquipItem item)
|
||||
{
|
||||
if (_items.ValidateItem(slot, item.Id, out item).Length > 0)
|
||||
if (!_items.IsItemValid(slot, item.Id, out item))
|
||||
return;
|
||||
|
||||
var old = design.DesignData.Item(slot);
|
||||
|
|
@ -250,32 +252,31 @@ public class DesignManager
|
|||
{
|
||||
case EquipSlot.MainHand:
|
||||
var newOff = currentOff;
|
||||
if (item.Type == currentMain.Type)
|
||||
{
|
||||
if (_items.ValidateWeapons(item.Id, currentOff.Id, out _, out _).Length != 0)
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (!_items.IsItemValid(EquipSlot.MainHand, item.Id, out item))
|
||||
return;
|
||||
|
||||
if (item.Type != currentMain.Type)
|
||||
{
|
||||
|
||||
var newOffId = FullEquipTypeExtensions.OffhandTypes.Contains(item.Type)
|
||||
? item.Id
|
||||
: ItemManager.NothingId(item.Type.Offhand());
|
||||
if (_items.ValidateWeapons(item.Id, newOffId, out _, out newOff).Length != 0)
|
||||
if (!_items.IsOffhandValid(item, newOffId, out newOff))
|
||||
return;
|
||||
}
|
||||
|
||||
design.DesignData.SetItem(EquipSlot.MainHand, item);
|
||||
design.DesignData.SetItem(EquipSlot.OffHand, newOff);
|
||||
if (!design.DesignData.SetItem(EquipSlot.MainHand, item) && !design.DesignData.SetItem(EquipSlot.OffHand, newOff))
|
||||
return;
|
||||
|
||||
design.LastEdit = DateTimeOffset.UtcNow;
|
||||
_saveService.QueueSave(design);
|
||||
Glamourer.Log.Debug(
|
||||
$"Set {EquipSlot.MainHand.ToName()} weapon in design {design.Identifier} from {currentMain.Name} ({currentMain.Id}) to {item.Name} ({item.Id}).");
|
||||
_event.Invoke(DesignChanged.Type.Weapon, design, (currentMain, currentOff, item, newOff));
|
||||
|
||||
return;
|
||||
case EquipSlot.OffHand:
|
||||
if (item.Type != currentOff.Type)
|
||||
return;
|
||||
if (_items.ValidateWeapons(currentMain.Id, item.Id, out _, out _).Length > 0)
|
||||
if (!_items.IsOffhandValid(currentOff.Type, item.Id, out item))
|
||||
return;
|
||||
|
||||
if (!design.DesignData.SetItem(EquipSlot.OffHand, item))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue