Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed the pulse thing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 2, 2023
1 parent 18f2f34 commit 05f2c43
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,38 +114,44 @@ private unsafe static void UpdateHightLight()
if (_highLightId == actId) return;
_highLightId = actId;

HighLightActionBar((slot) =>
HighLightActionBar((slot, hot) =>
{
return Service.Config.TeachingMode && IsActionSlotRight(slot, _highLightId);
return Service.Config.TeachingMode && IsActionSlotRight(slot, hot, _highLightId);
});
}

internal static unsafe void PulseActionBar(uint actionID)
{
LoopAllSlotBar((bar, index) =>
LoopAllSlotBar((bar, hot, index) =>
{
return IsActionSlotRight(bar, actionID);
return IsActionSlotRight(bar, hot, actionID);
});
}

private unsafe static bool IsActionSlotRight(ActionBarSlot slot, uint actionID)
private unsafe static bool IsActionSlotRight(ActionBarSlot slot, HotBarSlot* hot, uint actionID)
{
return Service.GetAdjustedActionId((uint)slot.ActionId) == actionID;
if ((IntPtr)hot == IntPtr.Zero) return false;
if (hot->IconTypeA != HotbarSlotType.CraftAction && hot->IconTypeA != HotbarSlotType.Action) return false;
if (hot->IconTypeB != HotbarSlotType.CraftAction && hot->IconTypeB != HotbarSlotType.Action) return false;

return Service.GetAdjustedActionId((uint)slot.ActionId) == actionID;
}

delegate bool ActionBarAction(ActionBarSlot bar,uint highLightID);
delegate bool ActionBarPredicate(ActionBarSlot bar);
unsafe delegate bool ActionBarAction(ActionBarSlot bar, HotBarSlot* hot, uint highLightID);
unsafe delegate bool ActionBarPredicate(ActionBarSlot bar, HotBarSlot* hot);
private static unsafe void LoopAllSlotBar(ActionBarAction doingSomething)
{
var index = 0;
foreach (var actionBar in Service.GetAddon<AddonActionBarX>().Select(i => i.AddonActionBarBase)
.Union(Service.GetAddon<AddonActionCross>().Select(i => i.ActionBarBase)))
{
var hotbar = Framework.Instance()->GetUiModule()->GetRaptureHotbarModule()->HotBar[index];
var slotIndex = 0;
foreach (var slot in actionBar.Slot)
{
var hotBarSlot = hotbar->Slot[slotIndex];
var highLightId = 0x53550000 + index;
if (doingSomething(slot, (uint)highLightId))
if (doingSomething(slot, hotBarSlot, (uint)highLightId))
{
actionBar.PulseActionBarSlot(slotIndex);
UIModule.PlaySound(12, 0, 0, 0);
Expand All @@ -160,7 +166,7 @@ private static unsafe void LoopAllSlotBar(ActionBarAction doingSomething)

private static unsafe void HighLightActionBar(ActionBarPredicate shouldShow = null)
{
LoopAllSlotBar((slot, highLightId) =>
LoopAllSlotBar((slot, hot, highLightId) =>
{
var iconAddon = slot.Icon;
if (!iconAddon->AtkResNode.IsVisible) return false;
Expand Down Expand Up @@ -225,7 +231,7 @@ private static unsafe void HighLightActionBar(ActionBarPredicate shouldShow = nu
highLightPtr->AtkResNode.SetHeight(lastHightLight->Height);

//Update Visibility
highLightPtr->AtkResNode.ToggleVisibility(shouldShow?.Invoke(slot) ?? false);
highLightPtr->AtkResNode.ToggleVisibility(shouldShow?.Invoke(slot, hot) ?? false);

return false;
});
Expand Down

0 comments on commit 05f2c43

Please sign in to comment.