Skip to content

Commit

Permalink
Experimental: no longer run in dev/staging dalamud when not Debug/Rel…
Browse files Browse the repository at this point in the history
…easeValidate
  • Loading branch information
RisaDev committed Nov 17, 2024
1 parent 9c0b8b7 commit 344dc52
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 18 deletions.
8 changes: 6 additions & 2 deletions CustomizePlus.GameData/CustomizePlus.GameData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>Debug;Release</Configurations>
<Configurations>Debug;Release;ReleaseValidate</Configurations>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -49,8 +49,12 @@
<DefineConstants>INCOGNIFY_STRINGS</DefineConstants>
</PropertyGroup>-->

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<PropertyGroup Condition="'$(Configuration)'=='Release' Or '$(Configuration)'=='ReleaseValidate'">
<DefineConstants>INCOGNIFY_STRINGS</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='ReleaseValidate'">
<DefineConstants>VALIDATE_BUILD</DefineConstants>
</PropertyGroup>

</Project>
30 changes: 30 additions & 0 deletions CustomizePlus.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Global
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
ReleaseValidate|Any CPU = ReleaseValidate|Any CPU
ReleaseValidate|x64 = ReleaseValidate|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.Debug|Any CPU.ActiveCfg = Debug|x64
Expand All @@ -40,6 +42,10 @@ Global
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.Release|Any CPU.Build.0 = Release|x64
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.Release|x64.ActiveCfg = Release|x64
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.Release|x64.Build.0 = Release|x64
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.ReleaseValidate|Any CPU.ActiveCfg = ReleaseValidate|x64
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.ReleaseValidate|Any CPU.Build.0 = ReleaseValidate|x64
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.ReleaseValidate|x64.ActiveCfg = Release|x64
{5BA385F5-C17E-4CE4-828A-24F7F19C434B}.ReleaseValidate|x64.Build.0 = Release|x64
{0D465539-6133-4088-B4BB-F260FA2A1557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -48,6 +54,10 @@ Global
{0D465539-6133-4088-B4BB-F260FA2A1557}.Release|Any CPU.Build.0 = Release|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.Release|x64.ActiveCfg = Release|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.Release|x64.Build.0 = Release|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.ReleaseValidate|Any CPU.ActiveCfg = Release|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.ReleaseValidate|Any CPU.Build.0 = Release|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.ReleaseValidate|x64.ActiveCfg = Release|Any CPU
{0D465539-6133-4088-B4BB-F260FA2A1557}.ReleaseValidate|x64.Build.0 = Release|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -56,6 +66,10 @@ Global
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.Release|Any CPU.Build.0 = Release|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.Release|x64.ActiveCfg = Release|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.Release|x64.Build.0 = Release|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.ReleaseValidate|Any CPU.ActiveCfg = ReleaseValidate|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.ReleaseValidate|Any CPU.Build.0 = ReleaseValidate|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.ReleaseValidate|x64.ActiveCfg = Release|Any CPU
{CDB26C94-1200-45AA-AF96-D4526DC76AD5}.ReleaseValidate|x64.Build.0 = Release|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -64,6 +78,10 @@ Global
{D79C8833-D241-4867-BF6F-8097E0ED8067}.Release|Any CPU.Build.0 = Release|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.Release|x64.ActiveCfg = Release|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.Release|x64.Build.0 = Release|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.ReleaseValidate|Any CPU.ActiveCfg = Release|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.ReleaseValidate|Any CPU.Build.0 = Release|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.ReleaseValidate|x64.ActiveCfg = Release|Any CPU
{D79C8833-D241-4867-BF6F-8097E0ED8067}.ReleaseValidate|x64.Build.0 = Release|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -72,6 +90,10 @@ Global
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.Release|Any CPU.Build.0 = Release|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.Release|x64.ActiveCfg = Release|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.Release|x64.Build.0 = Release|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.ReleaseValidate|Any CPU.ActiveCfg = Release|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.ReleaseValidate|Any CPU.Build.0 = Release|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.ReleaseValidate|x64.ActiveCfg = Release|Any CPU
{CC460943-1E07-4FA0-8B8C-67F0EF385290}.ReleaseValidate|x64.Build.0 = Release|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All @@ -80,6 +102,10 @@ Global
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|Any CPU.Build.0 = Release|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|x64.ActiveCfg = Release|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|x64.Build.0 = Release|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.ReleaseValidate|Any CPU.ActiveCfg = Release|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.ReleaseValidate|Any CPU.Build.0 = Release|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.ReleaseValidate|x64.ActiveCfg = Release|Any CPU
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.ReleaseValidate|x64.Build.0 = Release|Any CPU
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.Debug|Any CPU.ActiveCfg = Debug|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.Debug|Any CPU.Build.0 = Debug|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.Debug|x64.ActiveCfg = Debug|x64
Expand All @@ -88,6 +114,10 @@ Global
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.Release|Any CPU.Build.0 = Release|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.Release|x64.ActiveCfg = Release|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.Release|x64.Build.0 = Release|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.ReleaseValidate|Any CPU.ActiveCfg = Release|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.ReleaseValidate|Any CPU.Build.0 = Release|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.ReleaseValidate|x64.ActiveCfg = Release|x64
{41F4BB08-FCFD-420F-AD18-ED9D7FB3251C}.ReleaseValidate|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 9 additions & 0 deletions CustomizePlus/Core/Helpers/VersionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ internal static class VersionHelper

public static bool IsDebug { get; private set; } = false;

public static bool IsValidate { get; private set; } = false;

static VersionHelper()
{
#if DEBUG
Expand All @@ -24,7 +26,14 @@ static VersionHelper()
if (ThisAssembly.Git.BaseTag.ToLowerInvariant().Contains("testing"))
IsTesting = true;

#if VALIDATE_BUILD
IsValidate = true;
#endif

if (IsTesting)
Version += " [TESTING BUILD]";

if (IsValidate)
Version += " [VALIDATE BUILD]";
}
}
17 changes: 16 additions & 1 deletion CustomizePlus/Core/Services/Dalamud/DalamudBranchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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);
Expand All @@ -33,7 +44,11 @@ public DalamudBranchService(DalamudConfigService dalamudConfigService, Logger lo
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
Expand Down
13 changes: 8 additions & 5 deletions CustomizePlus/Core/Services/HookingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -46,7 +46,7 @@ public HookingService(
ProfileManager profileManager,
ArmatureManager armatureManager,
GameStateService gameStateService,
//DalamudBranchService dalamudBranchService,
DalamudBranchService dalamudBranchService,
Logger logger)
{
_configuration = configuration;
Expand All @@ -55,7 +55,7 @@ public HookingService(
_profileManager = profileManager;
_armatureManager = armatureManager;
_gameStateService = gameStateService;
//_dalamudBranchService = dalamudBranchService;
_dalamudBranchService = dalamudBranchService;
_logger = logger;

ReloadHooks();
Expand All @@ -75,8 +75,11 @@ public void ReloadHooks()
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
{
Expand Down
26 changes: 22 additions & 4 deletions CustomizePlus/Core/Services/UserNotifierService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand All @@ -32,13 +37,26 @@ public void Dispose()
}

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);
}
}
}
}
12 changes: 10 additions & 2 deletions CustomizePlus/CustomizePlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Aether-Tools/CustomizePlus</PackageProjectUrl>
<UseWindowsForms>true</UseWindowsForms>
<Configurations>Debug;Release</Configurations>
<Configurations>Debug;Release;ReleaseValidate</Configurations>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -90,10 +90,18 @@
<DefineConstants>INCOGNIFY_STRINGS</DefineConstants>
</PropertyGroup>-->

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<PropertyGroup Condition="'$(Configuration)'=='Release' Or '$(Configuration)'=='ReleaseValidate'">
<DefineConstants>INCOGNIFY_STRINGS</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DefineConstants>CHECK_DALAMUD_BRANCH</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='ReleaseValidate'">
<DefineConstants>VALIDATE_BUILD</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<GitVersion>false</GitVersion>
</PropertyGroup>
Expand Down
10 changes: 10 additions & 0 deletions CustomizePlus/UI/Windows/CPlusChangeLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public CPlusChangeLog(PluginConfiguration config)
Add2_0_6_0(Changelog);
Add2_0_6_3(Changelog);
Add2_0_7_0(Changelog);
Add2_0_7_2(Changelog);
}

