| 937 | } |
| 938 | |
| 939 | void PilotSelect(void) { |
| 940 | newuiMenu menu; |
| 941 | pilot_select_menu select; |
| 942 | pilot_edit_menu edit; |
| 943 | |
| 944 | PilotChooseDialogInfo.menu = &menu; |
| 945 | PilotChooseDialogInfo.select = &select; |
| 946 | PilotChooseDialogInfo.edit = &edit; |
| 947 | PilotChooseDialogInfo.initial_call = true; |
| 948 | PilotChooseDialogInfo.all_setup = false; |
| 949 | filelist = NULL; |
| 950 | filecount = 0; |
| 951 | |
| 952 | int res = -1; |
| 953 | bool done = false; |
| 954 | |
| 955 | if (cfexist(Default_pilot) != CFES_NOT_FOUND) { |
| 956 | // ok so the default pilot file is around, mark this as the current pilot |
| 957 | Current_pilot.set_filename(Default_pilot); |
| 958 | PltReadFile(&Current_pilot); |
| 959 | } |
| 960 | |
| 961 | char pfilename[_MAX_FNAME]; |
| 962 | |
| 963 | // open menu |
| 964 | menu.Create(); |
| 965 | |
| 966 | select.setup(&menu); // setup pilot select menu IDP_SELECT |
| 967 | edit.setup(&menu); // edit pilot |
| 968 | menu.AddSimpleOption(IDP_ADD, TXT_ADD); // add |
| 969 | menu.AddSimpleOption(IDP_DELETE, TXT_DELETE); // delete currently selected pilot |
| 970 | menu.AddSimpleOption(UID_OK, TXT_OK); |
| 971 | menu.AddSimpleOption(UID_CANCEL, TXT_CANCEL); |
| 972 | menu.SetCurrentOption(IDP_SELECT); |
| 973 | |
| 974 | menu.SetOnOptionFocusCB(selectcb, &select); |
| 975 | |
| 976 | PilotChooseDialogInfo.all_setup = true; |
| 977 | filelist = PltGetPilots(&filecount); |
| 978 | |
| 979 | if (!filecount) { |
| 980 | pilot temp_pilot; |
| 981 | // if there are currently no pilots force player to create a new pilot |
| 982 | if (PilotCreate(&temp_pilot, true)) { |
| 983 | PltClearList(); |
| 984 | PltGetPilotsFree(); |
| 985 | filelist = PltGetPilots(&filecount); |
| 986 | NewPltUpdate(select.pilot_list, filelist, filecount, filecount - 1); |
| 987 | |
| 988 | int index = select.pilot_list->GetCurrentIndex(); |
| 989 | |
| 990 | PilotListSelectChangeCallback(index); |
| 991 | |
| 992 | PilotCopyDefaultControls(&working_pilot); |
| 993 | |
| 994 | menu.SetCurrentOption(IDP_EDIT); |
| 995 | } |
| 996 | } |
no test coverage detected