feat: add config for disabling providers

This commit is contained in:
Anna 2021-02-22 20:22:40 -05:00
parent 23f0b29b0f
commit 908f405b88
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
26 changed files with 303 additions and 25 deletions

0
ExpandedSearchInfo.sln Executable file → Normal file
View File

View File

@ -0,0 +1,6 @@
namespace ExpandedSearchInfo.Configs {
public abstract class BaseConfig {
public bool Enabled { get; set; } = true;
public bool DefaultExpanded { get; set; } = true;
}
}

View File

@ -0,0 +1,4 @@
namespace ExpandedSearchInfo.Configs {
public class CarrdConfig : BaseConfig {
}
}

View File

@ -0,0 +1,4 @@
namespace ExpandedSearchInfo.Configs {
public class FListConfig : BaseConfig {
}
}

View File

@ -0,0 +1,4 @@
namespace ExpandedSearchInfo.Configs {
public class PastebinConfig : BaseConfig {
}
}

View File

@ -0,0 +1,4 @@
namespace ExpandedSearchInfo.Configs {
public class PlainTextConfig : BaseConfig {
}
}

View File

@ -0,0 +1,4 @@
namespace ExpandedSearchInfo.Configs {
public class RefsheetConfig : BaseConfig {
}
}

View File

@ -27,10 +27,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AngleSharp" Version="0.14.0"/> <PackageReference Include="AngleSharp" Version="0.14.0" />
<PackageReference Include="DalamudPackager" Version="1.2.0"/> <PackageReference Include="DalamudPackager" Version="1.2.0" />
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.18.2"/> <PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.18.2" />
<PackageReference Include="Nager.PublicSuffix" Version="2.1.0"/> <PackageReference Include="Nager.PublicSuffix" Version="2.2.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>

0
ExpandedSearchInfo/ExpandedSearchInfo.yaml Executable file → Normal file
View File

2
ExpandedSearchInfo/GameFunctions.cs Executable file → Normal file
View File

@ -44,4 +44,4 @@ namespace ExpandedSearchInfo {
return result; return result;
} }
} }
} }

17
ExpandedSearchInfo/Plugin.cs Executable file → Normal file
View File

