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

Commit

Permalink
fix: ui thing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 17, 2023
1 parent 8d007d1 commit ceac4df
Show file tree
Hide file tree
Showing 19 changed files with 249 additions and 345 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public unsafe virtual bool CanUse(out IAction act, CanUseOption option = CanUseO
if (!SkipDisable && !IsEnabled) return false;
if (IsDutyAction && !IsDutyActionOnSlot) return false;

if (DataCenter.DisabledAction != null && DataCenter.DisabledAction.Contains(ID)) return false;
if (DataCenter.DisabledActionSequencer != null && DataCenter.DisabledActionSequencer.Contains(ID)) return false;

if (ConfigurationHelper.BadStatus.Contains(ActionManager.Instance()->GetActionStatus(ActionType.Spell, AdjustedID)))
return false;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/BaseItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public virtual unsafe bool CanUse(out IAction item, bool clippingCheck = true)
item = this;
if (_item == null) return false;
if (!CanUseThis) return false;
if (DataCenter.DisabledAction != null && DataCenter.DisabledAction.Contains(ID)) return false;
if (DataCenter.DisabledActionSequencer != null && DataCenter.DisabledActionSequencer.Contains(ID)) return false;
if(!IsEnabled) return false;

if (ConfigurationHelper.BadStatus.Contains(ActionManager.Instance()->GetActionStatus(ActionType.Item, ID))
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static bool SetAutoStatus(AutoStatus status, bool keep)
}
return keep;
}
public static HashSet<uint> DisabledAction { get; set; } = new HashSet<uint>();
public static HashSet<uint> DisabledActionSequencer { get; set; } = new HashSet<uint>();

private static List<NextAct> NextActs = new();
public static IAction ActionSequencerAction { private get; set; }
Expand Down
1 change: 1 addition & 0 deletions RotationSolver.Basic/Rotations/Basic/RPR_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public abstract class RPR_Base : CustomRotation
{
TargetStatus = new[] { StatusID.DeathsDesign },
ActionCheck = (b, m) => !HasSoulReaver,
TimeToDie = 10,
};

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions RotationSolver/ActionSequencer/ActionCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ public void Draw(ICustomRotation combo)
{
ConditionHelper.CheckBaseAction(combo, ID, ref _action);

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

var name = _action?.Name ?? string.Empty;
ImGui.SetNextItemWidth(Math.Max(80, ImGui.CalcTextSize(name).X + 30));

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/ActionSequencer/ConditionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static bool DrawCheckBox(string name, ref int value, string desc = "")
result = true;
}

ImGuiHelper.HoveredString(desc);
ImguiTooltips.HoveredTooltip(desc);

return result;
}
Expand Down
85 changes: 66 additions & 19 deletions RotationSolver/ActionSequencer/ConditionSet.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
using RotationSolver.Localization;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface.Colors;
using ECommons.ImGuiMethods;
using FFXIVClientStructs.Havok;
using RotationSolver.Localization;
using RotationSolver.UI;
using RotationSolver.UI.SearchableConfigs;
using System.Windows.Forms;

namespace RotationSolver.ActionSequencer;

Expand All @@ -10,44 +16,69 @@ public bool IsTrue(ICustomRotation combo) => Conditions.Count != 0 && (IsAnd ? C
public List<ICondition> Conditions { get; set; } = new List<ICondition>();
public bool IsAnd { get; set; }

public void Draw(ICustomRotation combo)
public void Draw(ICustomRotation rotation)
{
var start = ImGui.GetCursorPos();
ImGui.BeginGroup();

AddButton();

ImGui.SameLine();

ImGuiHelper.DrawCondition(IsTrue(combo));

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

ImGui.Spacing();

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

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

void Delete()
{
Conditions.RemoveAt(i);
};

void Up()
{
Conditions.RemoveAt(i);
Conditions.Insert(Math.Max(0, i - 1), condition);
};
void Down()
{
Conditions.RemoveAt(i);
Conditions.Insert(Math.Min(Conditions.Count - 1, i + 1), condition);
}

var key = $"Condition Pop Up: {condition.GetHashCode()}";

Searchable.DrawHotKeysPopup(key, string.Empty,
(LocalizationManager.RightLang.ConfigWindow_List_Remove, Delete, new string[] { "Delete" }),
(LocalizationManager.RightLang.ConfigWindow_Actions_MoveUp, Up, new string[] { "↑" }),
(LocalizationManager.RightLang.ConfigWindow_Actions_MoveDown, Down, new string[] { "↓" }));

DrawCondition(condition.IsTrue(rotation));

Searchable.ExecuteHotKeysPopup(key, string.Empty, string.Empty, true,
(Delete, new VirtualKey[] { VirtualKey.DELETE }),
(Up, new VirtualKey[] { VirtualKey.UP }),
(Down, new VirtualKey[] { VirtualKey.DOWN }));

ImGui.SameLine();

condition.Draw(rotation);
}

ImGui.Unindent();
ImGui.EndGroup();

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

private void AddButton()
{
if (ImGuiHelper.IconButton(FontAwesomeIcon.Plus, "AddButton" + GetHashCode().ToString()))
if (ImGuiEx.IconButton(FontAwesomeIcon.Plus, "AddButton" + GetHashCode().ToString()))
{
ImGui.OpenPopup("Popup" + GetHashCode().ToString());
}
Expand All @@ -71,4 +102,20 @@ private void AddOneCondition<T>(string name) where T : ICondition
ImGui.CloseCurrentPopup();
}
}

