Fix classique titles display
[ryzomcore.git] / ryzom / client / src / sheet_manager.h
blobca9c574873da053bfd2127d38f2dea6c5a7cd1cf
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 #ifndef CL_SHEET_MANAGER_H
20 #define CL_SHEET_MANAGER_H
23 /////////////
24 // INCLUDE //
25 /////////////
26 // Misc
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/smart_ptr.h"
29 #include "nel/misc/progress_callback.h"
30 // Application
31 #include "client_sheets/entity_sheet.h"
32 #include "client_sheets/character_sheet.h"
33 #include "client_sheets/player_sheet.h"
34 #include "client_sheets/fx_sheet.h"
35 #include "client_sheets/forage_source_sheet.h"
36 #include "client_sheets/building_sheet.h"
37 #include "client_sheets/item_sheet.h"
38 #include "client_sheets/pact_sheet.h"
39 #include "client_sheets/plant_sheet.h"
40 #include "client_sheets/mission_sheet.h"
41 #include "client_sheets/mission_icon_sheet.h"
42 #include "client_sheets/race_stats_sheet.h"
43 #include "client_sheets/light_cycle_sheet.h"
44 #include "client_sheets/weather_setup_sheet.h"
45 #include "client_sheets/continent_sheet.h"
46 #include "client_sheets/world_sheet.h"
47 #include "client_sheets/weather_function_params_sheet.h"
48 #include "client_sheets/sbrick_sheet.h"
49 #include "client_sheets/sphrase_sheet.h"
50 #include "client_sheets/skills_tree_sheet.h"
51 #include "client_sheets/unblock_titles_sheet.h"
52 #include "client_sheets/success_table_sheet.h"
53 #include "client_sheets/automaton_list_sheet.h"
54 #include "client_sheets/animation_fx_sheet.h"
55 #include "client_sheets/id_to_string_array.h"
56 #include "client_sheets/emot_list_sheet.h"
57 #include "client_sheets/flora_sheet.h"
58 #include "client_sheets/attack_list_sheet.h"
59 #include "client_sheets/sky_sheet.h"
60 #include "client_sheets/text_emot_list_sheet.h"
61 #include "client_sheets/outpost_sheet.h"
62 #include "client_sheets/outpost_building_sheet.h"
63 #include "client_sheets/outpost_squad_sheet.h"
66 // game share
67 #include "game_share/slot_types.h"
68 #include "game_share/skills.h"
69 // Std
70 #include <map>
71 #include <string>
74 ///////////
75 // CLASS //
76 ///////////
77 namespace NLMISC
79 class CSheetId;
82 namespace NLGEORGES
84 class UFormLoader;
85 class UForm;
88 /**
89 * Class to manage all sheets.
90 * \author Guillaume PUZIN
91 * \author Nevrax France
92 * \date 2001
94 class CSheetManagerEntry
97 public:
98 /// The data which will be filled in readGeorges and serial
99 CEntitySheet *EntitySheet;
101 public:
103 /// Constructor
104 CSheetManagerEntry ();
105 virtual ~CSheetManagerEntry ();
107 /// Load the values using the george sheet
108 void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId);
110 /// Load/Save the values using the serial system
111 void serial (NLMISC::IStream &s);
112 // Useful for serial
113 void initSheet (CEntitySheet *pES, NLMISC::IStream &s, CEntitySheet::TType type);
117 * Event to implement any action when the sheet is no longer existent.
118 * This method is called when a sheet have been read from the packed sheet
119 * and the associated sheet file no more exist in the directories.
121 void removed();
123 static uint getVersion();
124 static void setVersion(uint version);
128 * Class to manage all sheets.
129 * \author Guillaume PUZIN
130 * \author Nevrax France
131 * \date 2001
133 class CSheetManager
135 friend class CSheetManagerEntry;
137 protected:
138 sint _NbEyesColor;
139 sint _NbHairColor;
141 public:
143 /// this is the structure that hold all the sheets needed
144 typedef std::map<NLMISC::CSheetId, CSheetManagerEntry> TEntitySheetMap;
146 typedef std::pair<SLOTTYPE::EVisualSlot, uint> TVisualSlotItem;
147 typedef std::vector<TVisualSlotItem> TVisualSlotItemArray;
149 public:
150 /// A ptr on a form loader
151 static NLGEORGES::UFormLoader *FormLoader;
153 public:
154 /// Constructor
155 CSheetManager();
156 /// Destructor
157 ~CSheetManager();
159 // release memory
160 void release();
162 /// Load all sheets.
163 /// \param needComputeVS : if 'true' this will compute the visual slot file too.
164 void load (NLMISC::IProgressCallback &callBack, bool updatePackedSheet, bool needComputeVS = false, bool dumpVSIndex = false);
165 /// Load all sheet or a subset of them (if 'extensions' is not NULL, them the extensions list is taken from that vector)
166 void loadAllSheet(NLMISC::IProgressCallback &callBack, bool updatePackedSheet, bool needComputeVS, bool dumpVSIndex, bool forceRecompute = false, const std::vector<std::string> *extensions = NULL);
167 /// Load all sheet, without packed sheet, and with a wildcard (for reload feature)
168 void loadAllSheetNoPackedSheet(NLMISC::IProgressCallback &callBack, const std::vector<std::string> &extensions, const std::string &wildcardFilter);
171 * Get a sheet from is number.
172 * \param CSheetId num : sheet number.
173 * \return CEntitySheet * : pointer on the sheet according to the param or 0 if any pb.
175 CEntitySheet *get(NLMISC::CSheetId num);
177 /// Get the number of available items for the given visual slot
178 uint getNumItem(SLOTTYPE::EVisualSlot slot);
180 /// Get the pointer on an item form from an index.
181 CItemSheet *getItem(SLOTTYPE::EVisualSlot slot, uint index);
183 // Get a pair of visual slots / index from a CItemSheet pointer.
184 const TVisualSlotItemArray *getVSItems(CItemSheet *sheet) const;
186 // From an item name and a slot, get its item, or -1 if not found
187 sint getVSIndex(const std::string &itemName, SLOTTYPE::EVisualSlot slot);
189 /// Return the number of color available for the eyes.
190 sint nbEyesColor() {return _NbEyesColor;}
191 /// Return the number of color available for the hair.
192 sint nbHairColor() {return _NbHairColor;}
195 /// Get all sheets (useful for other managers (skill, brick, ...))
196 // @{
197 const TEntitySheetMap & getSheets() { return _EntitySheetContainer; }
198 // @}
200 // tmp : dump the visual slots
201 void dumpVisualSlots();
203 /// dump all visual slots indexes in a file
204 void dumpVisualSlotsIndex();
206 /// Set output data path
207 void setOutputDataPath(const std::string &dataPath) { _OutputDataPath = dataPath; }
209 /// Return output data path
210 const std::string& getOutputDataPath() const { return _OutputDataPath; }
212 /// Return the rp item
213 const std::string &getRpItem(uint32 id) const
215 if (_RPItems.size() > id) {
216 return _RPItems[id];
218 static const std::string empty;
219 return empty;
222 /// Add rp item
223 void addRpItem(const std::string &item)
225 _RPItems.push_back(item);
229 private:
230 typedef std::vector<CItemSheet *> TItemVector;
231 typedef std::vector<TItemVector> TSlots;
232 typedef std::vector<std::string> TRPitems;
233 TSlots _VisualSlots;
234 TRPitems _RPItems;
236 // directory where to create .packed_sheets
237 std::string _OutputDataPath;
240 protected:
242 /// this structure is fill by the loadForm() function and will contain all the sheets needed
243 TEntitySheetMap _EntitySheetContainer;
246 typedef std::map<CItemSheet *, TVisualSlotItemArray> TItemSheet2SlotItemArray;
248 // Associate sheet to visual slots
249 TItemSheet2SlotItemArray _SheetToVS;
251 protected:
252 /** Processing the sheet.
253 * \param sheet : sheet to process.
255 void processSheet (CEntitySheet *sheet);
256 /// compute Visual Slots for this sheet.
257 void computeVS();
259 void loadTyp();
263 ////////////
264 // EXTERN //
265 ////////////
266 // Sheet manager.
267 extern CSheetManager SheetMngr;
270 #endif // CL_SHEET_MANAGER_H
272 /* End of sheet_manager.h */