2012-09-30 23:34:53 +04:00
|
|
|
#ifndef OPENMW_ESMTOOL_RECORD_H
|
|
|
|
#define OPENMW_ESMTOOL_RECORD_H
|
|
|
|
|
2022-01-29 21:09:27 +02:00
|
|
|
#include <memory>
|
2012-09-30 23:34:53 +04:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <components/esm/records.hpp>
|
2023-02-17 23:42:21 +01:00
|
|
|
#include <components/esm3/cellstate.hpp>
|
|
|
|
#include <components/esm3/fogstate.hpp>
|
2012-09-30 23:34:53 +04:00
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace EsmTool
|
|
|
|
{
|
|
|
|
template <class T>
|
|
|
|
class Record;
|
|
|
|
|
|
|
|
class RecordBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
std::string mId;
|
2015-01-22 19:04:59 +01:00
|
|
|
uint32_t mFlags;
|
2012-10-09 19:41:45 -04:00
|
|
|
ESM::NAME mType;
|
2013-05-22 20:09:11 +02:00
|
|
|
bool mPrintPlain;
|
2012-09-30 23:34:53 +04:00
|
|
|
|
|
|
|
public:
|
2013-12-06 07:36:16 +01:00
|
|
|
RecordBase()
|
|
|
|
: mFlags(0)
|
|
|
|
, mPrintPlain(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-30 23:34:53 +04:00
|
|
|
virtual ~RecordBase() {}
|
|
|
|
|
2015-07-19 14:55:54 +03:00
|
|
|
virtual std::string getId() const = 0;
|
2012-09-30 23:34:53 +04:00
|
|
|
|
2015-01-22 19:04:59 +01:00
|
|
|
uint32_t getFlags() const { return mFlags; }
|
2012-09-30 23:34:53 +04:00
|
|
|
|
2015-01-22 19:04:59 +01:00
|
|
|
void setFlags(uint32_t flags) { mFlags = flags; }
|
2012-09-30 23:34:53 +04:00
|
|
|
|
2012-10-09 19:41:45 -04:00
|
|
|
ESM::NAME getType() const { return mType; }
|
2012-09-30 23:34:53 +04:00
|
|
|
|
2013-05-22 20:09:11 +02:00
|
|
|
void setPrintPlain(bool plain) { mPrintPlain = plain; }
|
|
|
|
|
2012-09-30 23:34:53 +04:00
|
|
|
virtual void load(ESM::ESMReader& esm) = 0;
|
|
|
|
virtual void save(ESM::ESMWriter& esm) = 0;
|
|
|
|
virtual void print() = 0;
|
|
|
|
|
2022-01-29 21:09:27 +02:00
|
|
|
static std::unique_ptr<RecordBase> create(ESM::NAME type);
|
2012-09-30 23:34:53 +04:00
|
|
|
|
|
|
|
// just make it a bit shorter
|
|
|
|
template <class T>
|
|
|
|
Record<T>* cast()
|
|
|
|
{
|
|
|
|
return static_cast<Record<T>*>(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-17 23:42:21 +01:00
|
|
|
struct CellState
|
|
|
|
{
|
|
|
|
ESM::CellState mCellState;
|
|
|
|
ESM::FogState mFogState;
|
|
|
|
|
|
|
|
void load(ESM::ESMReader& reader, bool& deleted);
|
|
|
|
|
|
|
|
void save(ESM::ESMWriter& /*writer*/, bool /*deleted*/) {}
|
|
|
|
};
|
|
|
|
|
2012-09-30 23:34:53 +04:00
|
|
|
template <class T>
|
|
|
|
class Record : public RecordBase
|
|
|
|
{
|
|
|
|
T mData;
|
2015-07-21 20:47:02 +03:00
|
|
|
bool mIsDeleted;
|
2012-09-30 23:34:53 +04:00
|
|
|
|
|
|
|
public:
|
2015-07-21 20:47:02 +03:00
|
|
|
Record()
|
|
|
|
: mIsDeleted(false)
|
2020-06-10 10:58:07 +04:00
|
|
|
{
|
2015-07-19 14:55:54 +03:00
|
|
|
}
|
|
|
|
|
2022-10-06 19:39:46 +02:00
|
|
|
std::string getId() const override { return mData.mId.getRefIdString(); }
|
2012-09-30 23:34:53 +04:00
|
|
|
|
2015-07-21 20:47:02 +03:00
|
|
|
T& get() { return mData; }
|
2012-09-30 23:34:53 +04:00
|
|
|
|
2020-06-10 10:58:07 +04:00
|
|
|
void save(ESM::ESMWriter& esm) override { mData.save(esm, mIsDeleted); }
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-06-10 10:58:07 +04:00
|
|
|
void load(ESM::ESMReader& esm) override { mData.load(esm, mIsDeleted); }
|
2012-09-30 23:34:53 +04:00
|
|
|
|
2020-06-10 10:58:07 +04:00
|
|
|
void print() override;
|
2012-09-30 23:34:53 +04:00
|
|
|
};
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2015-07-19 14:55:54 +03:00
|
|
|
template <>
|
|
|
|
std::string Record<ESM::Cell>::getId() const;
|
|
|
|
template <>
|
|
|
|
std::string Record<ESM::Land>::getId() const;
|
|
|
|
template <>
|
|
|
|
std::string Record<ESM::MagicEffect>::getId() const;
|
|
|
|
template <>
|
|
|
|
std::string Record<ESM::Pathgrid>::getId() const;
|
|
|
|
template <>
|
|
|
|
std::string Record<ESM::Skill>::getId() const;
|
2023-02-17 23:42:21 +01:00
|
|
|
template <>
|
|
|
|
std::string Record<CellState>::getId() const;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2012-09-30 23:34:53 +04:00
|
|
|
template <>
|
|
|
|
void Record<ESM::Activator>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Potion>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Armor>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Apparatus>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::BodyPart>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Book>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::BirthSign>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Cell>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Class>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Clothing>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Container>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Creature>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Dialogue>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Door>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Enchantment>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Faction>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Global>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::GameSetting>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::DialInfo>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Ingredient>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Land>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::CreatureLevList>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::ItemLevList>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Light>::print();
|
2013-03-22 05:50:54 +01:00
|
|
|
template <>
|
|
|
|
void Record<ESM::Lockpick>::print();
|
2012-09-30 23:34:53 +04:00
|
|
|
template <>
|
|
|
|
void Record<ESM::Probe>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Repair>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::LandTexture>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::MagicEffect>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Miscellaneous>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::NPC>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Pathgrid>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Race>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Region>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Script>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Skill>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::SoundGenerator>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Sound>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Spell>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::StartScript>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Static>::print();
|
|
|
|
template <>
|
|
|
|
void Record<ESM::Weapon>::print();
|
2023-02-17 23:42:21 +01:00
|
|
|
template <>
|
|
|
|
void Record<CellState>::print();
|
2012-09-30 23:34:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|