private (int, ChangeLogDisplayType) ConfigData()
Expand All @@ -37,6 +38,15 @@ private void Save(int version, ChangeLogDisplayType type)
_config.Save();
}

private static void Add2_0_7_2(Changelog log)
=> log.NextVersion("Version 2.0.7.2")
.RegisterHighlight("Support for 7.1 and Dalamud API 11.")
.RegisterImportant("As an experiment Customize+ will no longer run if you are running testing or development version of Dalamud. Please leave your feedback about this change in support Discord.")
.RegisterEntry("Developers can prevent this from triggering by manually compiling \"Debug\" or \"ReleaseValidate\" builds of Customize+.", 1)
.RegisterHighlight("Fixed an issue which prevented owned characters (such as Carbuncles and Trust NPCs) from being detected. (2.0.7.1)")

.RegisterEntry("Source code maintenance - external libraries update.");

private static void Add2_0_7_0(Changelog log)
=> log.NextVersion("Version 2.0.7.0")
.RegisterImportant("Some parts of Customize+ have been considerably rewritten in this update. If you encounter any issues please report them.")
Expand Down
4 changes: 2 additions & 2 deletions CustomizePlus/UI/Windows/Controls/PluginStateBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public void Draw(float yPos)
severity = PluginStateSeverity.Error;
message = "Detected failure in IPC. Integrations with other plugins will not function.";
}
else if (_dalamudBranchService.CurrentBranch != DalamudBranchService.DalamudBranch.Release)
else if (!_dalamudBranchService.AllowPluginToRun)
{
severity = PluginStateSeverity.Error;
message = "You are running unsupported version of Dalamud, hover for more information.";
hoverInfo = "Regular users are not supposed to run Customize+ on development or testing versions of Dalamud.\nThis is not supported and might be actively prevented in the future.";
hoverInfo = "Regular users are not supposed to run Customize+ on development or testing versions of Dalamud.\nThis is not supported and therefore Customize+ has disabled itself.";
}
else if(VersionHelper.IsTesting)
{
Expand Down
6 changes: 5 additions & 1 deletion CustomizePlus/UI/Windows/MainWindow/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using CustomizePlus.Templates.Data;
using ECommonsLite.Schedulers;
using CustomizePlus.Core.Helpers;
using CustomizePlus.Core.Services.Dalamud;

namespace CustomizePlus.UI.Windows.MainWindow;

Expand All @@ -37,6 +38,7 @@ public class MainWindow : Window, IDisposable
private readonly TemplateEditorManager _templateEditorManager;
private readonly PluginConfiguration _configuration;
private readonly HookingService _hookingService;
private readonly DalamudBranchService _dalamudBranchService;

private readonly TemplateEditorEvent _templateEditorEvent;

Expand All @@ -59,6 +61,7 @@ public MainWindow(
TemplateEditorManager templateEditorManager,
PluginConfiguration configuration,
HookingService hookingService,
DalamudBranchService dalamudBranchService,
TemplateEditorEvent templateEditorEvent
) : base($"Customize+ {VersionHelper.Version}###CPlusMainWindow")
{
Expand All @@ -74,6 +77,7 @@ TemplateEditorEvent templateEditorEvent
_templateEditorManager = templateEditorManager;
_configuration = configuration;
_hookingService = hookingService;
_dalamudBranchService = dalamudBranchService;

_templateEditorEvent = templateEditorEvent;

Expand All @@ -97,7 +101,7 @@ public override void Draw()
{
var yPos = ImGui.GetCursorPosY();

using (var disabled = ImRaii.Disabled(_hookingService.RenderHookFailed || _hookingService.MovementHookFailed))
using (var disabled = ImRaii.Disabled(_hookingService.RenderHookFailed || _hookingService.MovementHookFailed || !_dalamudBranchService.AllowPluginToRun))
{
LockWindowClosureIfNeeded();
ImGuiEx.EzTabBar("##tabs", null, _switchToTab, [
Expand Down
Loading

0 comments on commit 344dc52

Please sign in to comment.