Skip to content

Commit

Permalink
Testing version warning
Browse files Browse the repository at this point in the history
  • Loading branch information
RisaDev committed Oct 24, 2024
1 parent 4284b32 commit a3c3d4d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
27 changes: 27 additions & 0 deletions CustomizePlus/Core/Helpers/VersionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#if !DEBUG
using System.Reflection;
#endif

namespace CustomizePlus.Core.Helpers;

internal static class VersionHelper
{
public static string Version { get; private set; } = "Initializing";

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

static VersionHelper()
{
#if DEBUG
Version = $"{ThisAssembly.Git.Commit}+{ThisAssembly.Git.Sha} [DEBUG]";
#else
Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
#endif

if (ThisAssembly.Git.BaseTag.ToLowerInvariant().Contains("testing"))
IsTesting = true;

if (IsTesting)
Version += " [TESTING BUILD]";
}
}
1 change: 1 addition & 0 deletions CustomizePlus/Core/Services/CommandService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ private void ProfileCommand(string argument)
{
if (state != null)
{
//todo: still check and disable other profiles in this case?
if (targetProfile!.Enabled == state)
{
_chatService.PrintInChat(new SeStringBuilder()
Expand Down
3 changes: 2 additions & 1 deletion CustomizePlus/Core/Services/SupportLogBuilderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CustomizePlus.Configuration.Data;
using CustomizePlus.Core.Data;
using CustomizePlus.Core.Extensions;
using CustomizePlus.Core.Helpers;
using CustomizePlus.Profiles;
using CustomizePlus.Templates;
using Dalamud.Plugin;
Expand Down Expand Up @@ -38,7 +39,7 @@ public string BuildSupportLog()
{
var sb = new StringBuilder(102400); //it's fair to assume this will very often be quite large
sb.AppendLine("**Settings**");
sb.Append($"> **`Plugin Version: `** {Plugin.Version}\n");
sb.Append($"> **`Plugin Version: `** {VersionHelper.Version}\n");
sb.Append($"> **`Commit Hash: `** {ThisAssembly.Git.Commit}+{ThisAssembly.Git.Sha}\n");
sb.Append($"> **`Plugin enabled: `** {_configuration.PluginEnabled}\n");
sb.AppendLine("**Settings -> Editor Settings**");
Expand Down
12 changes: 2 additions & 10 deletions CustomizePlus/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
#if !DEBUG
using System.Reflection;
#endif
using CustomizePlus.Api;
using CustomizePlus.Core;
using CustomizePlus.Core.Helpers;
using CustomizePlus.Core.Services;
using CustomizePlus.UI;
using Dalamud.Plugin;
Expand All @@ -16,12 +14,6 @@ namespace CustomizePlus;

public sealed class Plugin : IDalamudPlugin
{
#if DEBUG
public static readonly string Version = $"{ThisAssembly.Git.Commit}+{ThisAssembly.Git.Sha} [DEBUG]";
#else
public static readonly string Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
#endif

private readonly ServiceManager _services;

public static readonly Logger Logger = new(); //for loggin in static classes/methods
Expand All @@ -40,7 +32,7 @@ public Plugin(IDalamudPluginInterface pluginInterface)
_services.GetService<CPlusWindowSystem>();
_services.GetService<CommandService>();

Logger.Information($"Customize+ {Version} ({ThisAssembly.Git.Commit}+{ThisAssembly.Git.Sha}) [FantasiaPlus] started");
Logger.Information($"Customize+ {VersionHelper.Version} ({ThisAssembly.Git.Commit}+{ThisAssembly.Git.Sha}) [FantasiaPlus] started");
}
catch (Exception ex)
{
Expand Down
9 changes: 9 additions & 0 deletions CustomizePlus/UI/Windows/Controls/PluginStateBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void Draw(float yPos)
{
var severity = PluginStateSeverity.Normal;
string? message = null;
string? hoverInfo = null;

if(_hookingService.RenderHookFailed || _hookingService.MovementHookFailed)
{
Expand Down Expand Up @@ -74,6 +75,12 @@ public void Draw(float yPos)
severity = PluginStateSeverity.Error;
message = $"Detected failure in IPC. Integrations with other plugins will not function.";
}
else if(VersionHelper.IsTesting)
{
severity = PluginStateSeverity.Warning;
message = $"You are running testing version of Customize+, hover for more information.";
hoverInfo = "This is a testing build of Customize+. Some features like integration with other plugins might not function correctly.";
}

if (message != null)
{
Expand All @@ -96,6 +103,8 @@ public void Draw(float yPos)
ImGui.PushStyleColor(ImGuiCol.Text, color);
CtrlHelper.LabelWithIcon(icon, message, false);
ImGui.PopStyleColor();
if (hoverInfo != null)
CtrlHelper.AddHoverText(hoverInfo);
}
}

Expand Down
3 changes: 2 additions & 1 deletion CustomizePlus/UI/Windows/MainWindow/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using CustomizePlus.Templates.Events;
using CustomizePlus.Templates.Data;
using ECommons.Schedulers;
using CustomizePlus.Core.Helpers;

namespace CustomizePlus.UI.Windows.MainWindow;

Expand Down Expand Up @@ -59,7 +60,7 @@ public MainWindow(
PluginConfiguration configuration,
HookingService hookingService,
TemplateEditorEvent templateEditorEvent
) : base($"Customize+ {Plugin.Version}###CPlusMainWindow")
) : base($"Customize+ {VersionHelper.Version}###CPlusMainWindow")
{
_settingsTab = settingsTab;
_templatesTab = templatesTab;
Expand Down

0 comments on commit a3c3d4d

Please sign in to comment.