Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / tools / sheets_packer / sheets_packer_cfg.cpp
blob913b09b7dce936ec2ef11f4fe9bb206c03ce7b63
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 /////////////
21 // INCLUDE //
22 /////////////
23 #include "stdpch.h"
25 // Misc.
26 #include "nel/misc/config_file.h"
27 #include "nel/misc/bit_mem_stream.h"
28 // Client.
29 #include "sheets_packer_cfg.h"
32 ///////////
33 // MACRO //
34 ///////////
35 //-----------------------------------------------
36 /// Macro to read a Bool from the CFG.
37 /// variableName : Variable Name to Read and Set.
38 //-----------------------------------------------
39 #define READ_BOOL(variableName) \
40 /* Read the Variable Value From Script */ \
41 varPtr = AppCfg.ConfigFile.getVarPtr(#variableName); \
42 /* Value found, set the Variable */ \
43 if(varPtr) \
44 AppCfg.variableName = varPtr->asInt() ? true : false; \
45 /* Use the Default Value */ \
46 else \
47 nlwarning("CFG: Default value used for '"#variableName"' !!!"); \
49 //-----------------------------------------------
50 /// Macro to read an Int from the CFG.
51 /// variableName : Variable Name to Read and Set.
52 //-----------------------------------------------
53 #define READ_INT(variableName) \
54 /* Read the Variable Value From Script */ \
55 varPtr = AppCfg.ConfigFile.getVarPtr(#variableName); \
56 /* Value found, set the Variable */ \
57 if(varPtr) \
58 AppCfg.variableName = varPtr->asInt(); \
59 /* Use the Default Value */ \
60 else \
61 nlwarning("CFG: Default value used for '"#variableName"' !!!"); \
63 //-----------------------------------------------
64 /// Macro to read a Float from the CFG.
65 /// variableName : Variable Name to Read and Set.
66 //-----------------------------------------------
67 #define READ_FLOAT(variableName) \
68 /* Read the Variable Value From Script */ \
69 varPtr = AppCfg.ConfigFile.getVarPtr(#variableName); \
70 /* Value found, set the Variable */ \
71 if(varPtr) \
72 AppCfg.variableName = varPtr->asFloat(); \
73 /* Use the Default Value */ \
74 else \
75 nlwarning("CFG: Default value used for '"#variableName"' !!!"); \
77 //-----------------------------------------------
78 /// Macro to read a Double from the CFG.
79 /// variableName : Variable Name to Read and Set.
80 //-----------------------------------------------
81 #define READ_DOUBLE(variableName) \
82 /* Read the Variable Value From Script */ \
83 varPtr = AppCfg.ConfigFile.getVarPtr(#variableName); \
84 /* Value found, set the Variable */ \
85 if(varPtr) \
86 AppCfg.variableName = varPtr->asDouble(); \
87 /* Use the Default Value */ \
88 else \
89 nlwarning("CFG: Default value used for '"#variableName"' !!!"); \
91 //-----------------------------------------------
92 /// Macro to read a String from the CFG.
93 /// variableName : Variable Name to Read and Set.
94 //-----------------------------------------------
95 #define READ_STRING(variableName) \
96 /* Read the Variable Value From Script */ \
97 varPtr = AppCfg.ConfigFile.getVarPtr(#variableName); \
98 /* Value found, set the Variable */ \
99 if(varPtr) \
100 AppCfg.variableName = varPtr->asString(); \
101 /* Use the Default Value */ \
102 else \
103 nlwarning("CFG: Default value used for '"#variableName"' !!!"); \
105 //-----------------------------------------------
106 /// Macro to read a CVector from the CFG.
107 /// variableName : Variable Name to Read and Set.
108 //-----------------------------------------------
109 #define READ_CVECTOR(variableName) \
110 /* Read the Variable Value From Script */ \
111 varPtr = AppCfg.ConfigFile.getVarPtr(#variableName); \
112 if(varPtr) \
114 /* Check params */ \
115 if(varPtr->size()==3) \
117 AppCfg.variableName.x = varPtr->asFloat(0); \
118 AppCfg.variableName.y = varPtr->asFloat(1); \
119 AppCfg.variableName.z = varPtr->asFloat(2); \
121 else \
122 nlwarning("CFG: Bad params for '"#variableName"' !!!"); \
124 else \
125 nlwarning("CFG: Default value used for '"#variableName"' !!!"); \
128 ///////////
129 // USING //
130 ///////////
131 using namespace NLMISC;
134 ////////////
135 // GLOBAL //
136 ////////////
137 CClientConfig AppCfg;
138 const std::string ConfigFileName = "sheets_packer.cfg";
141 /////////////
142 // METHODS //
143 /////////////
144 //---------------------------------------------------
145 // CClientConfig :
146 // Constructor.
147 //---------------------------------------------------
148 CClientConfig::CClientConfig()
150 DumpVisualSlotsIndex = false;
151 }// CClientConfig //
154 //---------------------------------------------------
155 // load :
156 // Load the client config file.
157 //---------------------------------------------------
158 void setValues()
160 nlinfo ("reloading the config file!");
162 CConfigFile::CVar *varPtr = 0;
164 //////////
165 // MISC //
166 // Data Path.
169 AppCfg.DataPath.clear ();
170 CConfigFile::CVar &cvDataPath = AppCfg.ConfigFile.getVar("DataPath");
171 for (uint i = 0; i < cvDataPath.size(); i++)
172 AppCfg.DataPath.push_back(cvDataPath.asString(i));
174 catch(const EUnknownVar &) {nlwarning("Default value used for 'DataPath' !!!");}
176 // World sheet name
177 READ_STRING(WorldSheet)
178 // Primitives path
179 READ_STRING(PrimitivesPath)
180 // Output data path
181 READ_STRING(OutputDataPath)
182 // Ligo primitive class
183 READ_STRING(LigoPrimitiveClass)
184 //Dump VisualSlots index
185 READ_BOOL(DumpVisualSlotsIndex)
187 /////////////
188 // FILTERS //
189 createDebug ();
192 CConfigFile::CVar &cvTmp = AppCfg.ConfigFile.getVar("NegFiltersDebug");
193 for(uint k = 0; k < (uint)cvTmp.size(); ++k)
195 DebugLog->addNegativeFilter (cvTmp.asString(k).c_str());
198 catch(const EUnknownVar &) {}
201 CConfigFile::CVar &cvTmp = AppCfg.ConfigFile.getVar("NegFiltersInfo");
202 for(uint k = 0; k < (uint)cvTmp.size(); ++k)
204 InfoLog->addNegativeFilter (cvTmp.asString(k).c_str());
207 catch(const EUnknownVar &) {}
210 CConfigFile::CVar &cvTmp = AppCfg.ConfigFile.getVar("NegFiltersWarning");
211 for(uint k = 0; k < (uint)cvTmp.size(); ++k)
213 WarningLog->addNegativeFilter (cvTmp.asString(k).c_str());
216 catch(const EUnknownVar &) {}
217 }// load //
220 //-----------------------------------------------
221 // serial :
222 // Serialize CFG.
223 //-----------------------------------------------
224 void CClientConfig::serial(NLMISC::IStream &f)
226 // Start the opening of a new node named ClientCFG.
227 f.xmlPush("ClientCFG");
229 // Close the serial for hte Client CFG.
230 f.xmlPop();
231 }// serial //
234 //-----------------------------------------------
235 // init :
236 //-----------------------------------------------
237 void CClientConfig::init(const std::string &configFileName)
239 if(!CFile::fileExists(configFileName))
240 nlwarning("CFG::init: '%s' Not Found !!!", configFileName.c_str ());
242 // if the config file will be modified, it calls automatically the function setValues()
243 AppCfg.ConfigFile.setCallback (setValues);
245 // load the config files
246 AppCfg.ConfigFile.load (configFileName);
247 }// init //
250 //-----------------------------------------------
251 // release :
252 //-----------------------------------------------
253 void CClientConfig::release ()