Skip to content

Commit

Permalink
make the noop case a bit faster
Browse files Browse the repository at this point in the history
  • Loading branch information
KazWolfe committed Jul 17, 2024
1 parent e6204f9 commit 854b71a
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PluginManager>.GetNullable()?.InstalledPlugins
.Count(c => c.State == PluginState.Loaded) ?? 0;

if (this.configuration.ShowTsm)
{
var pluginCount = Service<PluginManager>.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();
Expand Down

0 comments on commit 854b71a

Please sign in to comment.