Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / client / src / client_sheets / outpost_building_sheet.cpp
blob8c54bc9fdf87dee3986d4921a60ecf8890947172
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/>.
20 #include "stdpch.h"
21 #include "outpost_building_sheet.h"
23 #include "nel/georges/u_form_elm.h"
25 using namespace std;
26 using namespace NLMISC;
27 using namespace NLGEORGES;
30 // ****************************************************************************
31 COutpostBuildingSheet::TOBType COutpostBuildingSheet::fromString( const string & str )
33 if (str == "TownHall") return OB_TownHall;
34 if (str == "Driller") return OB_Driller;
35 return OB_Empty;
38 // ****************************************************************************
39 string COutpostBuildingSheet::toString( TOBType type )
41 if (type == OB_TownHall) return "TownHall";
42 if (type == OB_Driller) return "Driller";
43 return "Empty";
46 // ****************************************************************************
47 COutpostBuildingSheet::COutpostBuildingSheet()
49 Type = CEntitySheet::OUTPOST_BUILDING;
51 CostDapper = 0;
52 CostTime = 0;
53 MPLevelOfHighestExtractRate = 0;
54 IdIconMain = 0;
55 IdIconBack = 0;
56 IdIconOver = 0;
57 IdIconText = 0;
60 // ****************************************************************************
61 void COutpostBuildingSheet::build(const NLGEORGES::UFormElm &root)
63 string sType;
64 root.getValueByName (sType, "type");
65 OBType = fromString(sType);
66 root.getValueByName(CostDapper, "cost_dapper");
67 root.getValueByName(CostTime, "cost_time");
69 // Driller
70 Mps.clear();
71 if (OBType == OB_Driller)
73 MPLevelOfHighestExtractRate= 50;
75 const UFormElm *pDriller;
76 if (root.getNodeByName(&pDriller, "driller") && pDriller)
78 // Get Mps sheets
79 const UFormElm *pMp;
80 uint32 i = 0;
81 while (pDriller->getNodeByName(&pMp, "mp" + NLMISC::toString(i)) && pMp)
83 string sTmp;
84 pMp->getValueByName(sTmp, "name");
85 CSheetId sheetId(sTmp);
86 if(sheetId!=CSheetId::Unknown)
87 Mps.push_back(sheetId);
88 i++;
91 // Get best mp level
92 float bestRate= 0.f;
93 for(uint i=50;i<=250;i+=50)
95 float tmp= 0;
96 if(pDriller->getValueByName(tmp, NLMISC::toString("quality_%03d", i).c_str()))
98 if(tmp>bestRate)
100 bestRate= tmp;
101 MPLevelOfHighestExtractRate= i;
106 else
108 debug("key 'driller' not found.");
112 // Get the icon associated.
113 string IconMain;
114 if(!root.getValueByName (IconMain, "icon"))
115 debug("key 'icon' not found.");
116 IconMain = toLowerAscii(IconMain);
117 IdIconMain = ClientSheetsStrings.add(IconMain);
119 // Get the icon associated.
120 string IconBack;
121 if(!root.getValueByName (IconBack, "icon background"))
122 debug("key 'icon background' not found.");
123 IconBack = toLowerAscii(IconBack);
124 IdIconBack = ClientSheetsStrings.add(IconBack);
126 // Get the icon associated.
127 string IconOver;
128 if(!root.getValueByName (IconOver, "icon overlay"))
129 debug("key 'icon overlay' not found.");
130 IconOver = toLowerAscii(IconOver);
131 IdIconOver = ClientSheetsStrings.add(IconOver);
133 // Get the icon text associated.
134 string IconText;
135 if(!root.getValueByName (IconText, "text overlay"))
136 debug("key 'text overlay' not found.");
137 IdIconText = ClientSheetsStrings.add(IconText);
140 // ****************************************************************************
141 void COutpostBuildingSheet::serial(NLMISC::IStream &f)
143 f.serialEnum(OBType);
144 f.serial(CostDapper);
145 f.serial(CostTime);
146 f.serial(MPLevelOfHighestExtractRate);
147 f.serialCont(Mps);
148 ClientSheetsStrings.serial(f, IdIconMain);
149 ClientSheetsStrings.serial(f, IdIconBack);
150 ClientSheetsStrings.serial(f, IdIconOver);
151 ClientSheetsStrings.serial(f, IdIconText);