2 * $Logfile: /Freespace2/code/FRED2/ShieldSysDlg.cpp $
7 * Shield generator system editor. This dialog allows one to indicate whether all ships
8 * (on a certain team or of a certain type) have a shield system or not.
11 * Revision 1.2 2002/05/07 03:16:44 theoddone33
12 * The Great Newline Fix
14 * Revision 1.1.1.1 2002/05/03 03:28:08 root
18 * 2 10/07/98 6:28p Dave
19 * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
20 * Fred. Globalized mission and campaign file extensions. Removed Silent
21 * Threat specific code.
23 * 1 10/07/98 3:01p Dave
25 * 1 10/07/98 3:00p Dave
27 * 2 8/18/97 9:31p Hoffoss
28 * Added grid adjustment dialog and shield system editor dialog.
35 #include "shieldsysdlg.h"
37 #include "missionparse.h"
42 static char THIS_FILE[] = __FILE__;
45 int Shield_sys_teams[MAX_TEAM_NAMES] = {0};
46 int Shield_sys_types[MAX_SHIP_TYPES] = {0};
48 /////////////////////////////////////////////////////////////////////////////
49 // shield_sys_dlg dialog
51 shield_sys_dlg::shield_sys_dlg(CWnd* pParent /*=NULL*/)
52 : CDialog(shield_sys_dlg::IDD, pParent)
54 //{{AFX_DATA_INIT(shield_sys_dlg)
60 void shield_sys_dlg::DoDataExchange(CDataExchange* pDX)
62 CDialog::DoDataExchange(pDX);
63 //{{AFX_DATA_MAP(shield_sys_dlg)
64 DDX_CBIndex(pDX, IDC_TEAM, m_team);
65 DDX_CBIndex(pDX, IDC_TYPE, m_type);
69 BEGIN_MESSAGE_MAP(shield_sys_dlg, CDialog)
70 //{{AFX_MSG_MAP(shield_sys_dlg)
71 ON_CBN_SELCHANGE(IDC_TEAM, OnSelchangeTeam)
72 ON_CBN_SELCHANGE(IDC_TYPE, OnSelchangeType)
76 /////////////////////////////////////////////////////////////////////////////
77 // shield_sys_dlg message handlers
79 BOOL shield_sys_dlg::OnInitDialog()
82 int teams[MAX_TEAM_NAMES];
83 int types[MAX_SHIP_TYPES];
86 for (i=0; i<MAX_TEAM_NAMES; i++)
89 for (i=0; i<MAX_SHIP_TYPES; i++)
92 for (i=0; i<MAX_SHIPS; i++)
93 if (Ships[i].objnum >= 0) {
94 z = (Objects[Ships[i].objnum].flags & OF_NO_SHIELDS) ? 1 : 0;
95 if (!teams[Ships[i].team])
96 Shield_sys_teams[Ships[i].team] = z;
97 else if (Shield_sys_teams[Ships[i].team] != z)
98 Shield_sys_teams[Ships[i].team] = 2;
100 if (!types[Ships[i].ship_info_index])
101 Shield_sys_types[Ships[i].ship_info_index] = z;
102 else if (Shield_sys_types[Ships[i].ship_info_index] != z)
103 Shield_sys_types[Ships[i].ship_info_index] = 2;
105 teams[Ships[i].team]++;
106 types[Ships[i].ship_info_index]++;
109 box = (CComboBox *) GetDlgItem(IDC_TYPE);
111 for (i=0; i<Num_ship_types; i++)
112 box->AddString(Ship_info[i].name);
114 box = (CComboBox *) GetDlgItem(IDC_TEAM);
116 for (i=0; i<Num_team_names; i++)
117 box->AddString(Team_names[i]);
119 CDialog::OnInitDialog();
125 void shield_sys_dlg::OnOK()
131 for (i=0; i<MAX_SHIPS; i++)
132 if (Ships[i].objnum >= 0) {
133 z = Shield_sys_teams[Ships[i].team];
134 if (!Shield_sys_types[Ships[i].ship_info_index])
136 else if (Shield_sys_types[Ships[i].ship_info_index] == 1)
140 Objects[Ships[i].objnum].flags &= ~OF_NO_SHIELDS;
142 Objects[Ships[i].objnum].flags |= OF_NO_SHIELDS;
148 void shield_sys_dlg::OnSelchangeTeam()
151 if (((CButton *) GetDlgItem(IDC_TEAM_YES))->GetCheck())
152 Shield_sys_teams[m_team] = 0;
153 else if (((CButton *) GetDlgItem(IDC_TEAM_NO))->GetCheck())
154 Shield_sys_teams[m_team] = 1;
160 void shield_sys_dlg::set_team()
162 if (!Shield_sys_teams[m_team])
163 ((CButton *) GetDlgItem(IDC_TEAM_YES))->SetCheck(TRUE);
165 ((CButton *) GetDlgItem(IDC_TEAM_YES))->SetCheck(FALSE);
167 if (Shield_sys_teams[m_team] == 1)
168 ((CButton *) GetDlgItem(IDC_TEAM_NO))->SetCheck(TRUE);
170 ((CButton *) GetDlgItem(IDC_TEAM_NO))->SetCheck(FALSE);
173 void shield_sys_dlg::OnSelchangeType()
176 if (((CButton *) GetDlgItem(IDC_TYPE_YES))->GetCheck())
177 Shield_sys_types[m_type] = 0;
178 else if (((CButton *) GetDlgItem(IDC_TYPE_NO))->GetCheck())
179 Shield_sys_types[m_type] = 1;
185 void shield_sys_dlg::set_type()
187 if (!Shield_sys_types[m_type])
188 ((CButton *) GetDlgItem(IDC_TYPE_YES))->SetCheck(TRUE);
190 ((CButton *) GetDlgItem(IDC_TYPE_YES))->SetCheck(FALSE);
192 if (Shield_sys_types[m_type] == 1)
193 ((CButton *) GetDlgItem(IDC_TYPE_NO))->SetCheck(TRUE);
195 ((CButton *) GetDlgItem(IDC_TYPE_NO))->SetCheck(FALSE);