void MsnPkgDlg::DrawNavPlan() { if (mission) { if (pkg_index < 0 || pkg_index >= mission->GetElements().size()) pkg_index = 0; MissionElement* element = mission->GetElements()[pkg_index]; if (nav_list && element) { nav_list->ClearItems(); Point loc = element->Location(); int i = 0; ListIter<Instruction> navpt = element->NavList(); while (++navpt) { char txt[256]; sprintf_s(txt, "%d", i + 1); nav_list->AddItem(txt); nav_list->SetItemText(i, 1, Instruction::ActionName(navpt->Action())); nav_list->SetItemText(i, 2, navpt->RegionName()); double dist = Point(loc - navpt->Location()).length(); FormatNumber(txt, dist); nav_list->SetItemText(i, 3, txt); sprintf_s(txt, "%d", navpt->Speed()); nav_list->SetItemText(i, 4, txt); loc = navpt->Location(); i++; } } } }
void MsnPkgDlg::DrawThreats() { for (int i = 0; i < 5; i++) if (threat[i]) threat[i]->SetText(""); if (!mission) return; MissionElement* player = mission->GetPlayer(); if (!player) return; Text rgn0 = player->Region(); Text rgn1; int iff = player->GetIFF(); ListIter<Instruction> nav = player->NavList(); while (++nav) { if (rgn0 != nav->RegionName()) rgn1 = nav->RegionName(); } if (threat[0]) { Point base_loc = mission->GetElements()[0]->Location(); int i = 0; ListIter<MissionElement> iter = mission->GetElements(); while (++iter) { MissionElement* elem = iter.value(); if (elem->GetIFF() == 0 || elem->GetIFF() == iff || elem->IntelLevel() <= Intel::SECRET) continue; if (elem->IsSquadron()) continue; if (elem->IsGroundUnit()) { if (!elem->GetDesign() || elem->GetDesign()->type != Ship::SAM) continue; if (elem->Region() != rgn0 && elem->Region() != rgn1) continue; } int mission_role = elem->MissionRole(); if (mission_role == Mission::STRIKE || mission_role == Mission::INTEL || mission_role >= Mission::TRANSPORT) continue; char rng[32]; char role[32]; char txt[256]; if (mission_role == Mission::SWEEP || mission_role == Mission::INTERCEPT || mission_role == Mission::FLEET || mission_role == Mission::BOMBARDMENT) strcpy_s(role, Game::GetText("MsnDlg.ATTACK").data()); else strcpy_s(role, Game::GetText("MsnDlg.PATROL").data()); double dist = Point(base_loc - elem->Location()).length(); FormatNumber(rng, dist); sprintf_s(txt, "%s - %d %s - %s", role, elem->Count(), elem->GetDesign()->abrv, rng); if (threat[i]) threat[i]->SetText(txt); i++; if (i >= 5) break; } } }