void CEditorGame::InitActionMapsEnums(IGameToEditorInterface* pGTE) { IActionMapManager* pAM = m_pGame->GetIGameFramework()->GetIActionMapManager(); IActionMapIteratorPtr iter = pAM->CreateActionMapIterator(); const int numActionMaps = pAM->GetActionMapsCount(); if(numActionMaps == 0) return; const char** nameValueStrings = new const char*[numActionMaps]; int curEntryIndex = 0; while (IActionMap* pMap = iter->Next()) { assert(curEntryIndex < numActionMaps); PREFAST_ASSUME(curEntryIndex < numActionMaps); nameValueStrings[curEntryIndex++] = pMap->GetName(); if (curEntryIndex > numActionMaps) { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "[InitActionMapsEnums] Wrong number of Action Maps."); break; } } pGTE->SetUIEnums("action_maps", nameValueStrings, numActionMaps); delete[] nameValueStrings; }
const char* CMPTutorial::GetKeyName(const char* action) { IActionMapManager* pAM = gEnv->pGame->GetIGameFramework()->GetIActionMapManager(); IActionMapIteratorPtr iter = pAM->CreateActionMapIterator(); while (IActionMap* pMap = iter->Next()) { const char* actionMapName = pMap->GetName(); IActionMapBindInfoIteratorPtr pIter = pMap->CreateBindInfoIterator(); while (const SActionMapBindInfo* pInfo = pIter->Next()) { if(!strcmp(pInfo->action, action)) return pInfo->keys[0]; } } return ""; }