StarSystem* Galaxy::GetSystem(const char* name) { ListIter<StarSystem> sys = systems; while (++sys) { if (!strcmp(sys->Name(), name)) return sys.value(); } return 0; }
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; }
void MsnEditNavDlg::Show() { bool need_tab_update = !shown; NavDlg::Show(); if (txt_name && cmb_type) { txt_name->SetText(""); if (cmb_system) { cmb_system->ClearItems(); Galaxy* galaxy = Galaxy::GetInstance(); ListIter<StarSystem> iter = galaxy->GetSystemList(); while (++iter) { cmb_system->AddItem(iter->Name()); } } if (mission) { int i; txt_name->SetText(mission->Name()); cmb_type->SetSelection(mission->Type()); StarSystem* sys = mission->GetStarSystem(); if (sys && cmb_system && cmb_region) { for (i = 0; i < cmb_system->NumItems(); i++) { if (!strcmp(cmb_system->GetItem(i), sys->Name())) { cmb_system->SetSelection(i); break; } } cmb_region->ClearItems(); int sel_rgn = 0; List<OrbitalRegion> regions; regions.append(sys->AllRegions()); regions.sort(); i = 0; ListIter<OrbitalRegion> iter = regions; while (++iter) { OrbitalRegion* region = iter.value(); cmb_region->AddItem(region->Name()); if (!strcmp(mission->GetRegion(), region->Name())) { sel_rgn = i; } i++; } cmb_region->SetSelection(sel_rgn); } } } if (need_tab_update) { ShowTab(2); } exit_latch = true; }