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

Commit

Permalink
fix: add macro timeline item.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 7, 2024
1 parent 5a24eff commit 49c5723
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ internal class ITimelineItemConverter : JsonCreationConverter<BaseTimelineItem>
{
return new DrawingTimeline();
}

else if (FieldExists(nameof(MacroTimelineItem.Macro), jObject))
{
return new MacroTimelineItem();
}
return null;
}
}
26 changes: 26 additions & 0 deletions RotationSolver.Basic/Configuration/Timeline/MacroTimelineItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using ECommons.Automation;

namespace RotationSolver.Basic.Configuration.Timeline;
internal class MacroTimelineItem : BaseTimelineItem
{
public string Macro { get; set; } = "";

public override bool InPeriod(TimelineItem item)
{
var time = item.Time - DataCenter.RaidTimeRaw;

if (time < 0) return false;

if (time > Time || Time - time > 3) return false;
return true;
}

protected override void OnEnable()
{
if (!string.IsNullOrEmpty(Macro))
{
Chat.Instance.SendMessage(Macro);
}
base.OnEnable();
}
}
11 changes: 11 additions & 0 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,16 @@ void Down()
{
DrawDrawingTimeline(drawingItem, item);
}
else if(timeLineItem is MacroTimelineItem macroItem)
{
ImGui.SameLine();

var macro = macroItem.Macro;
if(ImGui.InputTextMultiline("Macro: ##" + macroItem.GetHashCode(), ref macro, 500, Vector2.One * -1))
{
macroItem.Macro = macro;
}
}
}

ImGui.TableNextRow();
Expand All @@ -870,6 +880,7 @@ void AddButton()
AddOneCondition<ActionTimelineItem>();
AddOneCondition<StateTimelineItem>();
AddOneCondition<DrawingTimeline>();
AddOneCondition<MacroTimelineItem>();
}

void AddOneCondition<T>() where T : BaseTimelineItem
Expand Down

0 comments on commit 49c5723

Please sign in to comment.