Skip to content

Commit

Permalink
1.0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
paissaheavyindustries committed May 9, 2024
1 parent d3ff8a6 commit 092cb88
Show file tree
Hide file tree
Showing 4 changed files with 424 additions and 15 deletions.
55 changes: 48 additions & 7 deletions Lemegeton/Core/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
using Dalamud.Interface.Utility;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using Lemegeton.PacketHeaders;
using System.Text.RegularExpressions;

namespace Lemegeton.Core
{
Expand Down Expand Up @@ -211,6 +212,7 @@ internal class MarkerApplication
private PostCommandDelegate _postCmdFuncptr = null;
public Dictionary<AutomarkerSigns.SignEnum, uint> SoftMarkers = new Dictionary<AutomarkerSigns.SignEnum, uint>();
internal Dictionary<ushort, Timeline> AllTimelines = new Dictionary<ushort, Timeline>();
internal Dictionary<ushort, string> TimelineOverrides = new Dictionary<ushort, string>();

internal List<MarkerApplication> MarkerHistory = new List<MarkerApplication>();

Expand Down Expand Up @@ -413,27 +415,46 @@ public void PrepareFolder(string path)
Directory.CreateDirectory(Path.GetDirectoryName(path));
}

public void LoadLocalTimelines()
public void LoadLocalTimelines(ushort territory)
{
try
{
PrepareFolder(cfg.TimelineLocalFolder);
var timelinefiles = Directory.GetFiles(cfg.TimelineLocalFolder, "*.timeline.xml").OrderBy(x => new FileInfo(x).LastWriteTime);
Regex rex = new Regex("Lemegeton_(?<territory>[0-9]{1,})[^0-9]");
Dictionary<ushort, Timeline> tls = new Dictionary<ushort, Timeline>();
foreach (string fn in timelinefiles)
{
Match m = rex.Match(fn);
if (m.Success == false)
{
continue;
}
ushort t = ushort.Parse(m.Groups["territory"].Value);
if (tls.ContainsKey(t) == true || (territory != 0 && t != territory))
{
continue;
}
Timeline tlx = LoadTimeline(fn);
if (tlx != null)
{
tls[tlx.Territory] = tlx;
}
}
foreach (KeyValuePair<ushort, Timeline> tl in tls)
foreach (KeyValuePair<ushort, Timeline> kp in tls)
{
Log(LogLevelEnum.Debug, null, "Timeline from {0} set to territory {1}", tl.Value.Filename, tl.Key);
lock (TimelineOverrides)
{
if (TimelineOverrides.ContainsKey(kp.Key))
{
Log(LogLevelEnum.Debug, null, "Timeline from {0} not set to territory {1}, manually overridden", kp.Value.Filename, kp.Key);
continue;
}
}
Log(LogLevelEnum.Debug, null, "Timeline from {0} automatically set to territory {1}", kp.Value.Filename, kp.Key);
lock (AllTimelines)
{
AllTimelines[tl.Key] = tl.Value;
AllTimelines[kp.Key] = kp.Value;
}
}
}
Expand All @@ -442,7 +463,25 @@ public void LoadLocalTimelines()
Log(LogLevelEnum.Error, ex, "Couldn't load timelines due to an exception");
}
}


public void LoadOverriddenTimelines()
{
Dictionary<ushort, string> tlcopy;
lock (TimelineOverrides)
{
tlcopy = new Dictionary<ushort, string>(TimelineOverrides);
}
foreach (KeyValuePair<ushort, string> kp in tlcopy)
{
Timeline tlx = LoadTimeline(kp.Value);
Log(LogLevelEnum.Debug, null, "Timeline override from {0} set to territory {1}", kp.Value, kp.Key);
lock (AllTimelines)
{
AllTimelines[kp.Key] = tlx;
}
}
}

public Timeline LoadTimeline(string filename)
{
try
Expand Down Expand Up @@ -546,10 +585,12 @@ public void Initialize()
cs.TerritoryChanged += Cs_TerritoryChanged;
pi.UiBuilder.OpenMainUi += UiBuilder_OpenConfigUi;
pi.UiBuilder.OpenConfigUi += UiBuilder_OpenConfigUi;
plug.DeserializeTimelineOverrides(cfg.PropertyBlob);
if (cfg.TimelineLocalAllowed == true)
{
LoadLocalTimelines();
LoadLocalTimelines(0);
}
LoadOverriddenTimelines();
Cs_TerritoryChanged(cs.TerritoryType);
}

Expand Down Expand Up @@ -656,7 +697,7 @@ internal void AutoselectTimeline(ushort territory)
ClearReactionQueue();
}

