2013-08-17 15:46:48 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CRmgTemplateStorage.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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CRmgTemplate.h"
|
|
|
|
#include "CRmgTemplateZone.h"
|
2015-05-26 15:12:24 +02:00
|
|
|
#include "../IHandlerBase.h"
|
2013-08-17 15:46:48 +03:00
|
|
|
|
|
|
|
class JsonNode;
|
|
|
|
|
|
|
|
typedef std::vector<JsonNode> JsonVector;
|
|
|
|
|
2015-05-26 15:12:24 +02:00
|
|
|
/// The CJsonRmgTemplateLoader loads templates from a JSON file.
|
|
|
|
class DLL_LINKAGE CRmgTemplateStorage : public IHandlerBase
|
2013-08-17 15:46:48 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-05-26 15:12:24 +02:00
|
|
|
CRmgTemplateStorage();
|
|
|
|
~CRmgTemplateStorage();
|
|
|
|
|
2013-08-17 15:46:48 +03:00
|
|
|
const std::map<std::string, CRmgTemplate *> & getTemplates() const;
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
std::vector<bool> getDefaultAllowed() const override;
|
|
|
|
std::vector<JsonNode> loadLegacyData(size_t dataSize) override;
|
2013-08-17 15:46:48 +03:00
|
|
|
|
2015-05-26 15:12:24 +02:00
|
|
|
/// loads single object into game. Scope is namespace of this object, same as name of source mod
|
2015-10-12 15:47:10 +02:00
|
|
|
virtual void loadObject(std::string scope, std::string name, const JsonNode & data) override;
|
|
|
|
virtual void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
|
2013-08-17 15:46:48 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
CRmgTemplate::CSize parseMapTemplateSize(const std::string & text) const;
|
|
|
|
CRmgTemplateZone::CTownInfo parseTemplateZoneTowns(const JsonNode & node) const;
|
|
|
|
ETemplateZoneType::ETemplateZoneType parseZoneType(const std::string & type) const;
|
|
|
|
std::set<TFaction> parseTownTypes(const JsonVector & townTypesVector, const std::set<TFaction> & defaultTownTypes) const;
|
|
|
|
std::set<ETerrainType> parseTerrainTypes(const JsonVector & terTypeStrings, const std::set<ETerrainType> & defaultTerrainTypes) const;
|
|
|
|
CRmgTemplate::CPlayerCountRange parsePlayers(const std::string & players) const;
|
|
|
|
|
2015-05-26 15:12:24 +02:00
|
|
|
protected:
|
|
|
|
std::map<std::string, CRmgTemplate *> templates;
|
2013-08-17 15:46:48 +03:00
|
|
|
};
|
2015-05-26 15:12:24 +02:00
|
|
|
|