dao::messages
The engine’s messages: watch, intercept or send them.
Declared in dao/Messages.h.
Classes
| Class | |
|---|---|
| AcceptChantersQuestMessage | Accepts an entry of the Chanter’s board, as its Accept button does (“Journal.AcceptChantersQuest”). |
| AcquireAllItemsMessage | Takes everything in a container into the creature’s pack, as the loot panel’s Take All does. |
| AcquireItemMessage | Takes an item into a creature’s pack (“GUI.SelectedChar.AcquireItem”) or a container (“Container.AcquireItem”). |
| ActivateAnalogTargetModeMessage | Selects a target as the target-cycle keys do, for a gamepad’s radial targeting. |
| ActivateLinearTargetModeMessage | Selects a target as the target-cycle keys do, for a gamepad’s linear targeting. |
| ApplyPartyPickerChangesMessage | Raises the follower events for the members whose state the party picker changed. |
| AttachRuneToItemMessage | Puts a rune in an empty rune slot of an item. Sent to the item. |
| BuyItemMessage | Buys an item from the store that is open (“Store.BuyItem”). |
| CameraZoomInMessage | Zooms the explore camera in a step. |
| CameraZoomOutMessage | Zooms the explore camera out a step. |
| CancelAbilityTargetingMessage | Leaves targeting mode with the ability unused. Escape or the right button sends it there. |
| CenterOnMainPartyMemberMessage | Snaps the camera to the creature it follows. |
| CenterOnObjectMessage | Asks explore or combat mode to centre the camera on a party member. |
| CharGenAssignAbilityMessage | Picks an ability, or unpicks one, on the level-up or character creation screen. |
| CharGenSelectSpecializationMessage | Chooses a specialization on the character creation screen. Nothing in the game sends it. |
| ClearNewlyAcquiredFlagMessage | Clears an item’s New mark, as pointing at it in the inventory does. |
| ClearPartyPickerMessage | Takes every member but the hero out of the party being picked: the picker’s Remove All. |
| CloseStoreMessage | Settles the store as its screen closes. |
| ContainerChangedMessage | The inventory’s notice that the container’s items changed. |
| CountIngredientsMessage | Counts again the crafting screen’s ingredients the party has. |
| CraftItemMessage | Makes a recipe on the crafting screen, as its Create button does (“GUICrafting.CraftItem”). |
| DetachRuneFromItemMessage | Takes the rune out of a rune slot of an item into the party’s inventory. Sent to the item. |
| DialogBoxClosedMessage | Sent by the popup layer’s movie to the GUI system once a message box has closed (see Popup in dao/Gui.h). |
| DirtyPresetMessage | Marks the follower’s tactics changed from their preset. |
| DropItemMessage | Destroys an item’s whole stack, as the inventory’s Destroy does (“GUI.SelectedChar.DropItem”). |
| EquipItemMessage | Equips an item on a creature, in a slot, as the inventory’s paperdoll and radial menu do (“GUI.SelectedChar.EquipItem”). |
| EquipmentChangedMessage | The paperdoll’s notice that the character’s equipment changed. |
| ExitPartyPickerMessage | Leaves the party picker as it is. The picker’s Accept leaves through it. |
| FindAbilityChainsMessage | Rebuilds a creature’s chains of abilities of one type, as the ability screens show them. |
| ForceInventoryRefreshMessage | Has the inventory rebuild its lists. |
| GiftItemMessage | Gives an item to a follower: raises EVENT_TYPE_GIFT_ITEM on the follower for the scripts. |
| GoToCodexMessage | Opens the journal at a codex entry, as its alert does when clicked (“GUI.GoToCodex”). |
| GoToGuiWithFollowerMessage | Opens a full-screen screen showing a follower, as an alert’s click does. |
| GoToItemMessage | Opens the inventory, as a new item’s notice does when clicked. The item is not read. |
| GoToJournalPRCTabMessage | Opens the journal at its downloadable content’s tab (“GUI.GoToJournalPRCTab”). |
| GoToQuestMessage | Opens the journal at a quest, as a quest’s alert does when clicked (“GUI.GoToQuest”). |
| GUIDialogResultMessage | A dialog box’s answer, sent from the popup to the application: the code of the button pressed. |
| GUIPRCDialogResultMessage | A downloadable content offer’s prompt answered. |
| HideAbilityHeaderMessage | Collapses an ability header in a creature’s ability lists: adds it to the minimized ones. |
| HideAlertMessage | Dismisses the first alert of a type, as the alert area does when one fades or is clicked. |
| HideContainerGUIMessage | Closes the loot panel and the inventory with it. |
| HideCraftingGUIMessage | Closes the full-screen screen that is open, the crafting screen’s way out. |
| HideInventoryGUIMessage | Closes the inventory. |
| HideJournalGUIMessage | Closes the journal’s screen. |
| HideUberAlertMessage | Dismisses the first of the large alerts. Sent to the party (“Party.HideUberAlert”). |
| InventoryClosedMessage | A container’s loot panel closed. Sent to the container. |
| LoadGameMessage | Asks the save proxy to load a save (dao/Saves.h). |
| LoadPresetMessage | Loads a preset of tactics, or a custom slot, into the follower’s rows, or turns them off. |
| Message | The base of every engine message (the engine’s Messages::Message). |
| MoveCharacterToLocationMessage | The player’s click to move the selected creature, sent as the right mouse button comes up. |
| OpenStoreMessage | Opens the store’s screen. Sent to the store, as the script command OpenStore does. |
| PartyBackpackChangedMessage | The inventory’s and the store’s notice that the party’s pack changed. |
| PartyPlotItemsChangedMessage | The inventory’s notice that the party’s plot items changed. |
| PauseMessage | Pauses the game. |
| PerformAbilityMessage | The player’s order for a creature to use an ability, from the quickbar or a radial menu. |
| PerformAbilityOnPlayerMessage | Uses the ability waiting for a target on the object given. Nothing in the game sends it. |
| PerformAbilityOnSelectedTargetMessage | Uses the ability waiting for a target on the selected target, the one the target-cycle keys choose. |
| PerformAbilityOnTargetUnderCursorMessage | Uses the ability waiting for a target, after PerformAbilityMessage asked for one, on the object under the cursor, or the ground there. |
| PerformPrimaryActionOnTargetUnderCursorMessage | The player’s primary click on what is under the cursor: attack, talk, open or pick up. |
| PreMoveCharacterToLocationMessage | Sent as the right mouse button goes down, before a move. |
| RefreshHeroesMessage | Tells the save proxy to rebuild its list of characters from their save folders (dao/Saves.h). |
| RefreshTacticsDataMessage | Refreshes the items the follower’s Use Item rows name. |
| SaveGameMessage | Asks the save proxy, the engine object that runs saving and loading, to save the game (dao/Saves.h). |
| SavePresetMessage | Saves the follower’s rows into one of the custom slots. |
| ScriptDialogResultMessage | A popup’s button pressed, as the popup layer sends it for a popup a script showed. |
| SelectCharacterMessage | Selects one creature alone, as if the player picked it. |
| SelectedGUICharacterChangedMessage | The inventory’s notice that it shows another character. |
| SelectHeroMessage | Tells the save proxy to choose a character by its position in its list (dao/Saves.h). |
| SelectPartyMemberIndexMessage | Selects the party member at a place in the party bar, as F1 to F4 do, or adds it to the selection, as Shift with them does. |
| SelectPartyMemberUnderCursorMessage | Selects the party member under the cursor, as a left click does, or adds it, as Shift-click does. |
| SelectResponseMessage | Picks a reply in a conversation, as clicking it or pressing its number key does. |
| SellItemMessage | Sells an item to the store that is open (“Store.SellItem”). |
| SetBackpackSortMessage | Sorts the party’s pack in the inventory and the store. |
| SetBehaviourMessage | Sets the follower’s behaviour, as the tactics screen’s behaviour picker does. |
| SetGameModeMessage | Switches the game’s mode (dao/GameModes.h). The game mode controller handles it. |
| SetItemListFilterMessage | Filters the inventory’s or the store’s list of items. |
| SetQuickslotMessage | Puts an ability or an item in a slot of a creature’s quickbar, or clears the slot. |
| SetSaveLoadModeMessage | Tells the save proxy which mode the save screens are in (dao/Saves.h). |
| ShowAbilityHeaderMessage | Expands an ability header in a creature’s ability lists: takes it out of the minimized ones. |
| ShowContainerGUIMessage | Shows a container’s loot beside the inventory, as the script command OpenInventory does. |
| ShowCraftingGUIMessage | Opens the crafting screen for a crafting skill, as the script command ShowCraftingGUI does. |
| ShowDialogBoxMessage | Shows the message box the popup layer’s data says (“GUI.ShowDialogBox”). |
| ShowInventoryGUIMessage | Shows the inventory, with a container beside it if asked. Sent to the GUI system. |
| ShowItemExamineMessage | Shows the examine screen for an item, as Inspect does (“GUIItemExamine.ShowItemExamine”). |
| ShowItemSplitDialogMessage | Shows the dialog that splits a stack of items (“GUI.ShowItemSplitDialog”). |
| ShowJournalGUIMessage | Shows the journal’s screen. |
| ShowPartyPickerMessage | Opens the party picker, as its button on the navigation bar does. |
| SkipCutsceneMessage | The skip key in a cutscene. The cutscene mode handles it (dao/Dialogue.h). |
| SkipDialogMessage | The skip key in a conversation. The dialogue mode handles it (dao/Dialogue.h). |
| SkipMovieMessage | The skip key while a pre-rendered movie plays. |
| StartDraggingMessage | Starts dragging an icon from a place on the stage (“GUI.StartDragging”). |
| StopDraggingMessage | Ends dragging an icon (“GUI.StopDragging”). |
| StoreChangedMessage | The store screen’s notice that the store’s items changed. |
| SubmitPartyChangesMessage | Takes the party picked and leaves the picker: its Accept. |
| TakeScreenshotMessage | Takes a screenshot, including the interface, as the screenshot key does. |
| ToggleFullPartySelectMessage | Selects every controllable living party member, or the controlled one alone if all are. |
| ToggleHoldPartyMessage | Turns the party’s Hold Position on or off, as the H key does. |
| ToggleRunWalkMessage | Switches the party between running and walking, as numpad / does. |
| UnequipItemMessage | Takes an item off a creature into the pack (“GUI.SelectedChar.UnequipItem”). |
| UnpauseMessage | Unpauses the game. |
| UnselectPartyMemberMessage | Takes a member out of the party being picked in the party picker, as a click on its portrait does. |
| UserTogglePauseMessage | The pause key: the game mode controller pauses or unpauses the game. |
| ValidateActionMessage | Changes a tactics row’s command if its condition does not allow it. |
Type aliases
MessageInterceptor
using MessageInterceptor = std::function<bool(void *receiver, const Message &message)>
A function that can take a message before the receiver’s handler runs.
Return true to take it: no handler then runs, and the sender is told the message was handled.
MessageObserver
using MessageObserver = std::function<void(void *receiver, const Message &message)>
A function called with each message the engine delivers, and its receiver, just before the receiver’s handler runs.
TypedHandlerFn
using TypedHandlerFn = bool(__fastcall *)(void *owner, int edx, const M *message)
The function type of a handler for messages of class M, in the form dao::Detour takes: the handler’s owner, an unused edx, and the message.
A handler returns true if it handled the message.
Functions
As()
const M * As(const Message *message)
Returns the message as class M if it is one, checked by comparing its vtable with M’s.
Returns the message as M, or null if it is null or of another class
InterceptMessage()
void InterceptMessage(AddressId vftable, MessageInterceptor interceptor)
Lets an interceptor take messages of one class before their handler runs.
The interceptor sees a message at the first receiver with a handler for it, so taking it there keeps it from every later handler too. Once one interceptor takes a message, later interceptors are not asked, but observers still see it. Use this overload for a message class with no struct here.
| Parameter | |
|---|---|
vftable |
the vftable ID of the message class |
InterceptMessage()
void InterceptMessage(std::function<bool(void *receiver, const M &message)> interceptor)
Lets an interceptor take messages of class M before their handler runs.
This is the typed form of InterceptMessage, with the same rules.
dao::messages::InterceptMessage<dao::messages::PerformAbilityMessage>(
[](void *, const dao::messages::PerformAbilityMessage &m) { return !MyTurn(m.caster); });
Make()
M Make()
Creates a message of class M, ready to send, with its vtable set and its fields zeroed.
The message classes here hold only plain fields, so nothing needs to be freed afterwards.
OnAnyMessage()
void OnAnyMessage(MessageObserver observer)
Calls an observer for every message the engine delivers.
The engine often offers a message to several receivers, or passes it from one handler to another. The observer sees it only once, at the first receiver that has a handler for it, and never sees a message that no receiver handles. Every message passes through here, including mouse moves, so keep the observer fast. Observers run on the game thread.
OnMessage()
void OnMessage(AddressId vftable, MessageObserver observer)
Calls an observer for every message of one class, like OnAnyMessage.
Use this overload for a message class with no struct here.
| Parameter | |
|---|---|
vftable |
the vftable ID of the message class; dev/messages.csv lists them, and dao::TypeName gives a message’s class name |
OnMessage()
void OnMessage(std::function<void(void *receiver, const M &message)> observer)
Calls an observer for every message of class M, like OnAnyMessage.
dao::messages::OnMessage<dao::messages::SetGameModeMessage>(
[](void *, const dao::messages::SetGameModeMessage &m) { spdlog::info("mode {}", m.mode); });
Send()
bool Send(CGameObject *object, const Message &message)
Sends a message to a game object: a creature, a placeable or an item, whose handlers take the messages the movies send them (“GUI.SelectedChar.EquipItem”, “Container.AcquireItem”).
| Parameter | |
|---|---|
object |
the object; null sends nothing and answers false |
Returns as the other Send
Send()
bool Send(void *receiver, const Message &message)
Sends a message to an object, the same way the engine sends its own.
The receiver’s handler for the message’s class runs immediately, on the calling thread.
auto *modes = dao::CClientExoApp::Get()->GameModes();
auto message = dao::messages::Make<dao::messages::CenterOnObjectMessage>();
message.object = creature;
const bool handled = dao::messages::Send(modes->CurrentModeObject(), message);
Call it on the game thread, for example from a frame callback or a command intercept. That is where the engine’s own handlers run.
| Parameter | |
|---|---|
receiver |
the object that handles the message, such as a game mode or the game mode controller |
message |
the message; the caller keeps ownership of it |
Returns true if the receiver handled it; false if it has no handler for this message or is not accepting messages
SendBinding()
bool SendBinding(std::wstring_view text)
Builds a message from a key binding’s text and sends it to the game mode controller, as pressing the key does.
The controller passes it to the interface first and then to the current mode.
dao::messages::SendBinding(L"SaveGameMessage -1 2"); // what the quicksave key sends
A key only produces its message in the modes its binding is registered for, but SendBinding sends it in any mode. A mode with no handler for it ignores it. Call it on the game thread, like Send.
| Parameter | |
|---|---|
text |
the message’s class name and fields as KeyBindings.ini writes them, for example “UserTogglePauseMessage” or “SelectPartyMemberIndexMessage 0 1” |
Returns true if the message was sent, whether or not anything handled it; false, with nothing sent, if the key bindings do not know the message or the game modes do not exist yet
SendText()
bool SendText(std::wstring_view text)
Builds a message from a line of text and sends it to the receiver the text names, the same way a button in one of the game’s movies sends its callback.
dao::messages::SendText(L"CClientExoApp.GUIDialogResult 1 0");
The engine parses the fields itself, so you can send any message it can build from text, even one with no struct here. Call it on the game thread, like Send.
| Parameter | |
|---|---|
text |
“Receiver.Message fields”: the receiver’s name in the data tree (dao/Data.h), such as CClientExoApp or GUIPopupLayer, then the message’s class name without “Message”, then its fields in order, separated by spaces |
Returns true if the message was sent, whether or not the receiver handled it; false, with nothing sent, if the engine does not know the receiver or the message