Formatting

This commit is contained in:
shihan42 2024-04-22 17:16:44 +02:00
parent 7b69ed2b78
commit 5763bb577f
2 changed files with 37 additions and 13 deletions

View file

@ -6,8 +6,8 @@
#include <components/esm3/variant.hpp>
#include <components/misc/strings/format.hpp>
#include "nlohmannjson.hpp"
#include "labels.hpp"
#include "nlohmannjson.hpp"
#include "util.hpp"
namespace nlohmann
@ -35,7 +35,7 @@ namespace nlohmann
{
// obj = ESM::Header();
}
};
};
template <>
struct adl_serializer<ESM::Variant>
@ -145,7 +145,34 @@ namespace nlohmann
template <>
struct adl_serializer<ESM::Book>
{
static void to_json(json& j, const ESM::Book& obj) { j = json{ { "name", "ESM::Book" } }; }
static void to_json(json& j, const ESM::Book& obj)
{
j["name"] = obj.mName;
j["model"] = obj.mModel;
j["icon"] = obj.mIcon;
if (!obj.mScript.empty())
{
j["script"] = obj.mScript.getRefIdString();
}
if (!obj.mEnchant.empty())
{
j["enchantment"] = obj.mEnchant.getRefIdString();
}
j["weight"] = obj.mData.mWeight;
j["value"] = obj.mData.mValue;
j["scroll"] = obj.mData.mIsScroll != 0;
j["enchantmentPoints"] = obj.mData.mEnchant;
j["text"] = obj.mText;
if (obj.mData.mSkillId != -1)
{
j["skillId"] = obj.mData.mSkillId;
j["skillName"] = skillLabel(obj.mData.mSkillId);
}
}
static void from_json(const json& j, ESM::Book& obj)
{
@ -266,10 +293,7 @@ namespace nlohmann
template <>
struct adl_serializer<ESM::Global>
{
static void to_json(json& j, const ESM::Global& obj)
{
j = obj.mValue;
}
static void to_json(json& j, const ESM::Global& obj) { j = obj.mValue; }
static void from_json(const json& j, ESM::Global& obj)
{
@ -280,10 +304,7 @@ namespace nlohmann
template <>
struct adl_serializer<ESM::GameSetting>
{
static void to_json(json& j, const ESM::GameSetting& obj)
{
j = obj.mValue;
}
static void to_json(json& j, const ESM::GameSetting& obj) { j = obj.mValue; }
static void from_json(const json& j, ESM::GameSetting& obj)
{
@ -338,7 +359,10 @@ namespace nlohmann
template <>
struct adl_serializer<ESM::CreatureLevList>
{
static void to_json(json& j, const ESM::CreatureLevList& obj) { j = json{ { "name", "ESM::CreatureLevList" } }; }
static void to_json(json& j, const ESM::CreatureLevList& obj)
{
j = json{ { "name", "ESM::CreatureLevList" } };
}
static void from_json(const json& j, ESM::CreatureLevList& obj)
{

View file

@ -17,7 +17,7 @@ namespace EsmTool
void save(ESM::ESMWriter& /*writer*/, bool /*deleted*/) {}
};
std::string trimQuotes(std::string str);
std::string hexString8(uint32_t v);
nlohmann::json getRecordFlags(uint32_t flags);