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

Commit

Permalink
fix: fixed mistake ui.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 6, 2023
1 parent 2757d76 commit b0fe466
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 45 deletions.
12 changes: 8 additions & 4 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Style;
using Dalamud.Interface.Windowing;
using ECommons.DalamudServices;
using ImGuiScene;
Expand Down Expand Up @@ -184,11 +185,14 @@ private static void DrawSpecials()
ImGui.Text("Auto: " + DataCenter.AutoStatus.ToString());
ImGui.EndGroup();

ImGui.SameLine();

ImGui.Text(" Mistake:");
ImGui.SameLine();
DrawIAction(DateTime.Now - DidTime < TimeSpan.FromSeconds(5) ? Wrong : null, Service.Config.ControlWindow0GCDSize, 1);
if(Service.Config.MistakeRatio > 0)
{
ImGui.SameLine();
ImGui.TextColored(ImGuiColors.DPSRed, " | Mistake | \n | Mistake | ");
ImGui.SameLine();
DrawIAction(DateTime.Now - DidTime < TimeSpan.FromSeconds(5) ? Wrong : null, Service.Config.ControlWindowGCDSize, 1);
}
}

static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType command, Vector4 color)
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ public static void UndoValue<T>(string name, ref T value, T @default, Action oth
Spacing();

bool isLast = name == _undoName && DateTime.Now - _lastTime < TimeSpan.FromSeconds(2);
bool isTime = DateTime.Now - _lastTime > TimeSpan.FromSeconds(0.5);

if (isLast) ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.HealerGreen);
if (isLast) ImGui.PushStyleColor(ImGuiCol.Text, isTime ? ImGuiColors.HealerGreen : ImGuiColors.DPSRed);
if (IconButton(isLast ? FontAwesomeIcon.Check : FontAwesomeIcon.Undo, $"#{name}: Undo",
LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefault)
&& DateTime.Now - _lastTime > TimeSpan.FromSeconds(0.5))
&& isTime)
{
if (isLast)
{
Expand Down
77 changes: 38 additions & 39 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ internal static void UpdateNextAction()
PlayerCharacter localPlayer = Player.Object;
var customRotation = RotationUpdater.RightNowRotation;

if (localPlayer != null && customRotation != null)
try
{
try
if (localPlayer != null && customRotation != null
&& customRotation.TryInvoke(out var newAction, out var gcdAction))
{
if(Service.Config.MistakeRatio > 0)
if (Service.Config.MistakeRatio > 0)
{
var actions = customRotation.AllActions.Where(a =>
{
if (a.ID == newAction?.ID) return false;
if (a is IBaseAction action)
{
return !action.IsFriendly
Expand All @@ -46,55 +48,52 @@ internal static void UpdateNextAction()
WrongAction = actions.ElementAt(_wrongRandom.Next(actions.Count()));
}

if (customRotation.TryInvoke(out var newAction, out var gcdAction))
{
NextAction = newAction;
NextAction = newAction;

if (gcdAction is IBaseAction GcdAction)
if (gcdAction is IBaseAction GcdAction)
{
if (NextGCDAction != GcdAction)
{
if (NextGCDAction != GcdAction)
{
NextGCDAction = GcdAction;
NextGCDAction = GcdAction;

var rightJobAndTarget = (Player.Object.IsJobCategory(JobRole.Tank) || Player.Object.IsJobCategory(JobRole.Melee)) && GcdAction.Target.IsNPCEnemy();
var rightJobAndTarget = (Player.Object.IsJobCategory(JobRole.Tank) || Player.Object.IsJobCategory(JobRole.Melee)) && GcdAction.Target.IsNPCEnemy();

if (rightJobAndTarget && GcdAction.IsSingleTarget)
{
PainterManager.UpdatePositional(GcdAction.EnemyPositional, GcdAction.Target);
}
else
{
PainterManager.ClearPositional();
}
if (rightJobAndTarget && GcdAction.IsSingleTarget)
{
PainterManager.UpdatePositional(GcdAction.EnemyPositional, GcdAction.Target);
}
else
{
PainterManager.ClearPositional();
}

if (GcdAction.EnemyPositional != EnemyPositional.None
&& GcdAction.Target.HasPositional()
&& !localPlayer.HasStatus(true, CustomRotation.TrueNorth.StatusProvide))
{
if (GcdAction.EnemyPositional != EnemyPositional.None
&& GcdAction.Target.HasPositional()
&& !localPlayer.HasStatus(true, CustomRotation.TrueNorth.StatusProvide))
{

if (CheckAction())
{
string positional = GcdAction.EnemyPositional.ToName();
if (Service.Config.SayPositional) SpeechHelper.Speak(positional);
if (Service.Config.ToastPositional) Svc.Toasts.ShowQuest(" " + positional,
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = GcdAction.IconID,
});
}
if (CheckAction())
{
string positional = GcdAction.EnemyPositional.ToName();
if (Service.Config.SayPositional) SpeechHelper.Speak(positional);
if (Service.Config.ToastPositional) Svc.Toasts.ShowQuest(" " + positional,
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = GcdAction.IconID,
});
}
}
}
return;
}
return;
}
catch (Exception ex)
{
PluginLog.Error(ex, "Failed to update next action.");
}
}
catch (Exception ex)
{
PluginLog.Error(ex, "Failed to update next action.");
}

NextAction = NextGCDAction = null;
WrongAction = NextAction = NextGCDAction = null;
PainterManager.ClearPositional();
}

Expand Down

0 comments on commit b0fe466

Please sign in to comment.