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/>.
23 #include "stdpch.h" // First include for pre-compiled headers.
25 #include "nel/georges/u_form_elm.h"
27 #include "player_sheet.h"
29 #include "game_share/skills.h"
30 #include "game_share/skills_build.h"
36 using namespace NLGEORGES
;
43 //-----------------------------------------------
46 //-----------------------------------------------
47 CPlayerSheet::CPlayerSheet()
51 // Initialize the type.
52 Type
= CEntitySheet::CHAR
;
55 //-----------------------------------------------
57 // Build the sheet from an external script.
58 //-----------------------------------------------
59 void CPlayerSheet::build(const NLGEORGES::UFormElm
&item
)
61 // Initialize the scale.
65 if(!item
.getValueByName(Gender
, "Gender"))
66 debug("Key 'Gender' not found.");
69 if(!item
.getValueByName(SkelFilename
, "Skel"))
70 debug("Key 'Skel' not found.");
72 // Load the Animation Set Base Name.
73 if(!item
.getValueByName(AnimSetBaseName
, "AnimSetBaseName"))
74 debug("Key 'AnimSetBaseName' not found.");
75 // Force the CASE in UPPER to not be CASE SENSITIVE.
77 AnimSetBaseName
= NLMISC::toLowerAscii(AnimSetBaseName
);
79 // Load Lod character name
80 if(!item
.getValueByName(LodCharacterName
, "LodCharacterName"))
81 debug("Key 'LodCharacterName' not found.");
83 // Load Lod character apparition distance
84 if(!item
.getValueByName(LodCharacterDistance
, "LodCharacterDistance"))
85 debug("Key 'LodCharacterDistance' not found.");
87 // Get the people of the player.
89 if(!item
.getValueByName(people
, "Peuple"))
91 debug("Key 'Peuple' not found.");
92 People
= EGSPD::CPeople::EndPeople
;
95 People
= EGSPD::CPeople::fromString(people
);
97 // Get the Default Player Face filename.
98 if(!item
.getValueByName(DefaultFace
, "DefaultFace"))
99 debug("Key 'DefaultFace' not found.");
100 // Get the Default Player Chest filename.
101 if(!item
.getValueByName(DefaultChest
, "DefaultChest"))
102 debug("Key 'DefaultChest' not found.");
103 // Get the Default Player Legs filename.
104 if(!item
.getValueByName(DefaultLegs
, "DefaultLegs"))
105 debug("Key 'DefaultLegs' not found.");
106 // Get the Default Player Arms filename.
107 if(!item
.getValueByName(DefaultArms
, "DefaultArms"))
108 debug("Key 'DefaultArms' not found.");
109 // Get the Default Player Hands filename.
110 if(!item
.getValueByName(DefaultHands
, "DefaultHands"))
111 debug("Key 'DefaultHands' not found.");
112 // Get the Default Player Feet filename.
113 if(!item
.getValueByName(DefaultFeet
, "DefaultFeet"))
114 debug("Key 'DefaultFeet' not found.");
115 // Get the Default Player Hair filename.
116 if(!item
.getValueByName(DefaultHair
, "DefaultHair"))
117 debug("Key 'DefaultHair' not found.");
120 if(!item
.getValueByName(DefaultHair
, "DefaultHair"))
121 debug("Key 'DefaultHair' not found.");
124 // NB: lod colors are given with panoply colors for players
127 // value to scale the "pos" channel of the animation of the player.
128 if(!item
.getValueByName(CharacterScalePos
, "CharacterScalePos"))
129 debug("Key 'CharacterScalePos' not found.");
131 #define PLAYER_SHEET_EQUIP "Basics.Equipment."
132 Body
.build(PLAYER_SHEET_EQUIP
"Body", item
);
133 Legs
.build(PLAYER_SHEET_EQUIP
"Legs", item
);
134 Arms
.build(PLAYER_SHEET_EQUIP
"Arms", item
);
135 Hands
.build(PLAYER_SHEET_EQUIP
"Hands", item
);
136 Feet
.build(PLAYER_SHEET_EQUIP
"Feet", item
);
137 Head
.build(PLAYER_SHEET_EQUIP
"Head", item
);
138 Face
.build(PLAYER_SHEET_EQUIP
"Face", item
);
139 ObjectInRightHand
.build(PLAYER_SHEET_EQUIP
"ObjectInRightHand", item
);
140 ObjectInLeftHand
.build(PLAYER_SHEET_EQUIP
"ObjectInLeftHand", item
);
141 Headdress
.build(PLAYER_SHEET_EQUIP
"Headdress", item
);
142 EarL
.build(PLAYER_SHEET_EQUIP
"EarL", item
);
143 EarR
.build(PLAYER_SHEET_EQUIP
"EarR", item
);
144 Neck
.build(PLAYER_SHEET_EQUIP
"Neck", item
);
145 Shoulders
.build(PLAYER_SHEET_EQUIP
"Shoulders", item
);
146 Back
.build(PLAYER_SHEET_EQUIP
"Back", item
);
147 WristL
.build(PLAYER_SHEET_EQUIP
"WristL", item
);
148 WristR
.build(PLAYER_SHEET_EQUIP
"WristR", item
);
149 FingerL
.build(PLAYER_SHEET_EQUIP
"FingerL", item
);
150 FingerR
.build(PLAYER_SHEET_EQUIP
"FingerR", item
);
151 AnkleR
.build(PLAYER_SHEET_EQUIP
"AnkleR", item
);
152 AnkleL
.build(PLAYER_SHEET_EQUIP
"AnkleL", item
);
153 Ammo
.build(PLAYER_SHEET_EQUIP
"Ammo", item
);
159 loadSkillsSummaryFromSheet(item
, "Basics.", Skills
);
163 //-----------------------------------------------
164 void CPlayerSheet::buildCharac(const NLGEORGES::UFormElm
&item
)
166 static const char characsBasePath
[] = "Basics.Characteristics.";
167 for(uint k
= 0; k
< CHARACTERISTICS::NUM_CHARACTERISTICS
; ++k
)
169 const std::string
&characName
= CHARACTERISTICS::toString((CHARACTERISTICS::TCharacteristics
)k
);
170 std::string characPath
= characsBasePath
+ characName
;
171 if(!item
.getValueByName(Characteristics
[k
], characPath
.c_str()))
173 debug("Key " + characName
+ "not found.");
174 Characteristics
[k
] = 0;
180 //-----------------------------------------------
182 // Serialize player sheet into binary data file.
183 //-----------------------------------------------
184 void CPlayerSheet::serial(NLMISC::IStream
&f
)
186 // Serialize class components.
187 f
.serial(SkelFilename
);
188 f
.serial(AnimSetBaseName
);
190 f
.serial(LodCharacterName
);
191 f
.serial(LodCharacterDistance
);
192 f
.serial(CharacterScalePos
);
193 f
.serialEnum(People
);
194 f
.serial(DefaultFace
);
195 f
.serial(DefaultChest
);
196 f
.serial(DefaultLegs
);
197 f
.serial(DefaultArms
);
198 f
.serial(DefaultHands
);
199 f
.serial(DefaultFeet
);
200 f
.serial(DefaultHair
);
210 f
.serial(ObjectInRightHand
);
211 f
.serial(ObjectInLeftHand
);
226 for(uint k
= 0; k
< CHARACTERISTICS::NUM_CHARACTERISTICS
; ++k
)
228 f
.serial(Characteristics
[k
]);
231 f
.serialCont(Skills
);
235 //=========================================================================================
236 void CPlayerSheet::CEquipment::build(const std::string
&key
,const NLGEORGES::UFormElm
&item
)
238 // Get the item (or shape) name.
240 if(!item
.getValueByName(itemName
, string(key
+ ".Item").c_str() ))
241 debug(NLMISC::toString("Key '%s.Item' not found.", key
.c_str()));
243 Item
= NLMISC::toLowerAscii(itemName
);
246 if(!item
.getValueByName(Color
, string(key
+ ".Color").c_str() ))
247 debug(NLMISC::toString("Key '%s.Color' not found.", key
.c_str()));