Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UserInspectors not working for non-host users #14

Merged
merged 3 commits into from
Jan 20, 2025
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 CommunityBugFixCollection/CommunityBugFixCollection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>CommunityBugFixCollection</PackageId>
<Title>Component Selector Additions</Title>
<Authors>Banane9</Authors>
<Authors>Banane9; Nytra</Authors>
<Version>0.7.0-beta</Version>
<Description>This MonkeyLoader mod for Resonite overhauls the Component Selector / Protoflux Node Selector to have a search, as well as favorites and recents categories.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
4 changes: 3 additions & 1 deletion CommunityBugFixCollection/Contributors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace CommunityBugFixCollection
{
internal static class Contributors
{
public static string[] Banane9 => ["Banane9"];
public static string[] Banane9 { get; } = ["Banane9"];

public static string[] Nytra { get; } = ["Nytra"];
}
}
41 changes: 41 additions & 0 deletions CommunityBugFixCollection/UserInspectorsAsNonHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using FrooxEngine;
using FrooxEngine.UIX;
using HarmonyLib;
using MonkeyLoader.Resonite;
using System;
using System.Collections.Generic;
using System.Text;

namespace CommunityBugFixCollection
{
[HarmonyPatch(typeof(UserInspector), "OnAttach")]
[HarmonyPatchCategory(nameof(UserInspectorAsNonHost))]
internal class UserInspectorAsNonHost : ResoniteMonkey<UserInspectorAsNonHost>
{
public override IEnumerable<string> Authors => Contributors.Nytra;

public override bool CanBeDisabled => true;

private static void Postfix(UserInspector __instance)
{
if (!Enabled || __instance.World.IsAuthority)
return;

// Wait a bit to see if anything gets generated by the host
__instance.RunInSeconds(2, () =>
{
// Check if any items were generated, just in case this gets fixed in the future
if (__instance._userListContentRoot.Target.ChildrenCount != 0)
return;

foreach (var user in __instance.World.AllUsers)
{
var slot = __instance._userListContentRoot.Target.AddSlot("User");
slot.PersistentSelf = false;
slot.AttachComponent<VerticalLayout>().PaddingTop.Value = 4f;
slot.AttachComponent<UserInspectorItem>().Setup(user);
}
});
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ just disable them in the settings in the meantime.
* Tools derived from `BrushTool` not firing *OnDequipped* events (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/723)
* It not being possible to import multiple audio clips at once (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/737)
* URLs to text files or Resonite Packages failing to import instead of appearing as a hyperlink (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/785)
* UserInspectors not listing existing users in the session for non-host users (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1964)
* Animators updating all associated fields every frame while enabled but not playing (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3480)
Loading