Skip to content

Commit

Permalink
Merge pull request lichie567#47 from lichie567/develop
Browse files Browse the repository at this point in the history
merge Develop
  • Loading branch information
lichie567 authored May 6, 2022
2 parents ebfbb2e + 4eccd8c commit b28f32c
Show file tree
Hide file tree
Showing 33 changed files with 987 additions and 153 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.2.1")]
[assembly: AssemblyFileVersion("0.2.2.1")]
[assembly: AssemblyVersion("0.2.3.0")]
[assembly: AssemblyFileVersion("0.2.3.0")]
31 changes: 31 additions & 0 deletions XIVAuras/Auras/AuraGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,36 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi

this.LastFrameWasPreview = this.Preview;
}

public void ResizeIcons(Vector2 size, bool recurse, bool conditions)
{
foreach (AuraListItem item in this.AuraList.Auras)
{
if (item is AuraIcon icon)
{
icon.Resize(size, conditions);
}
else if (recurse && item is AuraGroup group)
{
group.ResizeIcons(size, recurse, conditions);
}
}
}

public void ScaleResolution(Vector2 scaleFactor, bool positionOnly)
{
this.GroupConfig.Position *= scaleFactor;
foreach (AuraListItem item in this.AuraList.Auras)
{
if (item is AuraIcon icon)
{
icon.ScaleResolution(scaleFactor, positionOnly);
}
else if (item is AuraGroup group)
{
group.ScaleResolution(scaleFactor, positionOnly);
}
}
}
}
}
52 changes: 48 additions & 4 deletions XIVAuras/Auras/AuraIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public override IEnumerable<IConfigPage> GetConfigPages()
yield return this.IconStyleConfig;
yield return this.LabelListConfig;
yield return this.TriggerConfig;

// ugly hack
this.StyleConditions.UpdateTriggerCount(this.TriggerConfig.TriggerOptions.Count);
this.StyleConditions.UpdateDefaultStyle(this.IconStyleConfig);

yield return this.StyleConditions;
yield return this.VisibilityConfig;
}
Expand All @@ -53,6 +58,8 @@ public override void ImportPage(IConfigPage page)
this.TriggerConfig = newPage;
break;
case StyleConditions<IconStyleConfig> newPage:
newPage.UpdateTriggerCount(0);
newPage.UpdateDefaultStyle(this.IconStyleConfig);
this.StyleConditions = newPage;
break;
case VisibilityConfig newPage:
Expand All @@ -74,11 +81,19 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi
return;
}

bool triggered = this.TriggerConfig.IsTriggered(this.Preview, out DataSource data);
IconStyleConfig style = this.StyleConditions.GetStyle(data) ?? this.IconStyleConfig;
bool triggered = this.TriggerConfig.IsTriggered(this.Preview, out DataSource[] datas, out int triggeredIndex);
DataSource data = datas[triggeredIndex];
IconStyleConfig style = this.StyleConditions.GetStyle(datas, triggeredIndex) ?? this.IconStyleConfig;

Vector2 localPos = pos + style.Position;
Vector2 size = style.Size;

if (Singletons.Get<PluginManager>().ShouldClip())
{
ClipRect? clipRect = Singletons.Get<ClipRectsHelper>().GetClipRectForArea(localPos, size);
if (clipRect.HasValue)
return;
}

