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

Commit

Permalink
fix: warning manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Oct 11, 2023
1 parent c50fd92 commit e9efc0c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

namespace RotationSolver.Basic.Helpers;

public static class UIHelper
public static class WarningHelper
{
private static Queue<string> _showWarnings = new Queue<string>();
private static bool _run = false;

public static void ShowWarning(this string message, int times = 3, DalamudLinkPayload link = null)
{
if (Service.Config.GetValue(Configuration.PluginConfigBool.HideWarning)) return;
Expand All @@ -31,8 +34,9 @@ public static void ShowWarning(this string message, int times = 3, DalamudLinkPa
new TextPayload("Rotation Solver"),
UIForegroundPayload.UIForegroundOff,
RawPayload.LinkTerminator,
new TextPayload(": "),
link,
new TextPayload(": " + message),
new TextPayload(message),
RawPayload.LinkTerminator,

RotationSolverPlugin.HideWarningLinkPayload,
Expand All @@ -45,13 +49,25 @@ public static void ShowWarning(this string message, int times = 3, DalamudLinkPa
Type = Dalamud.Game.Text.XivChatType.ErrorMessage,
});

Task.Run(async () =>
for (int i = 0; i < times; i++)
{
for (int i = 0; i < times; i++)
{
await Task.Delay(3000);
Svc.Toasts.ShowError(message);
}
});
_showWarnings.Enqueue(message);
}

if (!_run)
{
_run = true;
Task.Run(RunShowError);
}
}

private static async Task RunShowError()
{
while (_showWarnings.TryDequeue(out var message))
{
Svc.Toasts.ShowError(message);
await Task.Delay(3000);
}
_run = false;
}
}
1 change: 0 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ internal class Strings

public string ClickingMistakeMessage { get; set; } = "OOOps! RS clicked the wrong action ({0})!";


public string ConfigWindow_About_Punchline { get; set; } = "Analyses PvE combat information every frame and finds the best action.";
public string ConfigWindow_About_Description { get; set; } = "This means almost all the information available in one frame in combat, including the status of all players in the party, the status of any hostile targets, skill cooldowns, the MP and HP of characters, the location of characters, casting status of the hostile target, combo, combat duration, player level, etc.\n\nThen, it will highlight the best action on the hot bar, or help you to click on it.";

Expand Down
1 change: 1 addition & 0 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
if (id == 1)
{
Service.Config.SetValue(PluginConfigBool.HideWarning, true);
Svc.Chat.Print("Warning has been hidden.");
}
});
Task.Run(async () =>
Expand Down
5 changes: 2 additions & 3 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using ECommons.ImGuiMethods;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Control;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
Expand Down Expand Up @@ -137,11 +136,11 @@ private static void ShowWarning()

if (!Svc.PluginInterface.InstalledPlugins.Any(p => p.InternalName == "Avarice"))
{
Svc.Chat.PrintError(LocalizationManager.RightLang.AvariceWarning);
LocalizationManager.RightLang.AvariceWarning.ShowWarning(0);
}
if (!Svc.PluginInterface.InstalledPlugins.Any(p => p.InternalName == "TextToTalk"))
{
Svc.Chat.PrintError(LocalizationManager.RightLang.TextToTalkWarning);
LocalizationManager.RightLang.TextToTalkWarning.ShowWarning(0);
}
}

Expand Down

0 comments on commit e9efc0c

Please sign in to comment.