Live in 0.1.19 the plugin put three buttons on the plugin bar (MM, Mossy Tracker, Metas), the tracker carried the icon that belongs to the main window, and the metas downloads were in a window of their own. Now only the main window has a bar button: "MM" with the original window's icon (7735, 0x06001E37). Its tabs follow the original's notebook: Main, Settings, Statistics, Mossy Tracker, Metas, Tools. The Mossy Tracker tab is the original page, one "Open Mossy Tracker" button that opens the tracker window; that window is registered without a bar button and opened through the host's ShowPanel. The Metas tab holds everything the metas window had (list with search, refresh, check, download outdated, download one file, last check, status), plus the repository address and the two folders the files land in. The main window forwards those bindings to the meta sync's view model, since markup binds one object. Downloads already went to the host's VTank profile storage, the one MossTank reads, under mosstank/metas and mosstank/navs with each file's own name and extension; the tab now shows those full folder paths instead of the storage root. Backend frames are untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
159 lines
5.3 KiB
C#
159 lines
5.3 KiB
C#
using AcDream.Plugin.Abstractions;
|
|
using OpenAC.MosswartMassacre.Quests;
|
|
|
|
namespace OpenAC.MosswartMassacre.FlagTracker;
|
|
|
|
/// <summary>
|
|
/// The "Mossy Tracker" window, opened from the main window's Mossy Tracker
|
|
/// tab: augmentations, luminance auras, recalls,
|
|
/// cantrips, tracked weapons and quest timers for the character in the world.
|
|
/// Nothing here reaches the backend.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The window exists only on a host that draws one; on a headless host this
|
|
/// feature registers nothing and does nothing. The pages are read at login
|
|
/// and whenever the player presses a page's Refresh button, as the original
|
|
/// read them when its window opened and on Refresh; the quest page follows
|
|
/// the quest list and redraws its countdowns every five seconds.
|
|
/// </remarks>
|
|
internal sealed class FlagTrackerFeature : IMmFeature
|
|
{
|
|
/// <summary>The panel's markup file, beside the plugin assembly.</summary>
|
|
public const string MarkupFile = "mosswartmassacre-flagtracker.xml";
|
|
|
|
/// <summary>How often the quest countdowns are redrawn.</summary>
|
|
public static readonly TimeSpan QuestRedrawInterval = TimeSpan.FromSeconds(5);
|
|
|
|
private readonly MmContext _context;
|
|
private readonly QuestManager _quests;
|
|
private readonly FlagTrackerData _data;
|
|
private readonly IDisposable? _panel;
|
|
private readonly Action? _onQuestsChanged;
|
|
private IDisposable? _questRedraw;
|
|
|
|
public FlagTrackerFeature(MmContext context, QuestManager quests)
|
|
{
|
|
_context = context;
|
|
_quests = quests;
|
|
_data = new FlagTrackerData(context.Automation);
|
|
if (!context.Host.HasUi)
|
|
return;
|
|
|
|
Panel = new FlagTrackerViewModel();
|
|
Panel.RefreshRequested += OnRefreshRequested;
|
|
_onQuestsChanged = ShowQuests;
|
|
_quests.QuestsChanged += _onQuestsChanged;
|
|
|
|
string directory = Path.GetDirectoryName(typeof(FlagTrackerFeature).Assembly.Location) ?? ".";
|
|
_panel = context.Host.Ui.RegisterPanel(
|
|
new PluginPanelDescriptor("flagtracker", "Mossy Tracker")
|
|
{
|
|
// Shown while the binding's IsVisible is set; the host's own
|
|
// shown state starts true so that flag alone opens it.
|
|
StartVisible = true,
|
|
// No bar button: as in the original, the main window's
|
|
// Mossy Tracker tab opens it.
|
|
ShowInSidePanel = false,
|
|
},
|
|
Path.Combine(directory, MarkupFile),
|
|
Panel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The window's binding object; set its <c>IsVisible</c> to open the
|
|
/// window. Null on a host without a window.
|
|
/// </summary>
|
|
public FlagTrackerViewModel? Panel { get; }
|
|
|
|
internal FlagTrackerData Data => _data;
|
|
|
|
public void OnLogin()
|
|
{
|
|
if (Panel is null)
|
|
return;
|
|
RefreshAll();
|
|
_questRedraw?.Dispose();
|
|
_questRedraw = _context.Scheduler.Every(QuestRedrawInterval, ShowQuests);
|
|
}
|
|
|
|
public void OnLogoff()
|
|
{
|
|
_questRedraw?.Dispose();
|
|
_questRedraw = null;
|
|
Panel?.Clear();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
OnLogoff();
|
|
if (_onQuestsChanged is not null)
|
|
_quests.QuestsChanged -= _onQuestsChanged;
|
|
if (Panel is not null)
|
|
Panel.RefreshRequested -= OnRefreshRequested;
|
|
_panel?.Dispose();
|
|
}
|
|
|
|
/// <summary>Reads every page again and redraws it.</summary>
|
|
public void RefreshAll()
|
|
{
|
|
if (Panel is null)
|
|
return;
|
|
try
|
|
{
|
|
_data.RefreshAll();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_context.Chat.Write($"[MossyTracker] Data refresh failed: {ex.Message}");
|
|
}
|
|
Panel.ShowData(_data);
|
|
ShowQuests();
|
|
}
|
|
|
|
private void ShowQuests()
|
|
{
|
|
if (Panel is null || !_context.IsLoggedIn)
|
|
return;
|
|
Panel.ShowQuestRows(_quests.QuestList, _quests.UnixNow);
|
|
}
|
|
|
|
private void OnRefreshRequested(string button)
|
|
{
|
|
if (Panel is null || !_context.IsLoggedIn)
|
|
return;
|
|
try
|
|
{
|
|
switch (button)
|
|
{
|
|
case nameof(FlagTrackerViewModel.RefreshAugs):
|
|
_data.RefreshAugmentations();
|
|
Panel.ShowAugmentations(_data);
|
|
break;
|
|
case nameof(FlagTrackerViewModel.RefreshLum):
|
|
_data.RefreshLuminanceAuras();
|
|
Panel.ShowLuminance(_data);
|
|
break;
|
|
case nameof(FlagTrackerViewModel.RefreshRecalls):
|
|
_data.RefreshRecallSpells();
|
|
Panel.ShowRecallSpells(_data);
|
|
break;
|
|
case nameof(FlagTrackerViewModel.RefreshCantrips):
|
|
_data.RefreshCantrips();
|
|
Panel.ShowCantripRows(_data);
|
|
break;
|
|
case nameof(FlagTrackerViewModel.RefreshWeapons):
|
|
_data.RefreshWeapons();
|
|
Panel.ShowWeaponRows(_data);
|
|
break;
|
|
case nameof(FlagTrackerViewModel.RefreshQuests):
|
|
_quests.RefreshQuests();
|
|
ShowQuests();
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_context.Chat.Write($"[MossyTracker] Refresh failed: {ex.Message}");
|
|
}
|
|
}
|
|
}
|