if (triggered || this.Preview)
{
Expand Down Expand Up @@ -128,7 +143,7 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi
{
if (style.GcdSwipe && (data.Value == 0 || data.MaxValue == 0 || style.GcdSwipeOnly))
{
SpellHelpers.GetGCDInfo(out var recastInfo);
ActionHelpers.GetGCDInfo(out var recastInfo);
DrawProgressSwipe(style, localPos, size, recastInfo.RecastTime - recastInfo.RecastTimeElapsed, recastInfo.RecastTime, alpha, drawList);
}
else
Expand Down Expand Up @@ -172,7 +187,7 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi

if (triggered || label.Preview)
{
label.SetData(data);
label.SetData(datas, triggeredIndex);
label.Draw(localPos, size, visible);
}
}
Expand Down Expand Up @@ -239,6 +254,35 @@ private void DrawIconGlow(Vector2 pos, Vector2 size, int thickness, int segments
DrawHelpers.DrawSegmentedLineVertical(drawList, c4, thickness, -size.Y, prog, segments, col1, col2);
}

public void Resize(Vector2 size, bool conditions)
{
this.IconStyleConfig.Size = size;

if (conditions)
{
foreach (var condition in this.StyleConditions.Conditions)
{
condition.Style.Size = size;
}
}
}

public void ScaleResolution(Vector2 scaleFactor, bool positionOnly)
{
this.IconStyleConfig.Position *= scaleFactor;

if (!positionOnly)
this.IconStyleConfig.Size *= scaleFactor;

foreach (var condition in this.StyleConditions.Conditions)
{
condition.Style.Position *= scaleFactor;

if (!positionOnly)
condition.Style.Size *= scaleFactor;
}
}

public static AuraIcon GetDefaultAuraIcon(string name)
{
AuraIcon newIcon = new AuraIcon(name);
Expand Down
13 changes: 8 additions & 5 deletions XIVAuras/Auras/AuraLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace XIVAuras.Auras
{
public class AuraLabel : AuraListItem
{
[JsonIgnore] private DataSource? _data;
[JsonIgnore] private DataSource[]? _data;
[JsonIgnore] private int _dataIndex;

public override AuraType Type => AuraType.Label;

Expand Down Expand Up @@ -62,10 +63,10 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi
Vector2 size = parentSize.HasValue ? parentSize.Value : ImGui.GetMainViewport().Size;
pos = parentSize.HasValue ? pos : Vector2.Zero;

LabelStyleConfig style = this.StyleConditions.GetStyle(_data) ?? this.LabelStyleConfig;
LabelStyleConfig style = this.StyleConditions.GetStyle(_data, _dataIndex) ?? this.LabelStyleConfig;

string text = _data is not null
? _data.GetFormattedString(style.TextFormat, "N", style.Rounding)
string text = _data is not null && _dataIndex < _data.Length && _data[_dataIndex] is not null
? _data[_dataIndex].GetFormattedString(style.TextFormat, "N", style.Rounding)
: style.TextFormat;

using (FontsManager.PushFont(style.FontKey))
Expand All @@ -83,9 +84,11 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi
}
}

public void SetData(DataSource data)
public void SetData(DataSource[] data, int index)
{
_data = data;
_dataIndex = index;
this.StyleConditions.UpdateTriggerCount(data.Length);
}
}
}
2 changes: 1 addition & 1 deletion XIVAuras/Config/AboutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AboutPage : IConfigPage

public IConfigPage GetDefault() => new AboutPage();

