////////////////////////////////////////////////////// Displays a window to select a pilot
| 1398 | /////////////////////////////////////////////////////////// |
| 1399 | // Displays a window to select a pilot |
| 1400 | bool PilotChoose(pilot *Pilot, bool presets) { |
| 1401 | #define IDP_PCLIST 19 |
| 1402 | #define PCHOOSE_WND_H 288 |
| 1403 | #define PCHOOSE_WND_W 384 |
| 1404 | |
| 1405 | if (filecount == 0) |
| 1406 | return false; |
| 1407 | |
| 1408 | newuiTiledWindow window; |
| 1409 | newuiSheet *sheet; |
| 1410 | newuiListBox *pilot_list; |
| 1411 | |
| 1412 | bool exit_menu = false; |
| 1413 | |
| 1414 | if (presets) { |
| 1415 | window.Create(TXT_PRESETCONTROLS, 0, 0, PCHOOSE_WND_W, PCHOOSE_WND_H); |
| 1416 | } else { |
| 1417 | window.Create(TXT_PLTCHOOSE, 0, 0, PCHOOSE_WND_W, PCHOOSE_WND_H); |
| 1418 | } |
| 1419 | sheet = window.GetSheet(); |
| 1420 | |
| 1421 | sheet->NewGroup(NULL, 57, 0); |
| 1422 | sheet->AddText(TXT_PILOTPICTITLE); |
| 1423 | sheet->AddText(TXT_COPYCONTB); |
| 1424 | sheet->AddText(TXT_COPYCONTOLSC); |
| 1425 | |
| 1426 | sheet->NewGroup(NULL, 7, 40); |
| 1427 | pilot_list = sheet->AddListBox(284, 100, IDP_PCLIST); |
| 1428 | pilot_list->SetCurrentIndex(0); |
| 1429 | NewPltUpdate(pilot_list, filelist, filecount, 0); |
| 1430 | |
| 1431 | sheet->NewGroup(NULL, 80, 180, NEWUI_ALIGN_HORIZ); |
| 1432 | sheet->AddButton(TXT_OK, UID_OK); |
| 1433 | sheet->AddButton(TXT_CANCEL, UID_CANCEL); |
| 1434 | |
| 1435 | bool ret = false; |
| 1436 | |
| 1437 | window.Open(); |
| 1438 | |
| 1439 | while (!exit_menu) { |
| 1440 | int res = window.DoUI(); |
| 1441 | |
| 1442 | // handle all UI results. |
| 1443 | switch (res) { |
| 1444 | case IDP_PCLIST: |
| 1445 | case UID_OK: { |
| 1446 | int index = pilot_list->GetCurrentIndex(); |
| 1447 | if (index >= 0) { |
| 1448 | Pilot->set_filename(filelist[index]); |
| 1449 | PltReadFile(Pilot, false); |
| 1450 | ret = true; |
| 1451 | exit_menu = true; |
| 1452 | } |
| 1453 | } break; |
| 1454 | |
| 1455 | case UID_CANCEL: |
| 1456 | ret = false; |
| 1457 | exit_menu = true; |
no test coverage detected