Experimental: no longer run in dev/staging dalamud when not Debug/ReleaseValidate

This commit is contained in:
RisaDev
2024-11-18 01:08:25 +03:00
parent 9c0b8b7ab0
commit 344dc52614
11 changed files with 124 additions and 18 deletions

View File

@@ -5,6 +5,12 @@ namespace CustomizePlus.Core.Services.Dalamud;
public class DalamudBranchService : IService
{
/// <summary>
/// Message used in various places to tell user why the plugin is disabled
/// </summary>
public const string PluginDisabledMessage = "You are running development or testing version of Dalamud.\n" +
"Regular users are not supposed to run Customize+ on non-release versions of Dalamud therefore Customize+ has disabled itself.";
/// <summary>
/// Current Dalamud branch
/// </summary>
@@ -15,6 +21,11 @@ public class DalamudBranchService : IService
/// </summary>
public string CurrentBranchName { get; private set; }
/// <summary>
/// Whether to allow or not Customize+ to actually function
/// </summary>
public bool AllowPluginToRun { get; private set; } = true;
public DalamudBranchService(DalamudConfigService dalamudConfigService, Logger logger)
{
dalamudConfigService.GetDalamudConfig<string>(DalamudConfigService.BetaKindOption, out var betaOption);
@@ -33,7 +44,11 @@ public class DalamudBranchService : IService
break;
}
logger.Information($"Current Dalamud branch is: {CurrentBranchName} ({CurrentBranch})");
#if CHECK_DALAMUD_BRANCH
AllowPluginToRun = CurrentBranch == DalamudBranch.Release;
#endif
logger.Information($"Current Dalamud branch is: {CurrentBranchName} ({CurrentBranch}). Plugin allowed to run: {AllowPluginToRun}");
}
public enum DalamudBranch

View File

@@ -25,7 +25,7 @@ public class HookingService : IDisposable
private readonly ProfileManager _profileManager;
private readonly ArmatureManager _armatureManager;
private readonly GameStateService _gameStateService;
//private readonly DalamudBranchService _dalamudBranchService;
private readonly DalamudBranchService _dalamudBranchService;
private readonly Logger _logger;
private Hook<RenderDelegate>? _renderManagerHook;
@@ -46,7 +46,7 @@ public class HookingService : IDisposable
ProfileManager profileManager,
ArmatureManager armatureManager,
GameStateService gameStateService,
//DalamudBranchService dalamudBranchService,
DalamudBranchService dalamudBranchService,
Logger logger)
{
_configuration = configuration;
@@ -55,7 +55,7 @@ public class HookingService : IDisposable
_profileManager = profileManager;
_armatureManager = armatureManager;
_gameStateService = gameStateService;
//_dalamudBranchService = dalamudBranchService;
_dalamudBranchService = dalamudBranchService;
_logger = logger;
ReloadHooks();
@@ -75,8 +75,11 @@ public class HookingService : IDisposable
RenderHookFailed = false;
MovementHookFailed = false;
/*if(_dalamudBranchService.CurrentBranch != DalamudBranchService.DalamudBranch.Release)
return;*/
if(!_dalamudBranchService.AllowPluginToRun)
{
_logger.Error("Not reloading hooks because the plugin is not allowed to run. (Branch Service)");
return;
}
try
{

View File

@@ -2,7 +2,9 @@
using CustomizePlus.Core.Helpers;
using CustomizePlus.Core.Services.Dalamud;
using CustomizePlus.Game.Services;
using CustomizePlus.UI.Windows;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI;
namespace CustomizePlus.Core.Services;
@@ -11,17 +13,20 @@ public class UserNotifierService : IDisposable
private readonly IClientState _clientState;
private readonly ChatService _chatService;
private readonly DalamudBranchService _dalamudBranchService;
private readonly PopupSystem _popupSystem;
public UserNotifierService(
IClientState clientState,
ChatService chatService,
DalamudBranchService dalamudBranchService)
DalamudBranchService dalamudBranchService,
PopupSystem popupSystem)
{
_clientState = clientState;
_chatService = chatService;
_dalamudBranchService = dalamudBranchService;
_popupSystem = popupSystem;
OnLogin();
NotifyUser(true);
_clientState.Login += OnLogin;
}
@@ -32,13 +37,26 @@ public class UserNotifierService : IDisposable
}
private void OnLogin()
{
NotifyUser(true);
}
private void NotifyUser(bool displayOptionalMessages = false)
{
if (VersionHelper.IsTesting)
_chatService.PrintInChat($"You are running testing version of Customize+! Some features like integration with other plugins might not function correctly.",
ChatService.ChatMessageColor.Warning);
if (_dalamudBranchService.CurrentBranch != DalamudBranchService.DalamudBranch.Release)
_chatService.PrintInChat($"You are running development or testing version of Dalamud. This is not supported and might be actively prevented in the future.",
if (!_dalamudBranchService.AllowPluginToRun)
{
_chatService.PrintInChat(DalamudBranchService.PluginDisabledMessage,
ChatService.ChatMessageColor.Error);
if (displayOptionalMessages)
{
UIGlobals.PlayChatSoundEffect(11);
_popupSystem.ShowPopup(PopupSystem.Messages.PluginDisabledNonReleaseDalamud);
}
}
}
}