Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / client_sheets / player_sheet.cpp
blob999b683c6f523acbbb8ad99349b1a0346fd0ffc6
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) 2020 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/>.
23 /////////////
24 // INCLUDE //
25 /////////////
26 #include "stdpch.h" // First include for pre-compiled headers.
27 // Georges
28 #include "nel/georges/u_form_elm.h"
29 // Client.
30 #include "player_sheet.h"
31 // Game share
32 #include "game_share/skills.h"
33 #include "game_share/skills_build.h"
36 ///////////
37 // USING //
38 ///////////
39 using namespace NLGEORGES;
40 using namespace std;
43 /////////////
44 // METHODS //
45 /////////////
46 //-----------------------------------------------
47 // CPlayerSheet :
48 // Constructor.
49 //-----------------------------------------------
50 CPlayerSheet::CPlayerSheet()
52 CharacterScalePos= 1;
53 Gender=0;
54 // Initialize the type.
55 Type = CEntitySheet::CHAR;
56 }// CPlayerSheet //
58 //-----------------------------------------------
59 // build :
60 // Build the sheet from an external script.
61 //-----------------------------------------------
62 void CPlayerSheet::build(const NLGEORGES::UFormElm &item)
64 // Initialize the scale.
65 Scale = 1.f;
67 // Player Gender.
68 if(!item.getValueByName(Gender, "Gender"))
69 debug("Key 'Gender' not found.");
71 // Get the skel.
72 if(!item.getValueByName(SkelFilename, "Skel"))
73 debug("Key 'Skel' not found.");
75 // Load the Animation Set Base Name.
76 if(!item.getValueByName(AnimSetBaseName, "AnimSetBaseName"))
77 debug("Key 'AnimSetBaseName' not found.");
78 // Force the CASE in UPPER to not be CASE SENSITIVE.
79 else
80 AnimSetBaseName = NLMISC::toLowerAscii(AnimSetBaseName);
82 // Load Lod character name
83 if(!item.getValueByName(LodCharacterName, "LodCharacterName"))
84 debug("Key 'LodCharacterName' not found.");
86 // Load Lod character apparition distance
87 if(!item.getValueByName(LodCharacterDistance, "LodCharacterDistance"))
88 debug("Key 'LodCharacterDistance' not found.");
90 // Get the people of the player.
91 string people;
92 if(!item.getValueByName(people, "Peuple"))
94 debug("Key 'Peuple' not found.");
95 People = EGSPD::CPeople::EndPeople;
97 else
98 People = EGSPD::CPeople::fromString(people);
100 // Get the Default Player Face filename.
101 if(!item.getValueByName(DefaultFace, "DefaultFace"))
102 debug("Key 'DefaultFace' not found.");
103 // Get the Default Player Chest filename.
104 if(!item.getValueByName(DefaultChest, "DefaultChest"))
105 debug("Key 'DefaultChest' not found.");
106 // Get the Default Player Legs filename.
107 if(!item.getValueByName(DefaultLegs, "DefaultLegs"))
108 debug("Key 'DefaultLegs' not found.");
109 // Get the Default Player Arms filename.
110 if(!item.getValueByName(DefaultArms, "DefaultArms"))
111 debug("Key 'DefaultArms' not found.");
112 // Get the Default Player Hands filename.
113 if(!item.getValueByName(DefaultHands, "DefaultHands"))
114 debug("Key 'DefaultHands' not found.");
115 // Get the Default Player Feet filename.
116 if(!item.getValueByName(DefaultFeet, "DefaultFeet"))
117 debug("Key 'DefaultFeet' not found.");
118 // Get the Default Player Hair filename.
119 if(!item.getValueByName(DefaultHair, "DefaultHair"))
120 debug("Key 'DefaultHair' not found.");
122 // get carac
123 if(!item.getValueByName(DefaultHair, "DefaultHair"))
124 debug("Key 'DefaultHair' not found.");
127 // NB: lod colors are given with panoply colors for players
130 // value to scale the "pos" channel of the animation of the player.
131 if(!item.getValueByName(CharacterScalePos, "CharacterScalePos"))
132 debug("Key 'CharacterScalePos' not found.");
134 #define PLAYER_SHEET_EQUIP "Basics.Equipment."
135 Body.build(PLAYER_SHEET_EQUIP "Body", item);
136 Legs.build(PLAYER_SHEET_EQUIP "Legs", item);
137 Arms.build(PLAYER_SHEET_EQUIP "Arms", item);
138 Hands.build(PLAYER_SHEET_EQUIP "Hands", item);
139 Feet.build(PLAYER_SHEET_EQUIP "Feet", item);
140 Head.build(PLAYER_SHEET_EQUIP "Head", item);
141 Face.build(PLAYER_SHEET_EQUIP "Face", item);
142 ObjectInRightHand.build(PLAYER_SHEET_EQUIP "ObjectInRightHand", item);
143 ObjectInLeftHand.build(PLAYER_SHEET_EQUIP "ObjectInLeftHand", item);
144 Headdress.build(PLAYER_SHEET_EQUIP "Headdress", item);
145 EarL.build(PLAYER_SHEET_EQUIP "EarL", item);
146 EarR.build(PLAYER_SHEET_EQUIP "EarR", item);
147 Neck.build(PLAYER_SHEET_EQUIP "Neck", item);
148 Shoulders.build(PLAYER_SHEET_EQUIP "Shoulders", item);
149 Back.build(PLAYER_SHEET_EQUIP "Back", item);
150 WristL.build(PLAYER_SHEET_EQUIP "WristL", item);
151 WristR.build(PLAYER_SHEET_EQUIP "WristR", item);
152 FingerL.build(PLAYER_SHEET_EQUIP "FingerL", item);
153 FingerR.build(PLAYER_SHEET_EQUIP "FingerR", item);
154 AnkleR.build(PLAYER_SHEET_EQUIP "AnkleR", item);
155 AnkleL.build(PLAYER_SHEET_EQUIP "AnkleL", item);
156 Ammo.build(PLAYER_SHEET_EQUIP "Ammo", item);
158 // build charac
159 buildCharac(item);
161 // load skills
162 loadSkillsSummaryFromSheet(item, "Basics.", Skills);
163 }// build //
166 //-----------------------------------------------
167 void CPlayerSheet::buildCharac(const NLGEORGES::UFormElm &item)
169 static const char characsBasePath[] = "Basics.Characteristics.";
170 for(uint k = 0; k < CHARACTERISTICS::NUM_CHARACTERISTICS; ++k)
172 const std::string &characName = CHARACTERISTICS::toString((CHARACTERISTICS::TCharacteristics)k);
173 std::string characPath = characsBasePath + characName;
174 if(!item.getValueByName(Characteristics[k], characPath.c_str()))
176 debug("Key " + characName + "not found.");
177 Characteristics[k] = 0;
183 //-----------------------------------------------
184 // serial :
185 // Serialize player sheet into binary data file.
186 //-----------------------------------------------
187 void CPlayerSheet::serial(NLMISC::IStream &f)
189 // Serialize class components.
190 f.serial(SkelFilename);
191 f.serial(AnimSetBaseName);
192 f.serial(Scale);
193 f.serial(LodCharacterName);
194 f.serial(LodCharacterDistance);
195 f.serial(CharacterScalePos);
196 f.serialEnum(People);
197 f.serial(DefaultFace);
198 f.serial(DefaultChest);
199 f.serial(DefaultLegs);
200 f.serial(DefaultArms);
201 f.serial(DefaultHands);
202 f.serial(DefaultFeet);
203 f.serial(DefaultHair);
204 f.serial(Gender);
205 // equipment
206 f.serial(Body);
207 f.serial(Legs);
208 f.serial(Arms);
209 f.serial(Hands);
210 f.serial(Feet);
211 f.serial(Head);
212 f.serial(Face);
213 f.serial(ObjectInRightHand);
214 f.serial(ObjectInLeftHand);
215 f.serial(Headdress);
216 f.serial(EarL);
217 f.serial(EarR);
218 f.serial(Neck);
219 f.serial(Shoulders);
220 f.serial(Back);
221 f.serial(WristL);
222 f.serial(WristR);
223 f.serial(FingerL);
224 f.serial(FingerR);
225 f.serial(AnkleL);
226 f.serial(AnkleR);
227 f.serial(Ammo);
229 for(uint k = 0; k < CHARACTERISTICS::NUM_CHARACTERISTICS; ++k)
231 f.serial(Characteristics[k]);
234 f.serialCont(Skills);
235 }// serial //
238 //=========================================================================================
239 void CPlayerSheet::CEquipment::build(const std::string &key,const NLGEORGES::UFormElm &item)
241 // Get the item (or shape) name.
242 string itemName;
243 if(!item.getValueByName(itemName, string(key + ".Item").c_str() ))
244 debug(NLMISC::toString("Key '%s.Item' not found.", key.c_str()));
245 else
246 Item = NLMISC::toLowerAscii(itemName);
248 // Get the color.
249 if(!item.getValueByName(Color, string(key + ".Color").c_str() ))
250 debug(NLMISC::toString("Key '%s.Color' not found.", key.c_str()));