public void DrawConfig(Vector2 size, float padX, float padY)
public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float padY)
{
if (ImGui.BeginChild("##AboutPage", new Vector2(size.X, size.Y), true))
{
Expand Down
2 changes: 1 addition & 1 deletion XIVAuras/Config/AuraListConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public AuraListConfig()

public IConfigPage GetDefault() => new AuraListConfig();

public void DrawConfig(Vector2 size, float padX, float padY)
public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float padY)
{
this.DrawCreateMenu(size, padX);
this.DrawAuraTable(size.AddY(-padY), padX);
Expand Down
2 changes: 1 addition & 1 deletion XIVAuras/Config/BarStyleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class BarStyleConfig : IConfigPage

public IConfigPage GetDefault() => new BarStyleConfig();

public void DrawConfig(Vector2 size, float padX, float padY)
public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float padY)
{
if (ImGui.BeginChild("##BarStyleConfig", new Vector2(size.X, size.Y), true))
{
Expand Down
1 change: 1 addition & 0 deletions XIVAuras/Config/CharacterStateTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public override bool IsTriggered(bool preview, out DataSource data)
data.Gp = chara.CurrentGp;
data.MaxGp = chara.MaxGp;
data.Level = chara.Level;
data.Distance = chara.YalmDistanceX;
data.HasPet = this.TriggerSource == TriggerSource.Player &&
Singletons.Get<BuddyList>().PetBuddy != null;

Expand Down
39 changes: 26 additions & 13 deletions XIVAuras/Config/CooldownTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public class CooldownTrigger : TriggerOptions
[JsonIgnore] private static readonly string[] _usableOptions = new[] { "Usable", "Not Usable" };
[JsonIgnore] private static readonly string[] _rangeOptions = new[] { "In Range", "Not in Range" };
[JsonIgnore] private static readonly string[] _losOptions = new[] { "In LoS", "Not in LoS" };
[JsonIgnore] private static readonly string[] _combatTypeOptions = new[] { "PvE", "PvP" };

[JsonIgnore] private string _triggerNameInput = string.Empty;
[JsonIgnore] private string _cooldownValueInput = string.Empty;
[JsonIgnore] private string _chargeCountValueInput = string.Empty;

public string TriggerName = string.Empty;

public CombatType CombatType = CombatType.PvE;
public bool Adjust = false;

public bool Cooldown = false;
Expand Down Expand Up @@ -50,22 +52,22 @@ public class CooldownTrigger : TriggerOptions
public override bool IsTriggered(bool preview, out DataSource data)
{
data = new DataSource();
if (!this.TriggerData.Any())
{
return false;
}

if (preview)
{
data.Value = 10;
data.Stacks = 2;
data.MaxStacks = 2;
data.Icon = this.TriggerData.FirstOrDefault().Icon;
data.Icon = this.TriggerData.FirstOrDefault()?.Icon ?? 0;
return true;
}

TriggerData? actionTrigger = this.TriggerData.FirstOrDefault(t => t.CombatType == this.CombatType);
if (actionTrigger is null)
{
return false;
}

SpellHelpers helper = Singletons.Get<SpellHelpers>();
TriggerData actionTrigger = this.TriggerData.First();
ActionHelpers helper = Singletons.Get<ActionHelpers>();
uint actionId = this.Adjust ? helper.GetAdjustedActionId(actionTrigger.Id) : actionTrigger.Id;
helper.GetAdjustedRecastInfo(actionId, out RecastInfo recastInfo);

Expand Down Expand Up @@ -121,7 +123,7 @@ public override bool IsTriggered(bool preview, out DataSource data)
data.MaxStacks = recastInfo.MaxCharges;
data.Icon = this.Adjust ? helper.GetIconIdForAction(actionId) : actionTrigger.Icon;

return preview ||
return
(!this.Combo || (this.ComboValue == 0 ? comboActive : !comboActive)) &&
(!this.Usable || (this.UsableValue == 0 ? usable : !usable)) &&
(!this.RangeCheck || (this.RangeValue == 0 ? inRange : !inRange)) &&
Expand All @@ -134,18 +136,22 @@ public override void DrawTriggerOptions(Vector2 size, float padX, float padY)
{
if (string.IsNullOrEmpty(_triggerNameInput))
{
_triggerNameInput = TriggerName;
_triggerNameInput = this.TriggerName;
}

ImGui.Combo("Combat Type", ref Unsafe.As<CombatType, int>(ref this.CombatType), _combatTypeOptions, _combatTypeOptions.Length);
if (ImGui.InputTextWithHint("Action", "Action Name or ID", ref _triggerNameInput, 32, ImGuiInputTextFlags.EnterReturnsTrue))
{
this.TriggerData.Clear();
if (!string.IsNullOrEmpty(_triggerNameInput))
{
SpellHelpers.FindActionEntries(_triggerNameInput).ForEach(t => AddTriggerData(t));
foreach (var triggerData in ActionHelpers.FindActionEntries(_triggerNameInput))
{
AddTriggerData(triggerData);
}
}

_triggerNameInput = TriggerName;
_triggerNameInput = this.TriggerName;
}
ImGui.Checkbox("Use Adjusted Action", ref this.Adjust);
if (ImGui.IsItemHovered())
Expand Down Expand Up @@ -279,12 +285,19 @@ public override void DrawTriggerOptions(Vector2 size, float padX, float padY)
ImGui.PopItemWidth();
}
}

private void ResetTrigger()
{
this.TriggerData.Clear();
this.TriggerName = string.Empty;
this._triggerNameInput = string.Empty;
}

private void AddTriggerData(TriggerData triggerData)
{
this.TriggerName = triggerData.Name.ToString();
_triggerNameInput = TriggerName;
this.TriggerData.Add(triggerData);
_triggerNameInput = this.TriggerName;
}
}
}
2 changes: 1 addition & 1 deletion XIVAuras/Config/FontConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public FontConfig()
}
}

public void DrawConfig(Vector2 size, float padX, float padY)
public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float padY)
{
if (_fonts.Length == 0)
{
Expand Down
Loading

0 comments on commit b28f32c

Please sign in to comment.