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

Commit

Permalink
fix: action sequencer changing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 15, 2023
1 parent 3436d92 commit 21023ba
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 35 deletions.
49 changes: 24 additions & 25 deletions RotationSolver/ActionSequencer/ConditionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,39 @@ public bool IsTrue(ICustomRotation combo) => Conditions.Count != 0 && (IsAnd ? C
public List<ICondition> Conditions { get; set; } = new List<ICondition>();
public bool IsAnd { get; set; }

[JsonIgnore]
public float Height => Conditions.Sum(c => c is ConditionSet ? c.Height + 10 : c.Height) + ICondition.DefaultHeight + 12;

public void Draw(ICustomRotation combo)
{
if (ImGui.BeginChild("ConditionSet" + GetHashCode().ToString(), new Vector2(-1f, Height), true))
{
AddButton();
var start = ImGui.GetCursorPos();
ImGui.BeginGroup();

ImGui.SameLine();
AddButton();

ImGuiHelper.DrawCondition(IsTrue(combo));
ImGui.SameLine();

ImGui.SameLine();
ImGui.SetNextItemWidth(65);
int isAnd = IsAnd ? 1 : 0;
if (ImGui.Combo($"##Rule" + GetHashCode().ToString(), ref isAnd, new string[]
{
"OR", "AND",
}, 2))
{
IsAnd = isAnd != 0;
}
ImGuiHelper.DrawCondition(IsTrue(combo));

ImGui.Separator();
ImGui.SameLine();
ImGui.SetNextItemWidth(65);
int isAnd = IsAnd ? 1 : 0;
if (ImGui.Combo($"##Rule" + GetHashCode().ToString(), ref isAnd, new string[]
{
"OR", "AND",
}, 2))
{
IsAnd = isAnd != 0;
}

var relay = Conditions;
if (ImGuiHelper.DrawEditorList(relay, i => i.Draw(combo)))
{
Conditions = relay;
}
ImGui.Separator();

ImGui.EndChild();
var relay = Conditions;
if (ImGuiHelper.DrawEditorList(relay, i => i.Draw(combo)))
{
Conditions = relay;
}

ImGui.EndGroup();

ControlWindow.HighLight(ImGui.GetWindowPos() + start, ImGui.GetItemRectSize());
}

private void AddButton()
Expand Down
2 changes: 0 additions & 2 deletions RotationSolver/ActionSequencer/ICondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

internal interface ICondition
{
const float DefaultHeight = 33;
bool IsTrue(ICustomRotation rotation);
void Draw(ICustomRotation rotation);
float Height { get; }
}
4 changes: 0 additions & 4 deletions RotationSolver/ActionSequencer/RotationCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ public bool IsTrue(ICustomRotation rotation)
return false;
}


[JsonIgnore]
public float Height => ICondition.DefaultHeight;

string searchTxt = string.Empty;
public void Draw(ICustomRotation rotation)
{
Expand Down
3 changes: 0 additions & 3 deletions RotationSolver/ActionSequencer/TargetCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ public bool IsTrue(ICustomRotation combo)
return Condition ? !result : result;
}

[JsonIgnore]
public float Height => ICondition.DefaultHeight;

string searchTxt = string.Empty;
public void Draw(ICustomRotation combo)
{
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType c
ImGui.EndGroup();
}

static void HighLight(Vector2 pt, Vector2 size, float thickness = 2f)
public static void HighLight(Vector2 pt, Vector2 size, float thickness = 2f)
{
var offset = ImGui.GetStyle().ItemSpacing / 2;
ImGui.GetWindowDrawList().AddRect(pt - offset, pt + size + offset,
Expand Down

0 comments on commit 21023ba

Please sign in to comment.