-
Notifications
You must be signed in to change notification settings - Fork 0
Messaging
Messaging.lua: Chatlogs, dialogs and center-screen announcements.
Calling ZO_Dialogs_ShowDialog synchronously from inside another dialog's own button callback races that dialog's still-in-flight cleanup and crashes with "attempt to index a nil value" in ZO_Dialog.lua.
How it works: registers ESO_Dialogs[dialogId] on first use (if not already registered), then shows it via zo_callLater (default 50ms delay) instead of synchronously. Picks the gamepad or keyboard dialog variant automatically based on IsConsoleUI()/IsInGamepadPreferredMode().
LibAPH.ShowDialogChained("MY_CONFIRM_DIALOG", "Are you sure?", "This can't be undone.", {
{ text = SI_DIALOG_CONFIRM, callback = function() DoTheThing() end },
{ text = SI_DIALOG_CANCEL },
})buttons is a standard ESO_Dialogs buttons list. Call this from inside a previous dialog's own button callback whenever you're chaining one dialog into another.
One center-screen banner carrying a title and a body together.
LibAPH.SafeCSA(MyAddon.settings.is_csa_enabled, "Cleanup complete", "Freed 12.4 MB", 4000)
-- or title-only:
LibAPH.SafeCSA(MyAddon.settings.is_csa_enabled, "Cleanup complete", nil, 4000)No-ops if enabled is false or nil, or CENTER_SCREEN_ANNOUNCE doesn't exist. enabled is a parameter not a settings table.
How it works: returns a logger object with one method, :Print(message, colorOverride). On console, prints via d(...). Everywhere else, prints via CHAT_SYSTEM:AddMessage(...), same tagged text either way.
MyAddon.chat = LibAPH.CreateChatLogger("MA", "00FFFF")
MyAddon.chat:Print("Cleanup finished")
MyAddon.chat:Print("Something needs attention", "FF0000") -- one-off color override, doesn't need a second loggercolorOverride on :Print is for the rare single message that needs a different color than the logger's own default, without creating a whole separate logger instance just for that one case.
Not a fit for every message shape: a logger's :Print() always prepends its own tag. A multi-line listing that intentionally mixes tagged and untagged lines (a "-- Section --" header with no bracket tag, a blank-padded continuation line for wrapped text) needs the same console/PC split done by hand instead, via SendRawChatLine.
The CreateChatLogger calls internally: prints via d(...) on console and CHAT_SYSTEM:AddMessage(...) everywhere else, same text either way, untagged. Use it directly for a multi-line listing that intentionally mixes tagged and untagged lines, since :Print() always prepends its own tag.
LibAPH.SendRawChatLine("-- Commands --")
LibAPH.SendRawChatLine("/mycommand: does the thing")