Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / tools / phrase_generator / skill_tree.cpp
blobd1ef6f1019fed643068a58928ac89a06d9c1aafb
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/>.
17 #include "skill_tree.h"
19 using namespace std;
20 using namespace NLMISC;
21 using namespace NLGEORGES;
24 //-----------------------------------------------
25 // readGeorges for CStaticSkillsTree
27 //-----------------------------------------------
28 void CStaticSkillsTree::readGeorges( const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId )
30 if( form )
32 UFormElm& root = form->getRootNode();
34 UFormElm *arraySkillElt = NULL;
35 if( root.getNodeByName( &arraySkillElt, "SkillData" ) )
37 if( arraySkillElt )
39 uint NbSkills;
40 nlverify( arraySkillElt->getArraySize( NbSkills ) );
42 nlassertex( NbSkills == SKILLS::NUM_SKILLS, ("(%u != %u) Please synchronise game_share/skill.* with leveldesign/game_element/xp_table/skills.skill_tree (use skill_extractor.exe)", NbSkills, SKILLS::NUM_SKILLS));
44 SkillsTree.resize( NbSkills );
46 for( uint i = 0; i < NbSkills; ++i )
48 UFormElm* SkillElt = NULL;
49 if( ! ( arraySkillElt->getArrayNode( &SkillElt, i ) && SkillElt ) )
51 nlwarning("<CStaticSkillsTree::readGeorges> can't get array node of SkillElt in sheet %s", sheetId.toString().c_str() );
53 else
55 // Skill
56 string SkillName;
57 SkillElt->getValueByName( SkillName, "Skill" );
58 SKILLS::ESkills skill = SKILLS::toSkill( SkillName );
59 nlassert( skill != SKILLS::unknown );
60 if (skill == SKILLS::unknown)
62 continue;
64 SkillsTree[ skill ].Skill = skill;
66 if( ! SkillElt->getValueByName( SkillsTree[ skill ].SkillCode, "SkillCode" ) )
68 nlwarning("<CStaticSkillsTree::readGeorges> can't get node SkillCode in sheet %s", sheetId.toString().c_str() );
71 // Skill Code
72 if( ! SkillElt->getValueByName( SkillsTree[ skill ].SkillCode, "SkillCode" ) )
74 nlwarning("<CStaticSkillsTree::readGeorges> can't get node SkillCode in sheet %s", sheetId.toString().c_str() );
77 // Max skill value
78 if( ! SkillElt->getValueByName( SkillsTree[ skill ].MaxSkillValue, "MaxSkillValue" ) )
80 nlwarning("<CStaticSkillsTree::readGeorges> can't get node MaxSkillValue in sheet %s", sheetId.toString().c_str() );
83 // Type of stage
84 if( ! SkillElt->getValueByName( SkillsTree[ skill ].StageType, "Type of Stage" ) )
86 nlwarning("<CStaticSkillsTree::readGeorges> can't get node 'Type of Stage' in sheet %s", sheetId.toString().c_str() );
89 // ParentSkill
90 if( ! SkillElt->getValueByName( SkillName, "ParentSkill" ) )
92 nlwarning("<CStaticSkillsTree::readGeorges> can't get node ParentSkills in sheet %s", sheetId.toString().c_str() );
94 else
96 SkillsTree[ skill ].ParentSkill = SKILLS::toSkill( SkillName );
99 // ChildSkills
100 UFormElm *arrayChildSkillElt = NULL;
101 if( SkillElt->getNodeByName( &arrayChildSkillElt, "ChildSkills" ) )
103 if( arrayChildSkillElt )
105 uint NbChildSkills;
106 nlverify( arrayChildSkillElt->getArraySize( NbChildSkills ) );
108 SkillsTree[ skill ].ChildSkills.resize( NbChildSkills );
110 for( uint i = 0; i < NbChildSkills; ++i )
112 string childSkillName;
113 arrayChildSkillElt->getArrayValue( childSkillName, i );
114 SKILLS::ESkills childSkill = SKILLS::toSkill( childSkillName );
115 nlassert( childSkill != SKILLS::unknown );
116 if (skill == SKILLS::unknown)
118 continue;
120 SkillsTree[ skill ].ChildSkills[ i ] = childSkill;