MrxGuiHudMessage
Module: mrxguihudmessage.lua
Overview
The MrxGuiHudMessage module drives the game’s on-screen messages and fanfares — the full-screen contract/mission/wager payout fanfares, “new contact / new shop item / new landing zone” unlock pop-ups, business-card reveals, big “COMPLETED”/”FAILED” stamps, sliding two-line text fanfares, and the “classy text” effect. It is heavily Scaleform-backed: the big fanfares are MrxGui.FlashWidgets that load .swf/.gfx movies and are driven through ActionScript callbacks (CallActionScriptCallback, SetFlashEventHandler). Simpler messages use native MrxGui.ImageWidget/TextWidgets.
There is one shared “flash” fanfare at a time — _gFanfareFlashWidget is a module global, and CreateFanfare returns false if one is already active.
Inheritance
- Inherits from: none — base/utility module
- Imports (via
import()):MrxGui,MrxGuiBase,MrxGuiManager,MrxHqManager— see MrxGui, MrxGuiBase, MrxGuiManager, MrxHqManager. It also calls the Net, Player, Sys, Sound, Object, and Gui namespaces, plus the internal_GuiInternalandPdasingletons andLTILibName.ChangeShellState.
The earlier draft listed
Imports: MrxGui, MrxUtil.MrxUtilis not imported. The real import list is the four modules above. Corrected.
Instance pattern
Stateless module + module-global singletons + per-widget CustomData. No tInstance/metatable pattern. The active flash fanfare lives in the module global _gFanfareFlashWidget (plus _gFullscreenFadeWidget for the black slow-mo fade); everything else is per-widget CustomData. The _ev* locals (_evSkip, _evLSLeft, _evLSRight, _evSelect) hold live event handles for teardown by _DeleteFanfareEvents.
Module constants & tunables
- Default geometry/timing:
nGlobalWidth = 256,nGlobalHeight = 128,nX = 320,nY = 340,nMagnification = 5(the zoom-in scale factor forShowMessage),nAnimationTimeLength = 0.1,nLifeTime = 3(default on-screen seconds),nFadeTime = 1.nGlobalWidth/Height/nX/nYare overwritten at runtime byHandleInitializationfrom the announcement widget’s authored size/position. - Fanfare Scaleform movies (
.swf/.gfx, chosen bysTypeinCreateFanfare):fanfare_contract,fanfare_mission,fanfare_wager,fanfare_support_unlocked,fanfare_new_contact, andfanfare_new_contact_<faction>_businesscard(faction must be one ofan/ch/oc/gr/pr). The classy-text effect uses thetext_effectmovie. - Event-fanfare lookup tables (keyed by event
sType, used byShowEventFanfare/GetEventFanfareTitle):_tEventTitles: localized title tokens ([Fanfare.Common.NewContact],[Fanfare.Common.NewShopItem],[Fanfare.Common.NewStockpileItem],[Fanfare.Common.NewLandingZone],[Fanfare.Common.HvtCaptured],[Fanfare.Common.HvtKilled],[Fanfare.Common.NewBounties],[Fanfare.Common.NewOutfit],[Fanfare.Common.NewHighScore])._tEventTextures: icon texture per type (unlockables_newcontact,unlockables_newshopitem,unlockables_newstockpileitem,unlockables_landingzone,unlockables_hvtcaptured,unlockables_hvtkilled,unlockables_newbounties,unlockables_newoutfit,unlockables_leaderboardupdated)._tEventSounds:ui_signal_dingfor most,ui_signal_genericforhvtcapture/hvtkill._tEventTextureWidths: per-type pixel widths (398/456/512/512/432/365/428/370/512)._knTextQueueFadeTime = 0.5— cross-fade time between queued event-fanfare text lines.
- Classy-text geometry:
_nClassyTextWidth = 566.6667,_nClassyTextHeight = 33.333336. - Fonts:
Init()loadsfanfare_36; text fanfares use fontfanfare_36, event fanfaresenglish_18.
Functions
CreateFanfare(sType, sFaction)
Creates a new fanfare widget based on the specified type (contract, mission, wager, support, contact, or card) and faction. It initializes the widget with necessary properties and sets up event handlers for input and loading completion.
SetFanfareCompleteCallback(fCallback, tCallbackData)
Sets a callback function that will be called when the fanfare completes. The callback can include additional data passed through tCallbackData.
SupportFanfareAddItem(sTexture, sItemName, sFaction, sContactName, sBlipName)
Adds an item to the support fanfare widget with specified texture and details. This function is used to populate the items in a support-related fanfare.
SupportFanfareCommence()
Starts the support fanfare if it is ready to begin. It checks if the loading is complete before starting the fanfare.
_SupportLoadCompleteCallback(oWidget)
Internal callback function that marks the support widget as loaded and starts the fanfare if it is ready.
_BeginSupportFanfare(oWidget)
Begins playing the support fanfare by setting its visibility and triggering a scroll-out effect after 3 seconds.
_ScrollOutFanfare(oWidget)
Handles the scroll-out effect of the fanfare, calling an action script callback and scheduling the widget’s deletion.
ContactFanfareCommence(sTexture, sContactName, sFaction)
Starts the contact fanfare with specified texture and details. It checks if the loading is complete before starting the fanfare.
_ContactLoadCompleteCallback(oWidget)
Internal callback function that marks the contact widget as loaded and starts the fanfare if it is ready.
_BeginContactFanfare(oWidget)
Begins playing the contact fanfare by setting its visibility and triggering a scroll-out effect after 3 seconds.
CardFanfareSetParameters(sTitle, sName, sJobTitle, sPhone1, sPhone2, sEmail, nDisplayTime)
Sets parameters for the business card fanfare, including title, name, job title, contact information, and display time. It marks the card as ready if all required fields are provided.
CardFanfareCommence()
Starts the business card fanfare if it is ready to begin. It checks if the loading is complete before starting the fanfare and sends network events if applicable.
_CardLoadCompleteCallback(oWidget)
Internal callback function that marks the card widget as loaded and starts the fanfare if it is ready.
_BeginCardFanfare(oWidget)
Begins playing the business card fanfare by setting its visibility, calling an action script callback to start the fanfare, and scheduling cleanup events.
_ContinueCardFanfare(oWidget)
Continues the business card fanfare by calling an action script callback and scheduling the end of the fanfare based on the display time.
_EndCardFanfare(oWidget)
Ends the business card fanfare by calling an action script callback to conclude the fanfare.
_CleanupCardFanfare(oWidget)
Cleans up the business card fanfare by scheduling its deletion after a short delay.
SetFanfareParameters(sProfileName1, sProfileName2, sCancelMsg, bAllowRetry)
Sets parameters for contract or mission fanfares, including profile names, cancel message, and retry option. It ensures that only valid types are set.
AddFanfareLineItem(sDescription, nValue, sType, nPlayer)
Adds a line item to the contract or wager fanfare with specified description, value, type, and player index. It checks for valid input and ensures that the cancel message is not set.
CommenceFanfare(nSlowdownDuration)
Starts the fanfare by locking HQ, sending network events if applicable, setting up time dilation effects, and preparing the fanfare widget for display. It also handles UI state changes like disabling the HUD and PDA.
NetClientCloseFanfare()
Closes the fanfare on the client side by stopping sound callbacks, closing the fanfare, and ending it.
_SlowdownUpdate(oWidget, nDeltaTime)
Handles the time dilation effect during the fanfare, updating the time scale and fade widget’s alpha value accordingly. It triggers the beginning of the fanfare when the time scale reaches zero.
_LoadCompleteCallback(oWidget)
Internal callback function that marks the main widget as loaded and starts the fanfare if it is ready.
_BeginFanfareFlash(oWidget)
This function initializes the fanfare flash sequence for a given widget. It checks if the loading is complete and proceeds to close any pause screens, set invincibility for the local player, initialize the fanfare, create a timer event for an initial delay, and get control focus.
_InitializeFanfareFlash(oWidget)
This function initializes the fanfare flash by setting up various properties of the widget. It changes the shell state, sets visibility and pauses the widget, calls action script callbacks to initialize the fanfare with player data, and sets up event handlers for closing, retrying, and continuing the fanfare.
_ContinueFanfare(oWidget)
This function handles the continuation of the fanfare by calling an action script callback to make the fanfare buttons appear.
_InitialDelay(oWidget)
This function makes the widget visible and plays it after a short delay.
_SkipFanfare(oWidget)
This function sets up event listeners for skipping the fanfare based on player input. It creates events for button presses that trigger the _EndFanfare function.
_RetryEvents(oWidget)
This function sets up persistent event listeners for retrying the fanfare using left stick inputs and selection buttons. It sends flash inputs to handle these actions.
OnPlayerJoined()
This function handles the event when a player joins the game. If there is an active fanfare flash widget, it sends a specific input to the widget.
_DeleteFanfareEvents()
This function deletes various persistent events related to the fanfare flash sequence.
_EndFanfare(oWidget, sEnd)
This function ends the fanfare flash by handling cleanup tasks such as deleting events, releasing control focus, and calling callbacks. It also unlocks all HQs if necessary.
_DeleteFanfareWidget(oWidget)
This function deletes the fanfare widget, removes it from the GUI, and calls any callback functions associated with it. It also handles restoring certain game states like PDA suppression and scope enabling.
_HandleFanfareInput(oWidget, tEvent)
This function handles input events for the fanfare flash by calling a custom handler defined in the widget’s custom data.
ShowTextFanfare(uPlayerGuid, sLine1, sLine2, nEnterTime, nDisplayTime, nFadeTime, fCallback, tCallbackData)
This function creates and displays a text-based fanfare with two lines of text. It sets up animations for entering, displaying, and fading out the text, and calls a callback function when the fanfare is done.
_TextFanfareDone(oTextFanfare, fCallback, tCallbackData)
This function handles the completion of a text fanfare by calling the provided callback function and cleaning up the widget.
_TextDelay(oWidget, oTextFanfare, nDelayTime, nFadeTime)
This function sets up a delay before fading out the text in a text fanfare.
_TextFadeout(oWidget, oTextFanfare, nFadeTime)
This function handles the fade-out animation of the text in a text fanfare.
_TextDelete(oWidget, oTextFanfare)
This function removes and deletes the animated widget from the text fanfare.
ShowEventFanfare(sType, vText, fCallback, tCallbackData)
- Description: Displays an event fanfare message on the HUD.
- Parameters:
sType: Type of the event (used to determine the icon texture).vText: The text to display, can be a string or a table of strings for sequential display.fCallback: A callback function to execute after the fanfare completes.tCallbackData: Data to pass to the callback function.
_EventFanfareFinishAppear(oFanfare)
- Description: Handles the appearance animation completion of an event fanfare.
- Parameters:
oFanfare: The fanfare widget instance.
_EventFanfareProcessTextQueue(oInfo)
- Description: Processes the text queue for sequential display in the event fanfare.
- Parameters:
oInfo: The text widget instance.
_EventFanfareContinueTextFade(oInfo)
- Description: Continues the fade animation for the next text in the queue.
- Parameters:
oInfo: The text widget instance.
_EventFanfareFinishDisplay(oFanfare)
- Description: Handles the display animation completion of an event fanfare.
- Parameters:
oFanfare: The fanfare widget instance.
_EventFanfareComplete(oFanfare)
- Description: Completes the event fanfare by removing the widget and executing the callback.
- Parameters:
oFanfare: The fanfare widget instance.
GetEventFanfareTitle(sType)
- Description: Retrieves the title for a given event type.
- Parameters:
sType: Type of the event.
HandleInitialization(oWidget, tUnused)
- Description: Handles initialization of a widget by setting its translucency and scheduling removal.
- Parameters:
oWidget: The widget instance.tUnused: Unused parameter (likely for future expansion).
ShowCompletedMessage(uPlayerGuid, fZoomCompleteCallback, fFadeCompleteCallback)
- Description: Displays a completed message on the HUD.
- Parameters:
uPlayerGuid: GUID of the player to show the message to.fZoomCompleteCallback: Callback function for when the zoom animation completes.fFadeCompleteCallback: Callback function for when the fade animation completes.
ShowFailedMessage(uPlayerGuid, fZoomCompleteCallback, fFadeCompleteCallback)
- Description: Displays a failed message on the HUD.
- Parameters:
uPlayerGuid: GUID of the player to show the message to.fZoomCompleteCallback: Callback function for when the zoom animation completes.fFadeCompleteCallback: Callback function for when the fade animation completes.
ShowMessage(uPlayerGuid, sTextureName, fZoomCompleteCallback, fFadeCompleteCallback, nXLocation, nYLocation, sHorizontalAnchor, sVerticalAnchor, nMessageWidth, nMessageHeight, nMessageDisplayTime, vSoundEffect)
- Description: Displays a message on the HUD with specified parameters.
- Parameters:
uPlayerGuid: GUID of the player to show the message to.sTextureName: Name of the texture for the message.fZoomCompleteCallback: Callback function for when the zoom animation completes.fFadeCompleteCallback: Callback function for when the fade animation completes.nXLocation,nYLocation: Coordinates for the message location.sHorizontalAnchor,sVerticalAnchor: Anchor points for the message.nMessageWidth,nMessageHeight: Dimensions of the message.nMessageDisplayTime: Duration to display the message.vSoundEffect: Sound effect(s) to play with the message.
AnimationFinishCallback(oWidget)
- Description: Handles the completion of an animation for a widget.
- Parameters:
oWidget: The widget instance.
HandleUpdateEvent(oWidget, nTimeSinceLastUpdate)
- Description: Updates the display time remaining for a widget and handles removal if necessary.
- Parameters:
oWidget: The widget instance.nTimeSinceLastUpdate: Time since the last update event.
RemovalCallback(oWidget)
- Description: Handles the removal of a widget after its fade animation completes.
- Parameters:
oWidget: The widget instance.
Init()
- Description: Initializes the module by loading necessary fonts.
HandleClassyTextInit(oWidget)
- Description: Initializes a widget for displaying classy text.
- Parameters:
oWidget: The widget instance.
DisplayClassyText(oWidget, sText, nX, nY, nDuration, nScale, sHorizAnchor, sVertAnchor, sJustification, bExpand)
- Description: Displays classy text on the HUD with specified parameters.
- Parameters:
oWidget: The widget instance.sText: The text to display.nX,nY: Coordinates for the text location.nDuration: Duration to display the text.nScale: Scale of the text.sHorizAnchor,sVertAnchor: Anchor points for the text.sJustification: Justification of the text.bExpand: Whether to expand the text.
- Not previously documented: clamps
nX/nWidth/nY/nHeightto stay on-screen using a tinyClamp(n, nMin, nMax)helper defined inside this function’s own body (withoutlocal, so — like a couple of other modules on this wiki — it’s technically a global, just one only ever called from here).
_ClassyTextLoadCompleteCallback(oText, sText, nDuration, sJustification, bExpand)
- Description: Handles the completion of loading a classy text widget.
- Parameters:
oText: The text widget instance.sText: The text to display.nDuration: Duration to display the text.sJustification: Justification of the text.bExpand: Whether to expand the text.
_HandleClassyTextEnd(oText)
- Description: Handles the end of a classy text widget by scheduling its deletion.
- Parameters:
oText: The text widget instance.
_DeleteClassyText(oText)
- Description: Deletes a classy text widget from the HUD.
- Parameters:
oText: The text widget instance.
Events
The earlier draft listed
Event.ObjectHibernation,Event.PlayerInput, andEvent.PlayerJoined— none of these appear in the source. Removed. (OnPlayerJoined()here is an engine lifecycle callback, not anEvent.PlayerJoinedsubscription.)
The real engine-event usage in this file (see Event):
Event.Create(Event.TimerRelative, {nSeconds[, bRealtime]}, fCallback, tData)— the workhorse for all scheduled steps: fanfare scroll-out (3s), card fanfare stages, widget deletion delays, the announcement auto-remove (0.5s inHandleInitialization), and the text-fanfare done timer. Fire-and-forget one-shots.Event.Create(Event.Button, {uPlayer, sButton, "press", true}, fCallback, tData)andEvent.CreatePersistent(Event.Button, ...)— bound in_SkipFanfare(skip oncancel/selection) and_RetryEvents(left-sticklsleft/lsrightandselection/cancelmapped to_GuiInternal.SendFlashInput). Button choice depends onSys.IsConfirmOnCircle().Event.Delete(handle)—_DeleteFanfareEventstears down the stored_ev*handles.- Widget event handlers (not engine events):
SetEventHandler("GuiUpdate", _SlowdownUpdate)drives the slow-mo dilation;SetEventHandler("GuiUpdate", HandleUpdateEvent)counts down a message’s on-screen time. - Flash/ActionScript handlers (Scaleform, not engine events):
SetFlashEventHandler("closeFanfare"/"Retry"/"FanfareCountUpComplete"/"FanfareOff"/"close", ...)andSetEventHandler("ControllerInput", _HandleFanfareInput).
Notes for modders
- Fanfare build sequence (contract/mission/wager):
CreateFanfare(sType, sFaction)→SetFanfareParameters(...)and repeatedAddFanfareLineItem(...)→ optionalSetFanfareCompleteCallback(...)→CommenceFanfare(nSlowdownDuration).CommenceFanfarelocks all HQ (MrxHqManager.LockAllHq), starts a time-dilation slow-mo (via_SlowdownUpdate), hides the HUD, suppresses the PDA, and disables sniper scope;_EndFanfarereverses all of that andMrxHqManager.UnlockAllHq()s. If you spawn a fanfare, make sure it can reach_EndFanfareor the HUD/PDA/HQ stay locked. - Support / contact / card fanfares each have a
*Commenceentry point that only actually plays once the SWF’sbLoadingCompletefires (the*LoadCompleteCallbackre-checksbReadyToStart). So callingSupportFanfareCommence/ContactFanfareCommence/CardFanfareCommencebefore the movie finishes loading is safe — it defers. - Multiplayer: many entry points call
Net.SendEvent_*whenNet.IsServer()(Net.SendEvent_Fanfare,Net.SendEvent_CardFanfare,Net.SendEvent_TextFanfare,Net.SendEvent_ShowMessage,Net.SendEvent_CloseFanfare) to mirror the fanfare to clients. See Net. ShowMessagetunables: it zooms an image in fromnMagnification(×5) scale to normal overnAnimationTimeLength, holds fornMessageDisplayTime(defaultnLifeTime= 3s; pass a negative time to hold indefinitely), then fades overnFadeTime.ShowCompletedMessage/ShowFailedMessageare thin wrappers using texturesglobal_gui_completed/global_gui_failed.vSoundEffectmay be a single cue string or a table of them.ShowEventFanfare(sType, vText, ...):sTypemust be a key of_tEventTexturesor it silently returns.vTextcan be a string or a table of strings shown sequentially (each heldmax(1.5, 4/count)s, cross-faded by_knTextQueueFadeTime).- Business-card faction codes: only
an,ch,oc,gr,prare valid (case-insensitive) — any other faction makesCreateFanfare("card", ...)returnfalse.
Real bug in
ShowMessage(server→client path): theNet.SendEvent_ShowMessage(...)call passesnGlobalTimefor height andnMessageDisplayTime or nLifeTimepositionally in a way that references the undefined globalnGlobalTime(there is no such variable — the module definesnGlobalHeight/nLifeTime). On a dedicated-server non-local target this passesnilfor the height argument. Local display (the common path) is unaffected. Also note_DeleteFanfareWidgetsetsbSupressedPda(typo) instead of clearingbSuppressedPda.
- Decompiler artifacts:
DisplayClassyTextdefines itsClamp(n, nMin, nMax)helper inside its own body withoutlocal, so it leaks as a global — harmless, only called from here. Several*LoadCompleteCallbacks share the same defer-until-loaded shape.