MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / PilotChoose

Function PilotChoose

Descent3/pilot.cpp:1400–1466  ·  view source on GitHub ↗

////////////////////////////////////////////////////// Displays a window to select a pilot

Source from the content-addressed store, hash-verified

1398///////////////////////////////////////////////////////////
1399// Displays a window to select a pilot
1400bool 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;

Callers 2

PilotSelectFunction · 0.85
PilotCopyDefaultControlsFunction · 0.85

Calls 15

NewPltUpdateFunction · 0.85
PltReadFileFunction · 0.85
GetSheetMethod · 0.80
NewGroupMethod · 0.80
AddTextMethod · 0.80
AddListBoxMethod · 0.80
AddButtonMethod · 0.80
GetCurrentIndexMethod · 0.80
set_filenameMethod · 0.80
CreateMethod · 0.45
SetCurrentIndexMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected