| 861 | pilot working_pilot; |
| 862 | |
| 863 | void PilotListSelectChangeCallback(int index) { |
| 864 | if (!filecount || !PilotChooseDialogInfo.all_setup) |
| 865 | return; |
| 866 | |
| 867 | pilot *Pilot = &working_pilot; |
| 868 | char name[PILOT_STRING_SIZE]; |
| 869 | uint8_t difficulty; |
| 870 | bool profanity, audiotaunts; |
| 871 | bool in_edit = false; |
| 872 | |
| 873 | if (PilotChooseDialogInfo.menu->GetCurrentOption() == IDP_EDIT) { |
| 874 | in_edit = true; |
| 875 | PilotChooseDialogInfo.edit->sheet->Realize(); |
| 876 | } |
| 877 | |
| 878 | // Pilot has changed...reset all data to new pilot selected |
| 879 | if (!PilotChooseDialogInfo.initial_call) { |
| 880 | // save out old Pilot file so we can load up the new one |
| 881 | char filename[PAGENAME_LEN]; |
| 882 | working_pilot.get_filename(filename); |
| 883 | |
| 884 | if (cfexist(filename)) { |
| 885 | if (in_edit) |
| 886 | PilotChooseDialogInfo.edit->sheet->UpdateReturnValues(); |
| 887 | |
| 888 | // only save if the file is already there |
| 889 | // which keeps us from bringing deleted pilots |
| 890 | // back from the dead. |
| 891 | difficulty = *PilotChooseDialogInfo.edit->difficulty; |
| 892 | profanity = *PilotChooseDialogInfo.edit->profanity; |
| 893 | audiotaunts = *PilotChooseDialogInfo.edit->audiotaunts; |
| 894 | |
| 895 | Pilot->set_profanity_filter(profanity); |
| 896 | Pilot->set_difficulty(difficulty); |
| 897 | Pilot->set_audiotaunts(audiotaunts); |
| 898 | PltWriteFile(&working_pilot); |
| 899 | mprintf(0, "Pilot saved\n"); |
| 900 | } else { |
| 901 | mprintf(0, "Skipping pilot save...has the old pilot been deleted?\n"); |
| 902 | } |
| 903 | |
| 904 | working_pilot.clean(true); |
| 905 | } |
| 906 | |
| 907 | Pilot->set_filename(filelist[index]); |
| 908 | PltReadFile(Pilot); |
| 909 | |
| 910 | // Setup all values |
| 911 | /////////////////////////////// |
| 912 | Pilot->get_difficulty(&difficulty); |
| 913 | Pilot->get_profanity_filter(&profanity); |
| 914 | Pilot->get_audiotaunts(&audiotaunts); |
| 915 | *PilotChooseDialogInfo.edit->difficulty = difficulty; |
| 916 | *PilotChooseDialogInfo.edit->profanity = profanity; |
| 917 | *PilotChooseDialogInfo.edit->audiotaunts = audiotaunts; |
| 918 | |
| 919 | if (in_edit) |
| 920 | PilotChooseDialogInfo.edit->sheet->UpdateChanges(); |
no test coverage detected