Skip to content

Commit

Permalink
Moodle Stack Proposal Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CordeliaMist committed Dec 12, 2024
1 parent 16d1b78 commit d9ae284
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
32 changes: 21 additions & 11 deletions Moodles/MyStatusManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.Configuration;
using ECommons.GameHelpers;
using MemoryPack;
using Moodles.Data;
Expand Down Expand Up @@ -43,21 +44,30 @@ public void AddOrUpdate(MyStatus newStatus, UpdateSource source, bool Unchecked
// use newStatus to check, in case we changed the setting between applications. Performs stack count updating.
if (newStatus.StackOnReapply)
{
// Keep the current stack count set to the status.
var newStackCount = Statuses[i].Stacks;

// If valid, increase the stack count by 1 on reapplication is source is StatusTuple.
if (source is UpdateSource.StatusTuple && P.CommonProcessor.IconStackCounts.TryGetValue((uint)newStatus.IconID, out var max) && max > 1)
if (source is UpdateSource.StatusTuple)
{
if (Statuses[i].Stacks + 1 <= max)
// grab the current stack count.
var newStackCount = Statuses[i].Stacks;
// fetch what the max stack count for the icon is.
if (P.CommonProcessor.IconStackCounts.TryGetValue((uint)newStatus.IconID, out var max))
{
newStackCount++;
// remove status GUID from addTextShown so it can be shown again with the new stack on the next tick.
AddTextShown.Remove(newStatus.GUID);
// if the stack count is less than the max, increase it by 1, and remove it from addTextShown to display the new stack.
if (Statuses[i].Stacks + 1 <= max)
{
newStackCount++;
newStatus.Stacks = newStackCount;
AddTextShown.Remove(newStatus.GUID);
}
}
}
// update stack count.
newStatus.Stacks = newStackCount;
// Handle sources that are from status manager sets.
else if (source is UpdateSource.DataString)
{
// if the source is the data string, we simply apply the data string.
// HOWEVER, if and only if the stack count is different, we need to remove it from addTextShown to display the new stack.
if (Statuses[i].Stacks != newStatus.Stacks)
AddTextShown.Remove(newStatus.GUID);
}
}
// then update the status with the new status.
Statuses[i] = newStatus;
Expand Down
2 changes: 1 addition & 1 deletion Moodles/OtterGuiHandlers/MoodleFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void Save()

private (string, bool) SaveConverter(MyStatus status, string arg2)
{
PluginLog.Debug($"Saving {status.Title} {status.ID}");
PluginLog.LogVerbose($"Saving {status.Title} {status.ID}");
return (status.ID, true);
}

Expand Down
2 changes: 1 addition & 1 deletion Moodles/OtterGuiHandlers/PresetFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void Save()

private (string, bool) SaveConverter(Preset item, string arg2)
{
PluginLog.Debug($"Saving {item.ID}");
PluginLog.LogVerbose($"Saving {item.ID}");
return (item.ID, true);
}

Expand Down
Binary file added changes.patch
Binary file not shown.

0 comments on commit d9ae284

Please sign in to comment.