2010-08-22 23:09:35 +02:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
2011-12-14 08:40:48 +01:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2010-08-22 23:09:35 +02:00
|
|
|
//
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_ELEMENTTYPE_H_
|
|
|
|
#define _GLEST_GAME_ELEMENTTYPE_H_
|
|
|
|
|
2012-04-20 03:04:05 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
2010-08-22 23:09:35 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "texture.h"
|
|
|
|
#include "resource.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
#include "leak_dumper.h"
|
2010-08-22 23:09:35 +02:00
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
using Shared::Graphics::Texture2D;
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
class UpgradeType;
|
|
|
|
class TechTree;
|
|
|
|
class UnitType;
|
|
|
|
class UpgradeType;
|
|
|
|
class DisplayableType;
|
|
|
|
class ResourceType;
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class DisplayableType
|
|
|
|
//
|
|
|
|
/// Base class for anything that has a name and a portrait
|
|
|
|
// =====================================================
|
|
|
|
|
2012-03-10 04:27:25 +01:00
|
|
|
class DisplayableType {
|
2010-08-22 23:09:35 +02:00
|
|
|
protected:
|
|
|
|
string name; //name
|
|
|
|
Texture2D *image; //portrait
|
|
|
|
|
|
|
|
public:
|
|
|
|
DisplayableType();
|
|
|
|
virtual ~DisplayableType(){};
|
|
|
|
|
|
|
|
//get
|
2013-01-16 22:16:59 +01:00
|
|
|
virtual string getName(bool translatedValue=false) const;
|
2012-05-02 22:46:47 +02:00
|
|
|
virtual const Texture2D *getImage() const { return image; }
|
2012-03-10 04:27:25 +01:00
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
//virtual void saveGame(XmlNode *rootNode) const;
|
2010-08-22 23:09:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class RequirableType
|
|
|
|
//
|
|
|
|
/// Base class for anything that has requirements
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
class RequirableType: public DisplayableType{
|
|
|
|
private:
|
|
|
|
typedef vector<const UnitType*> UnitReqs;
|
|
|
|
typedef vector<const UpgradeType*> UpgradeReqs;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
UnitReqs unitReqs; //needed units
|
|
|
|
UpgradeReqs upgradeReqs; //needed upgrades
|
|
|
|
|
|
|
|
public:
|
|
|
|
//get
|
|
|
|
int getUpgradeReqCount() const {return upgradeReqs.size();}
|
|
|
|
int getUnitReqCount() const {return unitReqs.size();}
|
|
|
|
const UpgradeType *getUpgradeReq(int i) const {return upgradeReqs[i];}
|
|
|
|
const UnitType *getUnitReq(int i) const {return unitReqs[i];}
|
|
|
|
|
|
|
|
//other
|
|
|
|
virtual string getReqDesc() const;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
//virtual void saveGame(XmlNode *rootNode) const;
|
2010-08-22 23:09:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class ProducibleType
|
|
|
|
//
|
|
|
|
/// Base class for anything that can be produced
|
|
|
|
// =====================================================
|
|
|
|
|
2012-03-10 04:27:25 +01:00
|
|
|
class ProducibleType: public RequirableType {
|
2010-08-22 23:09:35 +02:00
|
|
|
private:
|
|
|
|
typedef vector<Resource> Costs;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Costs costs;
|
|
|
|
Texture2D *cancelImage;
|
|
|
|
int productionTime;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ProducibleType();
|
|
|
|
virtual ~ProducibleType();
|
|
|
|
|
|
|
|
//get
|
|
|
|
int getCostCount() const {return costs.size();}
|
|
|
|
const Resource *getCost(int i) const {return &costs[i];}
|
|
|
|
const Resource *getCost(const ResourceType *rt) const;
|
|
|
|
int getProductionTime() const {return productionTime;}
|
|
|
|
const Texture2D *getCancelImage() const {return cancelImage;}
|
|
|
|
|
|
|
|
//varios
|
|
|
|
void checkCostStrings(TechTree *techTree);
|
|
|
|
|
|
|
|
virtual string getReqDesc() const;
|
2012-11-10 20:39:55 +01:00
|
|
|
string getResourceReqDesc(bool lineBreaks=true) const;
|
|
|
|
string getUnitAndUpgradeReqDesc(bool lineBreaks=true) const;
|
2012-03-27 05:23:03 +02:00
|
|
|
string getReqDesc(bool ignoreResourceRequirements) const;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
// virtual void saveGame(XmlNode *rootNode) const;
|
|
|
|
// void loadGame(const XmlNode *rootNode);
|
2010-08-22 23:09:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|