void MsnPkgDlg::DrawPackages() { if (mission) { if (pkg_list) { pkg_list->ClearItems(); int i = 0; int elem_index = 0; ListIter<MissionElement> elem = mission->GetElements(); while (++elem) { // display this element? if (elem->GetIFF() == mission->Team() && !elem->IsSquadron() && elem->Region() == mission->GetRegion() && elem->GetDesign()->type < Ship::STATION) { char txt[256]; if (elem->Player() > 0) { sprintf_s(txt, "==>"); if (pkg_index < 0) pkg_index = elem_index; } else { strcpy_s(txt, " "); } pkg_list->AddItemWithData(txt, elem->ElementID()); pkg_list->SetItemText(i, 1, elem->Name()); pkg_list->SetItemText(i, 2, elem->RoleName()); const ShipDesign* design = elem->GetDesign(); if (elem->Count() > 1) sprintf_s(txt, "%d %s", elem->Count(), design->abrv); else sprintf_s(txt, "%s %s", design->abrv, design->name); pkg_list->SetItemText(i, 3, txt); i++; } elem_index++; } } } }
Menu* RadioView::GetRadioMenu(Ship* s) { dst_elem = 0; if (s && sim) { if (s->IsStarship()) { starship_menu->ClearItems(); int n = 0; int page_offset = starship_page*PAGE_SIZE; ListIter<Element> elem = sim->GetElements(); if (num_pages == 0) { while (++elem) { if (elem->IsFinished() || elem->IsSquadron() || elem->IsStatic()) continue; if (ship->GetIFF() == elem->GetIFF() && ship->GetElement() != elem.value()) n++; } num_pages = (n/PAGE_SIZE) + (n%PAGE_SIZE > 0); n = 0; elem.reset(); } while (++elem) { if (elem->IsFinished() || elem->IsSquadron() || elem->IsStatic()) continue; if (ship->GetIFF() == elem->GetIFF() && ship->GetElement() != elem.value()) { if (n >= page_offset && n < page_offset+PAGE_SIZE) { char text[64]; sprintf_s(text, "%d. %s", n+1 - page_offset, (const char*) elem->Name()); if (elem->IsActive()) { starship_menu->AddMenu(text, elem_menu, (DWORD) elem.value()); } else { strcat_s(text, " "); strcat_s(text, Game::GetText("RadioView.item.not-avail").data()); starship_menu->AddItem(text, 0, false); } } n++; } } if (num_pages > 1) { char text[64]; sprintf_s(text, Game::GetText("RadioView.item.next-page").data(), starship_page + 1, num_pages); starship_menu->AddItem(text); } return starship_menu; } else if (s->IsDropship()) { return fighter_menu; } } return 0; }