Skip to content

Commit

Permalink
Add PvE button patch & refactor UI patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 22, 2024
1 parent 5fcf5f4 commit d8a0480
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 56 deletions.
2 changes: 2 additions & 0 deletions Fika.Core/FikaPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ protected void Awake()
new InventoryScroll_Patch().Enable();
new AbstractGame_InRaid_Patch().Enable();
new DisconnectButton_Patch().Enable();
new ChangeGameModeButton_Patch().Enable();
#if GOLDMASTER
new TOS_Patch().Enable();
#endif
Expand Down Expand Up @@ -483,6 +484,7 @@ private void DisableSPTPatches()
new DogtagPatch().Disable();
new OfflineSaveProfilePatch().Disable(); // We handle this with our own exit manager
new ScavRepAdjustmentPatch().Disable();
new DisablePvEPatch().Disable();

new BTRInteractionPatch().Disable();
new BTRExtractPassengersPatch().Disable();
Expand Down
28 changes: 28 additions & 0 deletions Fika.Core/UI/Patches/ChangeGameModeButton_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using EFT.UI;
using SPT.Reflection.Patching;
using System.Reflection;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Fika.Core.UI.Patches
{
public class ChangeGameModeButton_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(ChangeGameModeButton).GetMethod(nameof(ChangeGameModeButton.Show));
}

[PatchPrefix]
private static bool PrefixChange(TextMeshProUGUI ____buttonLabel, TextMeshProUGUI ____buttonDescription, Image ____buttonDescriptionIcon,
GameObject ____availableState)
{
____buttonLabel.text = "PvE";
____buttonDescription.text = "Fika will always be <color=#51c6db>PvE</color>";
____buttonDescriptionIcon.gameObject.SetActive(false);
____availableState.SetActive(true);
return false;
}
}
}
28 changes: 9 additions & 19 deletions Fika.Core/UI/Patches/DisableInsuranceReadyButton_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// © 2024 Lacyway All Rights Reserved

using EFT.UI;
using EFT.UI.Matchmaker;
using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;

namespace Fika.Core.UI.Patches
{
Expand All @@ -12,28 +12,18 @@ namespace Fika.Core.UI.Patches
/// </summary>
public class DisableInsuranceReadyButton_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod() => typeof(MainMenuController).GetMethod(nameof(MainMenuController.method_42));
protected override MethodBase GetTargetMethod()
{
return typeof(MatchmakerInsuranceScreen).GetMethod(nameof(MatchmakerInsuranceScreen.Awake));
}

[PatchPostfix]
static void PatchPostfix()
static void Postfix(DefaultUIButton ____readyButton)
{
var readyButton = GameObject.Find("ReadyButton");

if (readyButton != null)
{
readyButton.SetActive(false);
DefaultUIButton uiButton = readyButton.GetComponent<DefaultUIButton>();
if (uiButton != null)
{
uiButton.SetDisabledTooltip("Disabled with Fika");
uiButton.SetEnabledTooltip("Disabled with Fika");
____readyButton.SetDisabledTooltip("Disabled with Fika");
____readyButton.SetEnabledTooltip("Disabled with Fika");

if (uiButton.Interactable == true)
{
uiButton.Interactable = false;
}
}
}
____readyButton.Interactable = false;
}
}
}
27 changes: 8 additions & 19 deletions Fika.Core/UI/Patches/DisableMatchSettingsReadyButton_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using EFT.UI.Matchmaker;
using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;

namespace Fika.Core.UI
{
Expand All @@ -13,28 +12,18 @@ namespace Fika.Core.UI
/// </summary>
public class DisableMatchSettingsReadyButton_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod() => typeof(MatchmakerOfflineRaidScreen).GetMethod(nameof(MatchmakerOfflineRaidScreen.Awake));
protected override MethodBase GetTargetMethod()
{
return typeof(MatchmakerOfflineRaidScreen).GetMethod(nameof(MatchmakerOfflineRaidScreen.Awake));
}

[PatchPostfix]
static void PatchPostfix()
static void Postfix(DefaultUIButton ____readyButton)
{
var readyButton = GameObject.Find("ReadyButton");

if (readyButton != null)
{
readyButton.SetActive(false);
DefaultUIButton uiButton = readyButton.GetComponent<DefaultUIButton>();
if (uiButton != null)
{
uiButton.SetDisabledTooltip("Disabled with Fika");
uiButton.SetEnabledTooltip("Disabled with Fika");
____readyButton.SetDisabledTooltip("Disabled with Fika");
____readyButton.SetEnabledTooltip("Disabled with Fika");

if (uiButton.Interactable == true)
{
uiButton.Interactable = false;
}
}
}
____readyButton.Interactable = false;
}
}
}
26 changes: 8 additions & 18 deletions Fika.Core/UI/Patches/DisableReadyButton_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,18 @@ namespace Fika.Core.UI
/// </summary>
public class DisableReadyButton_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod() => typeof(MatchMakerSelectionLocationScreen).GetMethod("method_7", BindingFlags.Public | BindingFlags.Instance);
protected override MethodBase GetTargetMethod()
{
return typeof(MatchMakerSelectionLocationScreen).GetMethod(nameof(MatchMakerSelectionLocationScreen.Awake));
}

[PatchPostfix]
static void PatchPostfix()
static void Postfix(DefaultUIButton ____readyButton)
{
var readyButton = GameObject.Find("ReadyButton");

if (readyButton != null)
{
readyButton.SetActive(false);
DefaultUIButton uiButton = readyButton.GetComponent<DefaultUIButton>();
if (uiButton != null)
{
uiButton.SetDisabledTooltip("Disabled with Fika");
uiButton.SetEnabledTooltip("Disabled with Fika");
____readyButton.SetDisabledTooltip("Disabled with Fika");
____readyButton.SetEnabledTooltip("Disabled with Fika");

if (uiButton.Interactable == true)
{
uiButton.Interactable = false;
}
}
}
____readyButton.Interactable = false;
}
}
}

0 comments on commit d8a0480

Please sign in to comment.