Skip to content

Commit

Permalink
Add patch from UI Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Dec 5, 2024
1 parent 72e7c7b commit 66a2d3c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
32 changes: 32 additions & 0 deletions Fika.Core/Coop/Patches/Bugfixes/PartyInfoPanel_method_3_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using EFT;
using EFT.InventoryLogic;
using EFT.UI.Matchmaker;
using SPT.Reflection.Patching;
using System.Reflection;

namespace Fika.Core.Coop.Patches
{
/// <summary>
/// Borrowed from Tyfon's UI Fixes with permission, a patch that fixes a bug if you inspect a player during loading when the controller is instantiated <br/><br/>
/// Source code here: <see href="https://github.com/tyfon7/UIFixes/blob/main/src/Patches/FixPlayerInspectPatch.cs"/>
/// </summary>
public class PartyInfoPanel_method_3_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(PartyInfoPanel).GetMethod(nameof(PartyInfoPanel.method_3));
}

[PatchPrefix]
public static bool Prefix(GClass1323 raidPlayer)
{
InventoryEquipment equipment = raidPlayer.PlayerVisualRepresentation.Equipment;
if (equipment.CurrentAddress.GetOwnerOrNull() is Player.SinglePlayerInventoryController)
{
return false;
}

return true;
}
}
}
21 changes: 19 additions & 2 deletions Fika.Core/Utils/FikaModHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Comfort.Common;
using EFT;
using EFT.UI;
using Fika.Core.Coop.Patches;
using Fika.Core.Networking.Http;
using LiteNetLib.Utils;
using Newtonsoft.Json;
Expand All @@ -27,6 +28,7 @@ public class FikaModHandler

public bool QuestingBotsLoaded = false;
public bool SAINLoaded = false;
public bool UIFixesLoaded = false;

public Version SPTCoreVersion { get; private set; }

Expand Down Expand Up @@ -94,6 +96,18 @@ public void VerifyMods()
{
StaticManager.BeginCoroutine(InformInstallationError());
}

HandleModSpecificPatches();
}

private void HandleModSpecificPatches()
{
// We only want to load this if UI Fixes is not loaded
if (!UIFixesLoaded)
{
logger.LogInfo("UI Fixes is not loaded, enabling PartyInfoPanel fix");
new PartyInfoPanel_method_3_Patch().Enable();
}
}

private IEnumerator InformInstallationError()
Expand All @@ -117,13 +131,16 @@ private void CheckSpecialMods(string key)
case "com.DanW.QuestingBots":
{
QuestingBotsLoaded = true;

break;
}
case "me.sol.sain":
{
SAINLoaded = true;

break;
}
case "Tyfon.UIFixes":
{
UIFixesLoaded = true;
break;
}
}
Expand Down

0 comments on commit 66a2d3c

Please sign in to comment.