void CreateGameForm::OnControlNotify(word idc, int nNotify) { if (idc == kidcCategories) { RadioButtonBarControl *prbbc = (RadioButtonBarControl *)GetControlPtr(kidcCategories); int iButtonSelected = prbbc->GetSelectionIndex(); if (iButtonSelected < 0) { iButtonSelected = 0; } MissionType mtNew = MissionTypeFromIndex(iButtonSelected); if (mtNew == m_mt) { return; } SwitchToMissionType(mtNew); // If in Add-On category, and there is nothing there, show this // label, otherwise hide it bool fShowLabel = false; ListControl *plstc = m_aplstc[IndexFromMissionType(kmtMultiplayerAddOn)]; if (m_mt == kmtMultiplayerAddOn) { if (plstc->GetCount() == 0) { fShowLabel = true; } } LabelControl *plbl = (LabelControl *)GetControlPtr(kidcAddOnMessage); if (fShowLabel) { plbl->Show(true); if (m_mt == kmtMultiplayerAddOn) { plstc->Show(false); } } else { plbl->Show(false); if (m_mt == kmtMultiplayerAddOn) { plstc->Show(true); } } } if (idc == kidcChallengeList || idc == kidcAddOnList) { UpdateLabels(); } // Handle button hiding bool fShow = true; ListControl *plstc = m_aplstc[IndexFromMissionType(m_mt)]; if (plstc->GetSelectedItemIndex() == -1) { fShow = false; } GetControlPtr(kidcOk)->Show(fShow); }
void LoadGameForm::SelectLast(bool fLast) { ListControl *plstc = (ListControl *)GetControlPtr(kidcGameList); int nGameSelect; if (fLast) { nGameSelect = m_nGameLast; if (nGameSelect == -1) nGameSelect = 0; } else { nGameSelect = m_nGameLast + 1; if (nGameSelect == plstc->GetCount()) nGameSelect = 0; } plstc->Select(nGameSelect); }
MissionType CreateGameForm::InitLists(int iMissionSelect) { // Fill in the lists, and along the way keep track of useful selection // indexes. int ailiFirstIncomplete[kmtUnknown + 1]; memset(ailiFirstIncomplete, 0xff, sizeof(ailiFirstIncomplete)); int iliSelectSpecial = -1; MissionType mtSelectSpecial = kmtUnknown; int cMissions = m_pml->GetCount(); for (int i = 0; i < cMissions; i++) { MissionDescription md; if (!m_pml->GetMissionDescription(i, &md)) { continue; } if (md.mt != kmtMultiplayerChallenge && md.mt != kmtMultiplayerAddOn) { continue; } // Add the item. const char *pszT; if (md.cPlayersMin == md.cPlayersMax) { pszT = base::Format::ToString("%s (%d players)", md.szLvlTitle, md.cPlayersMin); } else { pszT = base::Format::ToString("%s (%d-%d players)", md.szLvlTitle, md.cPlayersMin, md.cPlayersMax); } ListControl *plstc = m_aplstc[IndexFromMissionType(md.mt)]; plstc->Add(pszT, (void *)i); // Track the first incomplete, for later selection if (ailiFirstIncomplete[md.mt] == -1) { MissionIdentifier miid; m_pml->GetMissionIdentifier(i, &miid); if (!gpcptm->IsComplete(&miid)) { ailiFirstIncomplete[md.mt] = plstc->GetCount() - 1; } } // This is passed in when the form needs to select a certain // mission when it first shows. if (i == iMissionSelect) { iliSelectSpecial = plstc->GetCount() - 1; mtSelectSpecial = md.mt; } } // The initially selected missions are the first incomplete missions // for each mission type. MissionType mtSelect = kmtMultiplayerChallenge; for (int i = 0; i < ARRAYSIZE(m_aplstc); i++) { ListControl *plstc = m_aplstc[i]; // Is this the list that is awarded the special selection? if (i == IndexFromMissionType(mtSelectSpecial)) { plstc->Select(iliSelectSpecial, true, true); mtSelect = mtSelectSpecial; continue; } int iliSelect = ailiFirstIncomplete[MissionTypeFromIndex(i)]; if (iliSelect < 0) { iliSelect = 0; } plstc->Select(iliSelect, true, true); } return mtSelect; }