Move MetaFlag completely to API, rename, cleanup.

This commit is contained in:
Ottermandias 2025-01-24 23:28:23 +01:00
parent 5eb545f62d
commit f6c9ecad60
11 changed files with 33 additions and 46 deletions

@ -1 +1 @@
Subproject commit 4ac38fbed6fb0f31c0b75de26950ab82d3bee258
Subproject commit 8de6fa7246a403de50b3be4e17bb5f188717b279

View file

@ -127,9 +127,9 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
return ApiHelpers.Return(GlamourerApiEc.Success, args);
}
public GlamourerApiEc SetMeta(int objectIndex, SetMetaFlag types, bool newValue, uint key, ApplyFlag flags)
public GlamourerApiEc SetMetaState(int objectIndex, MetaFlag types, bool newValue, uint key, ApplyFlag flags)
{
var args = ApiHelpers.Args("Index", objectIndex, "Meta Types", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags);
var args = ApiHelpers.Args("Index", objectIndex, "MetaTypes", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags);
if (types == 0)
return ApiHelpers.Return(GlamourerApiEc.InvalidState, args);
@ -153,13 +153,12 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
return GlamourerApiEc.Success;
}
public GlamourerApiEc SetMetaState(string playerName, SetMetaFlag types, bool newValue, uint key, ApplyFlag flags)
public GlamourerApiEc SetMetaStateName(string playerName, MetaFlag types, bool newValue, uint key, ApplyFlag flags)
{
var args = ApiHelpers.Args("Name", playerName, "Meta Types", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags);
var args = ApiHelpers.Args("Name", playerName, "MetaTypes", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags);
if (types == 0)
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
var indices = types.ToIndices();
var anyHuman = false;
var anyFound = false;
var anyUnlocked = false;
@ -175,7 +174,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
anyUnlocked = true;
// update all MetaStates for this ActorState
foreach (var index in indices)
foreach (var index in types.ToIndices())
{
stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual);
ApiHelpers.Lock(state, key, flags);

View file

@ -1,4 +1,5 @@
using Glamourer.Designs;
using Glamourer.Api.Enums;
using Glamourer.Designs;
using Glamourer.GameData;
using Penumbra.GameData.Enums;

View file

@ -1,3 +1,4 @@
using Glamourer.Api.Enums;
using Glamourer.GameData;
using ImGuiNET;
using Penumbra.GameData.Enums;

View file

@ -1,4 +1,5 @@
using Glamourer.GameData;
using Glamourer.Api.Enums;
using Glamourer.GameData;
using Glamourer.State;
using ImGuiNET;
using Penumbra.GameData.Enums;

View file

@ -1,4 +1,5 @@
using Glamourer.Services;
using Glamourer.Api.Enums;
using Glamourer.Services;
using OtterGui;
using Penumbra.GameData.DataContainers;
using Penumbra.GameData.Enums;

View file

@ -1,4 +1,5 @@
using Glamourer.Automation;
using Glamourer.Api.Enums;
using Glamourer.Automation;
using Glamourer.Designs.Special;
using Glamourer.GameData;
using Glamourer.Interop.Material;

View file

@ -12,15 +12,6 @@ public enum MetaIndex
ModelId = StateIndex.MetaModelId,
}
[Flags]
public enum MetaFlag : byte
{
Wetness = 0x01,
HatState = 0x02,
VisorState = 0x04,
WeaponState = 0x08,
}
public static class MetaExtensions
{
public static readonly IReadOnlyList<MetaIndex> AllRelevant =
@ -38,29 +29,6 @@ public static class MetaExtensions
_ => (MetaFlag)byte.MaxValue,
};
public static MetaIndex ToIndex(this SetMetaFlag index)
=> index switch
{
SetMetaFlag.Wetness => MetaIndex.Wetness,
SetMetaFlag.HatState => MetaIndex.HatState,
SetMetaFlag.VisorState => MetaIndex.VisorState,
SetMetaFlag.WeaponState => MetaIndex.WeaponState,
_ => (MetaIndex)byte.MaxValue,
};
public static IEnumerable<MetaIndex> ToIndices(this SetMetaFlag index)
{
if (index.HasFlag(SetMetaFlag.Wetness))
yield return MetaIndex.Wetness;
if (index.HasFlag(SetMetaFlag.HatState))
yield return MetaIndex.HatState;
if (index.HasFlag(SetMetaFlag.VisorState))
yield return MetaIndex.VisorState;
if (index.HasFlag(SetMetaFlag.WeaponState))
yield return MetaIndex.WeaponState;
}
public static MetaIndex ToIndex(this MetaFlag index)
=> index switch
{
@ -71,6 +39,18 @@ public static class MetaExtensions
_ => (MetaIndex)byte.MaxValue,
};
public static IEnumerable<MetaIndex> ToIndices(this MetaFlag index)
{
if (index.HasFlag(MetaFlag.Wetness))
yield return MetaIndex.Wetness;
if (index.HasFlag(MetaFlag.HatState))
yield return MetaIndex.HatState;
if (index.HasFlag(MetaFlag.VisorState))
yield return MetaIndex.VisorState;
if (index.HasFlag(MetaFlag.WeaponState))
yield return MetaIndex.WeaponState;
}
public static string ToName(this MetaIndex index)
=> index switch
{

View file

@ -2,6 +2,7 @@
using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Interface.ImGuiNotification;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using Glamourer.Api.Enums;
using Glamourer.Automation;
using Glamourer.Designs;
using Glamourer.Designs.History;

View file

@ -1,4 +1,5 @@
using Glamourer.Designs;
using Glamourer.Api.Enums;
using Glamourer.Designs;
using Glamourer.State;
using Penumbra.GameData.Enums;

View file

@ -1,4 +1,5 @@
using Glamourer.Designs;
using Glamourer.Api.Enums;
using Glamourer.Designs;
using Glamourer.GameData;
using Penumbra.GameData.Enums;