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

Commit

Permalink
fix: fixed some ui stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 6, 2024
1 parent 673dd83 commit 2654937
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public bool CanGet(GameObject obj)
{
if (IsPlayer && obj is not PlayerCharacter) return false;

if (!string.IsNullOrEmpty(DataID) && new Regex(DataID).IsMatch(obj.DataId.ToString("X"))) return false;
if (!string.IsNullOrEmpty(DataID) && !new Regex(DataID).IsMatch(obj.DataId.ToString("X"))) return false;

if (Role != JobRole.None && !obj.IsJobCategory(Role)) return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class ObjectDrawingGetter : IDrawingGetter
public bool IsActorEffect { get; set; } = false;
public Vector3 Position { get; set; }
public float Rotation { get; set; }
public Vector3 Scale { get; set; }
public Vector3 Scale { get; set; } = Vector3.One;
public ObjectGetter ObjectGetter { get; set; } = new();
public ObjectGetter TargetGetter { get; set; } = new();
public bool IsTargetByTarget { get; set; } = true;
Expand Down
4 changes: 0 additions & 4 deletions RotationSolver.Basic/Data/JobRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ public static Job[] ToJobs(this JobRole role)
JobRole.Melee => [Job.MNK, Job.DRG, Job.NIN, Job.SAM, Job.RPR],
JobRole.RangedPhysical => [Job.BRD, Job.MCH, Job.DNC],
JobRole.RangedMagical => [Job.BLM, Job.SMN, Job.RDM, Job.BLU],
JobRole.Ranged => [
.. JobRole.RangedPhysical.ToJobs(),
.. JobRole.RangedMagical.ToJobs()
],
_ => [],
};
}
Expand Down
12 changes: 11 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,15 @@
"TargetDelayName": "The range of random delay for finding a target.",
"ShowOmenName": "Show The Omen things.",
"AutoCloseChestWindowName": "Auto close the loot window when auto opened the chest.",
"RotationSolver.Data.UiString.ConfigWindow_About_OpenConfigFolder": "Open Config Folder"
"RotationSolver.Data.UiString.ConfigWindow_About_OpenConfigFolder": "Open Config Folder",
"RotationSolver.Basic.Configuration.Timeline.DrawingTimeline": "Drawing Timeline",
"RotationSolver.Basic.Configuration.Timeline.TimelineDrawing.StaticDrawingGetter": "Static Drawing",
"RotationSolver.Basic.Configuration.Timeline.TimelineDrawing.ObjectDrawingGetter": "Object Drawing",
"RotationSolver.Basic.Configuration.Timeline.TimelineDrawing.ActionDrawingGetter": "Action Drawing",
"RotationSolver.Basic.Data.JobRole.None": "None",
"RotationSolver.Basic.Data.JobRole.Tank": "Tank",
"RotationSolver.Basic.Data.JobRole.Melee": "Melee",
"RotationSolver.Basic.Data.JobRole.Healer": "Healer",
"RotationSolver.Basic.Data.JobRole.RangedPhysical": "RangedPhysical",
"RotationSolver.Basic.Data.JobRole.RangedMagical": "RangedMagical"
}
2 changes: 1 addition & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
#if DEBUG
if (Player.Available)
{
_ = XIVPainterMain.ShowOff();
//_ = XIVPainterMain.ShowOff();
}
#endif
}
Expand Down
16 changes: 9 additions & 7 deletions RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +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)
public static bool DrawDragFloat2(ConfigUnitType type, string name, ref Vector2 value, string id, string name1, string name2)
{
ImGui.Text(name);
var result = DrawDragFloat(type, name1, ref value.X);
result |= DrawDragFloat(type, name2, ref value.Y);
id = "##" + id;
var result = DrawDragFloat(type, name1 + id, ref value.X);
result |= DrawDragFloat(type, name2 + id, ref value.Y);
return result;
}

public static bool DrawDragFloat3(ConfigUnitType type, string name, ref Vector3 value, string name1, string name2, string name3)
public static bool DrawDragFloat3(ConfigUnitType type, string name, ref Vector3 value, string id, 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);
id = "##" + id;
var result = DrawDragFloat(type, name1 + id, ref value.X);
result |= DrawDragFloat(type, name2 + id, ref value.Y);
result |= DrawDragFloat(type, name3 + id, ref value.Z);
return result;
}

