------------------------------------------------------- ShowPilotPicDialog Purpose: Displays the dialog to choose a pilot picture for the given pilot. -------------------------------------------------------
| 3743 | // the given pilot. |
| 3744 | // ------------------------------------------------------- |
| 3745 | void ShowPilotPicDialog(pilot *Pilot) { |
| 3746 | ASSERT(Pilot); |
| 3747 | if (!Pilot) |
| 3748 | return; |
| 3749 | |
| 3750 | char pname[PILOT_STRING_SIZE]; |
| 3751 | |
| 3752 | Pilot->get_name(pname); |
| 3753 | |
| 3754 | uint16_t num_pilots = PPic_QueryPilot(pname); |
| 3755 | int blank_bmp_handle; |
| 3756 | |
| 3757 | // only display the dialog if there is a pilot to choose from |
| 3758 | if (num_pilots == 0) { |
| 3759 | mprintf(0, "No Pilot Pics available for %s\n", pname); |
| 3760 | uint16_t pid; |
| 3761 | pid = PPIC_INVALID_ID; |
| 3762 | Pilot->set_multiplayer_data(NULL, NULL, NULL, &pid); |
| 3763 | |
| 3764 | DoMessageBox(TXT_ERROR, TXT_NOPICSAVAIL, MSGBOX_OK, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL); |
| 3765 | return; |
| 3766 | } |
| 3767 | |
| 3768 | blank_bmp_handle = bm_AllocBitmap(64, 64, 0); |
| 3769 | if (blank_bmp_handle <= BAD_BITMAP_HANDLE) { |
| 3770 | uint16_t pid; |
| 3771 | pid = PPIC_INVALID_ID; |
| 3772 | Pilot->set_multiplayer_data(NULL, NULL, NULL, &pid); |
| 3773 | |
| 3774 | mprintf(0, "Couldn't alloc bitmap\n"); |
| 3775 | DoMessageBox(TXT_ERROR, TXT_ERRCREATINGDIALOG, MSGBOX_OK, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL); |
| 3776 | return; |
| 3777 | } |
| 3778 | uint16_t *data = bm_data(blank_bmp_handle, 0); |
| 3779 | for (int i = 0; i < 64 * 64; i++) { |
| 3780 | data[i] = GR_RGB16(0, 0, 0) | OPAQUE_FLAG; |
| 3781 | } |
| 3782 | |
| 3783 | // create the dialog |
| 3784 | // ----------------- |
| 3785 | #define DLG_PPIC_W 320 |
| 3786 | #define DLG_PPIC_H 256 |
| 3787 | newuiTiledWindow hwnd; |
| 3788 | newuiSheet *sheet; |
| 3789 | newuiListBox *list; |
| 3790 | |
| 3791 | UIBitmapItem bmp_item(blank_bmp_handle); |
| 3792 | UIStatic bmp_disp; |
| 3793 | bool exit_menu = false; |
| 3794 | |
| 3795 | hwnd.Create(TXT_PILOTPICTURE, 0, 0, DLG_PPIC_W, DLG_PPIC_H); |
| 3796 | sheet = hwnd.GetSheet(); |
| 3797 | |
| 3798 | sheet->NewGroup(NULL, 0, 0); |
| 3799 | list = sheet->AddListBox(150, 150, IDP_SAVE, UILB_NOSORT); |
| 3800 | list->SetSelectChangeCallback(ShowPilotPicDialogListCallback); |
| 3801 | |
| 3802 | sheet->NewGroup(TXT_DISPLAY, 175, 0); |
no test coverage detected