void LogisticsPilotListBox::removePilot(LogisticsPilot* pPilot) { for(size_t i = 0; i < itemCount; i++) { LogisticsPilotListBoxItem* pItem = dynamic_cast<LogisticsPilotListBoxItem*>(items[i]); if(pItem && pItem->getPilot() == pPilot) { RemoveItem(pItem, true); return; } } }
int32_t LogisticsPilotListBox::AddItem(aListItem* pNewItem) { scrollBar->setOrange(); LogisticsPilotListBoxItem* pItem = dynamic_cast<LogisticsPilotListBoxItem*>(pNewItem); if(pItem) { LogisticsPilot* pPilot = pItem->getPilot(); for(size_t i = 0; i < itemCount; i++) { LogisticsPilotListBoxItem* pTmpItem = dynamic_cast<LogisticsPilotListBoxItem*>(items[i]); if(pTmpItem) { // do not put in twice. if(pPilot->getName().Compare(pTmpItem->getPilot()->getName()) == 0) { delete pItem; return -1; } if(pPilot->getRank() > pTmpItem->getPilot()->getRank()) { return InsertItem(pItem, i); } else if(pPilot->getRank() == pTmpItem->getPilot()->getRank()) { if(pPilot->getGunnery() > pTmpItem->getPilot()->getGunnery()) { return InsertItem(pItem, i); } else if(pPilot->getGunnery() == pTmpItem->getPilot()->getGunnery() && pPilot->getName().Compare(pTmpItem->getPilot()->getName()) < 0) { return InsertItem(pItem, i); } } } } } // if we got here return aListBox::AddItem(pNewItem); }
void PilotReadyScreen::begin() { getButton( MB_MSG_PREV )->disable( false ); getButton( MB_MSG_MAINMENU )->disable( false ); launchFadeTime = 0; // initialize both the inventory and icon lists EList< LogisticsMech*, LogisticsMech* > mechList; LogisticsData::instance->getInventory( mechList ); // reset force group forceGroupCount = 0; int maxUnits = 12; if ( MPlayer ) { long playerCount; MPlayer->getPlayers( playerCount ); if ( playerCount ) maxUnits = MAX_MULTIPLAYER_MECHS_IN_LOGISTICS/playerCount; if ( maxUnits > 12 ) maxUnits = 12; } for ( int i = 0; i < 12; i++ ) { pIcons[i].setMech( 0 ); pIcons[i].select( 0 ); if ( i >= maxUnits ) pIcons[i].disable( 1 ); else pIcons[i].disable( 0 ); } if ( getButton( MB_MSG_MAINMENU ) ) getButton( MB_MSG_MAINMENU )->setPressFX( -1 ); int bHasPilot = -1; // update pilot use here... things can get screwed up. pilotListBox.removeAllItems( true ); long count = 256; LogisticsPilot* pilots[256]; LogisticsData::instance->getPilots( pilots, count ); for ( i = 0; i < count; i++ ) { pilots[i]->setUsed(0); } for ( EList< LogisticsMech*, LogisticsMech* >::EIterator iter = mechList.Begin(); !iter.IsDone(); iter++ ) { if ( (*iter)->getForceGroup() ) { long FG = (*iter)->getForceGroup(); pIcons[FG-1].setMech( (*iter) ); if ( (*iter)->getPilot() ) { (*iter)->getPilot()->setUsed( true ); pIcons[FG-1].setPilot( (*iter)->getPilot() ); bHasPilot = FG - 1; } forceGroupCount++; } } for ( i = 0; i < count; i++ ) { if ( !pilots[i]->isUsed() && pilots[i]->isAvailable() ) { pilotListBox.AddItem( new LogisticsPilotListBoxItem( pilots[i] ) ); } } status = RUNNING; if ( bHasPilot != -1 ) { pIcons[bHasPilot].select( true ); setPilot( pIcons[bHasPilot].getPilot() ); } else { LogisticsPilotListBoxItem* pItem = ( LogisticsPilotListBoxItem*)pilotListBox.GetItem( 0 ); if ( pItem ) { pilotListBox.SelectItem( 0 ); setPilot( pItem->getPilot() ); } pIcons[0].select( true ); } }