Expand Down
111 changes: 79 additions & 32 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,8 @@ static string GetName(TerritoryType? territory)
}
}


#if DEBUG
ImGui.SameLine();
ImGui.Text("Raid Time: " + TimeSpan.FromSeconds(DataCenter.RaidTimeRaw).ToString("hh\\:mm\\:ss\\.f"));
#endif

using var table = ImRaii.Table("Rotation Solver List Timeline", 3, ImGuiTableFlags.BordersInner | ImGuiTableFlags.Resizable | ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.ScrollY);
if (table)
Expand Down Expand Up @@ -811,6 +808,10 @@ void Down()
(Up, [VirtualKey.UP]),
(Down, [VirtualKey.DOWN]));

ImGui.SameLine();

using var grp = ImRaii.Group();

var time = timeLineItem.Time;
if (ConditionDrawer.DrawDragFloat(ConfigUnitType.Seconds, $" ##Time{timeLineItem.GetHashCode()}", ref time))
{
Expand Down Expand Up @@ -923,17 +924,36 @@ void Down()

if (IconSet.GetTexture(30, out var texture))
{
ImGui.Image(texture.ImGuiHandle, ConditionDrawer.IconSize * Vector2.One);
if (ImGuiHelper.SilenceImageButton(texture.ImGuiHandle, Vector2.One * ConditionDrawer.IconSize, false, $"Icon :{item.GetHashCode()}"))
{
if(_previewItems == null)
{
_previewItems = item.GetDrawing();
}
else
{
foreach (var preview in _previewItems)
{
preview.Dispose();
}
_previewItems = null;
}
}
}

ImGuiHelper.ExecuteHotKeysPopup(key, string.Empty, string.Empty, true,
(Delete, [VirtualKey.DELETE]),
(Up, [VirtualKey.UP]),
(Down, [VirtualKey.DOWN]));

ImGui.SameLine();
using var grp = ImRaii.Group();
DrawingGetterDraw(item, timelineItem.ActionIDs);
}

ImGui.Spacing();
ImGui.Spacing();

TimelineConditionDraw(drawingItem.Condition, timelineItem);

void AddButton()
Expand Down Expand Up @@ -970,11 +990,13 @@ private static void TimelineConditionDraw(ITimelineCondition con, TimelineItem t
{
if (con is TimelineConditionSet set)
{
using var grp = ImRaii.Group();
AddButton();
ConditionDrawer.DrawCondition(set.IsTrue(timelineItem));

ImGui.SameLine();
using var grp = ImRaii.Group();
ConditionDrawer.DrawByteEnum($"##Rule{set.GetHashCode()}", ref set.Type);
ImGui.Spacing();
ImGui.SameLine();
AddButton();

for (int i = 0; i < set.Conditions.Count; i++)
{
Expand Down Expand Up @@ -1021,6 +1043,7 @@ void Copy()
(Copy, [VirtualKey.CONTROL]));

ImGui.SameLine();
using var g = ImRaii.Group();

TimelineConditionDraw(condition, timelineItem);
}
Expand Down Expand Up @@ -1074,7 +1097,7 @@ void AddOneCondition<T>() where T : ITimelineCondition
target.Count = count;
}

DrawObjectGetter(target.Getter);
DrawObjectGetter(target.Getter, "Target Getter");
}
else if(con is TimelineConditionAction action)
{
Expand All @@ -1089,21 +1112,32 @@ void AddOneCondition<T>() where T : ITimelineCondition
}
}

static readonly string[] _omenNames = typeof(GroundOmenHostile).GetRuntimeFields()
static readonly IEnumerable<FieldInfo> _omenInfo = typeof(GroundOmenHostile).GetRuntimeFields()
.Concat(typeof(GroundOmenNone).GetRuntimeFields())
.Concat(typeof(GroundOmenFriendly).GetRuntimeFields())
.Concat(typeof(GroundOmenFriendly).GetRuntimeFields());