private void Cs_TerritoryChanged(ushort e)
internal void Cs_TerritoryChanged(ushort e)
{
_timeline = null;
AutoselectTimeline(e);
Expand Down
43 changes: 40 additions & 3 deletions Lemegeton/Core/UserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Interface;
using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Interface.Internal;
using ImGuiNET;
using ImGuiScene;
Expand All @@ -20,6 +21,8 @@ internal class UserInterface
private Dictionary<AutomarkerPrio.PrioJobEnum, IDalamudTextureWrap> _jobs = new Dictionary<AutomarkerPrio.PrioJobEnum, IDalamudTextureWrap>();
private Dictionary<uint, IDalamudTextureWrap> _onDemand = new Dictionary<uint, IDalamudTextureWrap>();

internal FileDialogManager _dialogManager = new FileDialogManager();

internal State _state;

private DateTime _loaded = DateTime.Now;
Expand Down Expand Up @@ -57,7 +60,7 @@ internal enum MiscIconEnum
}

internal void LoadTextures()
{
{
_misc[MiscIconEnum.Lemegeton] = GetTexture(33237);
_misc[MiscIconEnum.BlueDiamond] = GetTexture(63937);
_misc[MiscIconEnum.PurpleDiamond] = GetTexture(63939);
Expand Down Expand Up @@ -354,6 +357,21 @@ internal ulong RenderJobSelector(ulong bitmap, bool allowLimited)
return bitmap;
}

internal static bool IconText(FontAwesomeIcon icon, string tooltip)
{
ImGui.PushFont(UiBuilder.IconFont);
string ico = icon.ToIconString();
ImGui.Text(ico);
ImGui.PopFont();
if (tooltip != null && ImGui.IsItemHovered() == true)
{
ImGui.BeginTooltip();
ImGui.Text(tooltip);
ImGui.EndTooltip();
}
return false;
}

internal static bool IconButton(FontAwesomeIcon icon, string tooltip)
{
ImGui.PushFont(UiBuilder.IconFont);
Expand All @@ -364,10 +382,18 @@ internal static bool IconButton(FontAwesomeIcon icon, string tooltip)
return true;
}
ImGui.PopFont();
if (ImGui.IsItemHovered() == true && ImGui.IsItemActive() == false)
if (tooltip != null && ImGui.IsItemHovered() == true && ImGui.IsItemActive() == false)
{
ImGui.BeginTooltip();
ImGui.Text(tooltip);
int cut = tooltip.IndexOf("##");
if (cut >= 0)
{
ImGui.Text(tooltip.Substring(0, cut));
}
else
{
ImGui.Text(tooltip);
}
ImGui.EndTooltip();
}
return false;
Expand Down Expand Up @@ -640,6 +666,17 @@ internal void RenderWarning(string text)
ImGui.SetCursorPos(new Vector2(tenp.X, Math.Max(anp1.Y, anp2.Y)));
}

internal void ClearDialog()
{
_dialogManager.Reset();
}

internal void OpenFileDialog(string title, string filter, string startPath, Action<bool, List<string>> callback)
{
ClearDialog();
_dialogManager.OpenFileDialog(title, filter, callback, 1, startPath, true);
}

}

}
15 changes: 15 additions & 0 deletions Lemegeton/Language/English.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ internal class English : Core.Language

public English(State st) : base(st)
{
#region 1.0.3.2
AddEntry("Timelines/TimelineSelector", "Open timeline selector");
AddEntry("Timelines/TimelineSelector/WindowTitle", "Lemegeton timeline selector");
AddEntry("Timelines/TimelineSelector/SelectionInfo", "By default, Lemegeton will select the most recently edited timeline file it can find for a specific zone. You can add zone-specific overrides to make it always use the same timeline file. Please note that timeline reactions are generally tied to a specific timeline file.");
AddEntry("Timelines/TimelineSelector/ColZoneID", "ID");
AddEntry("Timelines/TimelineSelector/ColZoneName", "Zone name");
AddEntry("Timelines/TimelineSelector/ColZoneFile", "Timeline file in use");
AddEntry("Timelines/TimelineSelector/ChangeTimelineFile", "Change timeline file");
AddEntry("Timelines/TimelineSelector/DeleteOverride", "Remove timeline override");
AddEntry("Timelines/TimelineSelector/SelTypeAutomatic", "Selected automatically");
AddEntry("Timelines/TimelineSelector/SelTypeOverride", "Overridden manually");
AddEntry("Timelines/TimelineSelector/SelectTimelineFile", "Select timeline file to use for '{0}'");
AddEntry("Timelines/TimelineSelector/SelectTimelineFileUnspecified", "Select timeline file to add");
AddEntry("Timelines/TimelineSelector/AddTimelineFile", "Add timeline file");
#endregion
#region 1.0.3.1
AddEntry("Content/Ultimate/UltDragonsongReprise/DoubleDragons", "(P6) Dragon HP difference indicator");
AddEntry("Content/Ultimate/UltDragonsongReprise/DoubleDragons/Enabled", "Enabled");
Expand Down
Loading

0 comments on commit 092cb88

Please sign in to comment.