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