2013-03-06 21:49:56 +03:00
|
|
|
/*
|
|
|
|
* CBonusTypeHandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-03-07 16:21:09 +03:00
|
|
|
#pragma once
|
2013-03-06 21:49:56 +03:00
|
|
|
|
|
|
|
#include "IBonusTypeHandler.h"
|
2013-04-21 15:49:26 +03:00
|
|
|
#include "IHandlerBase.h"
|
2023-05-01 19:29:53 +02:00
|
|
|
#include "bonuses/Bonus.h"
|
2013-03-06 21:49:56 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
|
|
|
|
class JsonNode;
|
|
|
|
|
|
|
|
class DLL_LINKAGE CBonusType
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CBonusType();
|
2023-01-17 12:42:43 +02:00
|
|
|
|
|
|
|
std::string getNameTextID() const;
|
|
|
|
std::string getDescriptionTextID() const;
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2017-08-08 16:53:01 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
2013-03-06 21:49:56 +03:00
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & icon;
|
2023-01-17 12:42:43 +02:00
|
|
|
h & identifier;
|
2017-07-31 15:35:42 +02:00
|
|
|
h & hidden;
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
}
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
private:
|
|
|
|
friend class CBonusTypeHandler;
|
2023-01-17 12:42:43 +02:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
std::string icon;
|
2023-01-17 12:42:43 +02:00
|
|
|
std::string identifier;
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
bool hidden;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE CBonusTypeHandler : public IBonusTypeHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CBonusTypeHandler();
|
|
|
|
virtual ~CBonusTypeHandler();
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2017-08-08 16:53:01 +02:00
|
|
|
std::string bonusToString(const std::shared_ptr<Bonus> & bonus, const IBonusBearer * bearer, bool description) const override;
|
2023-08-23 14:07:50 +02:00
|
|
|
ImagePath bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const override;
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2017-08-08 16:53:01 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h, const int version)
|
2013-03-06 21:49:56 +03:00
|
|
|
{
|
2017-08-08 16:53:01 +02:00
|
|
|
//for now always use up to date configuration
|
|
|
|
//once modded bonus type will be implemented, serialize only them
|
|
|
|
std::vector<CBonusType> ignore;
|
|
|
|
h & ignore;
|
2013-03-06 21:49:56 +03:00
|
|
|
}
|
|
|
|
private:
|
2017-08-08 16:53:01 +02:00
|
|
|
void load();
|
|
|
|
void load(const JsonNode & config);
|
2023-03-13 23:26:44 +02:00
|
|
|
void loadItem(const JsonNode & source, CBonusType & dest, const std::string & name) const;
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
std::vector<CBonusType> bonusTypes; //index = BonusType
|
2013-03-06 21:49:56 +03:00
|
|
|
};
|
2017-08-08 16:53:01 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2017-08-08 16:53:01 +02:00
|
|
|
#ifndef INSTANTIATE_CBonusTypeHandler_HERE
|
2022-07-26 15:07:42 +02:00
|
|
|
extern template class std::vector<VCMI_LIB_WRAP_NAMESPACE(CBonusType)>;
|
2017-08-08 16:53:01 +02:00
|
|
|
#endif
|