Skip to content

Commit

Permalink
[Fade Unavailable Actions] Fix error spam
Browse files Browse the repository at this point in the history
  • Loading branch information
Caraxi committed Nov 5, 2023
1 parent 28d4f6a commit 3ff2df5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Tweaks/UiAdjustment/FadeUnavailableActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace SimpleTweaksPlugin.Tweaks.UiAdjustment;
[TweakAuthor("MidoriKami")]
[TweakAutoConfig]
[TweakReleaseVersion("1.8.3.1")]
[TweakVersion(2)]
[Changelog("1.8.3.2", "Tweak now only applies to the icon image itself and not the entire button")]
[Changelog("1.8.3.2", "Add option to apply transparency to the slot frame of the icon")]
[Changelog("1.8.3.2", "Add option to apply to sync'd skills only")]
Expand All @@ -30,7 +31,7 @@ public unsafe class FadeUnavailableActions : UiAdjustments.SubTweak {
[TweakHook, Signature("E8 ?? ?? ?? ?? 49 81 C6 ?? ?? ?? ?? 83 C7 10", DetourName = nameof(OnHotBarSlotUpdate))]
private readonly HookWrapper<UpdateHotBarSlotDelegate>? onHotBarSlotUpdateHook = null!;

private readonly Dictionary<uint, Action> actionCache = new();
private readonly Dictionary<uint, Action?> actionCache = new();

private readonly List<string> addonActionBarNames = new() { "_ActionBar", "_ActionBar01", "_ActionBar02", "_ActionBar03", "_ActionBar04", "_ActionBar05", "_ActionBar06", "_ActionBar07", "_ActionBar08", "_ActionBar09", "_ActionCross", "_ActionDoubleCrossR", "_ActionDoubleCrossL" };

Expand Down Expand Up @@ -104,7 +105,12 @@ private void ProcessHotBarSlot(ActionBarSlot* hotBarSlotData, NumberArrayData* n
}

if (TweakConfig.ApplyToSyncActions) {
var action = GetAction((uint)hotBarSlotData->ActionId);
var action = GetAction(raptureSlotData.CommandId);
if (action == null) {
ApplyTransparency(hotBarSlotData, false);
ApplyReddening(hotBarSlotData, false);
return;
}
var actionLevel = action.ClassJobLevel;
var playerLevel = Service.ClientState.LocalPlayer?.Level ?? 0;

Expand All @@ -126,12 +132,12 @@ private void ProcessHotBarSlot(ActionBarSlot* hotBarSlotData, NumberArrayData* n
}
}

private Action GetAction(uint actionId) {
private Action? GetAction(uint actionId) {
var adjustedActionId = ActionManager.Instance()->GetAdjustedActionId(actionId);

if (actionCache.TryGetValue(adjustedActionId, out var action)) return action;

action = Service.Data.GetExcelSheet<Action>()!.GetRow(adjustedActionId)!;
action = Service.Data.GetExcelSheet<Action>()!.GetRow(adjustedActionId);
actionCache.Add(adjustedActionId, action);
return action;
}
Expand Down

0 comments on commit 3ff2df5

Please sign in to comment.