1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
22 #include "nel/misc/types_nl.h"
23 #include "nel/misc/sheet_id.h"
24 #include "nel/misc/config_file.h"
26 #include "nel/georges/u_form.h"
27 #include "nel/georges/u_form_elm.h"
28 #include "nel/georges/load_form.h"
39 using namespace NLMISC
;
46 * Class to manage a sheet.
47 * \author Stephane Coutelas
48 * \author Nevrax France
64 /// Load the values using the george sheet
65 void readGeorges (const CSmartPtr
<NLGEORGES::UForm
> &form
, const CSheetId
&sheetId
);
67 /// Load/Save the values using the serial system
68 void serial (NLMISC::IStream
&s
);
71 * Event to implement any action when the sheet is no longer existent.
72 * This method is called when a sheet have been read from the packed sheet
73 * and the associated sheet file no more exist in the directories.
77 static uint
getVersion();
81 static const uint _Version
;
84 uint
const CSheet::_Version
= 1;
88 //-----------------------------------------------
91 //-----------------------------------------------
92 void CSheet::readGeorges (const CSmartPtr
<NLGEORGES::UForm
> &form
, const CSheetId
&sheetId
)
94 // Load the form with given sheet id
97 if( !form
->getRootNode().getValueByName(Alias
, "Alias", NLGEORGES::UFormElm::NoEval
) )
105 //-----------------------------------------------
108 //-----------------------------------------------
109 void CSheet::serial (NLMISC::IStream
&s
)
116 //-----------------------------------------------
119 //-----------------------------------------------
120 uint
CSheet::getVersion ()
122 //return CSheetManager::_AliasFilenameVersion;
129 //-----------------------------------------------
132 //-----------------------------------------------
135 cout
<<"This tool creates a packed file which associates sheet id with sheet alias"<<endl
;
136 cout
<<"Vars used in make_alias_file.cfg :"<<endl
;
137 cout
<<" - SheetPaths : the paths where to find the sheets"<<endl
;
138 cout
<<" - AliasFilename : name used for alias file (default is 'alias.packed_sheets')"<<endl
;
139 cout
<<" - Extensions : the extensions list of sheets to read"<<endl
;
141 cout
<<"MAKE_ALIAS_FILE"<<endl
;
150 //-----------------------------------------------
153 //-----------------------------------------------
154 int main( int argc
, char ** argv
)
156 // get the output filename
164 CConfigFile configFile
;
165 string configFileName
= "make_alias_file.cfg";
166 if(!CFile::fileExists(configFileName
))
168 nlwarning("Config file %s not found",configFileName
.c_str());
171 configFile
.load(configFileName
);
174 // read the sheet paths
175 vector
<string
> sheetPaths
;
178 CConfigFile::CVar
& cvSheetPaths
= configFile
.getVar("SheetPaths");
180 for( i
= 0; i
< (sint
)cvSheetPaths
.size(); ++i
)
182 sheetPaths
.push_back(NLMISC::expandEnvironmentVariables(cvSheetPaths
.asString(i
)));
185 catch(const EUnknownVar
&)
187 nlwarning("var 'SheetPaths' not found");
190 // add the sheet paths
191 cout
<<"adding the sheet paths ..."<<endl
;
192 vector
<string
>::iterator itPath
;
193 for( itPath
= sheetPaths
.begin(); itPath
!= sheetPaths
.end(); ++itPath
)
195 CPath::addSearchPath(*itPath
,true,false);
198 // read the name that will be used for packed file
199 string aliasFilename
= "alias.packed_sheets";
202 CConfigFile::CVar
&cvAliasFilename
= configFile
.getVar("AliasFilename");
203 aliasFilename
= cvAliasFilename
.asString();
205 catch(const EUnknownVar
&)
207 nlwarning("var 'AliasFilename' not found");
210 // read the extensions list of sheets to read
211 vector
<string
> extensions
;
214 CConfigFile::CVar
& cvExtensions
= configFile
.getVar("Extensions");
216 for( i
= 0; i
< (sint
)cvExtensions
.size(); ++i
)
218 extensions
.push_back( cvExtensions
.asString(i
) );
221 catch(const EUnknownVar
&)
223 nlwarning("var 'Extensions' not found");
226 // load form and create packed sheets
227 cout
<<"reading the sheets ..."<<endl
;
228 map
<CSheetId
, CSheet
> sheetMap
;
229 bool updatePackedSheet
= true;
230 createDebug(); // needed to init WarningLog
231 loadForm (extensions
, aliasFilename
, sheetMap
, updatePackedSheet
);
232 cout
<<"finished."<<endl
;
234 // display the content of the map
236 map<CSheetId, CSheet>::iterator itAlias;
237 for( itAlias = sheetMap.begin(); itAlias != sheetMap.end(); ++itAlias )
239 nlinfo("sheet %s alias = %s",(*itAlias).first.toString().c_str(),(*itAlias).second.Alias.c_str());