FS2_Open
Open source remastering of the Freespace 2 engine
bgbitmapdlg.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 
13 #include "stdafx.h"
14 #include "FRED.h"
15 #include "BgBitmapDlg.h"
16 #include "backgroundchooser.h"
17 #include "starfield/starfield.h"
18 #include "bmpman/bmpman.h"
19 #include "FREDView.h"
20 #include "FREDDoc.h"
21 #include "palman/palman.h"
22 #include "starfield/nebula.h"
23 #include "nebula/neb.h"
24 #include "nebula/neblightning.h"
25 #include "parse/parselo.h"
26 #include "mission/missionparse.h"
27 
28 #ifdef _DEBUG
29 #undef THIS_FILE
30 static char THIS_FILE[] = __FILE__;
31 #endif
32 
34 // bg_bitmap_dlg dialog
35 
36 bg_bitmap_dlg::bg_bitmap_dlg(CWnd* pParent) : CDialog(bg_bitmap_dlg::IDD, pParent)
37 {
38  //{{AFX_DATA_INIT(bg_bitmap_dlg)
39  m_neb_intensity = _T("");
40  m_envmap = _T("");
41  m_nebula_color = -1;
42  m_nebula_index = -1;
43  m_bank = 0;
44  m_heading = 0;
45  m_pitch = 0;
46  m_neb2_texture = 0;
47  m_subspace = FALSE;
48  m_fullneb = 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;
56  s_pitch = 0;
57  s_bank = 0;
58  s_heading = 0;
59  s_scale = 1.0f;
60  s_index = -1;
61  b_pitch = 0;
62  b_bank = 0;
63  b_heading = 0;
64  b_scale_x = 1.0f; b_scale_y = 1.0f;
65  b_div_x = 1; b_div_y = 1;
66  b_index = -1;
67 
68  m_skybox_model = _T("");
69  m_skybox_pitch = 0;
70  m_skybox_bank = 0;
71  m_skybox_heading = 0;
78  //}}AFX_DATA_INIT
79 }
80 
81 void bg_bitmap_dlg::DoDataExchange(CDataExchange* pDX)
82 {
83  CDialog::DoDataExchange(pDX);
84  //{{AFX_DATA_MAP(bg_bitmap_dlg)
85  DDX_Control(pDX, IDC_AMBIENT_B_SLIDER, m_amb_blue);
86  DDX_Control(pDX, IDC_AMBIENT_G_SLIDER, m_amb_green);
87  DDX_Control(pDX, IDC_AMBIENT_R_SLIDER, m_amb_red);
88  DDX_Text(pDX, IDC_NEB2_INTENSITY, m_neb_intensity);
89  DDX_CBIndex(pDX, IDC_NEBCOLOR, m_nebula_color);
90  DDX_CBIndex(pDX, IDC_NEBPATTERN, m_nebula_index);
91  DDX_Text(pDX, IDC_BANK, m_bank);
92  DDX_Text(pDX, IDC_HEADING, m_heading);
93  DDX_Text(pDX, IDC_PITCH, m_pitch);
94  DDX_Control(pDX, IDC_SLIDER1, m_slider);
95  DDX_CBIndex(pDX, IDC_NEB2_TEXTURE, m_neb2_texture);
96  DDX_Check(pDX, IDC_SUBSPACE, m_subspace);
97  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);
104  DDX_Check(pDX, IDC_NEB_TOGGLE_TRAILS, m_toggle_trails);
105  DDX_Text(pDX, IDC_SUN1, s_name);
106  DDX_Text(pDX, IDC_SUN1_P, s_pitch);
107  DDV_MinMaxInt(pDX, s_pitch, 0, 359);
108  DDX_Text(pDX, IDC_SUN1_B, s_bank);
109  DDV_MinMaxInt(pDX, s_bank, 0, 359);
110  DDX_Text(pDX, IDC_SUN1_H, s_heading);
111  DDV_MinMaxInt(pDX, s_heading, 0, 359);
112  DDX_Text(pDX, IDC_SUN1_SCALE, s_scale);
113  DDV_MinMaxFloat(pDX, s_scale, 0.1f, 50.0f);
114  DDX_Text(pDX, IDC_SBITMAP, b_name);
115  DDX_Text(pDX, IDC_SBITMAP_P, b_pitch);
116  DDV_MinMaxInt(pDX, b_pitch, 0, 359);
117  DDX_Text(pDX, IDC_SBITMAP_B, b_bank);
118  DDV_MinMaxInt(pDX, b_bank, 0, 359);
119  DDX_Text(pDX, IDC_SBITMAP_H, b_heading);
120  DDV_MinMaxInt(pDX, b_heading, 0, 359); DDX_Text(pDX, IDC_SBITMAP_SCALE_X, b_scale_x);
121  DDV_MinMaxFloat(pDX, b_scale_x, .001f, 18.0f);
122  DDX_Text(pDX, IDC_SBITMAP_SCALE_Y, b_scale_y);
123  DDV_MinMaxFloat(pDX, b_scale_y, .001f, 18.0f);
124  DDX_Text(pDX, IDC_SBITMAP_DIV_X, b_div_x);
125  DDV_MinMaxInt(pDX, b_div_x, 1, 5);
126  DDX_Text(pDX, IDC_SBITMAP_DIV_Y, b_div_y);
127  DDV_MinMaxInt(pDX, b_div_y, 1, 5);
128  DDX_Text(pDX, IDC_SKYBOX_FNAME, m_skybox_model);
129  DDX_Text(pDX, IDC_SKYBOX_P, m_skybox_pitch);
130  DDV_MinMaxInt(pDX, m_skybox_pitch, 0, 359);
131  DDX_Text(pDX, IDC_SKYBOX_B, m_skybox_bank);
132  DDV_MinMaxInt(pDX, m_skybox_bank, 0, 359);
133  DDX_Text(pDX, IDC_SKYBOX_H, m_skybox_heading);
134  DDV_MinMaxInt(pDX, m_skybox_heading, 0, 359);
135  DDX_Text(pDX, IDC_ENVMAP, m_envmap);
136  DDX_Check(pDX, IDC_SKY_FLAG_NO_LIGHTING, m_sky_flag_1);
137  DDX_Check(pDX, IDC_SKY_FLAG_XPARENT, m_sky_flag_2);
138  DDX_Check(pDX, IDC_SKY_FLAG_NO_ZBUFF, m_sky_flag_3);
139  DDX_Check(pDX, IDC_SKY_FLAG_NO_CULL, m_sky_flag_4);
140  DDX_Check(pDX, IDC_SKY_FLAG_NO_GLOW, m_sky_flag_5);
141  DDX_Check(pDX, IDC_SKY_FLAG_CLAMP, m_sky_flag_6);
142  DDX_Text(pDX, IDC_NEB_FAR_MULTIPLIER, m_neb_far_multi);
144  //}}AFX_DATA_MAP
145 }
146 
147 BEGIN_MESSAGE_MAP(bg_bitmap_dlg, CDialog)
148  //{{AFX_MSG_MAP(bg_bitmap_dlg)
149  ON_WM_CLOSE()
150  ON_CBN_SELCHANGE(IDC_NEBCOLOR, OnSelchangeNebcolor)
151  ON_CBN_SELCHANGE(IDC_NEBPATTERN, OnSelchangeNebpattern)
152  ON_BN_CLICKED(IDC_FULLNEB, OnFullNeb)
153  ON_WM_HSCROLL()
154  ON_LBN_SELCHANGE(IDC_SUN1_LIST, OnSunChange)
155  ON_BN_CLICKED(IDC_ADD_SUN, OnAddSun)
156  ON_BN_CLICKED(IDC_DEL_SUN, OnDelSun)
157  ON_CBN_SELCHANGE(IDC_SUN1, OnSunDropdownChange)
158  ON_LBN_SELCHANGE(IDC_SBITMAP_LIST, OnBitmapChange)
159  ON_BN_CLICKED(IDC_ADD_SBITMAP, OnAddBitmap)
160  ON_BN_CLICKED(IDC_DEL_SBITMAP, OnDelBitmap)
161  ON_CBN_SELCHANGE(IDC_SBITMAP, OnBitmapDropdownChange)
162  ON_NOTIFY(UDN_DELTAPOS, IDC_SBITMAP_P_SPIN, OnDeltaposSbitmapPSpin)
163  ON_NOTIFY(UDN_DELTAPOS, IDC_SBITMAP_B_SPIN, OnDeltaposSbitmapBSpin)
164  ON_NOTIFY(UDN_DELTAPOS, IDC_SBITMAP_H_SPIN, OnDeltaposSbitmapHSpin)
165  ON_EN_KILLFOCUS(IDC_SBITMAP_SCALE_X, OnKillfocusSbitmapScaleX)
166  ON_EN_KILLFOCUS(IDC_SBITMAP_SCALE_Y, OnKillfocusSbitmapScaleY)
167  ON_EN_KILLFOCUS(IDC_SBITMAP_DIV_X, OnKillfocusSbitmapDivX)
168  ON_EN_KILLFOCUS(IDC_SBITMAP_DIV_Y, OnKillfocusSbitmapDivY)
169  ON_EN_KILLFOCUS(IDC_SBITMAP_P, OnKillfocusSbitmapP)
170  ON_EN_KILLFOCUS(IDC_SBITMAP_B, OnKillfocusSbitmapB)
171  ON_EN_KILLFOCUS(IDC_SBITMAP_H, OnKillfocusSbitmapH)
172  ON_NOTIFY(UDN_DELTAPOS, IDC_SUN1_P_SPIN, OnDeltaposSun1PSpin)
173  ON_NOTIFY(UDN_DELTAPOS, IDC_SUN1_H_SPIN, OnDeltaposSun1HSpin)
174  ON_NOTIFY(UDN_DELTAPOS, IDC_SUN1_B_SPIN, OnDeltaposSun1BSpin)
175  ON_EN_KILLFOCUS(IDC_SUN1_P, OnKillfocusSun1P)
176  ON_EN_KILLFOCUS(IDC_SUN1_H, OnKillfocusSun1H)
177  ON_EN_KILLFOCUS(IDC_SUN1_B, OnKillfocusSun1B)
178  ON_EN_KILLFOCUS(IDC_SUN1_SCALE, OnKillfocusSun1Scale)
179  ON_BN_CLICKED(IDC_IMPORT_BACKGROUND, OnImportBackground)
180  ON_BN_CLICKED(IDC_SWAP_BACKGROUND, OnSwapBackground)
181  ON_CBN_SELCHANGE(IDC_BACKGROUND_NUM, OnBackgroundDropdownChange)
182  ON_BN_CLICKED(IDC_SKYBOX_MODEL, OnSkyboxBrowse)
183  ON_NOTIFY(UDN_DELTAPOS, IDC_SKYBOX_P_SPIN, OnDeltaposSkyboxPSpin)
184  ON_NOTIFY(UDN_DELTAPOS, IDC_SKYBOX_B_SPIN, OnDeltaposSkyboxBSpin)
185  ON_NOTIFY(UDN_DELTAPOS, IDC_SKYBOX_H_SPIN, OnDeltaposSkyboxHSpin)
186  ON_EN_KILLFOCUS(IDC_SKYBOX_P, OnKillfocusSkyboxP)
187  ON_EN_KILLFOCUS(IDC_SKYBOX_B, OnKillfocusSkyboxB)
188  ON_EN_KILLFOCUS(IDC_SKYBOX_H, OnKillfocusSkyboxH)
189  ON_BN_CLICKED(IDC_ENVMAP_BROWSE, OnEnvmapBrowse)
190  //}}AFX_MSG_MAP
191 END_MESSAGE_MAP()
192 
193 const static float delta = .00001f;
194 
196 // bg_bitmap_dlg message handlers
197 
198 void bg_bitmap_dlg::create()
199 {
200  char buf[40];
201  int i;
202  CComboBox *box;
203 
204  CDialog::Create(bg_bitmap_dlg::IDD);
206 
207  box = (CComboBox *) GetDlgItem(IDC_NEBCOLOR);
208  for (i=0; i<NUM_NEBULA_COLORS; i++){
209  box->AddString(Nebula_colors[i]);
210  }
211 
212  m_slider.SetRange(0, MAX_STARS);
213  m_slider.SetPos(Num_stars);
214  sprintf(buf, "%d", Num_stars);
215  GetDlgItem(IDC_TOTAL)->SetWindowText(buf);
216 
217  build_nebfile_list();
218 
219  // setup neb poof names
220  GetDlgItem(IDC_POOF0)->SetWindowText(Neb2_poof_filenames[0]);
221  GetDlgItem(IDC_POOF1)->SetWindowText(Neb2_poof_filenames[1]);
222  GetDlgItem(IDC_POOF2)->SetWindowText(Neb2_poof_filenames[2]);
223  GetDlgItem(IDC_POOF3)->SetWindowText(Neb2_poof_filenames[3]);
224  GetDlgItem(IDC_POOF4)->SetWindowText(Neb2_poof_filenames[4]);
225  GetDlgItem(IDC_POOF5)->SetWindowText(Neb2_poof_filenames[5]);
226 
227  m_skybox_model = _T(The_mission.skybox_model);
228  m_envmap = _T(The_mission.envmap_name);
229 
230  angles skybox_angles;
232  m_skybox_pitch = fl2ir(fl_degrees(skybox_angles.p));
233  m_skybox_bank = fl2ir(fl_degrees(skybox_angles.b));
234  m_skybox_heading = fl2ir(fl_degrees(skybox_angles.h));
235 
236  //make sure angle values are in the 0-359 degree range
237  if (m_skybox_pitch < 0)
238  m_skybox_pitch = m_skybox_pitch + 360;
239  if (m_skybox_bank < 0)
240  m_skybox_bank = m_skybox_bank + 360;
241  if (m_skybox_heading < 0)
242  m_skybox_heading = m_skybox_heading + 360;
243 
244 
245  for(i=0; i<MAX_NEB2_BITMAPS; i++){
246  if(strlen(Neb2_bitmap_filenames[i]) > 0){ //-V805
247  ((CComboBox*)GetDlgItem(IDC_NEB2_TEXTURE))->AddString(Neb2_bitmap_filenames[i]);
248  }
249  }
250  // if we have a texture selected already
251  if(strlen(Neb2_texture_name) > 0){ //-V805
252  m_neb2_texture = ((CComboBox*)GetDlgItem(IDC_NEB2_TEXTURE))->SelectString(-1, Neb2_texture_name);
253  if(m_neb2_texture == CB_ERR){
254  ((CComboBox*)GetDlgItem(IDC_NEB2_TEXTURE))->SetCurSel(0);
255  m_neb2_texture = 0;
256  }
257  } else {
258  ((CComboBox*)GetDlgItem(IDC_NEB2_TEXTURE))->SetCurSel(0);
259  }
260 
261  // setup lightning storm names
262  ((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->ResetContent();
263  ((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->AddString(CString("none"));
264  for(size_t j=0; j<Storm_types.size(); j++){
265  ((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->AddString(CString(Storm_types[j].name));
266  }
267  ((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->SelectString(-1, Mission_parse_storm_name);
268 
269  // if the nebula intensity wasn't set before - set it now
270  if(Neb2_awacs < 0.0f){
271  m_neb_intensity = CString("3000");
272  } else {
273  char whee[25] = "";
274  m_neb_intensity = CString(itoa((int)Neb2_awacs, whee, 10));
275  }
276 
277  // determine if a full Neb2 is active - load in the full nebula filenames or the partial neb
278  // filenames
279  m_fullneb = (The_mission.flags & MISSION_FLAG_FULLNEB) ? 1 : 0;
280  if(m_fullneb){
281  ((CButton*)GetDlgItem(IDC_FULLNEB))->SetCheck(1);
282  } else {
283  // since there is no "none" option for the full nebulas
284  m_nebula_index = Nebula_index + 1;
285 
286  m_nebula_color = Mission_palette;
287  if (Nebula_index < 0){
288  GetDlgItem(IDC_NEBCOLOR)->EnableWindow(FALSE);
289  }
290 
291  m_pitch = Nebula_pitch;
292  m_bank = Nebula_bank;
293  m_heading = Nebula_heading;
294  }
295 
296  m_toggle_trails = (The_mission.flags & MISSION_FLAG_TOGGLE_SHIP_TRAILS) ? 1 : 0;
297  ((CButton*)GetDlgItem(IDC_NEB_TOGGLE_TRAILS))->SetCheck(m_toggle_trails);
298 
299  // setup background numbering
300  for (i = 0; i < MAX_BACKGROUNDS; i++)
301  {
302  char temp[NAME_LENGTH];
303  sprintf(temp, "Background %d", i + 1);
304 
305  ((CComboBox*) GetDlgItem(IDC_BACKGROUND_NUM))->AddString(temp);
306  ((CComboBox*) GetDlgItem(IDC_BACKGROUND_SWAP_NUM))->AddString(temp);
307  }
308  ((CComboBox*) GetDlgItem(IDC_BACKGROUND_NUM))->SetCurSel(0);
309  ((CComboBox*) GetDlgItem(IDC_BACKGROUND_SWAP_NUM))->SetCurSel(0);
310 
311  // setup sun and sunglow controls
312  sun_data_init();
313 
314  // setup bitmap info
315  bitmap_data_init();
316 
317  // determine if subspace is active
318  m_subspace = (The_mission.flags & MISSION_FLAG_SUBSPACE) ? 1 : 0;
319 
320  m_amb_red.SetRange(1,255);
321  m_amb_green.SetRange(1,255);
322  m_amb_blue.SetRange(1,255);
323 
324  m_amb_red.SetPos(The_mission.ambient_light_level & 0xff);
325  m_amb_green.SetPos((The_mission.ambient_light_level >> 8) & 0xff);
326  m_amb_blue.SetPos((The_mission.ambient_light_level >> 16) & 0xff);
327 
328  sprintf(buf, "Red: %d", m_amb_red.GetPos());
329  GetDlgItem(IDC_AMBIENT_R_TEXT)->SetWindowText(buf);
330  sprintf(buf, "Green: %d", m_amb_green.GetPos());
331  GetDlgItem(IDC_AMBIENT_G_TEXT)->SetWindowText(buf);
332  sprintf(buf, "Blue: %d", m_amb_blue.GetPos());
333  GetDlgItem(IDC_AMBIENT_B_TEXT)->SetWindowText(buf);
334 
335  m_neb_near_multi = Neb2_fog_near_mult;
336  m_neb_far_multi = Neb2_fog_far_mult;
337 
338  UpdateData(FALSE);
339  OnFullNeb();
340  update_data();
342  set_modified();
343 }
344 
346 {
347  OnClose();
348 }
349 
351 {
352  OnClose();
353 }
354 
356 {
357  UpdateData(TRUE);
359 
360  if(m_fullneb){
362  Neb2_awacs = (float)atoi((LPCSTR)m_neb_intensity);
363 
364  // override dumb values with reasonable ones
365  if(Neb2_awacs <= 0.00000001f){
366  Neb2_awacs = 3000.0f;
367  }
368 
369  // store poof flags
370  Neb2_poof_flags = 0;
371  if(m_poof_0)
372  {
373  Neb2_poof_flags |= (1<<0);
374  }
375  if(m_poof_1)
376  {
377  Neb2_poof_flags |= (1<<1);
378  }
379  if(m_poof_2)
380  {
381  Neb2_poof_flags |= (1<<2);
382  }
383  if(m_poof_3)
384  {
385  Neb2_poof_flags |= (1<<3);
386  }
387  if(m_poof_4)
388  {
389  Neb2_poof_flags |= (1<<4);
390  }
391  if(m_poof_5)
392  {
393  Neb2_poof_flags |= (1<<5);
394  }
395 
396  // get the bitmap name
398 
399  // init the nebula
400  neb2_level_init();
401  } else {
404  Neb2_awacs = -1.0f;
406  }
407 
408  // check for no ship trails -C
409  if( m_toggle_trails ) {
411  } else {
413  }
414 
415  // get selected storm
416  ((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->GetLBText(((CComboBox*)GetDlgItem(IDC_NEB2_LIGHTNING))->GetCurSel(), Mission_parse_storm_name);
417 
421  if (Nebula_index >= 0){
423  } else {
424  nebula_close();
425  }
426 
427  if (m_subspace){
429  } else {
431  }
432 
435 
436  angles skybox_angles;
437  skybox_angles.p = fl_radians(m_skybox_pitch);
438  skybox_angles.b = fl_radians(m_skybox_bank);
439  skybox_angles.h = fl_radians(m_skybox_heading);
441 
442  //store the skybox flags
444  if(m_sky_flag_1) {
446  }
447  if(m_sky_flag_2) {
449  }
450  if(m_sky_flag_3) {
452  }
453  if(m_sky_flag_4) {
455  }
456  if(m_sky_flag_5) {
458  }
459  if(m_sky_flag_6) {
461  }
462 
465 
466  // close sun data
467  sun_data_close();
468 
469  // close bitmap data
471 
472  // reset the background
475 
476  // close window stuff
478  delete Bg_bitmap_dialog;
479  Bg_bitmap_dialog = NULL;
480 }
481 
483 {
484  if (update){
485  UpdateData(TRUE);
486  }
487 
488  UpdateData(FALSE);
489 }
490 
492 {
493  CWaitCursor wait;
494 
495  UpdateData(TRUE);
497 
498 
499  char palette_filename[1024];
500 
501  Assert( Mission_palette >= 0 );
502  Assert( Mission_palette <= 98 );
503 
504  sprintf( palette_filename, "gamepalette%d-%02d", 1, Mission_palette+1 );
505 
506  mprintf(( "Loading palette %s\n", palette_filename ));
507 
508  palette_load_table(palette_filename);
509 
510  Update_window = 1;
511 }
512 
514 {
515  CWaitCursor wait;
516 
517  UpdateData(TRUE);
518 
519  // fullneb indexes differently
521 
522  GetDlgItem(IDC_NEBCOLOR)->EnableWindow(m_nebula_index ? TRUE : FALSE);
523  if (Nebula_index >= 0){
525  } else {
526  nebula_close();
527  }
528 
529  Update_window = 1;
530 }
531 
532 void bg_bitmap_dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
533 {
534  char buf[40];
535 
536  CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
537 
538  MODIFY(Num_stars, m_slider.GetPos());
539  sprintf(buf, "%d", Num_stars);
540  GetDlgItem(IDC_TOTAL)->SetWindowText(buf);
541 
542  int col = 0;
543 
544  col |= m_amb_red.GetPos();
545  col |= m_amb_green.GetPos() << 8;
546  col |= m_amb_blue.GetPos() << 16;
547 
548  sprintf(buf, "Red: %d", m_amb_red.GetPos());
549  GetDlgItem(IDC_AMBIENT_R_TEXT)->SetWindowText(buf);
550  sprintf(buf, "Green: %d", m_amb_green.GetPos());
551  GetDlgItem(IDC_AMBIENT_G_TEXT)->SetWindowText(buf);
552  sprintf(buf, "Blue: %d", m_amb_blue.GetPos());
553  GetDlgItem(IDC_AMBIENT_B_TEXT)->SetWindowText(buf);
554 
556  gr_set_ambient_light(m_amb_red.GetPos(), m_amb_green.GetPos(), m_amb_blue.GetPos());
557 }
558 
559 // when the user toggled the "Full Nebula" button
561 {
562  // determine what state we're in
563  UpdateData(TRUE);
564  if(m_fullneb){
565  // enable all fullneb controls
566  GetDlgItem(IDC_NEB2_INTENSITY)->EnableWindow(TRUE);
567  GetDlgItem(IDC_NEB2_TEXTURE)->EnableWindow(TRUE);
568  GetDlgItem(IDC_NEB2_LIGHTNING)->EnableWindow(TRUE);
569  GetDlgItem(IDC_POOF0)->EnableWindow(TRUE);
570  GetDlgItem(IDC_POOF1)->EnableWindow(TRUE);
571  GetDlgItem(IDC_POOF2)->EnableWindow(TRUE);
572  GetDlgItem(IDC_POOF3)->EnableWindow(TRUE);
573  GetDlgItem(IDC_POOF4)->EnableWindow(TRUE);
574  GetDlgItem(IDC_POOF5)->EnableWindow(TRUE);
575  GetDlgItem(IDC_NEB_TOGGLE_TRAILS)->EnableWindow(TRUE);
576 
577  // disable non-fullneb controls
578  GetDlgItem(IDC_NEBPATTERN)->EnableWindow(FALSE);
579  GetDlgItem(IDC_NEBCOLOR)->EnableWindow(FALSE);
580  GetDlgItem(IDC_PITCH)->EnableWindow(FALSE);
581  GetDlgItem(IDC_BANK)->EnableWindow(FALSE);
582  GetDlgItem(IDC_HEADING)->EnableWindow(FALSE);
583 
584  // check all relevant poofs
585  ((CButton*)GetDlgItem(IDC_POOF0))->SetCheck(FALSE);
586  if(m_poof_0){
587  ((CButton*)GetDlgItem(IDC_POOF0))->SetCheck(TRUE);
588  }
589  ((CButton*)GetDlgItem(IDC_POOF1))->SetCheck(FALSE);
590  if(m_poof_1){
591  ((CButton*)GetDlgItem(IDC_POOF1))->SetCheck(TRUE);
592  }
593  ((CButton*)GetDlgItem(IDC_POOF2))->SetCheck(FALSE);
594  if(m_poof_2){
595  ((CButton*)GetDlgItem(IDC_POOF2))->SetCheck(TRUE);
596  }
597  ((CButton*)GetDlgItem(IDC_POOF3))->SetCheck(FALSE);
598  if(m_poof_3){
599  ((CButton*)GetDlgItem(IDC_POOF3))->SetCheck(TRUE);
600  }
601  ((CButton*)GetDlgItem(IDC_POOF4))->SetCheck(FALSE);
602  if(m_poof_4){
603  ((CButton*)GetDlgItem(IDC_POOF4))->SetCheck(TRUE);
604  }
605  ((CButton*)GetDlgItem(IDC_POOF5))->SetCheck(FALSE);
606  if(m_poof_5){
607  ((CButton*)GetDlgItem(IDC_POOF5))->SetCheck(TRUE);
608  }
609  } else {
610  // enable all non-fullneb controls
611  GetDlgItem(IDC_NEBPATTERN)->EnableWindow(TRUE);
612  GetDlgItem(IDC_NEBCOLOR)->EnableWindow(TRUE);
613  GetDlgItem(IDC_PITCH)->EnableWindow(TRUE);
614  GetDlgItem(IDC_BANK)->EnableWindow(TRUE);
615  GetDlgItem(IDC_HEADING)->EnableWindow(TRUE);
616 
617  // disable all fullneb controls
618  GetDlgItem(IDC_NEB2_INTENSITY)->EnableWindow(FALSE);
619  GetDlgItem(IDC_NEB2_TEXTURE)->EnableWindow(FALSE);
620  GetDlgItem(IDC_NEB2_LIGHTNING)->EnableWindow(FALSE);
621  GetDlgItem(IDC_POOF0)->EnableWindow(FALSE);
622  GetDlgItem(IDC_POOF1)->EnableWindow(FALSE);
623  GetDlgItem(IDC_POOF2)->EnableWindow(FALSE);
624  GetDlgItem(IDC_POOF3)->EnableWindow(FALSE);
625  GetDlgItem(IDC_POOF4)->EnableWindow(FALSE);
626  GetDlgItem(IDC_POOF5)->EnableWindow(FALSE);
627  GetDlgItem(IDC_NEB_TOGGLE_TRAILS)->EnableWindow(FALSE);
628  }
629 }
630 
631 // clear and build the nebula filename list appropriately
633 {
634  int i;
635  CComboBox *box = (CComboBox *) GetDlgItem(IDC_NEBPATTERN);
636 
637  // wacky
638  Assert(box != NULL);
639  if(box == NULL){
640  return;
641  }
642 
643  // clear the box
644  box->ResetContent();
645 
646  // add all necessary strings
647  box->AddString("None");
648  for (i=0; i<NUM_NEBULAS; i++){
649  box->AddString(Nebula_filenames[i]);
650  }
651 
652  // select the first elementccombobox
653  box->SetCurSel(0);
655 }
656 
658 {
659  int idx;
660  CComboBox *ccb = (CComboBox*) GetDlgItem(IDC_SUN1);
661  CListBox *clb = (CListBox*) GetDlgItem(IDC_SUN1_LIST);
663 
664  // clear if necessary
665  ccb->ResetContent();
666  clb->ResetContent();
667 
668  // add all suns to the drop down
669  for (idx = 0; idx < stars_get_num_entries(true, true); idx++)
670  {
671  ccb->AddString(stars_get_name_FRED(idx, true));
672  }
673 
674  // add all suns by bitmap filename to the list
675  for (idx = 0; idx < (int)background->suns.size(); idx++)
676  {
677  clb->AddString(background->suns[idx].filename);
678  }
679 
680  // if we have at least one item, select it
681  if (background->suns.size() > 0)
682  {
683  clb->SetCurSel(0);
684  OnSunChange();
685  }
686 }
687 
689 {
690  // if there is an active sun, save it
692 }
693 
695 {
696  // if we have an active item
697  if (s_index >= 0)
698  {
700  starfield_list_entry *sle = &background->suns[s_index];
701 
702  // read out of the controls
703  UpdateData(TRUE);
704 
705  // store the data
706  strcpy_s(sle->filename, s_name);
707  sle->ang.p = (float) fl_radians(s_pitch);
708  sle->ang.b = (float) fl_radians(s_bank);
709  sle->ang.h = (float) fl_radians(s_heading);
710  sle->scale_x = (float) s_scale;
711  sle->scale_y = 1.0f;
712  sle->div_x = 1;
713  sle->div_y = 1;
714  }
715 }
716 
718 {
719  // save the current sun
721 
722  // select the new one
723  s_index = ((CListBox*) GetDlgItem(IDC_SUN1_LIST))->GetCurSel();
724 
725  // setup data
726  if (s_index >= 0)
727  {
728  int drop_index;
730  starfield_list_entry *sle = &background->suns[s_index];
731 
732  s_name = CString(sle->filename);
733  s_pitch = fl2ir(fl_degrees(sle->ang.p) + delta);
734  s_bank = fl2ir(fl_degrees(sle->ang.b) + delta);
735  s_heading = fl2ir(fl_degrees(sle->ang.h) + delta);
736  s_scale = sle->scale_x;
737 
738  // stuff back into the controls
739  UpdateData(FALSE);
740 
741  // select the proper item from the dropdown
742  drop_index = ((CComboBox*) GetDlgItem(IDC_SUN1))->FindString(-1, sle->filename);
743  if(drop_index != CB_ERR)
744  ((CComboBox*) GetDlgItem(IDC_SUN1))->SetCurSel(drop_index);
745  }
746 
747  // refresh the background
749 }
750 
752 {
754 
755  // save any current
757 
758  // select the first sun by default
759  strcpy_s(sle.filename, stars_get_name_FRED(0, true));
760 
761  sle.ang.p = 0;
762  sle.ang.b = 0;
763  sle.ang.h = 0;
764  sle.scale_x = 1.0f;
765  sle.scale_y = 1.0f;
766  sle.div_x = 1;
767  sle.div_y = 1;
768 
769  Backgrounds[get_active_background()].suns.push_back(sle);
770 
771  // add to the listbox and select it
772  int add_index = ((CListBox*) GetDlgItem(IDC_SUN1_LIST))->AddString(sle.filename);
773  ((CListBox*) GetDlgItem(IDC_SUN1_LIST))->SetCurSel(add_index);
774 
775  // call the OnSunChange function to setup all relevant data in the class
776  OnSunChange();
777 }
778 
780 {
781  // if we don't have an active item
782  if(s_index < 0)
783  return;
784 
785  // remove the item from the list
786  ((CListBox*) GetDlgItem(IDC_SUN1_LIST))->DeleteString(s_index);
787 
788  // remove it from the list
790  background->suns.erase(background->suns.begin() + s_index);
791 
792  // no item selected, let the message handler assign a new one
793  s_index = -1;
794 
795  // refresh the background
797 }
798 
800 {
801  // if we have no active sun, do nothing
802  if (s_index < 0)
803  return;
804 
805  int new_index = ((CComboBox*) GetDlgItem(IDC_SUN1))->GetCurSel();
806  Assert(new_index != CB_ERR);
807 
808  // get the new string
809  if(new_index != CB_ERR)
810  {
811  ((CComboBox*) GetDlgItem(IDC_SUN1))->GetLBText(new_index, s_name);
812 
813  // change the name of the string in the listbox
814  ((CListBox*) GetDlgItem(IDC_SUN1_LIST))->DeleteString(s_index);
815  ((CListBox*) GetDlgItem(IDC_SUN1_LIST))->InsertString(s_index, (const char*) s_name);
816 
817  OnSunChange();
818  }
819 }
820 
822 {
823  int idx;
824  CComboBox *ccb = (CComboBox*) GetDlgItem(IDC_SBITMAP);
825  CListBox *clb = (CListBox*) GetDlgItem(IDC_SBITMAP_LIST);
827 
828  // clear if necessary
829  ccb->ResetContent();
830  clb->ResetContent();
831 
832  // add all bitmaps to the drop down
833  for (idx = 0; idx < stars_get_num_entries(false, true); idx++)
834  {
835  ccb->AddString(stars_get_name_FRED(idx, false));
836  }
837 
838  // add all bitmaps by bitmap filename to the list
839  for (idx = 0; idx < (int)background->bitmaps.size(); idx++)
840  {
841  clb->AddString(background->bitmaps[idx].filename);
842  }
843 
844  // if we have at least one item, select it
845  if (background->bitmaps.size() > 0)
846  {
847  clb->SetCurSel(0);
848  OnBitmapChange();
849  }
850 }
851 
853 {
854  // if there is an active bitmap, save it
856 }
857 
859 {
860  // if we have an active item
861  if (b_index >= 0)
862  {
864  starfield_list_entry *sle = &background->bitmaps[b_index];
865 
866  // read out of the controls
867  UpdateData(TRUE);
868 
869  // store the data
870  strcpy_s(sle->filename, b_name);
871  sle->ang.p = (float) fl_radians(b_pitch);
872  sle->ang.b = (float) fl_radians(b_bank);
873  sle->ang.h = (float) fl_radians(b_heading);
874  sle->scale_x = (float) b_scale_x;
875  sle->scale_y = (float) b_scale_y;
876  sle->div_x = b_div_x;
877  sle->div_y = b_div_y;
878  }
879 }
880 
882 {
883  // save the current bitmap
885 
886  // select the new one
887  b_index = ((CListBox*) GetDlgItem(IDC_SBITMAP_LIST))->GetCurSel();
888 
889  // setup data
890  if (b_index >= 0)
891  {
892  int drop_index;
894  starfield_list_entry *sle = &background->bitmaps[b_index];
895 
896  b_name = CString(sle->filename);
897  b_pitch = fl2ir(fl_degrees(sle->ang.p) + delta);
898  b_bank = fl2ir(fl_degrees(sle->ang.b) + delta);
899  b_heading = fl2ir(fl_degrees(sle->ang.h) + delta);
900  b_scale_x = sle->scale_x;
901  b_scale_y = sle->scale_y;
902  b_div_x = sle->div_x;
903  b_div_y = sle->div_y;
904 
905  // stuff back into the controls
906  UpdateData(FALSE);
907 
908  // select the proper item from the dropdown
909  drop_index = ((CComboBox*) GetDlgItem(IDC_SBITMAP))->FindString(-1, sle->filename);
910  if(drop_index != CB_ERR)
911  ((CComboBox*) GetDlgItem(IDC_SBITMAP))->SetCurSel(drop_index);
912  }
913 
914  // refresh the background
916 }
917 
919 {
921 
922  // save any current
924 
925  // select the first bitmap by default
926  strcpy_s(sle.filename, stars_get_name_FRED(0, false));
927 
928  sle.ang.p = 0;
929  sle.ang.b = 0;
930  sle.ang.h = 0;
931  sle.scale_x = 1.0f;
932  sle.scale_y = 1.0f;
933  sle.div_x = 1;
934  sle.div_y = 1;
935 
936  Backgrounds[get_active_background()].bitmaps.push_back(sle);
937 
938  // add to the listbox and select it
939  int add_index = ((CListBox*) GetDlgItem(IDC_SBITMAP_LIST))->AddString(sle.filename);
940  ((CListBox*) GetDlgItem(IDC_SBITMAP_LIST))->SetCurSel(add_index);
941 
942  // call the OnBitmapChange function to setup all relevant data in the class
943  OnBitmapChange();
944 }
945 
947 {
948  // if we don't have an active item
949  if(b_index < 0)
950  return;
951 
952  // remove the item from the list
953  ((CListBox*) GetDlgItem(IDC_SBITMAP_LIST))->DeleteString(b_index);
954 
955  // remove it from the list
957  background->bitmaps.erase(background->bitmaps.begin() + b_index);
958 
959  // no item selected, let the message handler assign a new one
960  b_index = -1;
961 
962  // refresh the background
964 }
965 
967 {
968  // if we have no active bitmap, do nothing
969  if (b_index < 0)
970  return;
971 
972  int new_index = ((CComboBox*) GetDlgItem(IDC_SBITMAP))->GetCurSel();
973  Assert(new_index != CB_ERR);
974 
975  // get the new string
976  if(new_index != CB_ERR)
977  {
978  ((CComboBox*) GetDlgItem(IDC_SBITMAP))->GetLBText(new_index, b_name);
979 
980  // change the name of the string in the listbox
981  ((CListBox*) GetDlgItem(IDC_SBITMAP_LIST))->DeleteString(b_index);
982  ((CListBox*) GetDlgItem(IDC_SBITMAP_LIST))->InsertString(b_index, (const char*) b_name);
983 
984  OnBitmapChange();
985  }
986 }
987 
988 void bg_bitmap_dlg::get_data_spinner(NM_UPDOWN* pUD, int id, int *var, int min, int max)
989 {
990  if (pUD->iDelta > 0)
991  {
992  (*var)--;
993 
994  //go min->max
995  if (*var == (min-1))
996  {
997  *var = max;
998  }
999 
1000  this->SetDlgItemInt(id, *var);
1001  }
1002  else
1003  {
1004  (*var)++;
1005 
1006  //go max->min
1007  if (*var == (max+1))
1008  {
1009  *var=min;
1010  }
1011 
1012  this->SetDlgItemInt(id, *var);
1013  }
1014 }
1015 
1016 
1017 void bg_bitmap_dlg::get_data_float(int id, float *var, float min, float max)
1018 {
1019  char buf[16];
1020  char max_ch[16];
1021  char min_ch[16];
1022 
1023  this->GetDlgItemText(id, buf, 16);
1024 
1025  *var = (float)atof(buf);
1026  sprintf(max_ch,"%.3f",max);
1027  sprintf(min_ch,"%.3f",min);
1028  CString error_msg = "Please Enter a number between ";
1029  error_msg += min_ch;
1030  error_msg += " and ";
1031  error_msg += max_ch;
1032 
1033  if (*var < min)
1034  {
1035  *var = min;
1036  this->SetDlgItemText(id, min_ch);
1037  MessageBox(error_msg, "Error", MB_OK | MB_ICONWARNING);
1038  }
1039 
1040  if (*var > max)
1041  {
1042  *var = max;
1043  this->SetDlgItemText(id, max_ch);
1044  MessageBox(error_msg, "Error", MB_OK | MB_ICONWARNING);
1045  }
1046 }
1047 
1048 
1049 void bg_bitmap_dlg::get_data_int(int id, int *var, int min, int max)
1050 {
1051  char max_ch[16];
1052  char min_ch[16];
1053 
1054  *var=this->GetDlgItemInt(id);
1055 
1056  sprintf(max_ch,"%d",max);
1057  sprintf(min_ch,"%d",min);
1058  CString error_msg = "Please Enter a number between ";
1059  error_msg += min_ch;
1060  error_msg += " and ";
1061  error_msg += max_ch;
1062 
1063  if (*var < min)
1064  {
1065  *var = min;
1066  SetDlgItemInt(id, min);
1067  MessageBox(error_msg, "Error", MB_OK | MB_ICONWARNING);
1068  }
1069 
1070  if (*var > max)
1071  {
1072  *var = max;
1073  SetDlgItemInt(id, max);
1074  MessageBox(error_msg, "Error", MB_OK | MB_ICONWARNING);
1075  }
1076 }
1077 
1078 void bg_bitmap_dlg::OnDeltaposSbitmapPSpin(NMHDR* pNMHDR, LRESULT* pResult)
1079 {
1080  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1081 
1082  if (b_index < 0) return;
1083  get_data_spinner(pNMUpDown, IDC_SBITMAP_P, &b_pitch, 0, 359);
1084  OnBitmapChange();
1085  *pResult = 0;
1086 }
1087 
1088 void bg_bitmap_dlg::OnDeltaposSbitmapBSpin(NMHDR* pNMHDR, LRESULT* pResult)
1089 {
1090  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1091 
1092  if (b_index < 0) return;
1093  get_data_spinner(pNMUpDown, IDC_SBITMAP_B, &b_bank, 0, 359);
1094  OnBitmapChange();
1095  *pResult = 0;
1096 }
1097 
1098 void bg_bitmap_dlg::OnDeltaposSbitmapHSpin(NMHDR* pNMHDR, LRESULT* pResult)
1099 {
1100  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1101 
1102  if (b_index < 0) return;
1103  get_data_spinner(pNMUpDown, IDC_SBITMAP_H, &b_heading, 0, 359);
1104  OnBitmapChange();
1105  *pResult = 0;
1106 }
1107 
1109 {
1110  if (b_index < 0) return;
1112  OnBitmapChange();
1113 }
1114 
1116 {
1117  if (b_index < 0) return;
1119  OnBitmapChange();
1120 }
1121 
1123 {
1124  if (b_index < 0) return;
1126  OnBitmapChange();
1127 }
1128 
1130 {
1131  if (b_index < 0) return;
1133  OnBitmapChange();
1134 }
1135 
1137 {
1138  if (b_index < 0) return;
1139  get_data_int(IDC_SBITMAP_P, &b_pitch, 0, 359);
1140  OnBitmapChange();
1141 }
1142 
1144 {
1145  if (b_index < 0) return;
1146  get_data_int(IDC_SBITMAP_B, &b_bank, 0, 359);
1147  OnBitmapChange();
1148 }
1149 
1151 {
1152  if (b_index < 0) return;
1154  OnBitmapChange();
1155 }
1156 
1157 void bg_bitmap_dlg::OnDeltaposSun1PSpin(NMHDR* pNMHDR, LRESULT* pResult)
1158 {
1159  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1160 
1161  if (s_index < 0) return;
1162  //G5K - why? pNMUpDown->iDelta *= -1;
1163  get_data_spinner(pNMUpDown, IDC_SUN1_P, &s_pitch, 0, 359);
1164  OnSunChange();
1165  *pResult = 0;
1166 }
1167 
1168 void bg_bitmap_dlg::OnDeltaposSun1BSpin(NMHDR* pNMHDR, LRESULT* pResult)
1169 {
1170  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1171 
1172  if (s_index < 0) return;
1173  //G5K - why? pNMUpDown->iDelta *= -1;
1174  get_data_spinner(pNMUpDown, IDC_SUN1_B, &s_bank, 0, 359);
1175  OnSunChange();
1176  *pResult = 0;
1177 }
1178 
1179 void bg_bitmap_dlg::OnDeltaposSun1HSpin(NMHDR* pNMHDR, LRESULT* pResult)
1180 {
1181  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1182 
1183  if (s_index < 0) return;
1184  //G5K - why? pNMUpDown->iDelta *= -1;
1185  get_data_spinner(pNMUpDown, IDC_SUN1_H, &s_heading, 0, 359);
1186  OnSunChange();
1187  *pResult = 0;
1188 }
1189 
1191 {
1192  if (s_index < 0) return;
1193  get_data_int(IDC_SUN1_P, &s_pitch, 0, 359);
1194  OnSunChange();
1195 }
1196 
1198 {
1199  if (s_index < 0) return;
1200  get_data_int(IDC_SUN1_H, &s_heading, 0, 359);
1201  OnSunChange();
1202 }
1203 
1205 {
1206  if (s_index < 0) return;
1207  get_data_int(IDC_SUN1_B, &s_bank, 0, 359);
1208  OnSunChange();
1209 }
1210 
1212 {
1213  if (s_index < 0) return;
1214  get_data_float(IDC_SUN1_SCALE, &s_scale, 0.1f, 50.0f);
1215  OnSunChange();
1216 }
1217 
1218 void bg_bitmap_dlg::OnDeltaposSkyboxPSpin(NMHDR* pNMHDR, LRESULT* pResult)
1219 {
1220  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1221 
1222  get_data_spinner(pNMUpDown, IDC_SKYBOX_P, &m_skybox_pitch, 0, 359);
1224  *pResult = 0;
1225 }
1226 
1227 void bg_bitmap_dlg::OnDeltaposSkyboxBSpin(NMHDR* pNMHDR, LRESULT* pResult)
1228 {
1229  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1230 
1231  get_data_spinner(pNMUpDown, IDC_SKYBOX_B, &m_skybox_bank, 0, 359);
1233  *pResult = 0;
1234 }
1235 
1236 void bg_bitmap_dlg::OnDeltaposSkyboxHSpin(NMHDR* pNMHDR, LRESULT* pResult)
1237 {
1238  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
1239 
1240  get_data_spinner(pNMUpDown, IDC_SKYBOX_H, &m_skybox_heading, 0, 359);
1242  *pResult = 0;
1243 }
1244 
1246 {
1249 }
1250 
1252 {
1255 }
1256 
1258 {
1261 }
1262 
1263 
1264 extern void parse_one_background(background_t *background);
1265 
1267 {
1268  CFileDialog cfd(TRUE, ".fs2", NULL, 0, "FreeSpace2 Missions (*.fs2)|*.fs2||\0");
1269  char filename[256], error_str[1024];
1270  int temp, count;
1271  char *saved_mp;
1272 
1273  //warn on pressing the button
1274  if (MessageBox("This action will erase any nebulae and suns already placed. Continue?", "Fred2", MB_ICONWARNING | MB_YESNO) == IDNO)
1275  return;
1276 
1277  //check if cancel was pressed
1278  if (cfd.DoModal() == IDCANCEL)
1279  return;
1280 
1281  strcpy_s(filename, cfd.GetPathName());
1282 
1283  try
1284  {
1285  // parse in the new file
1286  read_file_text(filename);
1287  reset_parse();
1288 
1289  if (!skip_to_start_of_string("#Background bitmaps"))
1290  return;
1291 
1292  // skip beginning stuff
1293  required_string("#Background bitmaps");
1294  required_string("$Num stars:");
1295  stuff_int(&temp);
1296  required_string("$Ambient light level:");
1297  stuff_int(&temp);
1298 
1299  saved_mp = Mp;
1300 
1301  // see if we have more than one background in this mission
1302  count = 0;
1303  while (skip_to_string("$Bitmap List:"))
1304  count++;
1305 
1306  Mp = saved_mp;
1307 
1308  // pick one (if count is 0, it's retail with just one background)
1309  if (count > 0)
1310  {
1311  int i, which = 0;
1312 
1313  if (count > 1)
1314  {
1315  BackgroundChooser dlg(count);
1316  if (dlg.DoModal() == IDCANCEL)
1317  return;
1318 
1319  which = dlg.GetChosenBackground();
1320  }
1321 
1322  for (i = 0; i < which + 1; i++)
1323  skip_to_string("$Bitmap List:");
1324  }
1325 
1326  // now parse the background we've selected
1328 
1330  }
1331  catch (const parse::ParseException& e)
1332  {
1333  mprintf(("BGBITMAPDLG: Unable to parse '%s'! Error message = %s.\n", filename, e.what()));
1334  sprintf(error_str, "Could not parse file: %s\n\nError message: %s", filename, e.what());
1335 
1336  MessageBox((LPCTSTR)error_str, (LPCTSTR) "Unable to import mission background!", MB_ICONERROR | MB_OK);
1337  return;
1338  }
1339 }
1340 
1342 {
1343  b_index = -1;
1344  s_index = -1;
1345 
1346  // repopulate
1347  sun_data_init();
1348  bitmap_data_init();
1349 
1350  // refresh the background
1352 }
1353 
1355 {
1356  // find out which background we're editing
1357  int idx = ((CComboBox *) GetDlgItem(IDC_BACKGROUND_NUM))->GetCurSel();
1358  if (idx < 0 || idx >= MAX_BACKGROUNDS)
1359  idx = 0;
1360 
1361  return idx;
1362 }
1363 
1365 {
1366  // find out which background we're swapping
1367  int idx = ((CComboBox *) GetDlgItem(IDC_BACKGROUND_SWAP_NUM))->GetCurSel();
1368  if (idx < 0 || idx >= MAX_BACKGROUNDS)
1369  idx = 0;
1370 
1371  return idx;
1372 }
1373 
1375 {
1377 }
1378 
1380 {
1381  int idx1 = get_active_background();
1382  int idx2 = get_swap_background();
1383 
1384  // don't swap if they're the same
1385  if (idx1 == idx2)
1386  {
1387  MessageBox("Cannot swap a background with itself.", "FRED2", MB_OK);
1388  return;
1389  }
1390 
1391  // swap
1392  stars_swap_backgrounds(idx1, idx2);
1393 
1394  // refresh dialog
1396 }
1397 
1398 
1399 char *Model_file_ext = "Model Files (*.pof)|*.pof|"
1400  "|";
1401 
1402 char *Image_file_ext = "DDS Files (*.dds)|*.dds|"
1403  "|";
1404 
1406 {
1407  CString filename;
1408  int z;
1409 
1410  UpdateData(TRUE);
1411 
1412  // get list of
1414  CFileDialog dlg(TRUE, NULL, filename, OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, Model_file_ext);
1415 
1416  // if we have a result
1417  if (dlg.DoModal() == IDOK) {
1418  m_skybox_model = dlg.GetFileName();
1419 // } else {
1420 // m_skybox_model = _T("");
1421  }
1422 
1423  UpdateData(FALSE);
1424 
1425  // restore directory
1426  if ( !z )
1427  cfile_pop_dir();
1428 
1429  // load/display new skybox model (if one was selected)
1430  stars_set_background_model( (char*)(LPCTSTR)m_skybox_model, NULL );
1431 }
1432 
1434 {
1435  angles temp_angles;
1436  matrix temp_orient;
1437  temp_angles.p = fl_radians(m_skybox_pitch);
1438  temp_angles.b = fl_radians(m_skybox_bank);
1439  temp_angles.h = fl_radians(m_skybox_heading);
1440  vm_angles_2_matrix(&temp_orient, &temp_angles);
1441  stars_set_background_orientation( &temp_orient );
1442 }
1443 
1445 {
1446  CString filename;
1447  int z;
1448 
1449  UpdateData(TRUE);
1450 
1451  ENVMAP = -1;
1452 
1453  // get list of
1455  CFileDialog dlg(TRUE, NULL, filename, OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, Image_file_ext);
1456 
1457  // if we have a result
1458  if (dlg.DoModal() == IDOK) {
1459  m_envmap = dlg.GetFileName();
1460 // } else {
1461 // m_envmap = _T("");
1462  }
1463 
1464  UpdateData(FALSE);
1465 
1466  // restore directory
1467  if ( !z )
1468  cfile_pop_dir();
1469 
1470  // set the new envmap
1471  ENVMAP = bm_load( (char*)(LPCTSTR)m_envmap );
1472 }
void record_window_data(window_data *wndd, CWnd *wnd)
Definition: fred.cpp:670
CString b_name
Definition: bgbitmapdlg.h:73
#define IDC_SBITMAP_DIV_X
Definition: resource.h:1030
int Neb2_poof_flags
Definition: neb.cpp:64
#define IDC_SWAP_BACKGROUND
Definition: resource.h:985
CString s_name
Definition: bgbitmapdlg.h:67
int stars_get_num_entries(bool is_a_sun, bool bitmap_count)
Definition: starfield.cpp:2407
matrix skybox_orientation
Definition: missionparse.h:148
virtual void DoDataExchange(CDataExchange *pDX)
Definition: bgbitmapdlg.cpp:81
char Neb2_texture_name[MAX_FILENAME_LEN]
Definition: neb.cpp:75
int i
Definition: multi_pxo.cpp:466
CFREDApp theApp
Definition: fred.cpp:115
int Nebula_heading
Definition: nebula.cpp:40
float p
Definition: pstypes.h:111
char * Image_file_ext
SCP_vector< starfield_list_entry > suns
Definition: starfield.h:40
afx_msg void OnClose()
#define IDC_SKY_FLAG_NO_GLOW
Definition: resource.h:1148
#define MR_NO_CULL
Definition: model.h:879
CString m_neb_intensity
Definition: bgbitmapdlg.h:49
#define IDC_SUN1_H_SPIN
Definition: resource.h:1013
#define MB_YESNO
Definition: config.h:182
afx_msg void OnKillfocusSun1H()
#define MISSION_FLAG_FULLNEB
Definition: missionparse.h:70
CString m_skybox_model
Definition: bgbitmapdlg.h:88
afx_msg void OnKillfocusSun1Scale()
void reinitialize_lists()
afx_msg void OnKillfocusSkyboxB()
int div_y
Definition: starfield.h:33
void nebula_init(const char *filename, int pitch, int bank, int heading)
Definition: nebula.cpp:133
#define IDC_IMPORT_BACKGROUND
Definition: resource.h:981
void nebula_close()
Definition: nebula.cpp:42
const char * stars_get_name_FRED(int index, bool is_a_sun)
Definition: starfield.cpp:2543
background_t Backgrounds[MAX_BACKGROUNDS]
Definition: starfield.cpp:125
int ambient_light_level
Definition: missionparse.h:152
#define IDC_SBITMAP_SCALE_Y
Definition: resource.h:1021
#define MR_ALL_XPARENT
Definition: model.h:877
afx_msg void OnKillfocusSbitmapDivY()
afx_msg void OnDeltaposSkyboxPSpin(NMHDR *pNMHDR, LRESULT *pResult)
#define MR_FORCE_CLAMP
Definition: model.h:888
matrix * vm_angles_2_matrix(matrix *m, const angles *a)
Definition: vecmat.cpp:752
afx_msg void OnDeltaposSbitmapPSpin(NMHDR *pNMHDR, LRESULT *pResult)
void stars_set_background_orientation(matrix *orient)
Definition: starfield.cpp:2207
afx_msg void OnKillfocusSkyboxP()
int m_skybox_pitch
Definition: bgbitmapdlg.h:90
afx_msg void OnAddBitmap()
#define IDC_SUN1_H
Definition: resource.h:1003
Assert(pm!=NULL)
#define fl2ir(fl)
Definition: floating.h:34
void get_data_spinner(NM_UPDOWN *pUD, int id, int *var, int min, int max)
int init_window(window_data *wndd, CWnd *wnd, int adjust=0, int pre=0)
Definition: fred.cpp:639
#define mprintf(args)
Definition: pstypes.h:238
void update_data(int update=1)
#define IDC_NEBCOLOR
Definition: resource.h:593
#define IDC_SBITMAP_P_SPIN
Definition: resource.h:1018
#define IDC_BANK
Definition: resource.h:778
BOOL m_toggle_trails
Definition: bgbitmapdlg.h:65
#define MR_NO_LIGHTING
Definition: model.h:867
int cfile_pop_dir()
Definition: cfile.cpp:381
int skybox_flags
Definition: missionparse.h:150
int Nebula_index
afx_msg void OnSwapBackground()
GLclampf f
Definition: Glext.h:7097
#define IDC_SKYBOX_MODEL
Definition: resource.h:1132
afx_msg void OnCancel()
afx_msg void OnKillfocusSbitmapB()
afx_msg void OnImportBackground()
afx_msg void OnDeltaposSun1PSpin(NMHDR *pNMHDR, LRESULT *pResult)
#define TRUE
Definition: pstypes.h:399
void parse_one_background(background_t *background)
#define IDC_POOF5
Definition: resource.h:1029
afx_msg void OnBackgroundDropdownChange()
#define IDC_POOF3
Definition: resource.h:1027
#define IDC_SKYBOX_B
Definition: resource.h:815
#define IDC_SBITMAP_P
Definition: resource.h:1014
unsigned int UINT
Definition: config.h:82
float b_scale_y
Definition: bgbitmapdlg.h:78
#define IDC_SKYBOX_H_SPIN
Definition: resource.h:1043
afx_msg void OnKillfocusSun1B()
#define IDC_ENVMAP
Definition: resource.h:1128
char Neb2_poof_filenames[MAX_NEB2_POOFS][MAX_FILENAME_LEN]
Definition: neb.cpp:60
void sun_data_save_current()
#define MODIFY(a, b)
Definition: fred.h:26
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: Glext.h:7308
bg_bitmap_dlg * Bg_bitmap_dialog
Definition: fred.cpp:58
#define IDC_PITCH
Definition: resource.h:791
#define IDC_SUN1_SCALE
Definition: resource.h:1005
int div_x
Definition: starfield.h:33
#define IDC_SKY_FLAG_CLAMP
Definition: resource.h:1149
void OnOrientationChange()
#define gr_set_ambient_light
Definition: 2d.h:908
#define IDC_TOTAL
Definition: resource.h:712
#define IDC_SBITMAP_SCALE_X
Definition: resource.h:1007
afx_msg void OnBitmapDropdownChange()
afx_msg void OnFullNeb()
const int MAX_STARS
Definition: starfield.cpp:47
CSliderCtrl m_slider
Definition: bgbitmapdlg.h:55
float Neb2_awacs
Definition: neb.cpp:156
#define IDC_SKY_FLAG_NO_CULL
Definition: resource.h:1147
#define IDC_SKYBOX_H
Definition: resource.h:1010
#define IDC_AMBIENT_G_SLIDER
Definition: resource.h:1087
int cfile_push_chdir(int type)
Push current directory onto a 'stack' and change to a new directory.
Definition: cfile.cpp:342
float scale_x
Definition: starfield.h:32
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
afx_msg void OnAddSun()
int Num_stars
Definition: starfield.cpp:58
angles ang
Definition: starfield.h:34
int m_skybox_heading
Definition: bgbitmapdlg.h:92
afx_msg void OnKillfocusSbitmapDivX()
char Neb2_bitmap_filenames[MAX_NEB2_BITMAPS][MAX_FILENAME_LEN]
Definition: neb.cpp:68
#define IDC_POOF4
Definition: resource.h:1028
afx_msg void OnKillfocusSbitmapH()
void stars_set_background_model(char *model_name, char *texture_name, int flags)
Definition: starfield.cpp:2172
#define MR_NO_ZBUFFER
Definition: model.h:878
#define MAX_BACKGROUNDS
Definition: starfield.h:43
#define IDC_SKYBOX_P
Definition: resource.h:1034
void stars_load_background(int background_idx)
Definition: starfield.cpp:2690
#define IDC_SBITMAP_H_SPIN
Definition: resource.h:1015
void neb2_level_init()
Definition: neb.cpp:326
char * Nebula_filenames[NUM_NEBULAS]
char * filename
#define IDC_ADD_SUN
Definition: resource.h:335
#define fl_degrees(fl)
Definition: floating.h:45
#define IDC_SKY_FLAG_NO_ZBUFF
Definition: resource.h:1146
afx_msg void OnSkyboxBrowse()
#define IDC_SKY_FLAG_XPARENT
Definition: resource.h:1145
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
GLdouble GLdouble z
Definition: Glext.h:5451
#define IDC_NEB2_TEXTURE
Definition: resource.h:643
SCP_vector< storm_type > Storm_types
#define IDC_NEB_FAR_MULTIPLIER
Definition: resource.h:1173
#define IDC_SKYBOX_P_SPIN
Definition: resource.h:1037
#define IDC_SUN1_B_SPIN
Definition: resource.h:1012
int Nebula_bank
Definition: nebula.cpp:39
#define NUM_NEBULAS
Definition: missionparse.h:30
#define IDC_SKY_FLAG_NO_LIGHTING
Definition: resource.h:1143
int get_active_background()
int required_string(const char *pstr)
Definition: parselo.cpp:468
#define MB_OK
Definition: config.h:179
CSliderCtrl m_amb_red
Definition: bgbitmapdlg.h:48
afx_msg void OnDeltaposSbitmapBSpin(NMHDR *pNMHDR, LRESULT *pResult)
#define IDC_ADD_SBITMAP
Definition: resource.h:343
char skybox_model[MAX_FILENAME_LEN]
Definition: missionparse.h:147
afx_msg void OnKillfocusSbitmapScaleY()
angles * vm_extract_angles_matrix(angles *a, const matrix *m)
Definition: vecmat.cpp:1027
int m_nebula_color
Definition: bgbitmapdlg.h:50
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
Definition: parselo.cpp:1995
#define MAX_NEB2_BITMAPS
Definition: neb.h:51
#define IDC_POOF1
Definition: resource.h:1025
#define delta
Definition: fvi.cpp:418
int idx
Definition: multiui.cpp:761
#define MB_ICONWARNING
Definition: config.h:185
#define MB_ICONERROR
Definition: config.h:190
int get_swap_background()
afx_msg void OnDeltaposSun1BSpin(NMHDR *pNMHDR, LRESULT *pResult)
#define IDC_POOF0
Definition: resource.h:1023
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
#define IDC_AMBIENT_G_TEXT
Definition: resource.h:1093
float m_neb_far_multi
Definition: bgbitmapdlg.h:94
#define IDC_SBITMAP_B_SPIN
Definition: resource.h:1016
void string_copy(char *dest, const CString &src, int max_len, int modify)
Definition: management.cpp:142
void stars_swap_backgrounds(int idx1, int idx2)
Definition: starfield.cpp:2735
afx_msg void OnSunDropdownChange()
#define IDC_NEB_TOGGLE_TRAILS
Definition: resource.h:1049
#define IDC_AMBIENT_B_SLIDER
Definition: resource.h:1089
#define IDC_SBITMAP
Definition: resource.h:538
void bitmap_data_init()
#define IDC_SUN1_LIST
Definition: resource.h:762
void set_modified(BOOL arg)
Definition: freddoc.cpp:676
void reset_parse(char *text)
Definition: parselo.cpp:3305
GLuint const GLchar * name
Definition: Glext.h:5608
afx_msg void OnKillfocusSun1P()
void stars_load_first_valid_background()
Definition: starfield.cpp:2636
afx_msg void OnDelSun()
#define IDC_BACKGROUND_SWAP_NUM
Definition: resource.h:545
void bitmap_data_close()
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
Definition: bmpman.cpp:1119
#define CF_TYPE_DATA
Definition: cfile.h:46
void stuff_int(int *i)
Definition: parselo.cpp:2372
afx_msg void OnSelchangeNebcolor()
#define IDC_AMBIENT_B_TEXT
Definition: resource.h:1094
#define IDC_AMBIENT_R_SLIDER
Definition: resource.h:1083
afx_msg void OnKillfocusSbitmapP()
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
afx_msg void OnEnvmapBrowse()
afx_msg void OnKillfocusSbitmapScaleX()
#define IDC_HEADING
Definition: resource.h:918
#define IDC_BACKGROUND_NUM
Definition: resource.h:542
#define MISSION_FLAG_TOGGLE_SHIP_TRAILS
Definition: missionparse.h:73
afx_msg void OnKillfocusSkyboxH()
#define NAME_LENGTH
Definition: globals.h:15
int m_nebula_index
Definition: bgbitmapdlg.h:51
#define IDC_NEBPATTERN
Definition: resource.h:590
char Mission_parse_storm_name[NAME_LENGTH]
#define IDC_ENVMAP_BROWSE
Definition: resource.h:1129
afx_msg void OnDeltaposSun1HSpin(NMHDR *pNMHDR, LRESULT *pResult)
afx_msg void OnDeltaposSbitmapHSpin(NMHDR *pNMHDR, LRESULT *pResult)
#define IDC_SBITMAP_LIST
Definition: resource.h:767
#define IDC_DEL_SBITMAP
Definition: resource.h:571
#define IDC_POOF2
Definition: resource.h:1026
long LRESULT
Definition: config.h:100
#define IDC_SBITMAP_B
Definition: resource.h:807
#define IDC_SUBSPACE
Definition: resource.h:969
#define IDC_SUN1_B
Definition: resource.h:802
#define IDC_SUN1
Definition: resource.h:529
#define IDC_SKYBOX_FNAME
Definition: resource.h:1079
#define IDC_SUN1_P
Definition: resource.h:1008
float scale_y
Definition: starfield.h:32
void sun_data_init()
afx_msg void OnDelBitmap()
afx_msg void OnSelchangeNebpattern()
int MessageBox(HWND h, const char *s1, const char *s2, int i)
#define IDC_SBITMAP_DIV_Y
Definition: resource.h:1031
float m_neb_near_multi
Definition: bgbitmapdlg.h:93
char * Model_file_ext
int ENVMAP
References a map that is for environment mapping -Bobboau.
Definition: bmpman.cpp:59
#define IDC_SBITMAP_H
Definition: resource.h:1004
afx_msg void OnOK()
#define IDC_NEB2_INTENSITY
Definition: resource.h:988
#define IDC_SKYBOX_B_SPIN
Definition: resource.h:1040
#define IDC_NEB_NEAR_MULTIPLIER
Definition: resource.h:1171
GLint GLsizei count
Definition: Gl.h:1491
afx_msg void OnDeltaposSkyboxBSpin(NMHDR *pNMHDR, LRESULT *pResult)
#define IDC_NEB2_LIGHTNING
Definition: resource.h:652
bg_bitmap_dlg(CWnd *pParent=NULL)
Definition: bgbitmapdlg.cpp:36
int temp
Definition: lua.cpp:4996
void sun_data_close()
SCP_vector< starfield_list_entry > bitmaps
Definition: starfield.h:39
CString m_envmap
Definition: bgbitmapdlg.h:89
void get_data_float(int id, float *var, float max, float min)
Definition: starfield.h:30
void get_data_int(int id, int *var, int min, int max)
void stars_pack_backgrounds()
Definition: starfield.cpp:2750
char envmap_name[MAX_FILENAME_LEN]
Definition: missionparse.h:149
#define NUM_NEBULA_COLORS
Definition: missionparse.h:31
char filename[MAX_FILENAME_LEN]
Definition: starfield.h:31
#define IDC_FULLNEB
Definition: resource.h:982
mission The_mission
float h
Definition: pstypes.h:111
CSliderCtrl m_amb_blue
Definition: bgbitmapdlg.h:46
CSliderCtrl m_amb_green
Definition: bgbitmapdlg.h:47
#define MR_NO_GLOWMAPS
Definition: model.h:886
afx_msg void OnDeltaposSkyboxHSpin(NMHDR *pNMHDR, LRESULT *pResult)
float Neb2_fog_near_mult
Definition: neb.cpp:159
#define FALSE
Definition: pstypes.h:400
int m_neb2_texture
Definition: bgbitmapdlg.h:56
void bitmap_data_save_current()
#define IDC_DEL_SUN
Definition: resource.h:563
char * Nebula_colors[NUM_NEBULA_COLORS]
int Mission_palette
char * Mp
Definition: parselo.cpp:48
int skip_to_string(char *pstr, char *end)
Definition: parselo.cpp:375
void build_nebfile_list()
#define IDC_AMBIENT_R_TEXT
Definition: resource.h:1091
#define IDC_SUN1_P_SPIN
Definition: resource.h:1011
int skip_to_start_of_string(char *pstr, char *end)
Definition: parselo.cpp:404
#define MISSION_FLAG_SUBSPACE
Definition: missionparse.h:68
float b
Definition: pstypes.h:111
float Neb2_fog_far_mult
Definition: neb.cpp:160
int Update_window
Definition: fred.cpp:48
#define IDC_SLIDER1
Definition: resource.h:711
afx_msg void OnBitmapChange()
#define fl_radians(fl)
Definition: floating.h:42
#define strcpy_s(...)
Definition: safe_strings.h:67
void update_map_window()
Definition: fred.cpp:532
int Nebula_pitch
Definition: nebula.cpp:38
float b_scale_x
Definition: bgbitmapdlg.h:77
window_data Bg_wnd_data
Definition: fred.cpp:69
void palette_load_table(const char *filename)
Definition: palman.cpp:132
afx_msg void OnSunChange()