Component: Add ability to load TextAreaComponent from JSON
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Riyyi
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "ruc/json/json.h"
|
||||
|
||||
#include "inferno/component/textareacomponent.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
void fromJson(const ruc::Json& json, TextAreaComponent& value)
|
||||
{
|
||||
VERIFY(json.type() == ruc::Json::Type::Object);
|
||||
|
||||
if (json.exists("content") && json.at("content").type() == ruc::Json::Type::String) {
|
||||
json.at("content").getTo(value.content);
|
||||
}
|
||||
if (json.exists("font") && json.at("font").type() == ruc::Json::Type::String) {
|
||||
json.at("font").getTo(value.font);
|
||||
}
|
||||
if (json.exists("font-size") && json.at("font-size").type() == ruc::Json::Type::Number) {
|
||||
json.at("font-size").getTo(value.fontSize);
|
||||
}
|
||||
if (json.exists("width") && json.at("width").type() == ruc::Json::Type::Number) {
|
||||
json.at("width").getTo(value.width);
|
||||
}
|
||||
if (json.exists("lines") && json.at("lines").type() == ruc::Json::Type::Number) {
|
||||
json.at("lines").getTo(value.width);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Inferno
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "glm/ext/vector_float4.hpp" // glm::vec4
|
||||
#include "ruc/json/json.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
@@ -38,4 +39,6 @@ struct TextAreaComponent {
|
||||
// float dropShadow { 0.0f };
|
||||
};
|
||||
|
||||
void fromJson(const ruc::Json& json, TextAreaComponent& value);
|
||||
|
||||
} // namespace Inferno
|
||||
|
||||
Reference in New Issue
Block a user