Accessory sorting due to price.
[scorched3d/parasti.git] / src / common / weapons / AccessoryStore.h
blob9757ade6eed5f874ac4fabedef4d7650c7b7f36e
1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
3 //
4 // This file is part of Scorched3D.
5 //
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #if !defined(AFX_ACCESSORYSTORE_H__6A964E56_3784_42FA_A900_2AB4B98F99A8__INCLUDED_)
22 #define AFX_ACCESSORYSTORE_H__6A964E56_3784_42FA_A900_2AB4B98F99A8__INCLUDED_
24 #include <list>
25 #include <vector>
26 #include <map>
27 #include <set>
28 #include <weapons/Weapon.h>
29 #include <weapons/Accessory.h>
30 #include <weapons/AccessoryCreateContext.h>
31 #include <common/ProgressCounter.h>
33 class XMLNode;
34 class AccessoryStore
36 public:
38 // This is mirrored by accessorySortKeyEnum in client/graph/OptionsDisplay.cpp.
40 enum SortKey
42 SortNothing = 0,
43 SortName = 1,
44 SortPrice = 2
47 AccessoryStore();
48 virtual ~AccessoryStore();
50 bool parseFile(ScorchedContext &context, ProgressCounter *counter = 0);
51 void clearAccessories();
53 Accessory *findByAccessoryId(unsigned int id);
54 Accessory *findByPrimaryAccessoryName(const char *name); // **careful there**
55 AccessoryPart *findAccessoryPartByAccessoryId(unsigned int id, const char *type);
56 AccessoryPart *createAccessoryPart(AccessoryCreateContext &context,
57 Accessory *parent, XMLNode *currentNode);
58 AccessoryPart *findByAccessoryPartId(unsigned int id);
60 Weapon *getDeathAnimation();
61 Weapon *getMuzzelFlash();
63 std::list<Accessory *> getAllAccessories(int sortKey=SortNothing);
64 std::list<Accessory *> getAllAccessoriesByTabGroup(const char *tabgroup, int sortKey=SortNothing);
65 std::map<std::string, XMLNode *> &getParsingNodes() { return parsingNodes_; }
66 std::set<std::string> &getTabGroupNames() { return tabGroups_; }
68 bool writeWeapon(NetBuffer &buffer, Weapon *weapon);
69 Weapon *readWeapon(NetBufferReader &reader);
70 bool writeAccessoryPart(NetBuffer &buffer, AccessoryPart *weapon);
71 AccessoryPart *readAccessoryPart(NetBufferReader &reader);
73 bool writeEconomyToBuffer(NetBuffer &buffer);
74 bool readEconomyFromBuffer(NetBufferReader &reader);
76 void sortList(std::list<Accessory *> &accList, int sortKey=SortNothing);
78 protected:
79 std::set<std::string> tabGroups_;
80 std::list<Accessory *> accessories_;
81 std::list<AccessoryPart *> accessoryParts_;
82 std::map<std::string, XMLNode *> parsingNodes_;
83 Weapon *muzzleFlash_;
84 Weapon *deathAnimation_;
88 #endif // !defined(AFX_ACCESSORYSTORE_H__6A964E56_3784_42FA_A900_2AB4B98F99A8__INCLUDED_)