RynthSuite/Plugins/RynthCore.Plugin.RynthOracle/Views/WikiFeedPanel.cs

45 lines
2.3 KiB
C#

// The AC Community Wiki feed's controls (2026-11-27): on the About tab and atop the Guide tab. The feed is off by
// default, and these say what it reads and from where before anything is fetched (CommunityWikiFeed.WhatItReads).
using RynthCore.Plugin.RynthOracle.Data;
using RynthCore.Plugin.RynthOracle.Ui;
namespace RynthCore.Plugin.RynthOracle.Views;
internal sealed partial class OracleView
{
private string _wikiMsg = "";
/// <summary>The feed's on/off, Read now and its status. <paramref name="id"/> keeps the two copies' widgets apart.</summary>
private void DrawWikiFeedControls(UiWindow w, string id, bool full)
{
OracleSettings s = _c.Settings;
CommunityWikiFeed feed = _c.Wiki;
if (!s.WikiFeedOn)
{
w.TextColored(UiColors.Yellow, "AC Community Wiki feed: off. Nothing is fetched.");
w.TextWrapped("When on, RynthOracle reads " + CommunityWikiFeed.WhatItReads
+ " The copy is saved on this PC: " + feed.FilePath + ".");
w.Button("Turn the feed on and read it", id + ".wiki.on", () => _wikiMsg = _c.SetWikiFeed(true).Text);
w.Tooltip("Reads " + CommunityWikiFeed.Api + " now, and again at login once the copy is a day old (the setting below).");
}
else
{
w.TextColored(UiColors.Green, "AC Community Wiki feed: on (" + CommunityWikiFeed.Host + ").");
w.TextDisabled((feed.Running ? "Reading: " : "") + feed.Status);
if (!feed.Running)
{
w.Button("Read now", id + ".wiki.read", () => _wikiMsg = _c.ReadWikiNow().Text);
w.Tooltip("Reads the pages edited since the last read, from " + CommunityWikiFeed.Api + ".");
w.SameLine();
}
w.Button("Turn the feed off", id + ".wiki.off", () => _wikiMsg = _c.SetWikiFeed(false).Text);
w.Tooltip("Nothing more is fetched. The copy already saved stays in the Guide tab.");
if (full)
{
w.Checkbox("Read it again at login once the copy is a day old", id + ".wiki.daily", s.WikiFeedDaily, v => { s.WikiFeedDaily = v; s.Save(); });
w.Tooltip("Off: only Read now (or /ro wiki read) reads the wiki.");
}
}
if (_wikiMsg.Length > 0) w.TextWrapped(_wikiMsg);
}
}