1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
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.
10 //
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.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(AFX_ACCESSORY_H__21765D5B_DB45_4275_AB63_BAD1E84C1790__INCLUDED_)
22 #define AFX_ACCESSORY_H__21765D5B_DB45_4275_AB63_BAD1E84C1790__INCLUDED_
23 
24 #include <common/ToolTip.h>
25 #include <common/ModelID.h>
26 #include <XML/XMLFile.h>
27 #include <weapons/AccessoryPart.h>
28 #include <weapons/AccessoryCreateContext.h>
29 #include <lang/LangString.h>
30 #include <string>
31 #include <map>
32 
33 #ifndef S3D_SERVER
34 #include <GLEXT/GLTextureReference.h>
35 #endif
36 
37 class Tank;
38 class MissileMesh;
39 class Accessory
40 {
41 public:
42 	Accessory();
43 	virtual ~Accessory();
44 
45 	enum PositionSelectType
46 	{
47 		ePositionSelectNone = 0,
48 		ePositionSelectFuel = 1,
49 		ePositionSelectGeneric = 2,
50 		ePositionSelectLimit = 3,
51 		ePositionSelectFuelLimit = 4
52 	};
53 
54 	bool parseXML(AccessoryCreateContext &context, XMLNode *accessoryNode);
55 
56 	const char *getActivationSound();
getName()57 	const char *getName() { return name_.c_str(); }
58 	LangString &getStringName();
getDescription()59 	const char *getDescription() { return description_.c_str(); }
getPrice()60 	int getPrice() { return price_; }
getSellPrice()61 	int getSellPrice() { return sellPrice_; }
getOriginalSellPrice()62 	int getOriginalSellPrice() { return originalSellPrice_; }
getOriginalPrice()63 	int getOriginalPrice() { return originalPrice_; }
getFreeMarketLimits()64 	int getFreeMarketLimits() { return freemarketLimits_; }
getBundle()65 	int getBundle() { return bundle_; }
getArmsLevel()66 	int getArmsLevel() { return armsLevel_; }
getMaximumNumber()67 	int getMaximumNumber() { return maximumNumber_; }
getStartingNumber()68 	int getStartingNumber() { return startingNumber_; }
getUseNumber()69 	int getUseNumber() { return useNumber_; }
getAIOnly()70 	bool getAIOnly() { return aiOnly_; }
getBotOnly()71 	bool getBotOnly() { return botOnly_; }
getNoBuy()72 	bool getNoBuy() { return noBuy_; }
getPositionSelect()73 	PositionSelectType getPositionSelect() { return positionSelect_; }
getPositionSelectLimit()74 	int getPositionSelectLimit() { return positionSelectLimit_; }
75 
getToolTip()76 	ToolTip &getToolTip() { return toolTip_; }
getIconName()77 	const char *getIconName() { return iconName_.c_str(); }
getGroupName()78 	const char *getGroupName() { return groupName_.c_str(); }
getTabGroupName()79 	const char *getTabGroupName() { return tabGroupName_.c_str(); }
getAction()80 	AccessoryPart *getAction() { return accessoryAction_; }
getModelScale()81 	fixed getModelScale() { return modelScale_; }
getModel()82 	ModelID &getModel() { return modelId_; }
getMuzzleFlash()83 	bool getMuzzleFlash() { return muzzleFlash_; }
84 
getType()85 	AccessoryPart::AccessoryType getType() { return accessoryAction_->getType(); }
86 
setPrice(int p)87 	void setPrice(int p) { if (p>0) price_ = p; }
setSellPrice(int p)88 	void setSellPrice(int p) { if (p>0) sellPrice_ = p; }
89 
resetAccessoryIds()90 	static void resetAccessoryIds() { nextAccessoryId_ = 0; }
getAccessoryId()91 	unsigned int getAccessoryId() { return accessoryId_; }
92 
93 #ifndef S3D_SERVER
getTexture()94 	GLTextureReference &getTexture() { return texture_; }
95 	static MissileMesh *getWeaponMesh(ModelID &id, Tank *currentPlayer);
96 	static std::map<std::string, MissileMesh *> loadedMeshes_;
97 	GLTextureReference texture_;
98 #endif
99 
100 protected:
101 	static unsigned int nextAccessoryId_;
102 	unsigned int accessoryId_;
103 	bool aiOnly_;
104 	bool botOnly_;
105 	bool noBuy_;
106 	AccessoryPart *accessoryAction_;
107 	PositionSelectType positionSelect_;
108 	ToolTip toolTip_;
109 	ModelID modelId_;
110 	LangString stringName_;
111 	std::string iconName_;
112 	std::string groupName_, tabGroupName_;
113 	std::string name_;
114 	std::string description_;
115 	std::string activationSound_;
116 	int positionSelectLimit_;
117 	int price_;
118 	int originalPrice_;
119 	int bundle_;
120 	int armsLevel_;
121 	int sellPrice_;
122 	int originalSellPrice_;
123 	int freemarketLimits_;
124 	int maximumNumber_;
125 	int useNumber_;
126 	int startingNumber_;
127 	fixed modelScale_;
128 	bool muzzleFlash_;
129 };
130 
131 #endif // !defined(AFX_ACCESSORY_H__21765D5B_DB45_4275_AB63_BAD1E84C1790__INCLUDED_)
132