2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/FRED2/ShieldSysDlg.cpp $
15 * Shield generator system editor. This dialog allows one to indicate whether all ships
16 * (on a certain team or of a certain type) have a shield system or not.
19 * Revision 1.3 2002/06/09 04:41:16 relnev
20 * added copyright header
22 * Revision 1.2 2002/05/07 03:16:44 theoddone33
23 * The Great Newline Fix
25 * Revision 1.1.1.1 2002/05/03 03:28:08 root
29 * 2 10/07/98 6:28p Dave
30 * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
31 * Fred. Globalized mission and campaign file extensions. Removed Silent
32 * Threat specific code.
34 * 1 10/07/98 3:01p Dave
36 * 1 10/07/98 3:00p Dave
38 * 2 8/18/97 9:31p Hoffoss
39 * Added grid adjustment dialog and shield system editor dialog.
46 #include "shieldsysdlg.h"
48 #include "missionparse.h"
53 static char THIS_FILE[] = __FILE__;
56 int Shield_sys_teams[MAX_TEAM_NAMES] = {0};
57 int Shield_sys_types[MAX_SHIP_TYPES] = {0};
59 /////////////////////////////////////////////////////////////////////////////
60 // shield_sys_dlg dialog
62 shield_sys_dlg::shield_sys_dlg(CWnd* pParent /*=NULL*/)
63 : CDialog(shield_sys_dlg::IDD, pParent)
65 //{{AFX_DATA_INIT(shield_sys_dlg)
71 void shield_sys_dlg::DoDataExchange(CDataExchange* pDX)
73 CDialog::DoDataExchange(pDX);
74 //{{AFX_DATA_MAP(shield_sys_dlg)
75 DDX_CBIndex(pDX, IDC_TEAM, m_team);
76 DDX_CBIndex(pDX, IDC_TYPE, m_type);
80 BEGIN_MESSAGE_MAP(shield_sys_dlg, CDialog)
81 //{{AFX_MSG_MAP(shield_sys_dlg)
82 ON_CBN_SELCHANGE(IDC_TEAM, OnSelchangeTeam)
83 ON_CBN_SELCHANGE(IDC_TYPE, OnSelchangeType)
87 /////////////////////////////////////////////////////////////////////////////
88 // shield_sys_dlg message handlers
90 BOOL shield_sys_dlg::OnInitDialog()
93 int teams[MAX_TEAM_NAMES];
94 int types[MAX_SHIP_TYPES];
97 for (i=0; i<MAX_TEAM_NAMES; i++)
100 for (i=0; i<MAX_SHIP_TYPES; i++)
103 for (i=0; i<MAX_SHIPS; i++)
104 if (Ships[i].objnum >= 0) {
105 z = (Objects[Ships[i].objnum].flags & OF_NO_SHIELDS) ? 1 : 0;
106 if (!teams[Ships[i].team])
107 Shield_sys_teams[Ships[i].team] = z;
108 else if (Shield_sys_teams[Ships[i].team] != z)
109 Shield_sys_teams[Ships[i].team] = 2;
111 if (!types[Ships[i].ship_info_index])
112 Shield_sys_types[Ships[i].ship_info_index] = z;
113 else if (Shield_sys_types[Ships[i].ship_info_index] != z)
114 Shield_sys_types[Ships[i].ship_info_index] = 2;
116 teams[Ships[i].team]++;
117 types[Ships[i].ship_info_index]++;
120 box = (CComboBox *) GetDlgItem(IDC_TYPE);
122 for (i=0; i<Num_ship_types; i++)
123 box->AddString(Ship_info[i].name);
125 box = (CComboBox *) GetDlgItem(IDC_TEAM);
127 for (i=0; i<Num_team_names; i++)
128 box->AddString(Team_names[i]);
130 CDialog::OnInitDialog();
136 void shield_sys_dlg::OnOK()
142 for (i=0; i<MAX_SHIPS; i++)
143 if (Ships[i].objnum >= 0) {
144 z = Shield_sys_teams[Ships[i].team];
145 if (!Shield_sys_types[Ships[i].ship_info_index])
147 else if (Shield_sys_types[Ships[i].ship_info_index] == 1)
151 Objects[Ships[i].objnum].flags &= ~OF_NO_SHIELDS;
153 Objects[Ships[i].objnum].flags |= OF_NO_SHIELDS;
159 void shield_sys_dlg::OnSelchangeTeam()
161 SDL_assert(m_team >= 0);
162 if (((CButton *) GetDlgItem(IDC_TEAM_YES))->GetCheck())
163 Shield_sys_teams[m_team] = 0;
164 else if (((CButton *) GetDlgItem(IDC_TEAM_NO))->GetCheck())
165 Shield_sys_teams[m_team] = 1;
171 void shield_sys_dlg::set_team()
173 if (!Shield_sys_teams[m_team])
174 ((CButton *) GetDlgItem(IDC_TEAM_YES))->SetCheck(TRUE);
176 ((CButton *) GetDlgItem(IDC_TEAM_YES))->SetCheck(FALSE);
178 if (Shield_sys_teams[m_team] == 1)
179 ((CButton *) GetDlgItem(IDC_TEAM_NO))->SetCheck(TRUE);
181 ((CButton *) GetDlgItem(IDC_TEAM_NO))->SetCheck(FALSE);
184 void shield_sys_dlg::OnSelchangeType()
186 SDL_assert(m_type >= 0);
187 if (((CButton *) GetDlgItem(IDC_TYPE_YES))->GetCheck())
188 Shield_sys_types[m_type] = 0;
189 else if (((CButton *) GetDlgItem(IDC_TYPE_NO))->GetCheck())
190 Shield_sys_types[m_type] = 1;
196 void shield_sys_dlg::set_type()
198 if (!Shield_sys_types[m_type])
199 ((CButton *) GetDlgItem(IDC_TYPE_YES))->SetCheck(TRUE);
201 ((CButton *) GetDlgItem(IDC_TYPE_YES))->SetCheck(FALSE);
203 if (Shield_sys_types[m_type] == 1)
204 ((CButton *) GetDlgItem(IDC_TYPE_NO))->SetCheck(TRUE);
206 ((CButton *) GetDlgItem(IDC_TYPE_NO))->SetCheck(FALSE);