@ -1,9 +1,12 @@
using Dalamud.Plugin; using Dalamud.Game.Command;
using Dalamud.Plugin;
namespace ExpandedSearchInfo { namespace ExpandedSearchInfo {
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin : IDalamudPlugin { public class Plugin : IDalamudPlugin {
public string Name => "Expanded Search Info"; public string Name => "Expanded Search Info";
internal PluginConfiguration Config { get; private set; } = null!;
internal DalamudPluginInterface Interface { get; private set; } = null!; internal DalamudPluginInterface Interface { get; private set; } = null!;
internal GameFunctions Functions { get; private set; } = null!; internal GameFunctions Functions { get; private set; } = null!;
internal SearchInfoRepository Repository { get; private set; } = null!; internal SearchInfoRepository Repository { get; private set; } = null!;
@ -12,15 +15,27 @@ namespace ExpandedSearchInfo {
public void Initialize(DalamudPluginInterface pluginInterface) { public void Initialize(DalamudPluginInterface pluginInterface) {
this.Interface = pluginInterface; this.Interface = pluginInterface;
this.Config = (PluginConfiguration?) this.Interface.GetPluginConfig() ?? new PluginConfiguration();
this.Config.Initialise(this);
this.Functions = new GameFunctions(this); this.Functions = new GameFunctions(this);
this.Repository = new SearchInfoRepository(this); this.Repository = new SearchInfoRepository(this);
this.Ui = new PluginUi(this); this.Ui = new PluginUi(this);
this.Interface.CommandManager.AddHandler("/esi", new CommandInfo(this.OnCommand) {
HelpMessage = "Toggles Expanded Search Info's configuration window",
});
} }
public void Dispose() { public void Dispose() {
this.Interface.CommandManager.RemoveHandler("/esi");
this.Ui.Dispose(); this.Ui.Dispose();
this.Repository.Dispose(); this.Repository.Dispose();
this.Functions.Dispose(); this.Functions.Dispose();
} }
private void OnCommand(string command, string arguments) {
this.Ui.ConfigVisible = !this.Ui.ConfigVisible;
}
} }
} }

View File

@ -0,0 +1,28 @@
using Dalamud.Configuration;
using ExpandedSearchInfo.Configs;
namespace ExpandedSearchInfo {
public class PluginConfiguration : IPluginConfiguration {
private Plugin Plugin { get; set; } = null!;
public int Version { get; set; } = 1;
public ProviderConfigs Configs { get; set; } = new();
internal void Initialise(Plugin plugin) {
this.Plugin = plugin;
}
internal void Save() {
this.Plugin.Interface.SavePluginConfig(this);
}
}
public class ProviderConfigs {
public CarrdConfig Carrd { get; set; } = new();
public FListConfig FList { get; set; } = new();
public PastebinConfig Pastebin { get; set; } = new();
public PlainTextConfig PlainText { get; set; } = new();
public RefsheetConfig Refsheet { get; set; } = new();
}
}

101
ExpandedSearchInfo/PluginUi.cs Executable file → Normal file
View File

@ -8,13 +8,26 @@ namespace ExpandedSearchInfo {
public class PluginUi : IDisposable { public class PluginUi : IDisposable {
private Plugin Plugin { get; } private Plugin Plugin { get; }
private bool _configVisible;
internal bool ConfigVisible {
get => this._configVisible;
set => this._configVisible = value;
}
internal PluginUi(Plugin plugin) { internal PluginUi(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw; this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw;
this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.OnOpenConfigUi;
}
private void OnOpenConfigUi(object sender, EventArgs e) {
this.ConfigVisible = true;
} }
public void Dispose() { public void Dispose() {
this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.OnOpenConfigUi;
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw; this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
} }
@ -34,6 +47,88 @@ namespace ExpandedSearchInfo {
} }
private void Draw() { private void Draw() {
this.DrawConfig();
this.DrawExpandedSearchInfo();
}
private void DrawConfig() {
if (!this.ConfigVisible) {
return;
}
ImGui.SetNextWindowSize(new Vector2(500, -1), ImGuiCond.FirstUseEver);
if (!ImGui.Begin($"{this.Plugin.Name} settings", ref this._configVisible)) {
return;
}
ImGui.PushTextWrapPos();
if (ImGui.Button("Clear cache")) {
this.Plugin.Repository.SearchInfos.Clear();
}
ImGui.SameLine();
var cached = this.Plugin.Repository.SearchInfos.Count;
var playersString = cached switch {
1 => "One player",
_ => $"{cached} players",
};
ImGui.TextUnformatted($"{playersString} in the cache");
ImGui.Spacing();
ImGui.TextUnformatted("Expanded Search Info downloads information contained in search infos once and caches it for later retrieval. If you want to clear this cache, click the button above. You can also clear individual players from the cache with the button in their expanded info.");
ImGui.Separator();
if (ImGui.CollapsingHeader("Providers", ImGuiTreeNodeFlags.DefaultOpen)) {
if (!ImGui.BeginTabBar("ESI tabs")) {
return;
}
foreach (var provider in this.Plugin.Repository.AllProviders) {
if (!ImGui.BeginTabItem($"{provider.Name}##esi-provider")) {
continue;
}
ImGui.Columns(2);
ImGui.SetColumnWidth(0, ImGui.GetWindowWidth() / 3);
ImGui.TextUnformatted(provider.Description);
ImGui.NextColumn();
var enabled = provider.Config.Enabled;
if (ImGui.Checkbox($"Enabled##{provider.Name}", ref enabled)) {
provider.Config.Enabled = enabled;
this.Plugin.Config.Save();
}
var defaultOpen = provider.Config.DefaultExpanded;
if (ImGui.Checkbox($"Open by default##{provider.Name}", ref defaultOpen)) {
provider.Config.DefaultExpanded = defaultOpen;
this.Plugin.Config.Save();
}
provider.DrawConfig();
ImGui.Columns(1);
ImGui.EndTabItem();
}
ImGui.EndTabBar();
}
ImGui.PopTextWrapPos();
ImGui.End();
}
private void DrawExpandedSearchInfo() {
// check if the examine window is open // check if the examine window is open
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("CharacterInspect", 1); var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("CharacterInspect", 1);
if (addon == null || !addon.Visible) { if (addon == null || !addon.Visible) {
@ -78,7 +173,11 @@ namespace ExpandedSearchInfo {
for (var i = 0; i < expanded.Sections.Count; i++) { for (var i = 0; i < expanded.Sections.Count; i++) {
var section = expanded.Sections[i]; var section = expanded.Sections[i];
if (!ImGui.CollapsingHeader($"{section.Name}##{i}", ImGuiTreeNodeFlags.DefaultOpen)) { var flags = section.Provider.Config.DefaultExpanded switch {
true => ImGuiTreeNodeFlags.DefaultOpen,
false => ImGuiTreeNodeFlags.None,
};
if (!ImGui.CollapsingHeader($"{section.Name}##{i}", flags)) {
continue; continue;
} }

9
ExpandedSearchInfo/Providers/BaseHtmlProvider.cs Executable file → Normal file
View File

@ -5,14 +5,23 @@ using System.Threading.Tasks;
using AngleSharp; using AngleSharp;
using AngleSharp.Html.Dom; using AngleSharp.Html.Dom;
using AngleSharp.Html.Parser; using AngleSharp.Html.Parser;
using ExpandedSearchInfo.Configs;
using ExpandedSearchInfo.Sections; using ExpandedSearchInfo.Sections;
namespace ExpandedSearchInfo.Providers { namespace ExpandedSearchInfo.Providers {
public abstract class BaseHtmlProvider : IProvider { public abstract class BaseHtmlProvider : IProvider {
private IBrowsingContext Context { get; } = BrowsingContext.New(); private IBrowsingContext Context { get; } = BrowsingContext.New();
public abstract string Name { get; }
public abstract string Description { get; }
public abstract BaseConfig Config { get; }
public abstract bool ExtractsUris { get; } public abstract bool ExtractsUris { get; }
public abstract void DrawConfig();
public abstract bool Matches(Uri uri); public abstract bool Matches(Uri uri);
public abstract IEnumerable<Uri>? ExtractUris(int actorId, string info); public abstract IEnumerable<Uri>? ExtractUris(int actorId, string info);

17
ExpandedSearchInfo/Providers/CarrdProvider.cs Executable file → Normal file
View File

@ -3,12 +3,28 @@ using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using AngleSharp.Dom; using AngleSharp.Dom;
using ExpandedSearchInfo.Configs;
using ExpandedSearchInfo.Sections; using ExpandedSearchInfo.Sections;
namespace ExpandedSearchInfo.Providers { namespace ExpandedSearchInfo.Providers {
public class CarrdProvider : BaseHtmlProvider { public class CarrdProvider : BaseHtmlProvider {
private Plugin Plugin { get; }
public override string Name => "carrd.co/crd.co";
public override string Description => "This provider provides information for carrd.co and crd.co URLs.";
public override BaseConfig Config => this.Plugin.Config.Configs.Carrd;
public override bool ExtractsUris => false; public override bool ExtractsUris => false;
internal CarrdProvider(Plugin plugin) {
this.Plugin = plugin;
}
public override void DrawConfig() {
}
public override bool Matches(Uri uri) => uri.Host.EndsWith(".carrd.co") || uri.Host.EndsWith(".crd.co"); public override bool Matches(Uri uri) => uri.Host.EndsWith(".carrd.co") || uri.Host.EndsWith(".crd.co");
public override IEnumerable<Uri>? ExtractUris(int actorId, string info) => null; public override IEnumerable<Uri>? ExtractUris(int actorId, string info) => null;
@ -58,6 +74,7 @@ namespace ExpandedSearchInfo.Providers {
} }
return new TextSection( return new TextSection(
this,
$"{document.Title} (carrd.co)", $"{document.Title} (carrd.co)",
response.RequestMessage.RequestUri, response.RequestMessage.RequestUri,
text text

22
ExpandedSearchInfo/Providers/FListProvider.cs Executable file → Normal file
View File

@ -4,22 +4,29 @@ using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AngleSharp;
using AngleSharp.Dom; using AngleSharp.Dom;
using Dalamud.Plugin; using ExpandedSearchInfo.Configs;
using ExpandedSearchInfo.Sections; using ExpandedSearchInfo.Sections;
namespace ExpandedSearchInfo.Providers { namespace ExpandedSearchInfo.Providers {
public class FListProvider : BaseHtmlProvider { public class FListProvider : BaseHtmlProvider {
private Plugin Plugin { get; } private Plugin Plugin { get; }
public override string Name => "F-List";
public override string Description => "This provider provides information for F-List URLs. It also searches for F-List profiles matching the character's name if /c/ is in their search info.";
public override BaseConfig Config => this.Plugin.Config.Configs.FList;
public override bool ExtractsUris => true; public override bool ExtractsUris => true;
internal FListProvider(Plugin plugin) { internal FListProvider(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
} }
public override void DrawConfig() {
}
public override bool Matches(Uri uri) => (uri.Host == "www.f-list.net" || uri.Host == "f-list.net") && uri.AbsolutePath.StartsWith("/c/"); public override bool Matches(Uri uri) => (uri.Host == "www.f-list.net" || uri.Host == "f-list.net") && uri.AbsolutePath.StartsWith("/c/");
public override IEnumerable<Uri>? ExtractUris(int actorId, string info) { public override IEnumerable<Uri>? ExtractUris(int actorId, string info) {
@ -44,7 +51,13 @@ namespace ExpandedSearchInfo.Providers {
var error = document.QuerySelector("#DisplayedMessage"); var error = document.QuerySelector("#DisplayedMessage");
if (error != null) { if (error != null) {
if (error.Text().Contains("No such character exists")) { var errorText = error.Text();
if (errorText.Contains("No such character exists")) {
return null;
}
if (errorText.Contains("has been banned")) {
return null; return null;
} }
} }
@ -84,6 +97,7 @@ namespace ExpandedSearchInfo.Providers {
var charName = document.Title.Split('-')[2].Trim(); var charName = document.Title.Split('-')[2].Trim();
return new FListSection( return new FListSection(
this,
$"{charName} (F-List)", $"{charName} (F-List)",
response.RequestMessage.RequestUri, response.RequestMessage.RequestUri,
info, info,

9
ExpandedSearchInfo/Providers/IProvider.cs Executable file → Normal file
View File

@ -2,10 +2,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using ExpandedSearchInfo.Configs;
using ExpandedSearchInfo.Sections; using ExpandedSearchInfo.Sections;
namespace ExpandedSearchInfo.Providers { namespace ExpandedSearchInfo.Providers {
public interface IProvider { public interface IProvider {
string Name { get; }
string Description { get; }
BaseConfig Config { get; }
/// <summary> /// <summary>
/// If this provider is capable of parsing the search info for custom Uris, this should be true. /// If this provider is capable of parsing the search info for custom Uris, this should be true.
/// ///
@ -14,6 +21,8 @@ namespace ExpandedSearchInfo.Providers {
/// </summary> /// </summary>
bool ExtractsUris { get; } bool ExtractsUris { get; }
void DrawConfig();
/// <summary> /// <summary>
/// Determine if this provider should run on the given Uri. /// Determine if this provider should run on the given Uri.
/// </summary> /// </summary>

18
ExpandedSearchInfo/Providers/PastebinProvider.cs Executable file → Normal file
View File

@ -4,14 +4,30 @@ using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using ExpandedSearchInfo.Configs;
using ExpandedSearchInfo.Sections; using ExpandedSearchInfo.Sections;
namespace ExpandedSearchInfo.Providers { namespace ExpandedSearchInfo.Providers {
public class PastebinProvider : IProvider { public class PastebinProvider : IProvider {
private static readonly Regex Matcher = new(@"pb:(\S+)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex Matcher = new(@"pb:(\S+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private Plugin Plugin { get; }
public string Name => "pastebin.com";
public string Description => "This provider provides information from pastebin.com URLs. It also works on tags such as \"pb:pasteid\".";
public BaseConfig Config => this.Plugin.Config.Configs.Pastebin;
public bool ExtractsUris => true; public bool ExtractsUris => true;
public PastebinProvider(Plugin plugin) {
this.Plugin = plugin;
}
public void DrawConfig() {
}
public bool Matches(Uri uri) => uri.Host == "pastebin.com" && uri.AbsolutePath.Length > 1; public bool Matches(Uri uri) => uri.Host == "pastebin.com" && uri.AbsolutePath.Length > 1;
public IEnumerable<Uri>? ExtractUris(int actorId, string info) { public IEnumerable<Uri>? ExtractUris(int actorId, string info) {
@ -30,7 +46,7 @@ namespace ExpandedSearchInfo.Providers {
var info = await response.Content.ReadAsStringAsync(); var info = await response.Content.ReadAsStringAsync();
return new TextSection($"Pastebin ({id})", response.RequestMessage.RequestUri, info); return new TextSection(this, $"Pastebin ({id})", response.RequestMessage.RequestUri, info);
} }
} }
} }

18
ExpandedSearchInfo/Providers/PlainTextProvider.cs Executable file → Normal file
View File

@ -2,12 +2,28 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using ExpandedSearchInfo.Configs;
using ExpandedSearchInfo.Sections; using ExpandedSearchInfo.Sections;
namespace ExpandedSearchInfo.Providers { namespace ExpandedSearchInfo.Providers {
public class PlainTextProvider : IProvider { public class PlainTextProvider : IProvider {
private Plugin Plugin { get; }
public string Name => "Plain text";
public string Description => "This provider provides information for any URL that provides plain text.";
public BaseConfig Config => this.Plugin.Config.Configs.PlainText;
public bool ExtractsUris => false; public bool ExtractsUris => false;
internal PlainTextProvider(Plugin plugin) {
this.Plugin = plugin;
}
public void DrawConfig() {
}
public bool Matches(Uri uri) => true; public bool Matches(Uri uri) => true;
public IEnumerable<Uri>? ExtractUris(int actorId, string info) => null; public IEnumerable<Uri>? ExtractUris(int actorId, string info) => null;
@ -20,7 +36,7 @@ namespace ExpandedSearchInfo.Providers {
var info = await response.Content.ReadAsStringAsync(); var info = await response.Content.ReadAsStringAsync();
var uri = response.RequestMessage.RequestUri; var uri = response.RequestMessage.RequestUri;
return new TextSection($"Text##{uri}", response.RequestMessage.RequestUri, info); return new TextSection(this, $"Text##{uri}", response.RequestMessage.RequestUri, info);
} }
} }
} }

17
ExpandedSearchInfo/Providers/RefsheetProvider.cs Executable file → Normal file
View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using ExpandedSearchInfo.Configs;
using ExpandedSearchInfo.Sections; using ExpandedSearchInfo.Sections;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@ -11,8 +12,23 @@ namespace ExpandedSearchInfo.Providers {
public class RefsheetProvider : BaseHtmlProvider { public class RefsheetProvider : BaseHtmlProvider {
private const string JsonLineStart = "var props = "; private const string JsonLineStart = "var props = ";
private Plugin Plugin { get; }
public override string Name => "Refsheet";
public override string Description => "This provider provides information for refsheet.net and ref.st URLs.";
public override BaseConfig Config => this.Plugin.Config.Configs.Refsheet;
public override bool ExtractsUris => false; public override bool ExtractsUris => false;
internal RefsheetProvider(Plugin plugin) {
this.Plugin = plugin;
}
public override void DrawConfig() {
}
public override bool Matches(Uri uri) => uri.Host == "refsheet.net" || uri.Host == "ref.st"; public override bool Matches(Uri uri) => uri.Host == "refsheet.net" || uri.Host == "ref.st";
public override IEnumerable<Uri>? ExtractUris(int actorId, string info) => null; public override IEnumerable<Uri>? ExtractUris(int actorId, string info) => null;
@ -95,6 +111,7 @@ namespace ExpandedSearchInfo.Providers {
} }
return new RefsheetSection( return new RefsheetSection(
this,
$"{name} (Refsheet)", $"{name} (Refsheet)",
response.RequestMessage.RequestUri, response.RequestMessage.RequestUri,
attributes, attributes,

13
ExpandedSearchInfo/SearchInfoRepository.cs Executable file → Normal file
View File

@ -29,6 +29,7 @@ namespace ExpandedSearchInfo {
internal int LastActorId { get; private set; } internal int LastActorId { get; private set; }
private List<IProvider> Providers { get; } = new(); private List<IProvider> Providers { get; } = new();
internal IEnumerable<IProvider> AllProviders => this.Providers;
internal SearchInfoRepository(Plugin plugin) { internal SearchInfoRepository(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
@ -53,11 +54,11 @@ namespace ExpandedSearchInfo {
} }
private void AddProviders() { private void AddProviders() {
this.Providers.Add(new PastebinProvider()); this.Providers.Add(new PastebinProvider(this.Plugin));
this.Providers.Add(new CarrdProvider()); this.Providers.Add(new CarrdProvider(this.Plugin));
this.Providers.Add(new FListProvider(this.Plugin)); this.Providers.Add(new FListProvider(this.Plugin));
this.Providers.Add(new RefsheetProvider()); this.Providers.Add(new RefsheetProvider(this.Plugin));
this.Providers.Add(new PlainTextProvider()); this.Providers.Add(new PlainTextProvider(this.Plugin));
} }
private void ProcessSearchInfo(int actorId, string info) { private void ProcessSearchInfo(int actorId, string info) {
@ -93,7 +94,7 @@ namespace ExpandedSearchInfo {
// extract uris from the search info with providers // extract uris from the search info with providers
var extractedUris = this.Providers var extractedUris = this.Providers
.Where(provider => provider.ExtractsUris) .Where(provider => provider.Config.Enabled && provider.ExtractsUris)
.Select(provider => provider.ExtractUris(actorId, info)) .Select(provider => provider.ExtractUris(actorId, info))
.Where(uris => uris != null) .Where(uris => uris != null)
.SelectMany(uris => uris); .SelectMany(uris => uris);
@ -151,7 +152,7 @@ namespace ExpandedSearchInfo {
// find the providers that run on this uri // find the providers that run on this uri
var matching = this.Providers var matching = this.Providers
.Where(provider => provider.Matches(uri)) .Where(provider => provider.Config.Enabled && provider.Matches(uri))
.ToList(); .ToList();
// skip the uri if no providers // skip the uri if no providers

5
ExpandedSearchInfo/Sections/FListSection.cs Executable file → Normal file
View File

@ -1,10 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ExpandedSearchInfo.Providers;
using ImGuiNET; using ImGuiNET;
namespace ExpandedSearchInfo.Sections { namespace ExpandedSearchInfo.Sections {
public class FListSection : ISearchInfoSection { public class FListSection : ISearchInfoSection {
public IProvider Provider { get; }
public string Name { get; } public string Name { get; }
public Uri Uri { get; } public Uri Uri { get; }
@ -15,7 +17,8 @@ namespace ExpandedSearchInfo.Sections {
private List<Tuple<string, string>> Maybe { get; } private List<Tuple<string, string>> Maybe { get; }
private List<Tuple<string, string>> No { get; } private List<Tuple<string, string>> No { get; }
internal FListSection(string name, Uri uri, string info, List<Tuple<string, string>> stats, List<Tuple<string, string>> fave, List<Tuple<string, string>> yes, List<Tuple<string, string>> maybe, List<Tuple<string, string>> no) { internal FListSection(IProvider provider, string name, Uri uri, string info, List<Tuple<string, string>> stats, List<Tuple<string, string>> fave, List<Tuple<string, string>> yes, List<Tuple<string, string>> maybe, List<Tuple<string, string>> no) {
this.Provider = provider;
this.Name = name; this.Name = name;
this.Uri = uri; this.Uri = uri;

2
ExpandedSearchInfo/Sections/ISearchInfoSection.cs Executable file → Normal file
View File

@ -1,7 +1,9 @@
using System; using System;
using ExpandedSearchInfo.Providers;
namespace ExpandedSearchInfo.Sections { namespace ExpandedSearchInfo.Sections {
public interface ISearchInfoSection { public interface ISearchInfoSection {
IProvider Provider { get; }
string Name { get; } string Name { get; }
Uri Uri { get; } Uri Uri { get; }

5
ExpandedSearchInfo/Sections/RefsheetSection.cs Executable file → Normal file
View File

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ExpandedSearchInfo.Providers;
using ImGuiNET; using ImGuiNET;
namespace ExpandedSearchInfo.Sections { namespace ExpandedSearchInfo.Sections {
public class RefsheetSection : ISearchInfoSection { public class RefsheetSection : ISearchInfoSection {
public IProvider Provider { get; }
public string Name { get; } public string Name { get; }
public Uri Uri { get; } public Uri Uri { get; }
@ -11,7 +13,8 @@ namespace ExpandedSearchInfo.Sections {
private string Notes { get; } private string Notes { get; }
private List<Tuple<string, string>> Cards { get; } private List<Tuple<string, string>> Cards { get; }
internal RefsheetSection(string name, Uri uri, List<Tuple<string, string>> attributes, string notes, List<Tuple<string, string>> cards) { internal RefsheetSection(IProvider provider, string name, Uri uri, List<Tuple<string, string>> attributes, string notes, List<Tuple<string, string>> cards) {
this.Provider = provider;
this.Name = name; this.Name = name;
this.Uri = uri; this.Uri = uri;
this.Attributes = attributes; this.Attributes = attributes;

9
ExpandedSearchInfo/Sections/TextSection.cs Executable file → Normal file
View File

@ -1,13 +1,16 @@
using System; using System;
using ImGuiNET; using ExpandedSearchInfo.Providers;
namespace ExpandedSearchInfo.Sections { namespace ExpandedSearchInfo.Sections {
public class TextSection : ISearchInfoSection { public class TextSection : ISearchInfoSection {
private string Info { get; } public IProvider Provider { get; }
public string Name { get; } public string Name { get; }
public Uri Uri { get; } public Uri Uri { get; }
internal TextSection(string name, Uri uri, string info) { private string Info { get; }
internal TextSection(IProvider provider, string name, Uri uri, string info) {
this.Provider = provider;
this.Name = name; this.Name = name;
this.Uri = uri; this.Uri = uri;
this.Info = info; this.Info = info;

2
ExpandedSearchInfo/Util.cs Executable file → Normal file
View File

@ -33,4 +33,4 @@ namespace ExpandedSearchInfo {
} }
} }
} }
} }