1#include "Serialization/JsonParser.h"
2#include "Resources/AssetDefinition.h"
7#include "Resources/ResourceStore.h"
9Cogs::Core::GuiManager::~GuiManager()
13void Cogs::Core::GuiManager::initialize()
19 auto loadInfo = createLoadInfo();
21 loadInfo->resourcePath = source.to_string();
23 return loadResource(loadInfo);
28 auto guiDocument = get(loadInfo->
handle);
32 if (masterContent.empty()) {
33 guiDocument->setFailedLoad();
34 setProcessed(loadInfo);
38 guiDocument->htmlContext.load_master_stylesheet(masterContent.c_str());
41 setProcessed(loadInfo);
46 return valueType == DefaultValueType::Gui;
49void Cogs::Core::GuiManager::applyFieldValue(
void*
object,
const Reflection::Field* field,
const FieldValue& fieldValue)
51 assert(fieldValue.type == DefaultValueType::Gui);
53 ResourceHandleBase guiDoc;
54 if (fieldValue.value.front() ==
'$') {
55 guiDoc = getByName(fieldValue.value.substr(1));
58 guiDoc = load(fieldValue.value, NoResourceId);
60 auto * ptr = field->
getPtr<ResourceHandleBase>(object);
64void Cogs::Core::GuiManager::readSource(Context* , ResourceDefinition& definition,
const void* jsonResourcePtr)
66 const auto & jsonResource = *(
const rapidjson::Value*)jsonResourcePtr;
68 const auto & source = jsonResource[
"source"];
70 std::string srcString(source.GetString(), source.GetStringLength());
72 auto guiDocument = load(srcString, NoResourceId);
73 guiDocument->setName(definition.name);
void handleLoad(GuiLoadInfo *loadInfo) override
Handler for resource loading.
Field definition describing a single data member of a data structure.
FieldValueType * getPtr(void *container) const
Get a pointer to this field on the given container.
@ NoCachedContent
Never use cached data.
DefaultValueType
Defines value types for default values.
std::string resourcePath
Resource path. Used to locate resource.
ResourceHandleBase handle
Handle to resource structure for holding actual resource data.