Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DynamicBridge/Configuration/ApplyRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ApplyRule
public List<int> Gearsets = [];
public List<string> Players = [];
public List<uint> OnlineStatuses = [];
public List<uint> Mounts = [];
public List<TimelineSegment> Precise_Times = [
new TimelineSegment((float)0/24,(float)5/24,0),
new TimelineSegment((float)5/24,(float)7/24,0),
Expand Down Expand Up @@ -54,5 +55,6 @@ public class NotConditions
public List<int> Gearsets = [];
public List<string> Players = [];
public List<uint> OnlineStatuses = [];
public List<uint> Mounts = [];
}
}
1 change: 1 addition & 0 deletions DynamicBridge/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class Config : IEzConfig
public bool Cond_Gearset = false;
public bool Cond_Players = false;
public bool Cond_OnlineStatus = false;
public bool Cond_Mount = false;
public bool Cond_Delay = false;

public bool Cond_Time_Precise = false;
Expand Down
5 changes: 4 additions & 1 deletion DynamicBridge/DynamicBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ private void OnUpdate()
&& (!C.AllowNegativeConditions || !x.Not.Players.Any(rp => GuiPlayers.SimpleNearbyPlayers().Any(sp => rp == sp.Name && C.selectedPlayers.Any(sel => sel.Name == sp.Name && (sel.Distance >= sp.Distance || sel.Distance >= 150f))))))
&&
(!C.Cond_OnlineStatus || ((x.OnlineStatuses.Count == 0 || x.OnlineStatuses.Contains(Player.OnlineStatus))
&& (!C.AllowNegativeConditions || !x.Not.OnlineStatuses.Contains(Player.OnlineStatus))));
&& (!C.AllowNegativeConditions || !x.Not.OnlineStatuses.Contains(Player.OnlineStatus))))
&&
(!C.Cond_Mount || ((x.Mounts.Count == 0 || x.Mounts.Contains(Utils.GetCurrentMountId()))
&& (!C.AllowNegativeConditions || !x.Not.Mounts.Contains(Utils.GetCurrentMountId()))));

if(conditionsMet)
{
Expand Down
48 changes: 46 additions & 2 deletions DynamicBridge/Gui/GuiRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
using ECommons.Throttlers;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
using System.Globalization;
using System.IO;
using Action = System.Action;
using Emote = Lumina.Excel.Sheets.Emote;
using Mount = Lumina.Excel.Sheets.Mount;
using Weather = Lumina.Excel.Sheets.Weather;


namespace DynamicBridge.Gui;

public static unsafe class GuiRules
{

private static Vector2 iconSize => new(24f);

private static string[] Filters = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""];
Expand Down Expand Up @@ -45,7 +49,6 @@ void ButtonsLeft()
}
}
ImGuiEx.Tooltip("Add new rule");

ImGui.SameLine();
if(ImGuiEx.IconButton(FontAwesomeIcon.Paste))
{
Expand Down Expand Up @@ -264,6 +267,7 @@ static void DrawRuleFolder(Profile currentProfile, List<ApplyRule> rulesList, ou
C.Cond_ZoneGroup,
C.Cond_Players,
C.Cond_OnlineStatus,
C.Cond_Mount,
];

ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, Utils.CellPadding);
Expand All @@ -284,6 +288,7 @@ static void DrawRuleFolder(Profile currentProfile, List<ApplyRule> rulesList, ou
if(C.Cond_Gearset) ImGui.TableSetupColumn("Gearset");
if(C.Cond_Players) ImGui.TableSetupColumn("Players");
if(C.Cond_OnlineStatus) ImGui.TableSetupColumn("Online Status");
if(C.Cond_Mount) ImGui.TableSetupColumn("Mount");
if(C.Cond_Delay) ImGui.TableSetupColumn("Delays");
ImGui.TableSetupColumn("Preset");
ImGui.TableSetupColumn(" ", ImGuiTableColumnFlags.NoResize | ImGuiTableColumnFlags.WidthFixed);
Expand Down Expand Up @@ -787,7 +792,46 @@ void FiltersSelection()
if(fullList != null) ImGuiEx.Tooltip(UI.AnyNotice + fullList);
}
filterCnt++;


if(C.Cond_Mount)
{
ImGui.TableNextColumn();
//Mount
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
if(ImGui.BeginCombo("##mount", rule.Mounts.Select(x => Svc.Data.GetExcelSheet<Mount>().GetRowOrDefault(x)?.Singular.ExtractText().ToTitleCase() ?? $"{x}").PrintRange(rule.Not.Mounts.Select(x => Svc.Data.GetExcelSheet<Mount>().GetRowOrDefault(x)?.Singular.ExtractText().ToTitleCase() ?? $"{x}"), out var fullList), C.ComboSize))
{
FiltersSelection();

if(Player.Available && Utils.GetCurrentMountId() != 0)
{
var currentMount = Utils.GetCurrentMountId();
var currentMountName = Svc.Data.GetExcelSheet<Mount>().GetRowOrDefault(currentMount)?.Singular.ExtractText().ToTitleCase() ?? $"{currentMount}";
if(ImGui.Selectable($"Current: {currentMountName}"))
{
if(!rule.Mounts.Contains(currentMount))
rule.Mounts.Add(currentMount);
}
ImGui.Separator();
}

foreach(var mount in Svc.Data.GetExcelSheet<Mount>().Where(m => !m.Singular.ExtractText().IsNullOrEmpty()))
{
var name = mount.Singular.ExtractText().ToTitleCase() ?? "";
if(Filters[filterCnt].Length > 0 && !name.Contains(Filters[filterCnt], StringComparison.OrdinalIgnoreCase)) continue;
if(OnlySelected[filterCnt] && !rule.Mounts.Contains(mount.RowId)) continue;
if(ThreadLoadImageHandler.TryGetIconTextureWrap(mount.Icon, false, out var texture))
{
ImGui.Image(texture.Handle, iconSize);
ImGui.SameLine();
}
DrawSelector($"{name}##{mount.RowId}", mount.RowId, rule.Mounts, rule.Not.Mounts);
}
ImGui.EndCombo();
}
if(fullList != null) ImGuiEx.Tooltip(UI.AnyNotice + fullList);
}
filterCnt++;

if(C.Cond_Delay)
{
ImGui.TableNextColumn();
Expand Down
1 change: 1 addition & 0 deletions DynamicBridge/Gui/GuiSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public static void Draw()
() => ImGui.Checkbox($"Gearset", ref C.Cond_Gearset),
() => ImGui.Checkbox($"Nearby Players", ref C.Cond_Players),
() => ImGui.Checkbox($"Online Status", ref C.Cond_OnlineStatus),
() => ImGui.Checkbox($"Mount", ref C.Cond_Mount),
() => ImGui.Checkbox($"Delays", ref C.Cond_Delay),
],
(int)(ImGui.GetContentRegionAvail().X / 180f), ImGuiTableFlags.BordersInner);
Expand Down
12 changes: 12 additions & 0 deletions DynamicBridge/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ public static uint GetAdjustedEmote()
return em;
}

public static uint GetCurrentMountId()
{
if (!Player.Available) return 0;
return Player.Character->Mount.MountId;
}

public static string ToTitleCase(this string text)
{
if(string.IsNullOrEmpty(text)) return text;
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text.ToLower());
}

public static string[] SplitDirectories(this string path)
{
var ret = path.Split('/', StringSplitOptions.RemoveEmptyEntries);
Expand Down