-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionsDlg.cpp
More file actions
228 lines (191 loc) · 6.22 KB
/
OptionsDlg.cpp
File metadata and controls
228 lines (191 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// OptionsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MODVIEW32.h"
#include "MODVIEW32Doc.h"
#include "OptionsDlg.h"
#include "FolderDlg.h"
#include "MainFrm.h"
#include "DM_Reg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COptionsDlg dialog
COptionsDlg::COptionsDlg(CWnd* pParent /*=NULL*/)
: CDialog(COptionsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COptionsDlg)
//}}AFX_DATA_INIT
pImageList=new CImageList();
m_GameConfigChanged=FALSE;
}
COptionsDlg::~COptionsDlg()
{
delete(pImageList);
}
void COptionsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptionsDlg)
DDX_Control(pDX, IDC_MENU_STYLE, c_MenuStyle);
DDX_Control(pDX, IDC_QUICKRENDERING, m_QuickRendering);
DDX_Control(pDX, IDC_EXPLORERINDEX, m_ExplorerIndex);
DDX_Control(pDX, IDC_SWAPMOUSEBUTTONS, m_SwapMouseButtons);
DDX_Control(pDX, IDC_TOOLBAR_TEXT, m_ToolBar_Text);
DDX_Control(pDX, IDC_TOOLBAR_SIZE, m_ToolBar_Size);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COptionsDlg, CDialog)
//{{AFX_MSG_MAP(COptionsDlg)
ON_BN_CLICKED(IDC_CONFIGURE, OnConfigure)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_MENU_STYLE, &COptionsDlg::OnBnClickedMenuStyle)
// ON_BN_CLICKED(IDC_QUICKRENDERING, &COptionsDlg::OnBnClickedQuickrendering)
ON_BN_CLICKED(IDC_QUICKRENDERING, &COptionsDlg::OnBnClickedQuickrendering)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COptionsDlg message handlers
BOOL COptionsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ToolBar_Text.AddString("No button text");
m_ToolBar_Text.AddString("Selective text on right");
m_ToolBar_Text.AddString("Text below button");
//Image list
CBitmap bitmap;
pImageList->Create(16,16,ILC_MASK,4,0);
bitmap.LoadBitmap(IDB_ICON_DESCENT2);
pImageList->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ICON_DESCENT3);
pImageList->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ICON_FREESPACE1);
pImageList->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ICON_FREESPACE2);
pImageList->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
//Read toolbar settings
char *options=new char[256];
LoadOptions(options);
m_ToolBar_Text.SetCurSel(*(options+0));
if(*(options+1)==TOOLBAR_SIZE_SMALL)
m_ToolBar_Size.SetCheck(1);
if(*(options+2)==1)
m_SwapMouseButtons.SetCheck(1);
if(*(options+3)==1)
m_ExplorerIndex.SetCheck(1);
if(*(options+4)==1)
m_QuickRendering.SetCheck(1);
if(DMReg_ReadHKCUint("DisableXPMenuStyle",0)==0)
c_MenuStyle.SetCheck(TRUE);
delete[] options;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
CString COptionsDlg::GetF1Path()
{
return DMReg_GetGameDir(DMREG_GAMETYPE_FREESPACE1,DMREG_DISTRIBUTIONTYPE_FULL);
}
CString COptionsDlg::GetF2Path()
{
return DMReg_GetGameDir(DMREG_GAMETYPE_FREESPACE2,DMREG_DISTRIBUTIONTYPE_FULL);
}
void COptionsDlg::OnOK()
{
CString ininame=GetINIfile();
DMReg_WriteHKCU("SwapMouseButtons",m_SwapMouseButtons.GetCheck());
DMReg_WriteHKCU("ExplorerGroupModels",m_ExplorerIndex.GetCheck());
DMReg_WriteHKCU("QuickRendering",m_QuickRendering.GetCheck());
DMReg_WriteHKCU("ToolbarButtonText",m_ToolBar_Text.GetCurSel());
DMReg_WriteHKCU("ToolbarButtonSize",m_ToolBar_Size.GetCheck()); //Important: Invert!!
DMReg_WriteHKCU("DisableXPMenuStyle",1-c_MenuStyle.GetCheck()); //Important: Invert!!
//TODO: Now reload options into View!!
if(m_GameConfigChanged)
MessageBox("Note: The tool will be restarted now.","Descent Manager MODELVIEW32");
CDialog::OnOK();
}
char * COptionsDlg::GetMainPath(char *path)
{
strcpy(path,AfxGetApp()->m_pszHelpFilePath);
RemoveFilename(path);
return path;
}
//Removes a filename from a full path statement,
//so that only the directory stays.
//RETURNS: 1 if a "\" was found
// 0 if no "\" was found (path is not modified then)
int COptionsDlg::RemoveFilename(char *path)
{
char *p=path;
char *d=path;
int len=strlen(path);
for(int i=0;i<len;i++)
{
if(*p=='\\')
d=p;
p++;
}
if(d!=path)
{
d++;
*d='\0';
return 1;
}
else
return 0;
}
void COptionsDlg::LoadOptions(char *options)
{
//Convert from older MODELVIEW versions (only once)
if(DMReg_ReadHKLMint("Configured",0)!=2)
{
DMReg_WriteHKLM("Configured",2);
CString ininame=GetINIfile();
DMReg_WriteHKCU("ToolbarButtonText",GetPrivateProfileInt("Toolbar","ButtonText",TOOLBAR_TEXT_RIGHT,ininame));
DMReg_WriteHKCU("ToolbarButtonSize",1-GetPrivateProfileInt("Toolbar","ButtonSize",1,ininame));
DMReg_WriteHKCU("SwapMouseButtons",GetPrivateProfileInt("Controls","SwapMouseButtons",0,ininame));
DMReg_WriteHKCU("ExplorerGroupModels",GetPrivateProfileInt("Display","ExplorerIndex",1,ininame));
DMReg_WriteHKLM("OpenGL_WarningMessage",GetPrivateProfileInt("General","OpenGL_WarningMessage",0,ininame));
DMReg_WriteHKCU("TipOfTheDay",GetPrivateProfileInt("General","TipOfTheDay",0,ininame));
TRY
{
CFile::Remove(ininame); //Delete old INI file -> we do not need it anymore
}
CATCH(CFileException,e)
{
}
END_CATCH
}
//Load options
*(options+0)=DMReg_ReadHKCUint("ToolbarButtonText",TOOLBAR_TEXT_RIGHT);
*(options+1)=DMReg_ReadHKCUint("ToolbarButtonSize",TOOLBAR_SIZE_LARGE);
*(options+2)=DMReg_ReadHKCUint("SwapMouseButtons",0);
*(options+3)=DMReg_ReadHKCUint("ExplorerGroupModels",1);
*(options+4)=DMReg_ReadHKCUint("QuickRendering",1);
}
CString COptionsDlg::GetINIfile()
{
CString ininame=AfxGetApp()->m_pszHelpFilePath;
ininame.TrimRight(".HLP");
ininame.TrimRight(".hlp");
ininame=ininame+".ini";
return ininame;
}
void COptionsDlg::OnConfigure()
{
//DoGamesConfig();
m_GameConfigChanged=TRUE;
}
void COptionsDlg::OnBnClickedMenuStyle()
{
// TODO: Add your control notification handler code here
}
void COptionsDlg::OnBnClickedQuickrendering()
{
// TODO: Add your control notification handler code here
}