From 854b71a29974032b46dc9a929688fbb60f141180 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Wed, 17 Jul 2024 12:44:53 -0700 Subject: [PATCH] make the noop case a bit faster --- .../Internal/Windows/TitleScreenMenuWindow.cs | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs b/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs index 8b5701f06..768ebef04 100644 --- a/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs +++ b/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs @@ -445,27 +445,32 @@ private unsafe void OnVersionStringDraw(AddonEvent ev, AddonArgs args) if (args is not AddonDrawArgs setupArgs) return; var addon = (AtkUnitBase*)setupArgs.Addon; + var textNode = addon->GetTextNodeById(3); + + if (!this.configuration.ShowTsm || !this.showTsm.Value) + { + textNode->NodeText.SetString(addon->AtkValues[1].String); + return; + } // look and feel init. should be harmless to set. addon->GetTextNodeById(3)->TextFlags |= (byte)TextFlags.MultiLine; addon->GetTextNodeById(3)->AlignmentType = AlignmentType.TopLeft; - var titleVersionText = new SeStringBuilder().AddText(addon->AtkValues[1].GetValueAsString()); + var pluginCount = Service.GetNullable()?.InstalledPlugins + .Count(c => c.State == PluginState.Loaded) ?? 0; - if (this.configuration.ShowTsm) - { - var pluginCount = Service.GetNullable()?.InstalledPlugins - .Count(c => c.State == PluginState.Loaded) ?? 0; - - titleVersionText.AddText("\n\n") - .AddUiForeground(SeIconChar.BoxedLetterD.ToIconString(), 539) - .AddUiForeground(561) - .AddText($" Dalamud: {Util.GetScmVersion()} ({this.trackName})") - .AddText($" - {pluginCount} {(pluginCount != 1 ? "plugins" : "plugin")} loaded") - .AddUiForegroundOff(); - } - - addon->GetTextNodeById(3)->NodeText.SetString(titleVersionText.Build().Encode()); + var titleVersionText = new SeStringBuilder() + .AddText(addon->AtkValues[1].GetValueAsString()) + .AddText("\n\n") + .AddUiForeground(SeIconChar.BoxedLetterD.ToIconString(), 539) + .AddUiForeground(561) + .AddText($" Dalamud: {Util.GetScmVersion()} ({this.trackName})") + .AddText($" - {pluginCount} {(pluginCount != 1 ? "plugins" : "plugin")} loaded") + .AddUiForegroundOff() + .Build().Encode(); + + addon->GetTextNodeById(3)->NodeText.SetString(titleVersionText); } private void TitleScreenMenuEntryListChange() => this.privateAtlas.BuildFontsAsync();