You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This proposal would make it possible for plugin developers to create plugins
that would effectively replace the native DTR bar from the game with a custom
implementation by reading the registered DTR bar entries from Dalamud and
using a custom UI to display them.
In order to keep it streamlined and not conflict with Dalamud's existing config
options when it comes to DTR bar entry visibility and ordering, the exposed API
solely focuses on providing read-only access to the DTR bar entries.
Due to the specific use-case of this API and its immutability, it is
recommended to use a separate service interface that plugins can consume in
order to gain access to the DTR bar entries.
IDtrBarEntries
The IDtrBarEntries interface provides read-only access to the DTR bar
entries, as well as the ability to subscribe to changes in the DTR bar entries.
publicinterfaceIDtrBarEntries{/// <summary>/// Gets the DTR bar entries./// </summary>publicIReadOnlyList<ReadOnlyDtrBarEntry> Entries {get;}/// <summary>/// Invoked when an entry has been added./// </summary>publiceventAction<ReadOnlyDtrBarEntry>EntryAdded;/// <summary>/// Invoked when an entry has been removed./// </summary>publiceventAction<ReadOnlyDtrBarEntry>EntryRemoved;}
ReadOnlyDtrBarEntry
While the existing DtrBarEntry class is mutable and can be modified by
a plugin that registered it, the ReadOnlyDtrBarEntry class is immutable and
is intended to be shared with consuming plugins. This ensures that the original
DTR bar entry cannot be modified by any other plugin than the one that
originally registered it.
publicclassReadOnlyDtrBarEntry{/// <summary>/// Gets the name of the DTR bar entry./// </summary>publicstringName{get;}/// <summary>/// Gets the tooltip of the DTR bar entry./// </summary>publicstringTooltip{get;}/// <summary>/// Gets the visibility of the DTR bar entry./// </summary>publicboolIsVisible{get;}/// <summary>/// True if the DTR bar entry is interactive, meaning it has an OnClick/// event listener attached to it./// </summary>publicboolIsInteractive{get;}/// <summary>/// Gets the render-order of the DTR bar entry./// </summary>publicintSortIndex{get;}/// <summary>/// Invokes the OnClick event of the DTR bar entry./// </summary>publicvoidClick();}
Service Behavior
When a plugin registered a DTR bar entry, the EntryAdded event is invoked and
the ReadOnlyDtrBarEntry object will be part of the Entries list. When a
plugin unregisters a DTR bar entry, the EntryRemoved event is invoked and the ReadOnlyDtrBarEntry object will no longer be part of the Entries list.
Using these events allows a plugin to only update its own state or UI when it
is necessary, instead of polling the DTR bar entries list for changes on every
frame.
Note
A user can disable specific DTR bar entries in Dalamud's settings. In this case,
the ReadOnlyDtrBarEntry object will no longer be part of the Entries list.
The EntryRemoved event will be invoked if it was previously part of the list.
The EntryAdded event will be invoked if it was not previously part of the list.
This implicitly forces plugins to behave correctly when it comes to handling
visibility of individual DTR bar entries.
Usage Example
internalclassMyPlugin:IDalamudPlugin{privatereadonlyDalamudPluginInterface_pluginInterface;privatereadonlyIDtrBarEntries_dtrBarEntries;publicMyPlugin(DalamudPluginInterfacepluginInterface,IDtrBarEntriesdtrBarEntries){_pluginInterface=pluginInterface;_dtrBarEntries=dtrBarEntries;
_pluginInterface.UiBuilder.Draw +=OnDraw;
dtrBarEntries.EntryAdded +=OnEntryAdded;
dtrBarEntries.EntryRemoved +=OnEntryRemoved;}publicDispose(){
_pluginInterface.UiBuilder.Draw -=OnDraw;
dtrBarEntries.EntryAdded -=OnEntryAdded;
dtrBarEntries.EntryRemoved -=OnEntryRemoved;}privatevoidOnEntryAdded(ReadOnlyDtrBarEntryentry){// Handle entry added}privatevoidOnEntryRemoved(ReadOnlyDtrBarEntryentry){// Handle entry removed}privatevoidOnDraw(){// Draw DTR bar entries directly from the exposed list.foreach(var entry in _dtrBarEntries.Entries){// Draw entry}}}
The text was updated successfully, but these errors were encountered:
This proposal would make it possible for plugin developers to create plugins
that would effectively replace the native DTR bar from the game with a custom
implementation by reading the registered DTR bar entries from Dalamud and
using a custom UI to display them.
In order to keep it streamlined and not conflict with Dalamud's existing config
options when it comes to DTR bar entry visibility and ordering, the exposed API
solely focuses on providing read-only access to the DTR bar entries.
Due to the specific use-case of this API and its immutability, it is
recommended to use a separate service interface that plugins can consume in
order to gain access to the DTR bar entries.
IDtrBarEntries
The
IDtrBarEntries
interface provides read-only access to the DTR barentries, as well as the ability to subscribe to changes in the DTR bar entries.
ReadOnlyDtrBarEntry
While the existing
DtrBarEntry
class is mutable and can be modified bya plugin that registered it, the
ReadOnlyDtrBarEntry
class is immutable andis intended to be shared with consuming plugins. This ensures that the original
DTR bar entry cannot be modified by any other plugin than the one that
originally registered it.
Service Behavior
When a plugin registered a DTR bar entry, the
EntryAdded
event is invoked andthe
ReadOnlyDtrBarEntry
object will be part of theEntries
list. When aplugin unregisters a DTR bar entry, the
EntryRemoved
event is invoked and theReadOnlyDtrBarEntry
object will no longer be part of theEntries
list.Using these events allows a plugin to only update its own state or UI when it
is necessary, instead of polling the DTR bar entries list for changes on every
frame.
Note
A user can disable specific DTR bar entries in Dalamud's settings. In this case,
the
ReadOnlyDtrBarEntry
object will no longer be part of theEntries
list.The
EntryRemoved
event will be invoked if it was previously part of the list.The
EntryAdded
event will be invoked if it was not previously part of the list.This implicitly forces plugins to behave correctly when it comes to handling
visibility of individual DTR bar entries.
Usage Example
The text was updated successfully, but these errors were encountered: