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

Commit

Permalink
fix: add drawing ui etc without tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 6, 2024
1 parent df13743 commit a2db516
Show file tree
Hide file tree
Showing 13 changed files with 509 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace RotationSolver.Basic.Configuration.Timeline;
[Description("Drawing Timeline")]
internal class DrawingTimeline : BaseTimelineItem
{
public float Duration { get; set; } = 5;

public ITimelineCondition Condition { get; set; } = new TrueTimelineCondition();
public List<IDrawingGetter> DrawingGetters { get; set; } = [];

Expand All @@ -21,7 +23,7 @@ public override bool InPeriod(TimelineItem item)
{
var time = item.Time - DataCenter.RaidTimeRaw;

if (time < 0) return false;
if (time < Time - Duration) return false;
if (time > Time) return false;

if (!Condition.IsTrue()) return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;
public class ObjectGetter
using Dalamud.Game.ClientState.Objects.SubKinds;

namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;

internal class ObjectGetter
{
public bool IsPlayer { get; set; } = false;
public uint DataID { get; set; } = 0;
public JobRole Role { get; set; } = JobRole.None;
public bool CanGet(GameObject obj)
{
return true;
}
if (IsPlayer && obj is not PlayerCharacter) return false;

public GameObject[] TargetGetter(GameObject obj)
{
return [];
if (DataID != 0 && obj.DataId != DataID) return false;

if (Role != JobRole.None && !obj.IsJobCategory(Role)) return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ internal class ActionDrawingGetter : IDrawingGetter
{
public uint ActionID { get; set; }
public string Path { get; set; } = "";
public float? X { get; set; }
public float? Y { get; set; }
public float X { get; set; }
public float Y { get; set; }
public Vector3 Position { get; set; }
public float Rotation { get; set; }
public ObjectGetter ObjectGetter { get; set; } = new();
Expand All @@ -39,8 +39,8 @@ public IDisposable[] GetDrawing()
var omen = action.Omen.Value?.Path?.RawString;
omen = string.IsNullOrEmpty(omen) ? Path : omen.Omen();

var x = X ?? (action.XAxisModifier > 0 ? action.XAxisModifier / 2 : action.EffectRange);
var y = Y ?? action.EffectRange;
var x = X != 0 ? X : (action.XAxisModifier > 0 ? action.XAxisModifier / 2 : action.EffectRange);
var y = Y != 0 ? Y : action.EffectRange;
var scale = new Vector3(x, XIVPainterMain.HeightScale, y);

if (action.TargetArea)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ internal class ObjectDrawingGetter : IDrawingGetter
public float Rotation { get; set; }
public Vector3 Scale { get; set; }
public ObjectGetter ObjectGetter { get; set; } = new();
public ObjectGetter TargetGetter { get; set; } = new();
public bool IsTargetByTarget { get; set; } = true;
public bool GetATarget { get; set; } = false;
public TextDrawing ObjectText { get; set; } = new();
public TextDrawing TargetText { get; set; } = new();

Expand All @@ -23,9 +26,23 @@ public IDisposable[] GetDrawing()
..objs.SelectMany(GetObjectDrawing)];
}

private GameObject[] TargetGet(GameObject obj)
{
if (!GetATarget) return [];
if (IsTargetByTarget)
{
var tar = obj.TargetObject;
if (tar == null) return [];
return [tar];
}
else
{
return [.. Svc.Objects.Where(TargetGetter.CanGet)];
}
}
private IDisposable[] GetTextDrawing(GameObject obj)
{
return [..ObjectGetter.TargetGetter(obj).Select(TargetText.GetText)
return [..TargetGet(obj).Select(TargetText.GetText)
.Append(ObjectText.GetText(obj))
.OfType<IDisposable>()];
}
Expand All @@ -34,7 +51,7 @@ private IDisposable[] GetObjectDrawing(GameObject obj)
{
if (string.IsNullOrEmpty(Path)) return [];

var targets = ObjectGetter.TargetGetter(obj);
var targets = TargetGet(obj);
if (IsActorEffect)
{
if (targets.Length > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace RotationSolver.Basic.Configuration.Timeline.TimelineDrawing;
internal class TextDrawing
{
public string? Text { get; set; }
public string Text { get; set; } = "";
public Vector3 PositionOffset { get; set; }

public Vector2 Padding { get; set; } = Vector2.One * 5;

public float Scale { get; set; } = 1;

public uint BackgroundColor { get; set; } = 0x00000080;
public Vector4 BackgroundColor { get; set; } = new(0, 0, 0, 0.5f);

public uint Color { get; set; } = uint.MaxValue;
public Vector4 Color { get; set; } = new(1, 1, 1, 1);

/// <summary>
/// The corner of the background.
Expand All @@ -26,8 +26,8 @@ internal class TextDrawing
{
HideIfInvisible = false,
Padding = Padding,
BackgroundColor = BackgroundColor,
Color = Color,
BackgroundColor = ImGui.ColorConvertFloat4ToU32(BackgroundColor),
Color = ImGui.ColorConvertFloat4ToU32(Color),
Scale = Scale,
};
}
Expand Down
30 changes: 15 additions & 15 deletions RotationSolver.Basic/Data/JobRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public enum JobRole : byte
/// </summary>
Melee = 2,

/// <summary>
///
/// </summary>
Ranged = 3,
///// <summary>
/////
///// </summary>
//Ranged = 3,

/// <summary>
///
Expand All @@ -43,15 +43,15 @@ public enum JobRole : byte
/// </summary>
RangedMagical = 6,

/// <summary>
///
/// </summary>
DiscipleOfTheLand = 7,
///// <summary>
/////
///// </summary>
//DiscipleOfTheLand = 7,

/// <summary>
///
/// </summary>
DiscipleOfTheHand = 8,
///// <summary>
/////
///// </summary>
//DiscipleOfTheHand = 8,
}

/// <summary>
Expand All @@ -68,14 +68,14 @@ public static JobRole GetJobRole(this ClassJob job)
{
var role = (JobRole)job.Role;

if (role is JobRole.Ranged or JobRole.None)
if (role is (JobRole)3 or JobRole.None)
{
role = job.ClassJobCategory.Row switch
{
30 => JobRole.RangedPhysical,
31 => JobRole.RangedMagical,
32 => JobRole.DiscipleOfTheLand,
33 => JobRole.DiscipleOfTheHand,
//32 => JobRole.DiscipleOfTheLand,
//33 => JobRole.DiscipleOfTheHand,
_ => JobRole.None,
};
}
Expand Down
25 changes: 22 additions & 3 deletions RotationSolver.Basic/Data/TimelineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal enum TimelineType : byte
internal struct TimelineItem(float time, string name, TimelineType type, JObject? obj, RaidLangs langs, float? jumpTime, float windowMin, float windowMax)
{
private uint[]? ids = null;

public uint LastActionID { get; set; }
public uint[] ActionIDs => ids ??= GetActionIds();
private readonly uint[] GetActionIds()
{
Expand All @@ -26,15 +28,32 @@ private readonly uint[] GetActionIds()

if (idsRaw == null || idsRaw.Length == 0) return [];

var regex = idsRaw.Select(id => new Regex(id));
List<uint> reuslt = [];
List<Regex> regexes = [];

foreach ( var id in idsRaw)
{
if(uint.TryParse(id, out var i))
{
reuslt.Add(i);
}
else
{
regexes.Add(new(id));
}
}

if (regexes.Count == 0) return [.. reuslt];

#if DEBUG
Svc.Log.Debug("Need to cast the regex, with " + string.Join(", ", regexes));
#endif
var count = Svc.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()?.RowCount ?? ushort.MaxValue;

List<uint> reuslt = [];
for (uint i = 0; i < count; i++)
{
var text = i.ToString("X");
if (regex.Any(i => i.IsMatch(text)))
if (regexes.Any(i => i.IsMatch(text)))
{
reuslt.Add(i);
}
Expand Down
16 changes: 16 additions & 0 deletions RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ public static bool DrawByteEnum<T>(string name, ref T value) where T : struct, E
}
return false;
}
public static bool DrawDragFloat2(ConfigUnitType type, string name, ref Vector2 value, string name1, string name2)
{
ImGui.Text(name);
var result = DrawDragFloat(type, name1, ref value.X);
result |= DrawDragFloat(type, name2, ref value.Y);
return result;
}

public static bool DrawDragFloat3(ConfigUnitType type, string name, ref Vector3 value, string name1, string name2, string name3)
{
ImGui.Text(name);
var result = DrawDragFloat(type, name1, ref value.X);
result |= DrawDragFloat(type, name2, ref value.Y);
result |= DrawDragFloat(type, name3, ref value.Z);
return result;
}

public static bool DrawDragFloat(ConfigUnitType type, string name, ref float value)
{
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ public static void SearchCombo<T>(string popId, string name, ref string searchTx
public static unsafe bool SelectableCombo(string popUp, string[] items, ref int index, ImFontPtr? font = null, Vector4? color = null)
{
var count = items.Length;
var originIndex = index;
index = Math.Max(0, index) % count;
var name = items[index] + "##" + popUp;

var result = false;
var result = originIndex != index;

if (SelectableButton(name, font, color))
{
Expand Down
Loading

0 comments on commit a2db516

Please sign in to comment.