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

Commit

Permalink
fix: seperate the preview update.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 1, 2023
1 parent 7950f91 commit 67e3273
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
2 changes: 2 additions & 0 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private static void FrameworkUpdate(Framework framework)
// }
//#endif

//PreviewUpdater.UpdateCastBarState();
PreviewUpdater.UpdatePreview();
//ActionUpdater.UpdateActionInfo();
//TargetUpdater.UpdateTarget();
Expand Down Expand Up @@ -60,6 +61,7 @@ public static void Enable()
continue;
}

PreviewUpdater.UpdateCastBarState();
//PreviewUpdater.UpdatePreview();
ActionUpdater.UpdateActionInfo();
TargetUpdater.UpdateTarget();
Expand Down
57 changes: 37 additions & 20 deletions RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,57 @@ internal static void UpdatePreview()
UpdateHightLight();
}

static DtrBarEntry dtrEntry;
static DtrBarEntry _dtrEntry;
static string _showValue;
private static void UpdateEntry()
{
if (Service.Configuration.ShowInfoOnDtr && RSCommands.EntryString != null)
{
if (dtrEntry == null)
if (_dtrEntry == null)
{
dtrEntry = Service.DtrBar.Get("Rotation Solver");
_dtrEntry = Service.DtrBar.Get("Rotation Solver");
}
if(!_dtrEntry.Shown) _dtrEntry.Shown = true;
if(_showValue != RSCommands.EntryString)
{
_showValue = RSCommands.EntryString;
_dtrEntry.Text = new SeString(
new IconPayload(BitmapFontIcon.DPS),
new TextPayload(_showValue)
);
}
dtrEntry.Shown = true;
dtrEntry.Text = new SeString(
new IconPayload(BitmapFontIcon.DPS),
new TextPayload(RSCommands.EntryString)
);
}
else if (dtrEntry != null)
else if (_dtrEntry != null && _dtrEntry.Shown)
{
dtrEntry.Shown = false;
_dtrEntry.Shown = false;
}
}

private static unsafe void UpdateCastBar()
static bool _canMove;
internal static void UpdateCastBarState()
{
ByteColor redColor = new ByteColor() { A = 255, R = 120, G = 0, B = 60 };
ByteColor greenColor = new ByteColor() { A = 255, R = 60, G = 120, B = 30 };

bool canMove = !Service.Conditions[Dalamud.Game.ClientState.Conditions.ConditionFlag.OccupiedInEvent]
&& !Service.Conditions[Dalamud.Game.ClientState.Conditions.ConditionFlag.Casting];

ByteColor c = canMove && Service.Configuration.CastingDisplay ? greenColor : redColor;
var isTarDead = Service.ObjectTable.SearchById(Service.ClientState.LocalPlayer.CastTargetObjectId)
var isTarDead = Service.ObjectTable.SearchById(Service.ClientState.LocalPlayer.CastTargetObjectId)
is BattleChara b && b.CurrentHp == 0;

//For lock
var specialStatus = Service.ClientState.LocalPlayer.HasStatus(true, StatusID.PhantomFlurry, StatusID.TenChiJin);
MovingUpdater.IsMoving = specialStatus ? false : (canMove || isTarDead);

MovingUpdater.IsMoving = _canMove = specialStatus ? false : (canMove || isTarDead);
}

static bool _showCanMove;
static readonly ByteColor _redColor = new ByteColor() { A = 255, R = 120, G = 0, B = 60 };
static readonly ByteColor _greenColor = new ByteColor() { A = 255, R = 60, G = 120, B = 30 };
private static unsafe void UpdateCastBar()
{
var nowMove = _canMove && Service.Configuration.CastingDisplay;
if (nowMove == _showCanMove) return;
_showCanMove = nowMove;

ByteColor c = _showCanMove ? _greenColor : _redColor;

var castBar = Service.GameGui.GetAddonByName("_CastBar", 1);
if (castBar == IntPtr.Zero) return;
Expand All @@ -72,17 +87,19 @@ private static unsafe void UpdateCastBar()
progressBar->AddBlue = c.B;
}

static uint _higtLightId;
private unsafe static void UpdateHightLight()
{
var actId = ActionUpdater.NextAction?.AdjustedID ?? 0;
if (_higtLightId == actId) return;
_higtLightId = actId;

HigglightAtionBar((slot, hot) =>
{
return Service.Configuration.TeachingMode && IsActionSlotRight(slot, hot, actId);
return Service.Configuration.TeachingMode && IsActionSlotRight(slot, hot, _higtLightId);
});
}


internal static unsafe void PulseAtionBar(uint actionID)
{
LoopAllSlotBar((bar, hotbar, index) =>
Expand Down Expand Up @@ -236,6 +253,6 @@ public unsafe static void Dispose()
{
//Hide All highLight.
HigglightAtionBar();
dtrEntry?.Dispose();
_dtrEntry?.Dispose();
}
}

0 comments on commit 67e3273

Please sign in to comment.