mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Show mods loaded in cool debug message (!95)
needs merged with: SPT-AKI/Server#258 Shows if mods are loaded in the cool debug message, will show if either server mods or client mods are present. Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com> Reviewed-on: SPT-AKI/Modules#95 Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com> Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
6a77131249
commit
73db17ea78
@ -4,9 +4,16 @@ namespace Aki.Custom.Models
|
||||
{
|
||||
public bool isBeta { get; set; }
|
||||
public bool isModdable { get; set; }
|
||||
public string betaDisclaimer { get; set; }
|
||||
public bool isModded { get; set; }
|
||||
public float betaDisclaimerTimeoutDelay { get; set; }
|
||||
public string releaseSummary { get; set; }
|
||||
|
||||
public string betaDisclaimerText { get; set; }
|
||||
public string betaDisclaimerAcceptText { get; set; }
|
||||
public string serverModsLoadedText { get; set; }
|
||||
public string serverModsLoadedDebugText { get; set; }
|
||||
public string clientModsLoadedText { get; set; }
|
||||
public string clientModsLoadedDebugText { get; set; }
|
||||
public string illegalPluginsLoadedText { get; set; }
|
||||
public string illegalPluginsExceptionText { get; set; }
|
||||
public string releaseSummaryText { get; set; }
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Aki.Reflection.Patching;
|
||||
using Aki.SinglePlayer.Utils.MainMenu;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Logging;
|
||||
using EFT;
|
||||
@ -28,27 +29,10 @@ namespace Aki.SinglePlayer.Patches.MainMenu
|
||||
|
||||
private static void CheckForNonWhitelistedPlugins(ManualLogSource logger)
|
||||
{
|
||||
var whitelistedPlugins = new HashSet<string>
|
||||
if (MenuNotificationManager.disallowedPlugins.Any())
|
||||
{
|
||||
"com.spt-aki.core",
|
||||
"com.spt-aki.custom",
|
||||
"com.spt-aki.debugging",
|
||||
"com.spt-aki.singleplayer",
|
||||
"com.bepis.bepinex.configurationmanager",
|
||||
"com.terkoiz.freecam",
|
||||
"com.sinai.unityexplorer",
|
||||
"com.cwx.debuggingtool-dxyz",
|
||||
"com.cwx.debuggingtool",
|
||||
"xyz.drakia.botdebug",
|
||||
"com.kobrakon.camunsnap",
|
||||
"RuntimeUnityEditor"
|
||||
};
|
||||
|
||||
var disallowedPlugins = Chainloader.PluginInfos.Values.Select(pi => pi.Metadata.GUID).Except(whitelistedPlugins).ToArray();
|
||||
if (disallowedPlugins.Any())
|
||||
{
|
||||
logger.LogError($"One or more non-whitelisted plugins were detected. Mods are not allowed in BleedingEdge builds of SPT. Illegal plugins:\n{string.Join("\n", disallowedPlugins)}");
|
||||
throw new Exception("Non-debug client mods have been detected. Mods are not allowed in BleedingEdge builds of SPT - please remove them before playing!");
|
||||
logger.LogError($"{MenuNotificationManager.release.illegalPluginsLoadedText}\n{string.Join("\n", MenuNotificationManager.disallowedPlugins)}");
|
||||
throw new Exception(MenuNotificationManager.release.illegalPluginsExceptionText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,12 @@
|
||||
using Aki.Common.Utils;
|
||||
using Aki.Custom.Models;
|
||||
using Aki.SinglePlayer.Patches.MainMenu;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Logging;
|
||||
using Comfort.Common;
|
||||
using EFT.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -15,10 +17,25 @@ namespace Aki.SinglePlayer.Utils.MainMenu
|
||||
{
|
||||
public static string sptVersion;
|
||||
public static string commitHash;
|
||||
private ReleaseResponse release;
|
||||
internal static HashSet<string> whitelistedPlugins = new HashSet<string>
|
||||
{
|
||||
"com.spt-aki.core",
|
||||
"com.spt-aki.custom",
|
||||
"com.spt-aki.debugging",
|
||||
"com.spt-aki.singleplayer",
|
||||
"com.bepis.bepinex.configurationmanager",
|
||||
"com.terkoiz.freecam",
|
||||
"com.sinai.unityexplorer",
|
||||
"com.cwx.debuggingtool-dxyz",
|
||||
"com.cwx.debuggingtool",
|
||||
"xyz.drakia.botdebug",
|
||||
"com.kobrakon.camunsnap",
|
||||
"RuntimeUnityEditor"
|
||||
};
|
||||
|
||||
public static string[] disallowedPlugins;
|
||||
internal static ReleaseResponse release;
|
||||
private bool _isBetaDisclaimerOpen = false;
|
||||
|
||||
private ManualLogSource Logger;
|
||||
|
||||
public void Start()
|
||||
@ -43,6 +60,9 @@ namespace Aki.SinglePlayer.Utils.MainMenu
|
||||
new BetaLogoPatch3().Enable();
|
||||
}
|
||||
|
||||
disallowedPlugins = Chainloader.PluginInfos.Values
|
||||
.Select(pi => pi.Metadata.GUID).Except(whitelistedPlugins).ToArray();
|
||||
|
||||
// Prevent client mods if the server is built with mods disabled
|
||||
if (!release.isModdable)
|
||||
{
|
||||
@ -51,7 +71,20 @@ namespace Aki.SinglePlayer.Utils.MainMenu
|
||||
|
||||
if (release.isBeta && PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 1)
|
||||
{
|
||||
Logger.LogInfo("User accepted the beta disclaimer");
|
||||
Logger.LogInfo(release.betaDisclaimerAcceptText);
|
||||
ServerLog.Info("Aki.Custom", release.betaDisclaimerAcceptText);
|
||||
}
|
||||
|
||||
if (release.isModded && release.isBeta && release.isModdable)
|
||||
{
|
||||
commitHash += $"\n {release.serverModsLoadedDebugText}";
|
||||
ServerLog.Warn("Aki.Custom", release.serverModsLoadedText);
|
||||
}
|
||||
|
||||
if (disallowedPlugins.Any() && release.isBeta && release.isModdable)
|
||||
{
|
||||
commitHash += $"\n {release.clientModsLoadedDebugText}";
|
||||
ServerLog.Warn("Aki.Custom", $"{release.clientModsLoadedText}\n{string.Join("\n", disallowedPlugins)}");
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
@ -61,15 +94,27 @@ namespace Aki.SinglePlayer.Utils.MainMenu
|
||||
return;
|
||||
}
|
||||
|
||||
ShowBetaMessage();
|
||||
ShowReleaseNotes();
|
||||
}
|
||||
|
||||
// Show the beta message
|
||||
// if mods are enabled show that mods are loaded in the message.
|
||||
private void ShowBetaMessage()
|
||||
{
|
||||
if (Singleton<PreloaderUI>.Instantiated && ShouldShowBetaMessage())
|
||||
{
|
||||
Singleton<PreloaderUI>.Instance.ShowCriticalErrorScreen(sptVersion, release.betaDisclaimer, ErrorScreen.EButtonType.OkButton, release.betaDisclaimerTimeoutDelay, new Action(OnMessageAccepted), new Action(OnTimeOut));
|
||||
Singleton<PreloaderUI>.Instance.ShowCriticalErrorScreen(sptVersion, release.betaDisclaimerText, ErrorScreen.EButtonType.OkButton, release.betaDisclaimerTimeoutDelay, new Action(OnMessageAccepted), new Action(OnTimeOut));
|
||||
_isBetaDisclaimerOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Show the release notes.
|
||||
private void ShowReleaseNotes()
|
||||
{
|
||||
if (Singleton<PreloaderUI>.Instantiated && ShouldShowReleaseNotes())
|
||||
{
|
||||
Singleton<PreloaderUI>.Instance.ShowCriticalErrorScreen(sptVersion, release.releaseSummary, ErrorScreen.EButtonType.OkButton, 36000, null, null);
|
||||
Singleton<PreloaderUI>.Instance.ShowCriticalErrorScreen(sptVersion, release.releaseSummaryText, ErrorScreen.EButtonType.OkButton, 36000, null, null);
|
||||
PlayerPrefs.SetInt("SPT_ShownReleaseNotes", 1);
|
||||
}
|
||||
}
|
||||
@ -77,7 +122,7 @@ namespace Aki.SinglePlayer.Utils.MainMenu
|
||||
// User accepted the terms, allow to continue.
|
||||
private void OnMessageAccepted()
|
||||
{
|
||||
Logger.LogInfo("User accepted the terms");
|
||||
Logger.LogInfo(release.betaDisclaimerAcceptText);
|
||||
PlayerPrefs.SetInt("SPT_AcceptedBETerms", 1);
|
||||
_isBetaDisclaimerOpen = false;
|
||||
}
|
||||
@ -118,7 +163,7 @@ namespace Aki.SinglePlayer.Utils.MainMenu
|
||||
// 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;
|
||||
return PlayerPrefs.GetInt("SPT_ShownReleaseNotes") == 0 && !_isBetaDisclaimerOpen && release.releaseSummaryText != string.Empty ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user