diff --git a/project/Aki.Custom/Aki.Custom.csproj b/project/Aki.Custom/Aki.Custom.csproj
index 61b6458..e5d4afe 100644
--- a/project/Aki.Custom/Aki.Custom.csproj
+++ b/project/Aki.Custom/Aki.Custom.csproj
@@ -17,6 +17,7 @@
+
diff --git a/project/Aki.Custom/AkiCustomPlugin.cs b/project/Aki.Custom/AkiCustomPlugin.cs
index b6bfdc5..ebf9634 100644
--- a/project/Aki.Custom/AkiCustomPlugin.cs
+++ b/project/Aki.Custom/AkiCustomPlugin.cs
@@ -4,6 +4,8 @@ using Aki.Custom.Airdrops.Patches;
using Aki.Custom.BTR.Patches;
using Aki.Custom.Patches;
using Aki.Custom.Utils;
+using Aki.Reflection.Utils;
+using Aki.SinglePlayer.Utils.MainMenu;
using BepInEx;
namespace Aki.Custom
@@ -72,8 +74,8 @@ namespace Aki.Custom
new ResetTraderServicesPatch().Enable();
new CultistAmuletRemovalPatch().Enable();
-
- }
+ HookObject.AddOrGetComponent();
+ }
catch (Exception ex)
{
Logger.LogError($"A PATCH IN {GetType().Name} FAILED. SUBSEQUENT PATCHES HAVE NOT LOADED");
diff --git a/project/Aki.Custom/Models/ReleaseResponse.cs b/project/Aki.Custom/Models/ReleaseResponse.cs
index 17fe164..b60274d 100644
--- a/project/Aki.Custom/Models/ReleaseResponse.cs
+++ b/project/Aki.Custom/Models/ReleaseResponse.cs
@@ -3,6 +3,7 @@ namespace Aki.Custom.Models
public struct ReleaseResponse
{
public bool isBeta { get; set; }
+ public bool isModdable { get; set; }
public string betaDisclaimer { get; set; }
public float betaDisclaimerTimeoutDelay { get; set; }
public string releaseSummary { get; set; }
diff --git a/project/Aki.Debugging/Patches/DebugLogoPatch.cs b/project/Aki.Custom/Patches/BetaLogoPatch.cs
similarity index 80%
rename from project/Aki.Debugging/Patches/DebugLogoPatch.cs
rename to project/Aki.Custom/Patches/BetaLogoPatch.cs
index cb44a54..c978d90 100644
--- a/project/Aki.Debugging/Patches/DebugLogoPatch.cs
+++ b/project/Aki.Custom/Patches/BetaLogoPatch.cs
@@ -1,14 +1,15 @@
using Aki.Reflection.Patching;
-using EFT;
using EFT.UI;
+using EFT;
using HarmonyLib;
using System.Reflection;
+using Aki.SinglePlayer.Utils.MainMenu;
using TMPro;
using UnityEngine;
-namespace Aki.Debugging.Patches
+namespace Aki.SinglePlayer.Patches.MainMenu
{
- public class DebugLogoPatch : ModulePatch
+ public class BetaLogoPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
@@ -22,10 +23,8 @@ namespace Aki.Debugging.Patches
}
}
- public class DebugLogoPatch2 : ModulePatch
+ public class BetaLogoPatch2 : ModulePatch
{
- private static string sptVersion;
-
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(ClientWatermark), nameof(ClientWatermark.method_0));
@@ -34,29 +33,31 @@ namespace Aki.Debugging.Patches
[PatchPostfix]
private static void PatchPostfix(ref TextMeshProUGUI ____label, Profile ___profile_0)
{
- ____label.text = $"{AkiDebuggingPlugin.commitHash}";
+ ____label.text = $"{MenuNotificationManager.commitHash}";
}
}
- public class DebugLogoPatch3 : ModulePatch
+ public class BetaLogoPatch3 : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(ClientWatermark), nameof(ClientWatermark.smethod_0));
}
- // Prefix so the logic isnt being duplicated.
+ // Prefix so the logic isn't being duplicated.
[PatchPrefix]
private static bool PatchPrefix(int screenHeight, int screenWidth, int rectHeight, int rectWidth, ref Vector2 __result)
- {
+ {
System.Random random = new System.Random();
-
+
int maxX = (screenWidth / 4) - (rectWidth / 2);
int maxY = (screenHeight / 4) - (rectHeight / 2);
int newX = random.Next(-maxX, maxX);
int newY = random.Next(-maxY, maxY);
__result = new Vector2(newX, newY);
+
+ // Skip original
return false;
}
}
diff --git a/project/Aki.Debugging/Patches/PreventClientModsPatch.cs b/project/Aki.Custom/Patches/PreventClientModsPatch.cs
similarity index 97%
rename from project/Aki.Debugging/Patches/PreventClientModsPatch.cs
rename to project/Aki.Custom/Patches/PreventClientModsPatch.cs
index 8f5cb1f..983e941 100644
--- a/project/Aki.Debugging/Patches/PreventClientModsPatch.cs
+++ b/project/Aki.Custom/Patches/PreventClientModsPatch.cs
@@ -8,7 +8,7 @@ using BepInEx.Logging;
using EFT;
using HarmonyLib;
-namespace Aki.Core.Patches
+namespace Aki.SinglePlayer.Patches.MainMenu
{
///
/// Prevents loading of non-whitelisted client mods to minimize the amount of false issue reports being made during the public BE phase
diff --git a/project/Aki.Custom/Utils/MenuNotificationManager.cs b/project/Aki.Custom/Utils/MenuNotificationManager.cs
new file mode 100644
index 0000000..9912490
--- /dev/null
+++ b/project/Aki.Custom/Utils/MenuNotificationManager.cs
@@ -0,0 +1,124 @@
+using Aki.Common.Http;
+using Aki.Common.Utils;
+using Aki.Custom.Models;
+using Aki.SinglePlayer.Patches.MainMenu;
+using BepInEx.Logging;
+using Comfort.Common;
+using EFT.UI;
+using System;
+using System.Linq;
+using UnityEngine;
+
+namespace Aki.SinglePlayer.Utils.MainMenu
+{
+ public class MenuNotificationManager : MonoBehaviour
+ {
+ public static string sptVersion;
+ public static string commitHash;
+ private ReleaseResponse release;
+
+ private bool _isBetaDisclaimerOpen = false;
+
+ private ManualLogSource Logger;
+
+ public void Start()
+ {
+ Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(MenuNotificationManager));
+
+ var versionJson = RequestHandler.GetJson("/singleplayer/settings/version");
+ sptVersion = Json.Deserialize(versionJson).Version;
+ commitHash = sptVersion?.Trim()?.Split(' ')?.Last() ?? "";
+
+ var releaseJson = RequestHandler.GetJson("/singleplayer/release");
+ release = Json.Deserialize(releaseJson);
+
+ SetVersionPref();
+
+ // Enable the watermark if this is a bleeding edge build.
+ // Enabled in start to allow time for the request containing the bool to process.
+ if (release.isBeta)
+ {
+ new BetaLogoPatch().Enable();
+ new BetaLogoPatch2().Enable();
+ new BetaLogoPatch3().Enable();
+ }
+
+ // Prevent client mods if the server is built with mods disabled
+ if (!release.isModdable)
+ {
+ new PreventClientModsPatch().Enable();
+ }
+
+ if (release.isBeta && PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 1)
+ {
+ Logger.LogInfo("User accepted the beta disclaimer");
+ }
+ }
+ public void Update()
+ {
+ if (sptVersion == null)
+ {
+ return;
+ }
+
+ if (Singleton.Instantiated && ShouldShowBetaMessage())
+ {
+ Singleton.Instance.ShowCriticalErrorScreen(sptVersion, release.betaDisclaimer, ErrorScreen.EButtonType.OkButton, release.betaDisclaimerTimeoutDelay, new Action(OnMessageAccepted), new Action(OnTimeOut));
+ _isBetaDisclaimerOpen = true;
+ }
+
+ if (Singleton.Instantiated && ShouldShowReleaseNotes())
+ {
+ Singleton.Instance.ShowCriticalErrorScreen(sptVersion, release.releaseSummary, ErrorScreen.EButtonType.OkButton, 36000, null, null);
+ PlayerPrefs.SetInt("SPT_ShownReleaseNotes", 1);
+ }
+ }
+
+ // User accepted the terms, allow to continue.
+ private void OnMessageAccepted()
+ {
+ Logger.LogInfo("User accepted the terms");
+ PlayerPrefs.SetInt("SPT_AcceptedBETerms", 1);
+ _isBetaDisclaimerOpen = false;
+ }
+
+ // If the user doesnt accept the message "Ok" then the game will close.
+ private void OnTimeOut()
+ {
+ Application.Quit();
+ }
+
+ // Stores the current build in the registry to check later
+ // Return true if changed, false if not
+ private void SetVersionPref()
+ {
+ if (GetVersionPref() == string.Empty || GetVersionPref() != sptVersion)
+ {
+ PlayerPrefs.SetString("SPT_Version", sptVersion);
+
+ // 0 val used to indicate false, 1 val used to indicate true
+ PlayerPrefs.SetInt("SPT_AcceptedBETerms", 0);
+ PlayerPrefs.SetInt("SPT_ShownReleaseNotes", 0);
+ }
+ }
+
+ // Retrieves the current build from the registry to check against the current build
+ // If this is the first run and no entry exists returns an empty string
+ private string GetVersionPref()
+ {
+ return PlayerPrefs.GetString("SPT_Version", string.Empty);
+ }
+
+ // Should we show the message, only show if first run or if build has changed
+ private bool ShouldShowBetaMessage()
+ {
+ return PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 0 && release.isBeta && !_isBetaDisclaimerOpen ? true : false;
+ }
+
+ // Should we show the release notes, only show on first run or if build has changed
+ private bool ShouldShowReleaseNotes()
+ {
+ return PlayerPrefs.GetInt("SPT_ShownReleaseNotes") == 0 && !_isBetaDisclaimerOpen && release.releaseSummary != string.Empty ? true : false;
+ }
+ }
+}
diff --git a/project/Aki.Debugging/AkiDebuggingPlugin.cs b/project/Aki.Debugging/AkiDebuggingPlugin.cs
index 9a5bc8f..f4c9876 100644
--- a/project/Aki.Debugging/AkiDebuggingPlugin.cs
+++ b/project/Aki.Debugging/AkiDebuggingPlugin.cs
@@ -1,29 +1,13 @@
using System;
-using System.Runtime.CompilerServices;
using Aki.Common;
-using Aki.Common.Http;
-using Aki.Common.Utils;
-using Aki.Core.Patches;
-using Aki.Custom.Models;
using Aki.Debugging.Patches;
using BepInEx;
-using Comfort.Common;
-using EFT;
-using EFT.UI;
-using UnityEngine;
namespace Aki.Debugging
{
[BepInPlugin("com.spt-aki.debugging", "AKI.Debugging", AkiPluginInfo.PLUGIN_VERSION)]
public class AkiDebuggingPlugin : BaseUnityPlugin
{
- public static string sptVersion;
- public static string commitHash;
-
- private ReleaseResponse release;
-
- private bool _isBetaDisclaimerOpen = false;
-
public void Awake()
{
Logger.LogInfo("Loading: Aki.Debugging");
@@ -48,96 +32,5 @@ namespace Aki.Debugging
Logger.LogInfo("Completed: Aki.Debugging");
}
-
- public void Start()
- {
- var versionJson = RequestHandler.GetJson("/singleplayer/settings/version");
- sptVersion = Json.Deserialize(versionJson).Version;
-
- var splitVersion = sptVersion.Split(' ');
- commitHash = splitVersion[4] ?? "";
-
- var releaseJson = RequestHandler.GetJson("/singleplayer/release");
- release = Json.Deserialize(releaseJson);
-
- SetVersionPref();
-
- // Enable the watermark if this is a bleeding edge build.
- // Enabled in start to allow time for the request containing the bool to process.
- if (release.isBeta)
- {
- new DebugLogoPatch().Enable();
- new DebugLogoPatch2().Enable();
- new DebugLogoPatch3().Enable();
- new PreventClientModsPatch().Enable();
- }
-
- if (release.isBeta && PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 1)
- {
- Logger.LogInfo("User accepted the beta disclaimer");
- }
- }
-
- public void Update()
- {
- if (Singleton.Instantiated && ShouldShowBetaMessage())
- {
- Singleton.Instance.ShowCriticalErrorScreen(sptVersion, release.betaDisclaimer, ErrorScreen.EButtonType.OkButton, release.betaDisclaimerTimeoutDelay, new Action(OnMessageAccepted), new Action(OnTimeOut));
- _isBetaDisclaimerOpen = true;
- }
-
- if (Singleton.Instantiated && ShouldShowReleaseNotes())
- {
- Singleton.Instance.ShowCriticalErrorScreen(sptVersion, release.releaseSummary, ErrorScreen.EButtonType.OkButton, 36000, null, null);
- PlayerPrefs.SetInt("SPT_ShownReleaseNotes", 1);
- }
- }
-
- // User accepted the terms, allow to continue.
- private void OnMessageAccepted()
- {
- Logger.LogInfo("User accepted the terms");
- PlayerPrefs.SetInt("SPT_AcceptedBETerms", 1);
- _isBetaDisclaimerOpen = false;
- }
-
- // If the user doesnt accept the message "Ok" then the game will close.
- private void OnTimeOut()
- {
- Application.Quit();
- }
-
- // Stores the current build in the registry to check later
- // Return true if changed, false if not
- private void SetVersionPref()
- {
- if (GetVersionPref() == string.Empty || GetVersionPref() != sptVersion)
- {
- PlayerPrefs.SetString("SPT_Version", sptVersion);
-
- // 0 val used to indicate false, 1 val used to indicate true
- PlayerPrefs.SetInt("SPT_AcceptedBETerms", 0);
- PlayerPrefs.SetInt("SPT_ShownReleaseNotes", 0);
- }
- }
-
- // Retrieves the current build from the registry to check against the current build
- // If this is the first run and no entry exists returns an empty string
- private string GetVersionPref()
- {
- return PlayerPrefs.GetString("SPT_Version", string.Empty);
- }
-
- // Should we show the message, only show if first run or if build has changed
- private bool ShouldShowBetaMessage()
- {
- return PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 0 && release.isBeta && !_isBetaDisclaimerOpen ? true : false;
- }
-
- // Should we show the release notes, only show on first run or if build has changed
- private bool ShouldShowReleaseNotes()
- {
- return PlayerPrefs.GetInt("SPT_ShownReleaseNotes") == 0 && !_isBetaDisclaimerOpen && release.releaseSummary != string.Empty ? true : false;
- }
}
}