Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / tools / leveldesign / georges_dll / settings_dialog.cpp
bloba77b9604a810a77104590c0ad791f36b773498ea
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 // settings_dialog.cpp : implementation file
23 #include "stdafx.h"
25 #include "georges_edit.h"
26 #include "settings_dialog.h"
28 using namespace NLMISC;
30 /////////////////////////////////////////////////////////////////////////////
31 // CSettingsDialog dialog
34 CSettingsDialog::CSettingsDialog(CWnd* pParent /*=NULL*/)
35 : CDialog(CSettingsDialog::IDD, pParent)
37 //{{AFX_DATA_INIT(CSettingsDialog)
38 RootSearchPath = _T("");
39 RememberListSize = 0;
40 DefaultDfn = _T("");
41 DefaultType = _T("");
42 TypeDfnSubDirectory = _T("");
43 MaxUndo = 0;
44 StartExpanded = TRUE;
45 //}}AFX_DATA_INIT
49 void CSettingsDialog::DoDataExchange(CDataExchange* pDX)
51 CDialog::DoDataExchange(pDX);
52 //{{AFX_DATA_MAP(CSettingsDialog)
53 DDX_Text(pDX, IDC_ROOT_SEARCH_PATH, RootSearchPath);
54 DDX_Text(pDX, IDC_REMEMBER_LIST_SIZE, RememberListSize);
55 DDX_Text(pDX, IDC_DEFAULT_DFN, DefaultDfn);
56 DDX_Text(pDX, IDC_DEFAULT_TYPE, DefaultType);
57 DDX_Text(pDX, IDC_TYP_DFN_PATH, TypeDfnSubDirectory);
58 DDX_Text(pDX, IDC_MAX_UNDO, MaxUndo);
59 DDX_Check(pDX, IDC_START_EXPANDED, StartExpanded);
60 //}}AFX_DATA_MAP
64 BEGIN_MESSAGE_MAP(CSettingsDialog, CDialog)
65 //{{AFX_MSG_MAP(CSettingsDialog)
66 ON_EN_CHANGE(IDC_ROOT_SEARCH_PATH, OnChangeRootSearchPath)
67 ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
68 ON_EN_CHANGE(IDC_REMEMBER_LIST_SIZE, OnChangeRememberListSize)
69 ON_EN_CHANGE(IDC_DEFAULT_DFN, OnChangeDefaultDfn)
70 ON_EN_CHANGE(IDC_DEFAULT_TYPE, OnChangeDefaultType)
71 //}}AFX_MSG_MAP
72 END_MESSAGE_MAP()
74 /////////////////////////////////////////////////////////////////////////////
75 // CSettingsDialog message handlers
77 void CSettingsDialog::OnChangeRootSearchPath()
81 BOOL CSettingsDialog::OnInitDialog()
83 CDialog::OnInitDialog();
85 // Reset flags
86 RootSearchPath = "\\";
88 // Get the config file path
89 theApp.loadCfg ();
90 RootSearchPath = theApp.RootSearchPath.c_str();
91 TypeDfnSubDirectory = theApp.TypeDfnSubDirectory.c_str();
92 RememberListSize = theApp.RememberListSize;
93 MaxUndo = theApp.MaxUndo;
94 DefaultDfn = theApp.DefaultDfn.c_str ();
95 DefaultType = theApp.DefaultType.c_str ();
96 StartExpanded = theApp.StartExpanded;
98 UpdateData (FALSE);
100 return TRUE; // return TRUE unless you set the focus to a control
101 // EXCEPTION: OCX Property Pages should return FALSE
104 void CSettingsDialog::OnOK()
106 UpdateData ();
108 // Make a config file
109 theApp.RootSearchPath = NLMISC::tStrToUtf8(RootSearchPath);
110 theApp.TypeDfnSubDirectory = NLMISC::tStrToUtf8(TypeDfnSubDirectory);
111 theApp.RememberListSize = RememberListSize;
112 theApp.StartExpanded = StartExpanded ? TRUE : FALSE;
113 theApp.MaxUndo = MaxUndo;
114 theApp.DefaultDfn = NLMISC::tStrToUtf8(DefaultDfn);
115 theApp.DefaultType = NLMISC::tStrToUtf8(DefaultType);
116 theApp.saveCfg ();
117 theApp.initCfg ();
119 CDialog::OnOK();
122 void CSettingsDialog::OnBrowse()
124 UpdateData();
126 // Select a directory.
127 TCHAR path[MAX_PATH];
129 // Build the struct
130 BROWSEINFO info;
131 memset(&info, 0, sizeof(BROWSEINFO));
132 info.lpszTitle = _T("Select the root search directory");
133 info.ulFlags = BIF_RETURNONLYFSDIRS;
135 // Select the path
136 LPITEMIDLIST list;
137 if (list = SHBrowseForFolder(&info))
139 // Convert item into path string
140 BOOL bRet = SHGetPathFromIDList(list, path);
141 if (bRet)
143 // Set the path
144 RootSearchPath = path;
147 UpdateData(FALSE);
150 void CSettingsDialog::OnChangeRememberListSize()
154 void CSettingsDialog::OnChangeDefaultDfn()
158 void CSettingsDialog::OnChangeDefaultType()