mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 20:54:16 +01:00
Basic Addon structure
Name, X, Y, Scale, Visible
This commit is contained in:
parent
105ee55258
commit
24399dba25
3 changed files with 56 additions and 0 deletions
25
Dalamud/Game/Internal/Gui/Addon/Addon.cs
Normal file
25
Dalamud/Game/Internal/Gui/Addon/Addon.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Dalamud.Game.Internal.Gui.Addon {
|
||||
public class Addon {
|
||||
public IntPtr Address;
|
||||
protected Structs.Addon addonStruct;
|
||||
|
||||
public Addon(IntPtr address, Structs.Addon addonStruct) {
|
||||
this.Address = address;
|
||||
this.addonStruct = addonStruct;
|
||||
}
|
||||
|
||||
public string Name => this.addonStruct.Name;
|
||||
public short X => this.addonStruct.X;
|
||||
public short Y => this.addonStruct.Y;
|
||||
public float Scale => this.addonStruct.Scale;
|
||||
|
||||
public bool Visible => (this.addonStruct.Flags & 0x20) == 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -331,6 +331,13 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
return this.getUIObjectByName(baseUiProperties, name, index);
|
||||
}
|
||||
|
||||
public Addon.Addon GetAddonByName(string name, int index) {
|
||||
var addonMem = GetUiObjectByName(name, index);
|
||||
if (addonMem == IntPtr.Zero) return null;
|
||||
var addonStruct = Marshal.PtrToStructure<Structs.Addon>(addonMem);
|
||||
return new Addon.Addon(addonMem, addonStruct);
|
||||
}
|
||||
|
||||
public void SetBgm(ushort bgmKey) => this.setGlobalBgmHook.Original(bgmKey, 0, 0, 0, 0, 0);
|
||||
|
||||
public void Enable() {
|
||||
|
|
|
|||
24
Dalamud/Game/Internal/Gui/Structs/Addon.cs
Normal file
24
Dalamud/Game/Internal/Gui/Structs/Addon.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Dalamud.Game.Internal.Gui.Structs {
|
||||
|
||||
public class AddonOffsets {
|
||||
public const int Name = 0x8;
|
||||
public const int Flags = 0x182;
|
||||
public const int X = 0x1BC;
|
||||
public const int Y = 0x1BE;
|
||||
public const int Scale = 0x1AC;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Addon {
|
||||
[FieldOffset(AddonOffsets.Name), MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
|
||||
public string Name;
|
||||
|
||||
[FieldOffset(AddonOffsets.Flags)] public byte Flags;
|
||||
[FieldOffset(AddonOffsets.X)] public short X;
|
||||
[FieldOffset(AddonOffsets.Y)] public short Y;
|
||||
[FieldOffset(AddonOffsets.Scale)] public float Scale;
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue