mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-25 06:01:51 +01:00
Some further stuff.
This commit is contained in:
parent
0df12a34cb
commit
3fc724b7ee
15 changed files with 106 additions and 73 deletions
44
Penumbra/Interop/Services/FontReloader.cs
Normal file
44
Penumbra/Interop/Services/FontReloader.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using Penumbra.GameData;
|
||||
|
||||
namespace Penumbra.Interop.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Handle font reloading via game functions.
|
||||
/// May cause a interface flicker while reloading.
|
||||
/// </summary>
|
||||
public unsafe class FontReloader
|
||||
{
|
||||
public bool Valid
|
||||
=> _reloadFontsFunc != null;
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
if (Valid)
|
||||
_reloadFontsFunc(_atkModule, false, true);
|
||||
else
|
||||
Penumbra.Log.Error("Could not reload fonts, function could not be found.");
|
||||
}
|
||||
|
||||
private readonly AtkModule* _atkModule = null!;
|
||||
private readonly delegate* unmanaged<AtkModule*, bool, bool, void> _reloadFontsFunc = null!;
|
||||
|
||||
public FontReloader()
|
||||
{
|
||||
var framework = Framework.Instance();
|
||||
if (framework == null)
|
||||
return;
|
||||
|
||||
var uiModule = framework->GetUiModule();
|
||||
if (uiModule == null)
|
||||
return;
|
||||
|
||||
var atkModule = uiModule->GetRaptureAtkModule();
|
||||
if (atkModule == null)
|
||||
return;
|
||||
|
||||
_atkModule = &atkModule->AtkModule;
|
||||
_reloadFontsFunc = ((delegate* unmanaged<AtkModule*, bool, bool, void>*)_atkModule->vtbl)[Offsets.ReloadFontsVfunc];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue