Converting a COC to an MFD

From SIMboxWiki
Revision as of 21:39, 7 March 2013 by Seanjarvis (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This tutorial will show you how to convert a normal COC to a Multi-Function Display (MFD) COC.

  • In the wizard, add an attribute change callback for ATT_CURRENT_DISPLAYED_SYSTEM. Since this attribute is owned by the base content LOC GeneralAvionics, your base object must have this LOC.
  • In RegisterToAttributeChanges(), replace ATT2_STRING_ALL_KEYS_LISTENER with _sParentGaugeNameW. Now the component is only registered to the 2-parameter attribute ATT_CURRENT_DISPLAYED_SYSTEM for its parent gauge.
  • In the start() function, replace the line of code between the //DLC_ATTRIBUTECHANGE_CALLS tags with the line below:
CBFuncAttChangeCurrentDisplayedSystem(GET_ENTITY_ATT_INDEX(_pOwnerEntity, _T("ATT_CURRENT_DISPLAYED_SYSTEM")), _sParentGaugeNameW);
  • In the callback function for ATT_CURRENT_DISPLAYED_SYSTEM, add code to unregister mouse regions and hide the page if the current displayed system isn't the name of this MFD page. Follow the example below.
if (AttCurrentDisplayedSystem != _T("NAME"))
  • Use the wizard to add an input event called INPUT_CHANGE_TO_NAME. In the registerToInputDevices() function, edit the code so that the input event has the parent gauge name appended to it. Follow the example below.
wstring inputStr = wstring(L"INPUT_CHANGE_TO_NAME") + _sParentGaugeNameW;
REGISTER_INPUT_EVENT_MULTIPLE(_pOwnerEntity, this, &LOC_Class::CBFuncInputEventChangeToName, LOC_Class, inputStr.c_str(), _T("Change to NAME MFD page."));

  • In the CBFuncInputEventChangeToName(…) function, add the following code:
  • In start(), comment out showDlc() and registerAllMouseRegionsEvents().
  • Build and analyze your component. The component will now display only if ATT_CURRENT_DISPLAYED_SYSTEM is equal to NAME.