Debian Codegraph @

editor/PreferencesDialog.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/PreferencesDialog.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:38 $
23 * $Author: kevinb $
24 *
25 * Preferences
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 18 4/02/99 11:32p Jeff
30 * able to turn off IGC in debug mode. Better handling of cinematics
31 * quick exit if playing via alt-p
32 *
33 * 17 3/15/99 9:24p Gwar
34 *
35 * 16 3/15/99 6:02p Jeff
36 * PltClearList no longer takes an arg
37 *
38 * 15 11/30/98 11:56a Jeff
39 * fixed bug, allowing unlimited pilots
40 *
41 * 14 9/04/98 3:16p Samir
42 * control whether to allow joystick slewing.
43 *
44 * 13 7/16/98 12:06p Jason
45 * added special flags to room structure
46 *
47 * 12 5/20/98 6:59p Samir
48 * added slew speed slider.
49 *
50 * 11 3/20/98 1:20p Jeff
51 * Hooked Default Pilot into the code and database
52 *
53 * 10 3/19/98 6:57p Jeff
54 * Added in a default pilot section for Preferences
55 *
56 * 9 2/14/98 10:48p Jason
57 * got preferred rendering working
58 *
59 * 8 8/01/97 11:59a Samir
60 * Added a preference for debugging in fullscreen.
61 *
62 * 7 7/25/97 4:00p Matt
63 * Was swapping zbuffer and bilinear filter states
64 *
65 * 6 7/24/97 3:03p Matt
66 * Got rid of D3EditState fields that duplicated other variables
67 *
68 * 5 7/23/97 10:18a Matt
69 * Cleaned up D3EditState, moving some vars in and some out, and renaming
70 * and changing a few others
71 *
72 * 6 6/16/97 2:34p Jason
73 * added 3dfx support
74 *
75 * 5 6/05/97 6:10p Jason
76 * added support for zbuffering and bilinear filtering
77 *
78 * 4 5/27/97 5:41p Jason
79 * added toggling of opengl renderer
80 *
81 * 3 5/12/97 2:50p Jason
82 * fixed dumb bug with 16bit mode setting
83 *
84 *
85 * 2 4/30/97 5:43p Jason
86 * added ability to toggle whether or not you want to run in 16 bit mode
87 *
88 * 1 2/05/97 11:58a Samir
89 *
90 * 2 2/05/97 11:45a Samir
91 * Baisc functionality for D3windowed toggle
92 *
93 * $NoKeywords: $
94 */
95
96 // PreferencesDialog.cpp : implementation file
97 //
98
99 #include "stdafx.h"
100 #include "editor.h"
101 #include "PreferencesDialog.h"
102 #include "game.h"
103 #include "pilot.h"
104 #include "slew.h"
105
106 #ifdef _DEBUG
107 #define new DEBUG_NEW
108 #undef THIS_FILE
109 static char THIS_FILE[] = __FILE__;
110 #endif
111
112 extern bool Cinematics_enabled;
113
114 /////////////////////////////////////////////////////////////////////////////
115 // CPreferencesDialog dialog
116
117 CPreferencesDialog::CPreferencesDialog(CWnd *pParent /*=NULL*/) : CDialog(CPreferencesDialog::IDD, pParent) {
118 //{{AFX_DATA_INIT(CPreferencesDialog)
119 // NOTE: the ClassWizard will add member initialization here
120 //}}AFX_DATA_INIT
121 }
122
123 void CPreferencesDialog::DoDataExchange(CDataExchange *pDX) {
124 CDialog::DoDataExchange(pDX);
125 //{{AFX_DATA_MAP(CPreferencesDialog)
126 // NOTE: the ClassWizard will add DDX and DDV calls here
127 //}}AFX_DATA_MAP
128 }
129
130 BEGIN_MESSAGE_MAP(CPreferencesDialog, CDialog)
131 //{{AFX_MSG_MAP(CPreferencesDialog)
132 ON_BN_CLICKED(IDC_BILINEAR_CHECK, OnBilinearCheck)
133 ON_BN_CLICKED(IDC_WINDOWED, OnWindowed)
134 ON_BN_CLICKED(IDC_FULLSCREEN_HW, OnFullScreenHW)
135 ON_BN_CLICKED(IDC_FULLSCREEN_SW, OnFullScreenSW)
136 ON_BN_CLICKED(IDC_MIPPING_CHECK, OnMippingCheck)
137 ON_BN_CLICKED(IDC_IGC_ENABLED, OnIgcEnabled)
138 //}}AFX_MSG_MAP
139 END_MESSAGE_MAP()
140
141 /////////////////////////////////////////////////////////////////////////////
142 // CPreferencesDialog message handlers
143
144 #define GET_CHECK(id) (((CButton *)GetDlgItem(id))->GetCheck() != 0)
145
146 void CPreferencesDialog::OnOK() {
147 CSliderCtrl *slew_slider = (CSliderCtrl *)GetDlgItem(IDC_SLEWSLIDER);
148 bool joyslew;
149
150 if (GET_CHECK(IDC_WINDOWED))
151 D3EditState.game_render_mode = GM_WINDOWED;
152 else if (GET_CHECK(IDC_FULLSCREEN_SW))
153 D3EditState.game_render_mode = GM_FULLSCREEN_SW;
154 else if (GET_CHECK(IDC_FULLSCREEN_HW))
155 D3EditState.game_render_mode = GM_FULLSCREEN_HW;
156 else
157 Int3(); // unknown game render mode
158
159 // Do we want fullscreen debug mode?
160 if (GET_CHECK(IDC_DEBUG_CHECK))
161 D3EditState.fullscreen_debug_state = true;
162 else
163 D3EditState.fullscreen_debug_state = false;
164
165 if (GET_CHECK(IDC_USE_OPENGL))
166 PreferredRenderer = RENDERER_OPENGL;
167 else if (GET_CHECK(IDC_USE_GLIDE))
168 PreferredRenderer = RENDERER_GLIDE;
169 else if (GET_CHECK(IDC_USE_D3D))
170 PreferredRenderer = RENDERER_DIRECT3D;
171 else
172 Int3(); // unknown hardware renderer
173
174 joyslew = (GET_CHECK(IDC_JOYENABLE)) ? true : false;
175
176 if (joyslew != D3EditState.joy_slewing) {
177 D3EditState.joy_slewing = joyslew;
178 SlewControlInit();
179 }
180
181 Render_preferred_state.filtering = GET_CHECK(IDC_BILINEAR_CHECK);
182 Render_preferred_state.mipping = GET_CHECK(IDC_MIPPING_CHECK);
183
184 CComboBox *combo = (CComboBox *)GetDlgItem(IDC_DEFAULT_PILOT);
185 if (combo->GetCount()) {
186 combo->GetLBText(combo->GetCurSel(), Default_pilot);
187 } else {
188 strcpy(Default_pilot, " ");
189 }
190
191 Slew_key_speed = (slew_slider->GetPos() * 0.5) + 0.5;
192
193 CDialog::OnOK();
194 }
195
196 BOOL CPreferencesDialog::OnInitDialog() {
197 CDialog::OnInitDialog();
198 char **pilotlist;
199 int pilot_count;
200
201 // TODO: Add extra initialization here
202 CSliderCtrl *slew_slider = (CSliderCtrl *)GetDlgItem(IDC_SLEWSLIDER);
203
204 ((CButton *)GetDlgItem(IDC_WINDOWED))->SetCheck(D3EditState.game_render_mode == GM_WINDOWED);
205 ((CButton *)GetDlgItem(IDC_FULLSCREEN_SW))->SetCheck(D3EditState.game_render_mode == GM_FULLSCREEN_SW);
206 ((CButton *)GetDlgItem(IDC_FULLSCREEN_HW))->SetCheck(D3EditState.game_render_mode == GM_FULLSCREEN_HW);
207 ((CButton *)GetDlgItem(IDC_DEBUG_CHECK))->SetCheck(D3EditState.fullscreen_debug_state);
208 ((CButton *)GetDlgItem(IDC_USE_OPENGL))->SetCheck(PreferredRenderer == RENDERER_OPENGL);
209 ((CButton *)GetDlgItem(IDC_USE_GLIDE))->SetCheck(PreferredRenderer == RENDERER_GLIDE);
210 ((CButton *)GetDlgItem(IDC_USE_D3D))->SetCheck(PreferredRenderer == RENDERER_DIRECT3D);
211 ((CButton *)GetDlgItem(IDC_BILINEAR_CHECK))->SetCheck(Render_preferred_state.filtering);
212 ((CButton *)GetDlgItem(IDC_MIPPING_CHECK))->SetCheck(Render_preferred_state.mipping);
213 ((CButton *)GetDlgItem(IDC_JOYENABLE))->SetCheck(D3EditState.joy_slewing);
214 ((CButton *)GetDlgItem(IDC_IGC_ENABLED))->SetCheck(Cinematics_enabled);
215
216 slew_slider->SetRange(0, 3);
217 slew_slider->SetPos((Slew_key_speed - 0.5) / 0.5);
218
219 CComboBox *combo = (CComboBox *)GetDlgItem(IDC_DEFAULT_PILOT);
220 combo->ResetContent();
221 pilotlist = PltGetPilots(&pilot_count);
222 for (int i = 0; i < pilot_count; i++) {
223 combo->AddString(pilotlist[i]);
224 }
225 if (pilot_count) {
226 combo->SelectString(-1, Default_pilot);
227 }
228 PltClearList();
229
230 if (D3EditState.game_render_mode == GM_FULLSCREEN_HW)
231 EnableHardwareOptions();
232 else
233 DisableHardwareOptions();
234
235 PltGetPilotsFree();
236
237 return TRUE; // return TRUE unless you set the focus to a control
238 // EXCEPTION: OCX Property Pages should return FALSE
239 }
240
241 void CPreferencesDialog::OnBilinearCheck() {
242 // TODO: Add your control notification handler code here
243 }
244
245 void CPreferencesDialog::DisableHardwareOptions() {
246 ((CButton *)GetDlgItem(IDC_HARDWARE_ACC))->EnableWindow(0);
247 ((CButton *)GetDlgItem(IDC_USE_OPENGL))->EnableWindow(0);
248 ((CButton *)GetDlgItem(IDC_USE_GLIDE))->EnableWindow(0);
249 ((CButton *)GetDlgItem(IDC_USE_D3D))->EnableWindow(0);
250 ((CButton *)GetDlgItem(IDC_BILINEAR_CHECK))->EnableWindow(0);
251 ((CButton *)GetDlgItem(IDC_MIPPING_CHECK))->EnableWindow(0);
252 }
253
254 void CPreferencesDialog::EnableHardwareOptions() {
255 ((CButton *)GetDlgItem(IDC_HARDWARE_ACC))->EnableWindow(1);
256 ((CButton *)GetDlgItem(IDC_USE_OPENGL))->EnableWindow(1);
257 ((CButton *)GetDlgItem(IDC_USE_GLIDE))->EnableWindow(1);
258 ((CButton *)GetDlgItem(IDC_USE_D3D))->EnableWindow(1);
259 ((CButton *)GetDlgItem(IDC_BILINEAR_CHECK))->EnableWindow(1);
260 ((CButton *)GetDlgItem(IDC_MIPPING_CHECK))->EnableWindow(1);
261 }
262
263 void CPreferencesDialog::OnWindowed() {
264 if (((CButton *)GetDlgItem(IDC_WINDOWED))->GetCheck())
265 DisableHardwareOptions();
266 else
267 EnableHardwareOptions();
268 }
269
270 void CPreferencesDialog::OnFullScreenSW() {
271 if (((CButton *)GetDlgItem(IDC_FULLSCREEN_SW))->GetCheck())
272 DisableHardwareOptions();
273 else
274 EnableHardwareOptions();
275 }
276
277 void CPreferencesDialog::OnFullScreenHW() {
278 if (((CButton *)GetDlgItem(IDC_FULLSCREEN_HW))->GetCheck())
279 EnableHardwareOptions();
280 else
281 DisableHardwareOptions();
282 }
283
284 void CPreferencesDialog::OnMippingCheck() {
285 // TODO: Add your control notification handler code here
286 }
287
288 void CPreferencesDialog::OnIgcEnabled() {
289 CButton *button = (CButton *)GetDlgItem(IDC_IGC_ENABLED);
290 Cinematics_enabled = (bool)(button->GetCheck() != 0);
291 }