internal static void DrawCondition(bool? tag)
{
if (!tag.HasValue)
{
ImGui.TextColored(ImGuiColors.DalamudGrey3, "Null");
}
else if (tag.Value)
{
ImGui.TextColored(ImGuiColors.HealerGreen, "True");
}
else
{
ImGui.TextColored(ImGuiColors.DalamudRed, "False");
}
}
}
28 changes: 25 additions & 3 deletions RotationSolver/ActionSequencer/MajorConditionSet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using ECommons.DalamudServices;
using Lumina.Data.Parsing;
using static FFXIVClientStructs.FFXIV.Client.UI.AddonAOZNotebook;

namespace RotationSolver.ActionSequencer;

Expand All @@ -7,15 +9,35 @@ internal class MajorConditionSet
/// <summary>
/// Key for action id.
/// </summary>
public Dictionary<uint, ConditionSet> Conditions { get; } = new Dictionary<uint, ConditionSet>();
public Dictionary<uint, ConditionSet> Conditions { get; } = new ();

public Dictionary<uint, ConditionSet> DiabledConditions { get; } = new Dictionary<uint, ConditionSet>();
public Dictionary<uint, ConditionSet> DiabledConditions { get; } = new();

public string Name;
public void DrawCondition(uint id, ICustomRotation rotation)
{

if (!Conditions.TryGetValue(id, out var conditionSet))
{
conditionSet = Conditions[id] = new ConditionSet();
}

if (conditionSet == null) return;

public MajorConditionSet()
ConditionSet.DrawCondition(conditionSet.IsTrue(rotation));
conditionSet?.Draw(rotation);
}

public void DrawDisabledCondition(uint id, ICustomRotation rotation)
{
if (!DiabledConditions.TryGetValue(id, out var conditionSet))
{
conditionSet = DiabledConditions[id] = new ConditionSet();
}
if (conditionSet == null) return;

ConditionSet.DrawCondition(conditionSet.IsTrue(rotation));
conditionSet?.Draw(rotation);
}

public MajorConditionSet(string name)
Expand Down
74 changes: 42 additions & 32 deletions RotationSolver/ActionSequencer/RotationCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ public void Draw(ICustomRotation rotation)
{
UpdateInfo(rotation);

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

ConditionHelper.DrawByteEnum($"##Category{GetHashCode()}", ref ComboConditionType, EnumTranslations.ToName);

switch (ComboConditionType)
Expand Down Expand Up @@ -163,35 +160,48 @@ public void Draw(ICustomRotation rotation)

break;

//case ComboConditionType.Last:
// ImGui.SameLine();
// ImGuiHelper.SearchItemsReflection($"##Time{GetHashCode()}", _method?.GetMemberName(), ref searchTxt, rotation.AllLast, i =>
// {
// _method = i;
// MethodName = i.Name;
// });

// ImGui.SameLine();
// ImGui.SetNextItemWidth(80);
// ImGui.Combo($"##IsNot{GetHashCode()}", ref Condition, new string[]
// {
// LocalizationManager.RightLang.ActionSequencer_Is,
// LocalizationManager.RightLang.ActionSequencer_Isnot,
// }, 2);

// ImGui.SameLine();
// var name = _action?.Name ?? string.Empty;
// ImGuiHelper.SearchCombo($"##ActionChoice{GetHashCode()}", name, ref searchTxt, rotation.AllBaseActions, i =>
// {
// _action = (BaseAction)i;
// ID = (ActionID)_action.ID;
// });

// ImGui.SameLine();
// ImGui.SetNextItemWidth(50);
// ImGui.Combo($"##Adjust{GetHashCode()}", ref Param1, new string[] { "Original", "Adjusted" }, 2);

// break;
case ComboConditionType.Last:
ImGui.SameLine();

ImGui.SetNextItemWidth(Math.Max(80, ImGui.CalcTextSize(MethodName).X + 30));
if (ImGui.BeginCombo($"##Last{GetHashCode()}", MethodName))
{
foreach(var methodName in new string[]
{
nameof(CustomRotation.IsLastGCD),
nameof(CustomRotation.IsLastAction),
nameof(CustomRotation.IsLastAbility),
})
{
if (ImGui.Selectable(methodName))
{
MethodName = methodName;
}
}
ImGui.EndCombo();
}

ImGui.SameLine();
ImGui.SetNextItemWidth(80);
ImGui.Combo($"##IsNot{GetHashCode()}", ref Condition, new string[]
{
LocalizationManager.RightLang.ActionSequencer_Is,
LocalizationManager.RightLang.ActionSequencer_Isnot,
}, 2);

ImGui.SameLine();
var name = _action?.Name ?? string.Empty;
ImGuiHelper.SearchCombo($"##ActionChoice{GetHashCode()}", name, ref searchTxt, rotation.AllBaseActions, i =>
{
_action = (BaseAction)i;
ID = (ActionID)_action.ID;
});

ImGui.SameLine();
ImGui.SetNextItemWidth(50);
ImGui.Combo($"##Adjust{GetHashCode()}", ref Param1, new string[] { "Original", "Adjusted" }, 2);

break;
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions RotationSolver/ActionSequencer/TargetCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ public void Draw(ICustomRotation combo)
Status = AllStatus.FirstOrDefault(a => a.ID == StatusId);
}

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