static readonly string[] _omenNames = _omenInfo
.Select(f => f.GetValue(null))
.OfType<string>().Select(OmenHelper.UnOmen).ToArray();
.OfType<string>().ToArray();

static readonly string[] _actorNames = typeof(ActorOmen).GetRuntimeFields()
static readonly string[] _omenShowNames = _omenInfo
.Select(f => f.Name).ToArray();

static readonly IEnumerable<FieldInfo> _actorInfo = typeof(ActorOmen).GetRuntimeFields();
static readonly string[] _actorNames = _actorInfo
.Select(f => f.GetValue(null))
.OfType<string>().Select(OmenHelper.UnLockOn).ToArray();
.OfType<string>().ToArray();

static readonly string[] _actorShowNames = _actorInfo
.Select(f => f.Name).ToArray();

private static IDisposable[]? _previewItems = null;
private static void DrawingGetterDraw(IDrawingGetter drawing, uint[] actionIds)
{
if (drawing is StaticDrawingGetter staticDrawing)
{
var index = Array.IndexOf(_omenNames, staticDrawing.Path.UnOmen());
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _omenNames, ref index))
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _omenShowNames, ref index))
{
staticDrawing.Path = _omenNames[index].Omen();
}
Expand All @@ -1115,13 +1149,13 @@ private static void DrawingGetterDraw(IDrawingGetter drawing, uint[] actionIds)
}

var pos = staticDrawing.Position;
if(ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position: ##" + drawing.GetHashCode(), ref pos, "X", "Y", "Z"))
if(ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position: ", ref pos, drawing.GetHashCode().ToString() + "Position", "X", "Y", "Z"))
{
staticDrawing.Position = pos;
}

var scale = staticDrawing.Scale;
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Scale: ##" + drawing.GetHashCode(), ref scale, "X", "Y", "Z"))
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Scale: ", ref scale, drawing.GetHashCode().ToString() + "Scale", "X", "Y", "Z"))
{
staticDrawing.Scale = scale;
}
Expand All @@ -1136,18 +1170,19 @@ private static void DrawingGetterDraw(IDrawingGetter drawing, uint[] actionIds)
objectDrawing.IsActorEffect = index != 0;
}

ImGui.SameLine();
if (objectDrawing.IsActorEffect)
{
index = Array.IndexOf(_actorNames, objectDrawing.Path.UnLockOn());
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _actorNames, ref index))
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _actorShowNames, ref index))
{
objectDrawing.Path = _actorNames[index].LockOn();
}
}
else
{
index = Array.IndexOf(_omenNames, objectDrawing.Path.UnOmen());
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _omenNames, ref index))
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _omenShowNames, ref index))
{
objectDrawing.Path = _omenNames[index].Omen();
}
Expand All @@ -1159,20 +1194,20 @@ private static void DrawingGetterDraw(IDrawingGetter drawing, uint[] actionIds)
}

var pos = objectDrawing.Position;
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position: ##" + drawing.GetHashCode(), ref pos, "X", "Y", "Z"))
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position: ", ref pos, drawing.GetHashCode().ToString() + "Position", "X", "Y", "Z"))
{
objectDrawing.Position = pos;
}

var scale = objectDrawing.Scale;
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Scale: ##" + drawing.GetHashCode(), ref scale, "X", "Y", "Z"))
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Scale: ", ref scale, drawing.GetHashCode().ToString() + "Scale", "X", "Y", "Z"))
{
objectDrawing.Scale = scale;
}
}

DrawObjectGetter(objectDrawing.ObjectGetter);
DrawTextDrawing(objectDrawing.ObjectText, "Object Text: ");
DrawObjectGetter(objectDrawing.ObjectGetter, "Object Getter");
DrawTextDrawing(objectDrawing.ObjectText, "Object Text");

var check = objectDrawing.GetATarget;
if(ImGui.Checkbox("Need a Target: ##" + drawing.GetHashCode(), ref check))
Expand All @@ -1191,15 +1226,15 @@ private static void DrawingGetterDraw(IDrawingGetter drawing, uint[] actionIds)

if (!check)
{
DrawObjectGetter(objectDrawing.TargetGetter);
DrawObjectGetter(objectDrawing.TargetGetter, "Target Getter");
}

