Skip to content

Commit

Permalink
chore: Clean up TSM changes
Browse files Browse the repository at this point in the history
- Add new GameGui#RequestAddonUpdate to easily fire any such update.
- Make TSM settings redraw the revision addon on change
- no more blorp
  • Loading branch information
KazWolfe committed Nov 21, 2024
1 parent 18fff5c commit 3bf6a5d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
20 changes: 20 additions & 0 deletions Dalamud/Game/Gui/GameGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,26 @@ internal void ResetUiHideState()
this.GameUiHidden = false;
}

/// <summary>
/// Requests an addon update immediately, assuming it's visible. Calls AtkUnitManager#AddonRequestUpdateById.
/// </summary>
/// <param name="name">The name of the addon to request.</param>
/// <param name="index">The index to pass to GetAddonByName.</param>
/// <param name="force">A force flag to pass to AddonRequestUpdateById.</param>
internal void RequestAddonUpdate(string name, int index = 1, bool force = false)
{
var atkStage = AtkStage.Instance();
var addon = (AtkUnitBase*)this.GetAddonByName(name, index);

if (addon == null || !addon->IsVisible) return;

RaptureAtkUnitManager.Instance()->AddonRequestUpdateById(
addon->Id,
atkStage->GetNumberArrayData(),
atkStage->GetStringArrayData(),
force);
}

private IntPtr HandleSetGlobalBgmDetour(ushort bgmKey, byte a2, uint a3, uint a4, uint a5, byte a6)
{
var retVal = this.setGlobalBgmHook.Original(bgmKey, a2, a3, a4, a5, a6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using CheapLoc;
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.Gui;
using Dalamud.Game.Text;
using Dalamud.Interface.Colors;
using Dalamud.Interface.FontIdentifier;
Expand Down Expand Up @@ -124,7 +125,12 @@ private static readonly (string, float)[] GlobalUiScalePresets =
Loc.Localize("DalamudSettingToggleTsm", "Show title screen menu"),
Loc.Localize("DalamudSettingToggleTsmHint", "This will allow you to access certain Dalamud and Plugin functionality from the title screen.\nDisabling this will also hide the Dalamud version text on the title screen."),
c => c.ShowTsm,
(v, c) => c.ShowTsm = v),
(v, c) =>
{
c.ShowTsm = v;

Service<GameGui>.GetNullable()?.RequestAddonUpdate("_TitleRevision", force: true);
}),

new SettingsEntry<bool>(
Loc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
Expand Down
6 changes: 2 additions & 4 deletions Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,9 @@ private void FrameworkOnUpdate(IFramework unused)

private unsafe void OnVersionStringUpdate(AddonEvent ev, AddonArgs args)
{
if (args is not AddonRequestedUpdateArgs drawArgs) return;
if (args is not AddonRequestedUpdateArgs) return;

Serilog.Log.Warning("blorp");

var addon = (AtkUnitBase*)drawArgs.Addon;
var addon = (AtkUnitBase*)args.Addon;
var textNode = addon->GetTextNodeById(3);

// look and feel init. should be harmless to set.
Expand Down

0 comments on commit 3bf6a5d

Please sign in to comment.