-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic nameplate service #1830
base: master
Are you sure you want to change the base?
Conversation
967a9fc
to
632dd95
Compare
Dalamud/Game/Gui/Nameplates/EventArgs/NameplateUpdateEventArgs.cs
Outdated
Show resolved
Hide resolved
@Infiziert90 noticed that you are using |
Changed everything to nint now. |
98d0cd5
to
d59d536
Compare
Is there a particular reason or reasons why this is still a draft? |
@MidoriKami I didn't actually tested this via the Tesplugin yet as I had no time this week. :/ But mainly just thought it's better to keep it as draft before I (or someone) actually tested it. xD |
Understandable, not trying to rush, it just seemed like it was pretty close to being good to go, we can always make minor adjustments later. |
ce01bfa
to
7f410c3
Compare
4635db7
to
606c96b
Compare
Will this be merged in with apix? No pressure, but we're talking about falling back to the library if not and want to plan accordingly. |
That would be nice, but it'd have to go in this weekend. Could you please re-review if you have time? @Haselnussbomber, @nebel and @MidoriKami - thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some concerns that I think need to be addressed immediately before it can be merged, and some suggestions that would be nice to have.
I won't be available for follow up reviews until I have completed MSQ.
/// Gets all available nameplate elements. | ||
/// </summary> | ||
/// <returns>Returns an array of all nameplate element.</returns> | ||
INameplateElement[] GetAllElement(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a specific reason why this is an Array instead of a List?
[ServiceManager.ServiceDependency] | ||
private readonly AddonLifecycle addonLifecycle = Service<AddonLifecycle>.Get(); | ||
|
||
[Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 8B 5C 24 ?? 45 38 BE", DetourName = nameof(HandleSetPlayerNameplateDetour))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in a AddressResolver class, see AddonLifecycleAddressResolver
, and AddonLifecycle
for an example.
private nint PluginAllocate(SeString seString) | ||
{ | ||
return this.PluginAllocate(seString.Encode()); | ||
} | ||
|
||
private nint PluginAllocate(byte[] bytes) | ||
{ | ||
var pointer = Marshal.AllocHGlobal(bytes.Length + 1); | ||
Marshal.Copy(bytes, 0, pointer, bytes.Length); | ||
Marshal.WriteByte(pointer, bytes.Length, 0); | ||
return pointer; | ||
} | ||
|
||
private void PluginFree(nint ptr) | ||
{ | ||
Marshal.FreeHGlobal(ptr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there has to be a better way, but we can look into that later, as this is implementation details that we can address at any time without breaking the API.
There is currently an issue with this service which could be quite difficult to address, namely that the main function we hook to do all the work ( |
Arg, that was unintended... Maybe they moved it to the paren function now. Hm, there is another function we could hook to. But I don't know how it's called (maybe something like |
No, MemoryHelper.WriteString didn't the trick. :/
Removing GetNameplateGameObject from INameplateGui and splitting it into two methods. Provided & cached by INameplateObject
04b64df
to
de9f6df
Compare
Keep in mind that this is just a basic (but futureorientate) implementation, re-implemented inspired by Pilz.Dalamud. The current implementation uses the
SetPlayerNameplateDetourDelegate
event and provides just a basic way to edit the existing elements of a player nameplate.It's not possible yet to directly get/edit/add/remove nodes. This can be done in a future PR by a future implementation of the Nameplate service wich uses another Event (more low-level wich then access AktResNode etc.). But I had not the time to get involved with this Event. Most plugins uses this one and that's enough for now imao.
I know the other event is more low-level that gives you more options. But I have no expierience with it and time to investigate and it's not really required for this basic PR in my opinion.
Also, the manual allocation has it's reason.
MemoryHelper.WriteString
didn't work. The parameters liketitlePtr
are addresses to raw byte arrays, soUtf8String
isn't working too.