DrawTextDrawing(objectDrawing.TargetText, "Target Text: ");
DrawTextDrawing(objectDrawing.TargetText, "Target Text");
}
else if(drawing is ActionDrawingGetter actionDrawing)
{
var index = Array.IndexOf(_omenNames, actionDrawing.Path.UnOmen());
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _omenNames, ref index))
if (ImGuiHelper.SelectableCombo("##PathName" + drawing.GetHashCode(), _omenShowNames, ref index))
{
actionDrawing.Path = _omenNames[index].Omen();
}
Expand All @@ -1220,7 +1255,7 @@ private static void DrawingGetterDraw(IDrawingGetter drawing, uint[] actionIds)
}

var pos = actionDrawing.Position;
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position: ##" + drawing.GetHashCode(), ref pos, "X", "Y", "Z"))
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position: ", ref pos, drawing.GetHashCode().ToString(), "X", "Y", "Z"))
{
actionDrawing.Position = pos;
}
Expand All @@ -1237,26 +1272,38 @@ private static void DrawingGetterDraw(IDrawingGetter drawing, uint[] actionIds)
actionDrawing.Y = scale;
}

DrawObjectGetter(actionDrawing.ObjectGetter);
DrawObjectGetter(actionDrawing.ObjectGetter, "Object Getter");
}
}

private static void DrawObjectGetter(ObjectGetter getter)
private static void DrawObjectGetter(ObjectGetter getter, string getterName)
{
ImGui.Text(getterName);

using var indent = new ImRaii.Indent();
indent.Push();

var check = getter.IsPlayer;
if (ImGui.Checkbox("Is A Player: ##" + getter.GetHashCode(), ref check))
{
getter.IsPlayer = check;
}

ImGui.SameLine();

ImGui.Text("Job Role:");
ImGui.SameLine();
var v = getter.Role;
if (ConditionDrawer.DrawByteEnum("Job Role: ##" + getter.GetHashCode(), ref v))
if (ConditionDrawer.DrawByteEnum("Job Role" + getter.GetHashCode(), ref v))
{
getter.Role = v;
}

ImGui.SameLine();

ImGui.SetNextItemWidth(150 * Scale);
var name = getter.DataID;
if(ImGui.InputText("Data ID :## " + getter.GetHashCode(), ref name, 256))
if(ImGui.InputText("Data ID## " + getter.GetHashCode(), ref name, 256))
{
getter.DataID = name;
}
Expand All @@ -1273,7 +1320,7 @@ private static void DrawTextDrawing(TextDrawing textDrawing, string name)
if (string.IsNullOrEmpty(text)) return;

var positionOffset = textDrawing.PositionOffset;
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position Offset: ##" + textDrawing.GetHashCode(), ref positionOffset, "X", "Y", "Z"))
if (ConditionDrawer.DrawDragFloat3(ConfigUnitType.Yalms, "Position Offset: ", ref positionOffset, textDrawing.GetHashCode().ToString(), "X", "Y", "Z"))
{
textDrawing.PositionOffset = positionOffset;
}
Expand All @@ -1286,7 +1333,7 @@ private static void DrawTextDrawing(TextDrawing textDrawing, string name)
}

var padding = textDrawing.Padding;
if (ConditionDrawer.DrawDragFloat2(ConfigUnitType.Pixels, "Background Padding: ##" + textDrawing.GetHashCode(), ref padding, "X", "Y"))
if (ConditionDrawer.DrawDragFloat2(ConfigUnitType.Pixels, "Background Padding: ", ref padding, textDrawing.GetHashCode().ToString(), "X", "Y"))
{
textDrawing.Padding = padding;
}
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/StateUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static RandomDelay
private static AutoStatus StatusFromAutomatic()
{
var hasTimeline = Service.Config.Timeline.TryGetValue(Svc.ClientState.TerritoryType, out var timeline)
&& timeline.Any(p => p.Value.Any());
&& timeline.Any(p => p.Value.Any(i => i is not DrawingTimeline));

AutoStatus status = AutoStatus.None;

Expand Down

0 comments on commit 2654937

Please sign in to comment.