var name = _action != null ? string.Format(LocalizationManager.RightLang.ActionSequencer_ActionTarget, _action.Name)
: IsTarget
? LocalizationManager.RightLang.ActionSequencer_Target
Expand Down Expand Up @@ -205,7 +202,7 @@ public void Draw(ICustomRotation combo)
ImGui.SameLine();

ImGui.Checkbox($"{LocalizationManager.RightLang.ActionSequencer_StatusSelf}##Self{GetHashCode()}", ref FromSelf);
ImGuiHelper.HoveredString(LocalizationManager.RightLang.ActionSequencer_StatusSelfDesc);
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ActionSequencer_StatusSelfDesc);
break;

case TargetConditionType.StatusEnd:
Expand All @@ -221,7 +218,7 @@ public void Draw(ICustomRotation combo)

ImGui.Checkbox($"{LocalizationManager.RightLang.ActionSequencer_StatusSelf}##Self{GetHashCode()}", ref FromSelf);

ImGuiHelper.HoveredString(LocalizationManager.RightLang.ActionSequencer_StatusSelfDesc);
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ActionSequencer_StatusSelfDesc);

ConditionHelper.DrawDragFloat($"s##Seconds{GetHashCode()}", ref DistanceOrTime);
break;
Expand All @@ -240,7 +237,7 @@ public void Draw(ICustomRotation combo)

ImGui.Checkbox($"{LocalizationManager.RightLang.ActionSequencer_StatusSelf}##Self{GetHashCode()}", ref FromSelf);

ImGuiHelper.HoveredString(LocalizationManager.RightLang.ActionSequencer_StatusSelfDesc);
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ActionSequencer_StatusSelfDesc);

ConditionHelper.DrawDragInt($"GCD##GCD{GetHashCode()}", ref GCD);
ConditionHelper.DrawDragFloat($"{LocalizationManager.RightLang.ActionSequencer_TimeOffset}##Ability{GetHashCode()}", ref DistanceOrTime);
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,4 +698,6 @@ internal partial class Strings
public string ConfigWindow_Tab_Target { get; set; } = "The way to find the targets, hostiles or friends.";
public string ConfigWindow_Tab_Extra { get; set; } = "Some features shouldn't be included by RS.";
public string ConfigWindow_List_AddPosition { get; set; } = "Add One territory position";
public string ConfigWindow_Actions_MoveUp { get; set; } = "Move Up";
public string ConfigWindow_Actions_MoveDown { get; set; } = "Move Down";
}
6 changes: 3 additions & 3 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static void DrawIAction(nint handle, string id, float width, SpecialCommandType
ImGui.PopID();
if (ImGui.IsItemHovered())
{
ImGuiHelper.ShowTooltip(help);
ImguiTooltips.ShowTooltip(help);
}
}

Expand All @@ -386,7 +386,7 @@ static void DrawIAction(nint handle, string id, float width, StateCommandType co
ImGui.PopID();
if (ImGui.IsItemHovered())
{
ImGuiHelper.ShowTooltip(help);
ImguiTooltips.ShowTooltip(help);
}
}

Expand Down Expand Up @@ -519,7 +519,7 @@ static unsafe void DrawNextAction(float gcd, float ability, float width)
{
var help = LocalizationManager.RightLang.ConfigWindow_Control_ResetButtonOrKeyCommand;

ImGuiHelper.ShowTooltip(help);
ImguiTooltips.ShowTooltip(help);
}
}
}
2 changes: 1 addition & 1 deletion RotationSolver/UI/CooldownWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private static void DrawActionCooldown(IAction act)
var pair = ControlWindow.DrawIAction(act, width, r, false);
var pos = pair.Item1;
var size = pair.Item2;
ImGuiHelper.HoveredString(act.Name + "\n" + LocalizationManager.RightLang.ConfigWindow_Control_ClickToUse);
ImguiTooltips.HoveredTooltip(act.Name + "\n" + LocalizationManager.RightLang.ConfigWindow_Control_ClickToUse);

if (!act.EnoughLevel)
{
Expand Down
Loading

0 comments on commit ceac4df

Please sign in to comment.