mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Merge branch 'refs/heads/CordeliaMist/PR-SetMetaState'
This commit is contained in:
commit
f1fa5c2fa9
11 changed files with 99 additions and 21 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4ac38fbed6fb0f31c0b75de26950ab82d3bee258
|
Subproject commit 8de6fa7246a403de50b3be4e17bb5f188717b279
|
||||||
|
|
@ -96,9 +96,9 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
|
||||||
if (!ResolveBonusItem(slot, bonusItemId, out var item))
|
if (!ResolveBonusItem(slot, bonusItemId, out var item))
|
||||||
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
||||||
|
|
||||||
var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key);
|
var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key);
|
||||||
var anyHuman = false;
|
var anyHuman = false;
|
||||||
var anyFound = false;
|
var anyFound = false;
|
||||||
var anyUnlocked = false;
|
var anyUnlocked = false;
|
||||||
foreach (var state in helpers.FindStates(playerName))
|
foreach (var state in helpers.FindStates(playerName))
|
||||||
{
|
{
|
||||||
|
|
@ -115,6 +115,72 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
|
||||||
ApiHelpers.Lock(state, key, flags);
|
ApiHelpers.Lock(state, key, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!anyFound)
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args);
|
||||||
|
|
||||||
|
if (!anyHuman)
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args);
|
||||||
|
|
||||||
|
if (!anyUnlocked)
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args);
|
||||||
|
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.Success, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlamourerApiEc SetMetaState(int objectIndex, MetaFlag types, bool newValue, uint key, ApplyFlag flags)
|
||||||
|
{
|
||||||
|
var args = ApiHelpers.Args("Index", objectIndex, "MetaTypes", types, "NewValue", newValue, "Key", key, "ApplyFlags", flags);
|
||||||
|
if (types == 0)
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.InvalidState, args);
|
||||||
|
|
||||||
|
if (helpers.FindState(objectIndex) is not { } state)
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args);
|
||||||
|
|
||||||
|
if (!state.ModelData.IsHuman)
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args);
|
||||||
|
|
||||||
|
if (!state.CanUnlock(key))
|
||||||
|
return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args);
|
||||||
|
|
||||||
|
// Grab MetaIndices from attached flags, and update the states.
|
||||||
|
var indices = types.ToIndices();
|
||||||
|
foreach (var index in indices)
|
||||||
|
{
|
||||||
|
stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual);
|
||||||
|
ApiHelpers.Lock(state, key, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GlamourerApiEc.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlamourerApiEc SetMetaStateName(string playerName, MetaFlag types, bool newValue, uint key, ApplyFlag 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 anyHuman = false;
|
||||||
|
var anyFound = false;
|
||||||
|
var anyUnlocked = false;
|
||||||
|
foreach (var state in helpers.FindStates(playerName))
|
||||||
|
{
|
||||||
|
anyFound = true;
|
||||||
|
if (!state.ModelData.IsHuman)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
anyHuman = true;
|
||||||
|
if (!state.CanUnlock(key))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
anyUnlocked = true;
|
||||||
|
// update all MetaStates for this ActorState
|
||||||
|
foreach (var index in types.ToIndices())
|
||||||
|
{
|
||||||
|
stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual);
|
||||||
|
ApiHelpers.Lock(state, key, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!anyFound)
|
if (!anyFound)
|
||||||
return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args);
|
return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.Designs;
|
using Glamourer.Api.Enums;
|
||||||
|
using Glamourer.Designs;
|
||||||
using Glamourer.GameData;
|
using Glamourer.GameData;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Glamourer.Api.Enums;
|
||||||
using Glamourer.GameData;
|
using Glamourer.GameData;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.GameData;
|
using Glamourer.Api.Enums;
|
||||||
|
using Glamourer.GameData;
|
||||||
using Glamourer.State;
|
using Glamourer.State;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.Services;
|
using Glamourer.Api.Enums;
|
||||||
|
using Glamourer.Services;
|
||||||
using OtterGui;
|
using OtterGui;
|
||||||
using Penumbra.GameData.DataContainers;
|
using Penumbra.GameData.DataContainers;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.Automation;
|
using Glamourer.Api.Enums;
|
||||||
|
using Glamourer.Automation;
|
||||||
using Glamourer.Designs.Special;
|
using Glamourer.Designs.Special;
|
||||||
using Glamourer.GameData;
|
using Glamourer.GameData;
|
||||||
using Glamourer.Interop.Material;
|
using Glamourer.Interop.Material;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.State;
|
using Glamourer.Api.Enums;
|
||||||
|
using Glamourer.State;
|
||||||
|
|
||||||
namespace Glamourer.Designs;
|
namespace Glamourer.Designs;
|
||||||
|
|
||||||
|
|
@ -11,15 +12,6 @@ public enum MetaIndex
|
||||||
ModelId = StateIndex.MetaModelId,
|
ModelId = StateIndex.MetaModelId,
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum MetaFlag : byte
|
|
||||||
{
|
|
||||||
Wetness = 0x01,
|
|
||||||
HatState = 0x02,
|
|
||||||
VisorState = 0x04,
|
|
||||||
WeaponState = 0x08,
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MetaExtensions
|
public static class MetaExtensions
|
||||||
{
|
{
|
||||||
public static readonly IReadOnlyList<MetaIndex> AllRelevant =
|
public static readonly IReadOnlyList<MetaIndex> AllRelevant =
|
||||||
|
|
@ -44,9 +36,21 @@ public static class MetaExtensions
|
||||||
MetaFlag.HatState => MetaIndex.HatState,
|
MetaFlag.HatState => MetaIndex.HatState,
|
||||||
MetaFlag.VisorState => MetaIndex.VisorState,
|
MetaFlag.VisorState => MetaIndex.VisorState,
|
||||||
MetaFlag.WeaponState => MetaIndex.WeaponState,
|
MetaFlag.WeaponState => MetaIndex.WeaponState,
|
||||||
_ => (MetaIndex)byte.MaxValue,
|
_ => (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)
|
public static string ToName(this MetaIndex index)
|
||||||
=> index switch
|
=> index switch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Dalamud.Interface.ImGuiFileDialog;
|
using Dalamud.Interface.ImGuiFileDialog;
|
||||||
using Dalamud.Interface.ImGuiNotification;
|
using Dalamud.Interface.ImGuiNotification;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||||
|
using Glamourer.Api.Enums;
|
||||||
using Glamourer.Automation;
|
using Glamourer.Automation;
|
||||||
using Glamourer.Designs;
|
using Glamourer.Designs;
|
||||||
using Glamourer.Designs.History;
|
using Glamourer.Designs.History;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.Designs;
|
using Glamourer.Api.Enums;
|
||||||
|
using Glamourer.Designs;
|
||||||
using Glamourer.State;
|
using Glamourer.State;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.Designs;
|
using Glamourer.Api.Enums;
|
||||||
|
using Glamourer.Designs;
|
||||||
using Glamourer.GameData;
|
using Glamourer.GameData;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue