Fix classique titles display
[ryzomcore.git] / ryzom / client / src / client_sheets / continent_sheet.cpp
blobaa2bdb142f989ce28169f01a00c4c6b5d9a5e4e6
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/>.
19 #include "stdpch.h"
20 #include "continent_sheet.h"
21 #include "game_share/georges_helper.h"
23 #include "nel/georges/u_form_elm.h"
24 #include "nel/georges/u_form.h"
25 #include "nel/georges/u_form_loader.h"
27 #include "nel/misc/smart_ptr.h"
29 using namespace NLMISC;
30 using namespace std;
31 using namespace NLGEORGES;
33 //=========================================================================
34 CContinentParameters::CContinentParameters()
36 Indoor = false;
38 EntitySunContributionPower = 0.0f;
39 EntitySunContributionMaxThreshold = 0.0f;
40 LandscapePointLightMaterial.set( 0, 0, 0, 255 );
42 FogStart = 0.0f;
43 FogEnd = 0.0f;
44 RootFogStart = 0.0f,
45 RootFogEnd = 0.0f;
47 for( uint32 i = 0; i < EGSPD::CSeason::Invalid; ++i )
49 TileColorMono[i] = false;
50 TileColorFactor[i] = 0.0f;
51 StaticLightingFactor[i] = 0.0f;
52 ForceDisplayedSeason[i] = (EGSPD::CSeason::TSeason)i;
56 //=========================================================================
57 CContinentSheet::CContinentSheet()
59 Type = CEntitySheet::CONTINENT;
62 //=========================================================================
63 void CContinentParameters::build(const NLGEORGES::UFormElm &item)
65 // Name.
66 item.getValueByName (Name, "Name");
68 // WorldMap
69 item.getValueByName (WorldMap, "WorldMap");
71 //Zone min/max
72 item.getValueByName (ZoneMin, "ZoneMin");
73 item.getValueByName (ZoneMax, "ZoneMax");
75 // Load Light Landscape Day.
76 const UFormElm *elm;
77 if (item.getNodeByName (&elm, "LightLandscapeDay") && elm)
78 LandscapeLightDay.build(*elm);
80 // Load Light Landscape Night.
81 if (item.getNodeByName (&elm, "LightLandscapeNight") && elm)
82 LandscapeLightNight.build(*elm);
84 // Load Light Landscape Dusk.
85 if (item.getNodeByName (&elm, "LightLandscapeDusk") && elm)
87 if (!LandscapeLightDusk.build(*elm)) LandscapeLightDusk.blend(LandscapeLightDay, LandscapeLightNight, 0.5f);
89 else LandscapeLightDusk.blend(LandscapeLightDay, LandscapeLightNight, 0.5f);
92 // Load Landscape PointLightMaterial
93 if (item.getNodeByName (&elm, "LandscapePointLightMaterial") && elm)
94 CGeorgesHelper::convert (LandscapePointLightMaterial, *elm);
95 else
96 LandscapePointLightMaterial= CRGBA::White;
98 // Load Light Entity Day.
99 if (item.getNodeByName (&elm, "LightEntityDay") && elm)
100 EntityLightDay.build(*elm);
103 // Load Light Entity Night.
104 if (item.getNodeByName (&elm, "LightEntityNight") && elm)
105 EntityLightNight.build(*elm);
107 // Load Light Entity Dusk
108 if (item.getNodeByName (&elm, "LightEntityDusk") && elm)
110 if (!EntityLightDusk.build(*elm)) EntityLightDusk.blend(EntityLightDay, EntityLightNight, 0.5f);
112 else EntityLightDusk.blend(EntityLightDay, EntityLightNight, 0.5f);
114 // Load Light Root Day.
115 if (item.getNodeByName (&elm, "LightRootDay") && elm)
116 RootLightDay.build(*elm);
118 // Load Light Root Night.
119 if (item.getNodeByName (&elm, "LightRootNight") && elm)
120 RootLightNight.build(*elm);
122 // Load Light Root Dusk
123 if (item.getNodeByName (&elm, "LightRootDusk") && elm)
125 if (!RootLightDusk.build(*elm)) RootLightDusk.blend(RootLightDay, RootLightNight, 0.5f);
127 else RootLightDusk.blend(RootLightDay, RootLightNight, 0.5f);
130 // Load Entity sun contribution power.
131 item.getValueByName (EntitySunContributionPower, "EntitySunPower");
133 // Load Entity sun contribution max threshold.
134 item.getValueByName (EntitySunContributionMaxThreshold, "EntitySunMaxThreshold");
136 // Load PACS RBank.
137 item.getValueByName (PacsRBank, "PacsRBank");
139 // Load PACS RBank.
140 item.getValueByName (PacsGR, "PacsGR");
142 // Load IG list filename.
143 item.getValueByName (LandscapeIG, "LandscapeIG");
145 // Load Sky day filename.
146 item.getValueByName (SkyDay, "SkyDay");
148 // Load Sky night filename.
149 item.getValueByName (SkyNight, "SkyNight");
151 // Load Sky fog part filename.
152 item.getValueByName (SkyFogPartName, "SkyFogPart");
154 // Load Sky ig filename.
155 item.getValueByName (BackgroundIGName, "SkyIg");
157 // Load IG for canopy for each season
158 for (uint season = 0; season < EGSPD::CSeason::Invalid; ++season)
160 item.getValueByName(CanopyIGfileName[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season) + "CanopyIG").c_str());
163 // Load the form
164 string filename;
165 if (item.getValueByName (filename, "Ecosystem"))
167 UFormLoader *loader = UFormLoader::createLoader();
168 if (loader)
170 // Load the form
171 CSmartPtr<UForm> form = loader->loadForm (filename.c_str ());
173 // Form loaded ?
174 if (form)
176 // Root node
177 elm = &form->getRootNode ();
179 // MicroVeget.
180 elm->getValueByName (MicroVeget, "MicroVeget");
182 // Small bank.
183 elm->getValueByName (SmallBank, "SmallBank");
185 // Far bank.
186 elm->getValueByName (FarBank, "FarBank");
188 // Coarse mesh texture.
189 elm->getValueByName (CoarseMeshMap, "CoarseMeshMap");
191 else
193 nlwarning("CContinent::build : Can't load form %s.", filename.c_str());
195 UFormLoader::releaseLoader(loader);
199 // Load all "Zone Constructible".
200 if(item.getNodeByName(&elm, "ZCs") && elm)
202 // Get number of ZC
203 uint nbZC;
204 if(elm->getArraySize(nbZC))
206 // For each village
207 for(uint i = 0; i < nbZC; ++i)
209 // Village pointer
210 const UFormElm *zc;
211 if(elm->getArrayNode(&zc, i) && zc)
213 // Get the zone associated.
214 CZC zone;
215 zone.EnableRuins= true;
216 if(!zc->getValueByName(zone.Name, "Zone"))
217 nlwarning("CContinent::build : key 'Zone' not found.");
218 if(!zc->getValueByName(zone.ForceLoadDist, "ForceLoadDist"))
219 nlwarning("CContinent::build : key 'ForceLoadDist' not found.");
220 if(!zc->getValueByName(zone.LoadDist, "LoadDist"))
221 nlwarning("CContinent::build : key 'LoadDist' not found.");
222 if(!zc->getValueByName(zone.UnloadDist, "UnloadDist"))
223 nlwarning("CContinent::build : key 'UnloadDist' not found.");
224 if(!zc->getValueByName(zone.EnableRuins, "EnableRuins"))
225 nlwarning("CContinent::build : key 'EnableRuins' not found.");
227 ZCList.push_back(zone);
231 else
232 nlwarning("CContinent::build : it seems 'ZCs' is not an array.");
235 // build fog map descriptor
236 buildFogMapBuild(item);
238 // Load Sky ig filename.
239 item.getValueByName (Indoor, "Indoor");
242 // Load the landmark list
244 if(item.getNodeByName (&elm, "LandMarks") && elm)
246 // Get number of village
247 uint numLandMarks;
248 nlverify (elm->getArraySize (numLandMarks));
249 LandMarks.resize(numLandMarks);
251 // For each village
252 for(uint k = 0; k < numLandMarks; ++k)
254 // Village pointer
255 const UFormElm *landMarkForm;
256 if (elm->getArrayNode (&landMarkForm, k) && landMarkForm)
258 LandMarks[k].build(*landMarkForm);
263 // LocalizedName
264 item.getValueByName (LocalizedName, "LocalizedName");
266 // Micro-life primitives
267 if(item.getNodeByName(&elm, "MicroLifePrimitives") && elm)
269 // Get number of prims
270 uint numPrims;
271 if(elm->getArraySize(numPrims))
273 // For each prims
274 for(uint i = 0; i < numPrims; ++i)
276 std::string primFilename;
277 if (elm->getArrayValue(primFilename, i))
279 MicroLifeZones.push_back(primFilename);
283 else
284 nlwarning("CContinent::build : it seems 'ZCs' is not an array.");
287 // Read Season related parameters
288 for (uint season = 0; season < EGSPD::CSeason::Invalid; ++season)
290 item.getValueByName(TileColorMono[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season) + "TileColorMono").c_str());
291 item.getValueByName(TileColorFactor[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season ) + "TileColorFactor").c_str());
292 item.getValueByName(StaticLightingFactor[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season ) + "StaticLightingFactor").c_str());
293 item.getValueByName(SkySheet[season], ("SkySheet" + EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season )).c_str());
295 // A continent may want to force some season instead another. read it
296 ForceDisplayedSeason[season]= (EGSPD::CSeason::TSeason)season;
297 string strSeason;
298 item.getValueByName(strSeason, ("DisplayedSeasonFor" + EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season)).c_str());
299 EGSPD::CSeason::TSeason readSeason= ForceDisplayedSeason[season]= EGSPD::CSeason::fromString(strSeason);
300 if(readSeason<EGSPD::CSeason::Invalid)
301 ForceDisplayedSeason[season]= readSeason;
306 void CContinentParameters::buildFogMapBuild(const NLGEORGES::UFormElm &item)
308 item.getValueByName (FogMapBuild.Map[CFogMapBuild::Day], "FogDayMap");
309 item.getValueByName (FogMapBuild.Map[CFogMapBuild::Night], "FogNightMap");
310 item.getValueByName (FogMapBuild.Map[CFogMapBuild::Distance], "FogDistMap");
311 item.getValueByName (FogMapBuild.Map[CFogMapBuild::Depth], "FogDepthMap");
312 item.getValueByName (FogMapBuild.Map[CFogMapBuild::NoPrecipitation], "NoRainMap");
313 item.getValueByName (FogStart, "FogStart");
314 item.getValueByName (FogEnd, "FogEnd");
315 item.getValueByName (FogMapBuild.ZoneMin, "ZoneMin");
316 item.getValueByName (FogMapBuild.ZoneMax, "ZoneMax");
317 if (FogStart > FogEnd)
319 std::swap(FogStart, FogEnd);
321 if (!item.getValueByName (RootFogStart, "RootFogStart"))
323 RootFogStart = FogStart;
325 if (!item.getValueByName (RootFogEnd, "RootFogEnd"))
327 RootFogEnd = FogEnd;
329 if (RootFogStart > RootFogEnd)
331 std::swap(RootFogStart, RootFogEnd);
336 //=========================================================================
337 void CContinentParameters::serial(NLMISC::IStream &f)
339 f.serial(Name);
340 f.serial(PacsRBank);
341 f.serial(PacsGR);
342 f.serial(LandscapeIG);
343 f.serial(SkyDay);
344 f.serial(SkyNight);
345 f.serial(SkyFogPartName);
346 f.serial(BackgroundIGName);
348 for(uint k = 0; k < EGSPD::CSeason::Invalid; ++k)
350 f.serial(CanopyIGfileName[k]);
353 f.serial(MicroVeget);
354 f.serial(SmallBank);
355 f.serial(FarBank);
356 f.serial(CoarseMeshMap);
357 f.serial(EntitySunContributionPower);
358 f.serial(EntitySunContributionMaxThreshold);
359 f.serial(LandscapeLightDay);
360 f.serial(LandscapeLightDusk);
361 f.serial(LandscapeLightNight);
362 f.serial(LandscapePointLightMaterial);
363 f.serial(EntityLightDay);
364 f.serial(EntityLightDusk);
365 f.serial(EntityLightNight);
366 f.serial(RootLightDay);
367 f.serial(RootLightDusk);
368 f.serial(RootLightNight);
370 f.serialCont(ZCList);
372 f.serial(FogMapBuild);
373 f.serial(FogStart);
374 f.serial(FogEnd);
375 f.serial(RootFogStart);
376 f.serial(RootFogEnd);
377 f.serial(Indoor);
379 f.serial(WorldMap);
380 //f.serialCont(LandMarks);
381 f.serial(LocalizedName);
383 f.serialCont(MicroLifeZones);
385 f.serial(ZoneMin);
386 f.serial(ZoneMax);
388 for (uint i = 0; i < EGSPD::CSeason::Invalid; ++i)
390 f.serial(TileColorMono[i]);
391 f.serial(TileColorFactor[i]);
392 f.serial(StaticLightingFactor[i]);
393 f.serial(SkySheet[i]);
394 f.serialEnum(ForceDisplayedSeason[i]);
398 //=========================================================================
400 void CContinentParameters::CZC::serial(NLMISC::IStream &f)
402 f.serial (Name);
403 f.serial (ForceLoadDist);
404 f.serial (LoadDist);
405 f.serial (UnloadDist);
406 f.serial (EnableRuins);
409 //=========================================================================
410 void CContinentSheet::build(const NLGEORGES::UFormElm &item)
412 Continent.build(item);
413 const UFormElm *elm;
414 // Load the village list
415 if(item.getNodeByName (&elm, "Villages") && elm)
417 // Get number of village
418 uint numVillage;
419 nlverify (elm->getArraySize (numVillage));
420 Villages.resize(numVillage);
422 // For each village
423 for(uint k = 0; k < numVillage; ++k)
425 // Village pointer
426 const UFormElm *villageForm;
427 if (elm->getArrayNode (&villageForm, k) && villageForm)
429 Villages[k].build(*villageForm);
430 elm->getArrayNodeName(Villages[k].Name, k);
434 // load the weather functions
435 // Build season descriptor
436 static const char *seasonFuncName[] =
438 "SpringWeatherFunction",
439 "SummerWeatherFunction",
440 "AutumnWeatherFunction",
441 "WinterWeatherFunction"
443 // added - 1 because there is an invalid season
444 nlctassert(sizeof(seasonFuncName) / sizeof(seasonFuncName[0]) == EGSPD::CSeason::Invalid );
446 // Load weather functions & sky sheets
447 for(uint k = 0; k < EGSPD::CSeason::Invalid; ++k)
449 const NLGEORGES::UFormElm *elm;
450 if (item.getNodeByName(&elm, seasonFuncName[k]) && elm)
452 WeatherFunction[k].build(*elm);
458 //=========================================================================
459 void CContinentSheet::serial(NLMISC::IStream &f)
461 f.serial(Continent);
462 f.serialCont(Villages);
463 for(uint k = 0; k < EGSPD::CSeason::Invalid; ++k)
465 f.serial(WeatherFunction[k]);
469 //=========================================================================
470 /*void CLandMark::build(const NLGEORGES::UFormElm &item)
472 item.getValueByName(Pos.x, "X");
473 item.getValueByName(Pos.y, "Y");
474 item.getValueByName(TitleTextID, "Name");
477 //=========================================================================
478 void CLandMark::serial(NLMISC::IStream &f)
480 f.serial(Pos, TitleTextID);