mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 13:12:06 +00:00
Update T6 json material loading to include JSON being passed directy instead of a stream.
This commit is contained in:
@@ -32,9 +32,7 @@
|
|||||||
|
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
using namespace nlohmann;
|
|
||||||
using namespace GAME;
|
using namespace GAME;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -42,17 +40,15 @@ namespace
|
|||||||
class JsonLoader
|
class JsonLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JsonLoader(std::istream& stream, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
JsonLoader(MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
||||||
: m_stream(stream),
|
: m_memory(memory),
|
||||||
m_memory(memory),
|
|
||||||
m_context(context),
|
m_context(context),
|
||||||
m_registration(registration)
|
m_registration(registration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Load(Material& material) const
|
bool Load(json& jRoot, Material& material) const
|
||||||
{
|
{
|
||||||
const auto jRoot = json::parse(m_stream);
|
|
||||||
std::string type;
|
std::string type;
|
||||||
unsigned version;
|
unsigned version;
|
||||||
|
|
||||||
@@ -505,7 +501,6 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istream& m_stream;
|
|
||||||
MemoryManager& m_memory;
|
MemoryManager& m_memory;
|
||||||
AssetCreationContext& m_context;
|
AssetCreationContext& m_context;
|
||||||
AssetRegistration<AssetMaterial>& m_registration;
|
AssetRegistration<AssetMaterial>& m_registration;
|
||||||
@@ -517,8 +512,18 @@ namespace GAME
|
|||||||
bool LoadMaterialAsJson(
|
bool LoadMaterialAsJson(
|
||||||
std::istream& stream, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
std::istream& stream, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
||||||
{
|
{
|
||||||
const JsonLoader loader(stream, memory, context, registration);
|
const JsonLoader loader(memory, context, registration);
|
||||||
|
|
||||||
return loader.Load(material);
|
auto jRoot = json::parse(stream);
|
||||||
|
|
||||||
|
return loader.Load(jRoot, material);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadMaterialAsJson(
|
||||||
|
json& json, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
||||||
|
{
|
||||||
|
const JsonLoader loader(memory, context, registration);
|
||||||
|
|
||||||
|
return loader.Load(json, material);
|
||||||
}
|
}
|
||||||
} // namespace GAME
|
} // namespace GAME
|
||||||
|
|||||||
@@ -15,9 +15,15 @@
|
|||||||
#include "Utils/MemoryManager.h"
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using namespace nlohmann;
|
||||||
|
|
||||||
namespace GAME
|
namespace GAME
|
||||||
{
|
{
|
||||||
bool LoadMaterialAsJson(
|
bool LoadMaterialAsJson(
|
||||||
std::istream& stream, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration);
|
std::istream& stream, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration);
|
||||||
|
|
||||||
|
bool LoadMaterialAsJson(
|
||||||
|
json& json, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration);
|
||||||
} // namespace GAME
|
} // namespace GAME
|
||||||
|
|||||||
Reference in New Issue
Block a user