1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00
Files
vcmi/lib/entities/ResourceTypeHandler.h

67 lines
1.8 KiB
C++
Raw Normal View History

2025-09-14 14:36:02 +02:00
/*
* ResourceTypeHandler.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 <vcmi/EntityService.h>
#include <vcmi/Entity.h>
2025-09-15 00:08:18 +02:00
#include <vcmi/ResourceType.h>
#include <vcmi/ResourceTypeService.h>
2025-09-14 14:36:02 +02:00
#include "../constants/EntityIdentifiers.h"
#include "../IHandlerBase.h"
#include "../filesystem/ResourcePath.h"
VCMI_LIB_NAMESPACE_BEGIN
class ResourceTypeHandler;
2025-09-15 00:08:18 +02:00
class DLL_LINKAGE Resource : public ResourceType
2025-09-14 14:36:02 +02:00
{
2025-09-15 00:08:18 +02:00
friend class ResourceTypeHandler;
2025-09-14 14:36:02 +02:00
GameResID id; //backlink
int price;
2025-09-14 17:05:48 +02:00
std::string iconSmall;
std::string iconMedium;
std::string iconLarge;
2025-09-14 14:36:02 +02:00
std::string identifier;
std::string modScope;
public:
2025-09-15 00:08:18 +02:00
int getPrice() const override { return price; }
2025-09-14 14:36:02 +02:00
std::string getJsonKey() const override { return identifier; }
int32_t getIndex() const override { return id.getNum(); }
GameResID getId() const override { return id;}
2025-09-14 18:10:05 +02:00
int32_t getIconIndex() const override { return id.getNum(); }
2025-09-14 14:36:02 +02:00
std::string getModScope() const override { return modScope; };
2025-09-14 17:05:48 +02:00
void registerIcons(const IconRegistar & cb) const override;
2025-09-14 14:36:02 +02:00
std::string getNameTextID() const override;
std::string getNameTranslated() const override;
};
2025-09-15 00:08:18 +02:00
class DLL_LINKAGE ResourceTypeHandler : public CHandlerBase<GameResID, ResourceType, Resource, ResourceTypeService>
2025-09-14 14:36:02 +02:00
{
public:
2025-09-15 00:08:18 +02:00
std::shared_ptr<Resource> loadFromJson(const std::string & scope,
const JsonNode & json,
const std::string & identifier,
size_t index) override;
const std::vector<std::string> & getTypeNames() const override;
2025-09-14 14:36:02 +02:00
std::vector<JsonNode> loadLegacyData() override;
std::vector<GameResID> getAllObjects() const;
};
VCMI_LIB_NAMESPACE_END