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

Commit

Permalink
fix: add conditions for auto switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Oct 24, 2023
1 parent 1a97362 commit bbfec02
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public Dictionary<uint, ConditionSet> DisableConditionDict
public ConditionSet AntiKnockbackConditionSet { get; set; } = new ConditionSet();
public ConditionSet SpeedConditionSet { get; set; } = new ConditionSet();

public ConditionSet SwitchAutoConditionSet { get; set; } = new ConditionSet();
public ConditionSet SwitchManualConditionSet { get; set; } = new ConditionSet();
public ConditionSet SwitchCancelConditionSet { get; set; } = new ConditionSet();


public string Name;

public ConditionSet GetCondition(uint id)
Expand Down
21 changes: 20 additions & 1 deletion RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Logging;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using RotationSolver.Basic.Configuration;
Expand Down Expand Up @@ -185,6 +184,26 @@ internal static void UpdateRotationState()
CancelState();
ActionUpdater.AutoCancelTime = DateTime.MinValue;
}

//Auto switch conditions.
else if (DataCenter.RightSet.SwitchCancelConditionSet?.IsTrue(DataCenter.RightNowRotation) ?? false)
{
CancelState();
}
else if (DataCenter.RightSet.SwitchManualConditionSet?.IsTrue(DataCenter.RightNowRotation) ?? false)
{
if (!DataCenter.State)
{
DoStateCommandType(StateCommandType.Manual);
}
}
else if (DataCenter.RightSet.SwitchAutoConditionSet?.IsTrue(DataCenter.RightNowRotation) ?? false)
{
if (!DataCenter.State)
{
DoStateCommandType(StateCommandType.Auto);
}
}
}
}
}
4 changes: 3 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -785,5 +785,7 @@ internal class Strings
public string ConfigWindow_Auto_SpeedConditionSet { get; set; } = "Speed Forced Condition";
public string ConfigWindow_ConditionSetDesc { get; set; } = "The Condition set you chose, click to modify.";
public string ConfigWindow_Basic_UseAdditionalConditions { get; set; } = "Use additional conditions";

public string ConfigWindow_Basic_SwitchCancelConditionSet { get; set; } = "Auto turn off conditions";
public string ConfigWindow_Basic_SwitchManualConditionSet { get; set; } = "Auto turn manual conditions";
public string ConfigWindow_Basic_SwitchAutoConditionSet { get; set; } = "Auto turn auto conditions";
}
30 changes: 12 additions & 18 deletions RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ private static void DrawAfter(this ConditionSet conditionSet, ICustomRotation ro

for (int i = 0; i < conditionSet.Conditions.Count; i++)
{
ICondition condition = conditionSet.Conditions[i];
var condition = conditionSet.Conditions[i];

void Delete()
{
Expand All @@ -485,6 +485,7 @@ void Up()
conditionSet.Conditions.RemoveAt(i);
conditionSet.Conditions.Insert(Math.Max(0, i - 1), condition);
};

void Down()
{
conditionSet.Conditions.RemoveAt(i);
Expand Down Expand Up @@ -519,16 +520,14 @@ void AddButton()
ImGui.OpenPopup("Popup" + conditionSet.GetHashCode().ToString());
}

using (var popUp = ImRaii.Popup("Popup" + conditionSet.GetHashCode().ToString()))
using var popUp = ImRaii.Popup("Popup" + conditionSet.GetHashCode().ToString());
if (popUp.Success)
{
if (popUp.Success)
{
AddOneCondition<ConditionSet>(LocalizationManager.RightLang.ActionSequencer_ConditionSet);
AddOneCondition<ActionCondition>(LocalizationManager.RightLang.ActionSequencer_ActionCondition);
AddOneCondition<TraitCondition>(LocalizationManager.RightLang.ActionSequencer_TraitCondition);
AddOneCondition<TargetCondition>(LocalizationManager.RightLang.ActionSequencer_TargetCondition);
AddOneCondition<RotationCondition>(LocalizationManager.RightLang.ActionSequencer_RotationCondition);
}
AddOneCondition<ConditionSet>(LocalizationManager.RightLang.ActionSequencer_ConditionSet);
AddOneCondition<ActionCondition>(LocalizationManager.RightLang.ActionSequencer_ActionCondition);
AddOneCondition<TraitCondition>(LocalizationManager.RightLang.ActionSequencer_TraitCondition);
AddOneCondition<TargetCondition>(LocalizationManager.RightLang.ActionSequencer_TargetCondition);
AddOneCondition<RotationCondition>(LocalizationManager.RightLang.ActionSequencer_RotationCondition);
}

void AddOneCondition<T>(string name) where T : ICondition
Expand Down Expand Up @@ -653,14 +652,9 @@ private static void DrawAfter(this RotationCondition rotationCondition, ICustomR
}

private static Status[] _allStatus = null;
private static Status[] AllStatus
{
get
{
_allStatus ??= Enum.GetValues<StatusID>().Select(id => Service.GetSheet<Status>().GetRow((uint)id)).ToArray();
return _allStatus;
}
}
private static Status[] AllStatus => _allStatus ??= Enum.GetValues<StatusID>()
.Select(id => Service.GetSheet<Status>().GetRow((uint)id)).ToArray();

private static void DrawAfter(this TargetCondition targetCondition, ICustomRotation rotation)
{
DelayCondition.CheckBaseAction(rotation, targetCondition.ID, ref targetCondition._action);
Expand Down
23 changes: 21 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,38 @@ private static void DrawBasicTimer()
}
}

private static readonly CollapsingHeaderGroup _autoSwitch = new(new()
{
{ () => LocalizationManager.RightLang.ConfigWindow_Basic_SwitchCancelConditionSet,
() => DataCenter.RightSet.SwitchCancelConditionSet?.DrawMain(DataCenter.RightNowRotation) },

{ () => LocalizationManager.RightLang.ConfigWindow_Basic_SwitchManualConditionSet,
() => DataCenter.RightSet.SwitchManualConditionSet?.DrawMain(DataCenter.RightNowRotation) },

{ () => LocalizationManager.RightLang.ConfigWindow_Basic_SwitchAutoConditionSet,
() => DataCenter.RightSet.SwitchAutoConditionSet?.DrawMain(DataCenter.RightNowRotation) },
})
{
HeaderSize = 18,
};
private static void DrawBasicAutoSwitch()
{
foreach (var searchable in _basicSwitchTurnOn)

foreach (var searchable in _basicSwitchTurnOff)
{
searchable?.Draw(Job);
}

ImGui.Separator();

foreach (var searchable in _basicSwitchTurnOff)
foreach (var searchable in _basicSwitchTurnOn)
{
searchable?.Draw(Job);
}

ImGui.Separator();

_autoSwitch?.Draw();
}

private static void DrawBasicOthers()
Expand Down

0 comments on commit bbfec02

Please sign in to comment.