1 #ifndef CORE_FILES_ITEMDB_HPP
2 #define CORE_FILES_ITEMDB_HPP
4 #include <BLIB/Resources.hpp>
5 #include <BLIB/Serialization.hpp>
6 #include <BLIB/Util/NonCopyable.hpp>
12 #include <unordered_map>
24 struct ItemDB :
private bl::util::NonCopyable {
38 bool loadDev(std::istream& input);
46 bool loadProd(bl::serial::binary::InputStream& input);
62 bool saveBundle(bl::serial::binary::OutputStream& output,
63 bl::resource::bundle::FileHandlerContext& ctx)
const;
65 std::unordered_map<item::Id, std::string>
names;
67 std::unordered_map<item::Id, std::int32_t>
values;
78 struct SerializableObject<
core::file::ItemDB> :
public SerializableObjectBase {
82 SerializableField<1, DB, std::unordered_map<Id, std::string>>
names;
83 SerializableField<2, DB, std::unordered_map<Id, std::string>>
descriptions;
84 SerializableField<3, DB, std::unordered_map<Id, std::int32_t>>
values;
87 : SerializableObjectBase(
"ItemDB")
88 , names(
"names", *this, &
DB::names, SerializableFieldBase::Required{})
89 , descriptions(
"descriptions", *this, &
DB::descriptions, SerializableFieldBase::Required{})
90 , values(
"values", *this, &
DB::values, SerializableFieldBase::Required{}) {}
Id
Represents an item in its simplist form.
Core classes and functionality for both the editor and game.
Loads and stores metadata surrounding items in the game.
bool loadProd(bl::serial::binary::InputStream &input)
Loads the database from its json format.
bool save() const
Writes the item metadata to the data file.
bool saveBundle(bl::serial::binary::OutputStream &output, bl::resource::bundle::FileHandlerContext &ctx) const
Saves the data from this object to the given bundle and registers depency files if any.
std::unordered_map< item::Id, std::string > names
std::unordered_map< item::Id, std::string > descriptions
std::unordered_map< item::Id, std::int32_t > values
bool loadDev(std::istream &input)
Loads the database from its json format.
bool load()
Loads the item metadata from the data file.
SerializableField< 3, DB, std::unordered_map< Id, std::int32_t > > values
SerializableField< 2, DB, std::unordered_map< Id, std::string > > descriptions
SerializableField< 1, DB, std::unordered_map< Id, std::string > > names