@@ -33,6 +33,9 @@ static char THIS_FILE[] = __FILE__;
3333// ///////////////////////////////////////////////////////////////////////////
3434// bg_bitmap_dlg dialog
3535
36+ // FRED has a fixed number of checkboxes and supports only up to this number of nebula poofs
37+ #define MAX_NEB2_POOF_CHECKBOXES 6
38+
3639bg_bitmap_dlg::bg_bitmap_dlg (CWnd* pParent) : CDialog(bg_bitmap_dlg::IDD, pParent)
3740{
3841 // {{AFX_DATA_INIT(bg_bitmap_dlg)
@@ -47,12 +50,10 @@ bg_bitmap_dlg::bg_bitmap_dlg(CWnd* pParent) : CDialog(bg_bitmap_dlg::IDD, pParen
4750 m_subspace = FALSE ;
4851 m_fullneb = FALSE ;
4952 m_toggle_trails = FALSE ;
50- m_poof_0 = Neb2_poof_flags & (1 <<0 ) ? 1 : 0 ;
51- m_poof_1 = Neb2_poof_flags & (1 <<1 ) ? 1 : 0 ;
52- m_poof_2 = Neb2_poof_flags & (1 <<2 ) ? 1 : 0 ;
53- m_poof_3 = Neb2_poof_flags & (1 <<3 ) ? 1 : 0 ;
54- m_poof_4 = Neb2_poof_flags & (1 <<4 ) ? 1 : 0 ;
55- m_poof_5 = Neb2_poof_flags & (1 <<5 ) ? 1 : 0 ;
53+
54+ for (int i = 0 ; i < MAX_NEB2_POOFS; ++i)
55+ m_poofs[i] = Neb2_poof_flags & (1 << i) ? 1 : 0 ;
56+
5657 s_pitch = 0 ;
5758 s_bank = 0 ;
5859 s_heading = 0 ;
@@ -95,12 +96,10 @@ void bg_bitmap_dlg::DoDataExchange(CDataExchange* pDX)
9596 DDX_CBIndex (pDX, IDC_NEB2_TEXTURE, m_neb2_texture);
9697 DDX_Check (pDX, IDC_SUBSPACE, m_subspace);
9798 DDX_Check (pDX, IDC_FULLNEB, m_fullneb);
98- DDX_Check (pDX, IDC_POOF0, m_poof_0);
99- DDX_Check (pDX, IDC_POOF1, m_poof_1);
100- DDX_Check (pDX, IDC_POOF2, m_poof_2);
101- DDX_Check (pDX, IDC_POOF3, m_poof_3);
102- DDX_Check (pDX, IDC_POOF4, m_poof_4);
103- DDX_Check (pDX, IDC_POOF5, m_poof_5);
99+
100+ for (int i = 0 ; i < MAX_NEB2_POOF_CHECKBOXES; ++i)
101+ DDX_Check (pDX, IDC_POOF0 + i, m_poofs[i]);
102+
104103 DDX_Check (pDX, IDC_NEB_TOGGLE_TRAILS, m_toggle_trails);
105104 DDX_Text (pDX, IDC_SUN1, s_name);
106105 DDX_Text (pDX, IDC_SUN1_P, s_pitch);
@@ -219,12 +218,8 @@ void bg_bitmap_dlg::create()
219218 build_nebfile_list ();
220219
221220 // setup neb poof names
222- GetDlgItem (IDC_POOF0)->SetWindowText (Poof_info[0 ].name );
223- GetDlgItem (IDC_POOF1)->SetWindowText (Poof_info[1 ].name );
224- GetDlgItem (IDC_POOF2)->SetWindowText (Poof_info[2 ].name );
225- GetDlgItem (IDC_POOF3)->SetWindowText (Poof_info[3 ].name );
226- GetDlgItem (IDC_POOF4)->SetWindowText (Poof_info[4 ].name );
227- GetDlgItem (IDC_POOF5)->SetWindowText (Poof_info[5 ].name );
221+ for (i = 0 ; i < MAX_NEB2_POOF_CHECKBOXES; ++i)
222+ GetDlgItem (IDC_POOF0 + i)->SetWindowText (Poof_info[i].name );
228223
229224 m_skybox_model = _T (The_mission.skybox_model );
230225 m_envmap = _T (The_mission.envmap_name );
@@ -372,32 +367,11 @@ void bg_bitmap_dlg::OnClose()
372367 }
373368
374369 // store poof flags
375-
376- // This will clear the first six poof flags to then be set by the checkboxes, and keep higher bits as is, for example when manuall set for custom poofs by editing the mission file
377- Neb2_poof_flags &= ~(0b111111 );
378- if (m_poof_0)
379- {
380- Neb2_poof_flags |= (1 <<0 );
381- }
382- if (m_poof_1)
383- {
384- Neb2_poof_flags |= (1 <<1 );
385- }
386- if (m_poof_2)
387- {
388- Neb2_poof_flags |= (1 <<2 );
389- }
390- if (m_poof_3)
391- {
392- Neb2_poof_flags |= (1 <<3 );
393- }
394- if (m_poof_4)
395- {
396- Neb2_poof_flags |= (1 <<4 );
397- }
398- if (m_poof_5)
370+ Neb2_poof_flags = 0 ;
371+ for (int i = 0 ; i < MAX_NEB2_POOFS; ++i)
399372 {
400- Neb2_poof_flags |= (1 <<5 );
373+ if (m_poofs[i])
374+ Neb2_poof_flags |= (1 << i);
401375 }
402376
403377 // get the bitmap name
@@ -553,12 +527,10 @@ void bg_bitmap_dlg::OnFullNeb()
553527 GetDlgItem (IDC_NEB2_INTENSITY)->EnableWindow (TRUE );
554528 GetDlgItem (IDC_NEB2_TEXTURE)->EnableWindow (TRUE );
555529 GetDlgItem (IDC_NEB2_LIGHTNING)->EnableWindow (TRUE );
556- GetDlgItem (IDC_POOF0)->EnableWindow (TRUE );
557- GetDlgItem (IDC_POOF1)->EnableWindow (TRUE );
558- GetDlgItem (IDC_POOF2)->EnableWindow (TRUE );
559- GetDlgItem (IDC_POOF3)->EnableWindow (TRUE );
560- GetDlgItem (IDC_POOF4)->EnableWindow (TRUE );
561- GetDlgItem (IDC_POOF5)->EnableWindow (TRUE );
530+
531+ for (int i = 0 ; i < MAX_NEB2_POOF_CHECKBOXES; ++i)
532+ GetDlgItem (IDC_POOF0 + i)->EnableWindow (TRUE );
533+
562534 GetDlgItem (IDC_NEB_TOGGLE_TRAILS)->EnableWindow (TRUE );
563535
564536 // disable non-fullneb controls
@@ -568,30 +540,12 @@ void bg_bitmap_dlg::OnFullNeb()
568540 GetDlgItem (IDC_BANK)->EnableWindow (FALSE );
569541 GetDlgItem (IDC_HEADING)->EnableWindow (FALSE );
570542
571- // check all relevant poofs
572- ((CButton*)GetDlgItem (IDC_POOF0))->SetCheck (FALSE );
573- if (m_poof_0){
574- ((CButton*)GetDlgItem (IDC_POOF0))->SetCheck (TRUE );
575- }
576- ((CButton*)GetDlgItem (IDC_POOF1))->SetCheck (FALSE );
577- if (m_poof_1){
578- ((CButton*)GetDlgItem (IDC_POOF1))->SetCheck (TRUE );
579- }
580- ((CButton*)GetDlgItem (IDC_POOF2))->SetCheck (FALSE );
581- if (m_poof_2){
582- ((CButton*)GetDlgItem (IDC_POOF2))->SetCheck (TRUE );
583- }
584- ((CButton*)GetDlgItem (IDC_POOF3))->SetCheck (FALSE );
585- if (m_poof_3){
586- ((CButton*)GetDlgItem (IDC_POOF3))->SetCheck (TRUE );
587- }
588- ((CButton*)GetDlgItem (IDC_POOF4))->SetCheck (FALSE );
589- if (m_poof_4){
590- ((CButton*)GetDlgItem (IDC_POOF4))->SetCheck (TRUE );
591- }
592- ((CButton*)GetDlgItem (IDC_POOF5))->SetCheck (FALSE );
593- if (m_poof_5){
594- ((CButton*)GetDlgItem (IDC_POOF5))->SetCheck (TRUE );
543+ // check all relevant poofs
544+ for (int i = 0 ; i < MAX_NEB2_POOF_CHECKBOXES; ++i)
545+ {
546+ ((CButton*)GetDlgItem (IDC_POOF0 + i))->SetCheck (FALSE );
547+ if (m_poofs[i])
548+ ((CButton*)GetDlgItem (IDC_POOF0 + i))->SetCheck (TRUE );
595549 }
596550 } else {
597551 // enable all non-fullneb controls
@@ -605,12 +559,10 @@ void bg_bitmap_dlg::OnFullNeb()
605559 GetDlgItem (IDC_NEB2_INTENSITY)->EnableWindow (FALSE );
606560 GetDlgItem (IDC_NEB2_TEXTURE)->EnableWindow (FALSE );
607561 GetDlgItem (IDC_NEB2_LIGHTNING)->EnableWindow (FALSE );
608- GetDlgItem (IDC_POOF0)->EnableWindow (FALSE );
609- GetDlgItem (IDC_POOF1)->EnableWindow (FALSE );
610- GetDlgItem (IDC_POOF2)->EnableWindow (FALSE );
611- GetDlgItem (IDC_POOF3)->EnableWindow (FALSE );
612- GetDlgItem (IDC_POOF4)->EnableWindow (FALSE );
613- GetDlgItem (IDC_POOF5)->EnableWindow (FALSE );
562+
563+ for (int i = 0 ; i < MAX_NEB2_POOF_CHECKBOXES; ++i)
564+ GetDlgItem (IDC_POOF0 + i)->EnableWindow (FALSE );
565+
614566 GetDlgItem (IDC_NEB_TOGGLE_TRAILS)->EnableWindow (FALSE );
615567 }
616568}
0 commit comments