Skip to content
Merged
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: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<OutputType>Library</OutputType>
<TargetFramework>net462</TargetFramework>
<AssemblyFileName>$(AssemblyTitle).dll</AssemblyFileName>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using MonkeyLoader.Resonite.UI;
using MonkeyLoader.Resonite.Configuration;
using ComponentSelectorAdditions;
using System.Collections.Generic;

namespace WikiIntegration
{
Expand All @@ -17,6 +18,8 @@ internal sealed class CategoryWikiArticleButtons : ResoniteEventHandlerMonkey<Ca
private static readonly Lazy<LocaleString> _componentLocale = new(() => Mod.GetLocaleString("WikiHyperlink.ComponentCategory"));
private static readonly Lazy<LocaleString> _protoFluxLocale = new(() => Mod.GetLocaleString("WikiHyperlink.ProtoFluxCategory"));

public override IEnumerable<string> Authors { get; } = ["Banane9"];

public override int Priority => HarmonyLib.Priority.Normal;

private static LocaleString ComponentLocale => _componentLocale.Value;
Expand All @@ -36,6 +39,8 @@ protected override void Handle(PostProcessButtonsEvent eventData)
var path = button.Slot.GetComponent<ButtonRelay<string>>().Argument.Value;

// more generalized check instead of: path.EndsWith("Favorites") || path.EndsWith("Recents"))
// presuming that all non-user excluded categories are ones added by mods
// which won't have a wiki article to link to anyways
if (SearchConfig.Instance.HasExcludedCategory(path, out var isUserCategory) && !isUserCategory.Value)
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>WikiIntegration</PackageId>
<Title>Wiki Integration</Title>
<Authors>Banane9</Authors>
<Version>0.5.0-beta</Version>
<Authors>Banane9; E1int</Authors>
<Version>0.6.0-beta</Version>
<Description>This MonkeyLoader mod for Resonite that adds links to the Wiki to Components in Worker Inspectors, and ProtoFlux nodes.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand Down
14 changes: 12 additions & 2 deletions WikiIntegration/OpenWikiArticleButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using FrooxEngine.ProtoFlux;
using FrooxEngine.UIX;
using HarmonyLib;
using MonkeyLoader.Components;
using MonkeyLoader.Configuration;
using MonkeyLoader.Events;
using MonkeyLoader.Resonite;
Expand All @@ -30,12 +29,20 @@ internal sealed class OpenWikiArticleButton : ConfiguredResoniteInspectorMonkey<
IAsyncEventHandler<FallbackLocaleGenerationEvent>
{
private static readonly Lazy<LocaleString> _componentLocale = new(() => Mod.GetLocaleString("WikiHyperlink.Component"));

private static readonly Dictionary<string, string> _nameOverrides = new() {
{"dT", "Delta_Time"},
{"ObjectCast", "Object_Cast"},
{"ValueCast", "Value_Cast"}
};

private static readonly Lazy<LocaleString> _protoFluxLocale = new(() => Mod.GetLocaleString("WikiHyperlink.ProtoFlux"));

private static ProtoFluxCategoryConfig _categoryConfig = null!;

public override int Priority => HarmonyLib.Priority.HigherThanNormal;

private static LocaleString ComponentLocale => _componentLocale.Value;

private static LocaleString ProtoFluxLocale => _protoFluxLocale.Value;

public Task Handle(FallbackLocaleGenerationEvent eventData)
Expand Down Expand Up @@ -104,6 +111,9 @@ private static void AddHyperlink(Slot slot, Worker worker)
nodeName = dotIndex > 0 ? overload[(dotIndex + 1)..] : nodeName;
}

if (_nameOverrides.TryGetValue(nodeName, out var overrideName))
nodeName = overrideName;

wikiPage = $"ProtoFlux:{nodeName.Replace(' ', '_')}";
}
else
Expand Down