]> icculus.org git repositories - taylor/freespace2.git/blob - src/fred2/starfieldeditor.cpp
Initial revision
[taylor/freespace2.git] / src / fred2 / starfieldeditor.cpp
1 /*
2  * $Logfile: /Freespace2/code/FRED2/StarfieldEditor.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Starfield editor dialog handling code
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:08  root
11  * Initial revision
12  *
13  * 
14  * 2     10/07/98 6:28p Dave
15  * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
16  * Fred. Globalized mission and campaign file extensions. Removed Silent
17  * Threat specific code.
18  * 
19  * 1     10/07/98 3:01p Dave
20  * 
21  * 1     10/07/98 3:00p Dave
22  * 
23  * 11    12/08/97 4:48p Hoffoss
24  * Moved starfield editor controls to background editor.
25  * 
26  * 10    4/17/97 2:01p Hoffoss
27  * All dialog box window states are saved between sessions now.
28  * 
29  * 9     4/17/97 9:33a Hoffoss
30  * Squished a warning.
31  * 
32  * 8     4/16/97 5:18p Hoffoss
33  * Moved Asteroid field editor stuff to a seperate dialog box.
34  * 
35  * 7     3/17/97 3:00p Hoffoss
36  * slider updates on the fly now.
37  * 
38  * 6     2/21/97 5:34p Hoffoss
39  * Added extensive modification detection and fixed a bug in initial
40  * orders editor.
41  * 
42  * 5     2/17/97 5:28p Hoffoss
43  * Checked RCS headers, added them were missing, changing description to
44  * something better, etc where needed.
45  * 
46  * 4     1/31/97 3:16p Hoffoss
47  * Asteroid field management implemented.
48  *
49  * $NoKeywords: $
50  */
51
52 #include "stdafx.h"
53 #include "fred.h"
54 #include "starfieldeditor.h"
55 #include "starfield.h"
56 #include "freddoc.h"
57
58 #ifdef _DEBUG
59 #define new DEBUG_NEW
60 #undef THIS_FILE
61 static char THIS_FILE[] = __FILE__;
62 #endif
63
64 /////////////////////////////////////////////////////////////////////////////
65 // starfield_editor dialog
66
67 starfield_editor::starfield_editor(CWnd* pParent /*=NULL*/)
68         : CDialog(starfield_editor::IDD, pParent)
69 {
70         //{{AFX_DATA_INIT(starfield_editor)
71         //}}AFX_DATA_INIT
72 }
73
74 void starfield_editor::DoDataExchange(CDataExchange* pDX)
75 {
76         CDialog::DoDataExchange(pDX);
77         //{{AFX_DATA_MAP(starfield_editor)
78         DDX_Control(pDX, IDC_SLIDER1, m_slider);
79         //}}AFX_DATA_MAP
80 }
81
82 BEGIN_MESSAGE_MAP(starfield_editor, CDialog)
83         //{{AFX_MSG_MAP(starfield_editor)
84         ON_WM_HSCROLL()
85         //}}AFX_MSG_MAP
86 END_MESSAGE_MAP()
87
88 /////////////////////////////////////////////////////////////////////////////
89 // starfield_editor message handlers
90
91 void starfield_editor::OnOK()
92 {
93         char buf[40];
94
95         UpdateData(TRUE);
96         theApp.record_window_data(&Starfield_wnd_data, this);
97         MODIFY(Num_stars, m_slider.GetPos());
98         sprintf(buf, "%d", Num_stars);
99         GetDlgItem(IDC_TOTAL)->SetWindowText(buf);
100         update_map_window();
101 }
102
103 void starfield_editor::OnCancel()
104 {
105         theApp.record_window_data(&Starfield_wnd_data, this);
106         CDialog::OnCancel();
107 }
108
109 BOOL starfield_editor::OnInitDialog() 
110 {
111         char buf[40];
112         CDialog::OnInitDialog();
113         theApp.init_window(&Starfield_wnd_data, this);
114         
115         m_slider.SetRange(100, MAX_STARS);
116         m_slider.SetPos(Num_stars);
117         sprintf(buf, "%d", Num_stars);
118         GetDlgItem(IDC_TOTAL)->SetWindowText(buf);
119         return TRUE;
120 }
121
122 void starfield_editor::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
123 {
124         char buf[40];
125
126         CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
127
128         MODIFY(Num_stars, m_slider.GetPos());
129         sprintf(buf, "%d", Num_stars);
130         GetDlgItem(IDC_TOTAL)->SetWindowText(buf);
131 }