2013-11-08 23:36:26 +03:00
|
|
|
/*
|
|
|
|
* ResourceID.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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
2013-11-08 23:36:26 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2013-11-08 23:36:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies the resource type.
|
|
|
|
*
|
|
|
|
* Supported file extensions:
|
|
|
|
*
|
|
|
|
* Text: .txt .json
|
|
|
|
* Animation: .def
|
|
|
|
* Mask: .msk .msg
|
|
|
|
* Campaign: .h3c
|
|
|
|
* Map: .h3m
|
|
|
|
* Font: .fnt
|
|
|
|
* Image: .bmp, .jpg, .pcx, .png, .tga
|
|
|
|
* Sound: .wav .82m
|
|
|
|
* Video: .smk, .bik .mjpg .mpg
|
|
|
|
* Music: .mp3, .ogg
|
|
|
|
* Archive: .lod, .snd, .vid .pac .zip
|
|
|
|
* Palette: .pal
|
|
|
|
* Savegame: .v*gm1
|
|
|
|
*/
|
|
|
|
namespace EResType
|
|
|
|
{
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TEXT,
|
|
|
|
ANIMATION,
|
|
|
|
MASK,
|
|
|
|
CAMPAIGN,
|
|
|
|
MAP,
|
|
|
|
BMP_FONT,
|
|
|
|
TTF_FONT,
|
|
|
|
IMAGE,
|
|
|
|
VIDEO,
|
|
|
|
SOUND,
|
|
|
|
MUSIC,
|
|
|
|
ARCHIVE_VID,
|
|
|
|
ARCHIVE_ZIP,
|
|
|
|
ARCHIVE_SND,
|
|
|
|
ARCHIVE_LOD,
|
|
|
|
PALETTE,
|
|
|
|
CLIENT_SAVEGAME,
|
|
|
|
SERVER_SAVEGAME,
|
|
|
|
DIRECTORY,
|
|
|
|
ERM,
|
|
|
|
ERT,
|
|
|
|
ERS,
|
2015-02-06 09:51:32 +02:00
|
|
|
OTHER,
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
UNDEFINED,
|
|
|
|
LUA
|
2013-11-08 23:36:26 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A struct which identifies a resource clearly.
|
|
|
|
*/
|
|
|
|
class DLL_LINKAGE ResourceID
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default c-tor.
|
|
|
|
*/
|
2016-01-29 16:16:14 +02:00
|
|
|
//ResourceID();
|
2013-11-08 23:36:26 +03:00
|
|
|
|
|
|
|
/**
|
2014-03-23 15:59:03 +03:00
|
|
|
* Ctor. Can be used to create identifier for resource loading using one parameter
|
2013-11-08 23:36:26 +03:00
|
|
|
*
|
|
|
|
* @param fullName The resource name including extension.
|
|
|
|
*/
|
|
|
|
explicit ResourceID(std::string fullName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ctor.
|
|
|
|
*
|
|
|
|
* @param name The resource name.
|
|
|
|
* @param type The resource type. A constant from the enumeration EResType.
|
|
|
|
*/
|
|
|
|
ResourceID(std::string name, EResType::Type type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares this object with a another resource identifier.
|
|
|
|
*
|
|
|
|
* @param other The other resource identifier.
|
|
|
|
* @return Returns true if both are equally, false if not.
|
|
|
|
*/
|
|
|
|
inline bool operator==(ResourceID const & other) const
|
|
|
|
{
|
|
|
|
return name == other.name && type == other.type;
|
|
|
|
}
|
|
|
|
|
2016-01-29 16:16:14 +02:00
|
|
|
std::string getName() const {return name;}
|
|
|
|
EResType::Type getType() const {return type;}
|
2016-01-26 15:51:38 +02:00
|
|
|
//void setName(std::string name);
|
|
|
|
//void setType(EResType::Type type);
|
2013-11-08 23:36:26 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Specifies the resource type. EResType::OTHER if not initialized.
|
|
|
|
* Required to prevent conflicts if files with different types (e.g. text and image) have the same name.
|
|
|
|
*/
|
|
|
|
EResType::Type type;
|
2016-01-26 15:51:38 +02:00
|
|
|
|
|
|
|
/** Specifies the resource name. No extension so .pcx and .png can override each other, always in upper case. **/
|
|
|
|
std::string name;
|
2013-11-08 23:36:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A helper class which provides a functionality to convert extension strings to EResTypes.
|
|
|
|
*/
|
|
|
|
class DLL_LINKAGE EResTypeHelper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Converts a extension string to a EResType enum object.
|
|
|
|
*
|
|
|
|
* @param extension The extension string e.g. .BMP, .PNG
|
|
|
|
* @return Returns a EResType enum object
|
|
|
|
*/
|
|
|
|
static EResType::Type getTypeFromExtension(std::string extension);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the EResType as a string representation.
|
|
|
|
*
|
|
|
|
* @param type the EResType
|
|
|
|
* @return the type as a string representation
|
|
|
|
*/
|
|
|
|
static std::string getEResTypeAsString(EResType::Type type);
|
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
|
2022-08-17 14:31:19 +02:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <> struct hash<VCMI_LIB_WRAP_NAMESPACE(ResourceID)>
|
2022-07-26 15:07:42 +02:00
|
|
|
{
|
|
|
|
size_t operator()(const VCMI_LIB_WRAP_NAMESPACE(ResourceID) & resourceIdent) const
|
|
|
|
{
|
|
|
|
std::hash<int> intHasher;
|
|
|
|
std::hash<std::string> stringHasher;
|
|
|
|
return stringHasher(resourceIdent.getName()) ^ intHasher(static_cast<int>(resourceIdent.getType()));
|
|
|
|
}
|
|
|
|
};
|
2022-08-17 14:31:19 +02:00
|
|
|
}
|