mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Start TEngine3.0
Start TEngine3.0
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include ""CoreMinimal.h""
|
||||
#include ""FCfgObj.h""
|
||||
|
||||
{{editor_cpp_includes}}
|
||||
|
||||
namespace editor
|
||||
{
|
||||
|
||||
{{cpp_namespace_begin}}
|
||||
|
||||
struct X6PROTOEDITOR_API {{ue_fname}} : public {{if parent_def_type}} {{parent_def_type.ue_fname}}{{else}}FCfgObj{{end}}
|
||||
{
|
||||
{{~for field in fields ~}}
|
||||
{{field.ctype.editor_ue_cpp_define_type}} {{field.name}};
|
||||
{{~end~}}
|
||||
|
||||
{{~if !is_abstract_type~}}
|
||||
bool Load(FJsonObject* _json) override;
|
||||
bool Save(FJsonObject*& result) override;
|
||||
{{~end~}}
|
||||
|
||||
static bool Create(FJsonObject* _json, {{ue_fname}}*& result);
|
||||
};
|
||||
|
||||
|
||||
{{cpp_namespace_end}}
|
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include ""CoreMinimal.h""
|
||||
|
||||
namespace editor
|
||||
{
|
||||
|
||||
{{cpp_namespace_begin}}
|
||||
|
||||
enum class {{ue_fname}}
|
||||
{
|
||||
{{~for item in items ~}}
|
||||
{{item.name}} = {{item.value}},
|
||||
{{~end~}}
|
||||
};
|
||||
|
||||
bool X6PROTOEDITOR_API {{ue_fname}}ToString({{ue_fname}} value, FString& s);
|
||||
bool X6PROTOEDITOR_API {{ue_fname}}FromString(const FString& s, {{ue_fname}}& x);
|
||||
|
||||
{{cpp_namespace_end}}
|
||||
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
#include ""JsonUtil.h""
|
||||
|
||||
{{includes}}
|
||||
|
||||
namespace editor
|
||||
{
|
||||
|
||||
{{~for type in types~}}
|
||||
{{type.cpp_namespace_begin}}
|
||||
{{~if type.is_bean~}}
|
||||
{{~if type.is_abstract_type~}}
|
||||
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
||||
{
|
||||
FString type;
|
||||
if (_json->TryGetStringField(FString(""{{type.json_type_name_key}}""), type))
|
||||
{
|
||||
{{~for child in type.hierarchy_not_abstract_children~}}
|
||||
if (type == ""{{cs_impl_data_type child x}}"")
|
||||
{
|
||||
result = new {{child.ue_fname}}();
|
||||
} else
|
||||
{{~end~}}
|
||||
{
|
||||
result = nullptr;
|
||||
return false;
|
||||
}
|
||||
if (!result->Load(_json))
|
||||
{
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{{~else~}}
|
||||
bool {{type.ue_fname}}::Create(FJsonObject* _json, {{type.ue_fname}}*& result)
|
||||
{
|
||||
result = new {{type.ue_fname}}();
|
||||
if (!result->Load(_json))
|
||||
{
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool {{type.ue_fname}}::Save(FJsonObject*& result)
|
||||
{
|
||||
auto _json = new FJsonObject();
|
||||
_json->SetStringField(""{{type.json_type_name_key}}"", ""{{type.name}}"");
|
||||
|
||||
{{~for field in type.hierarchy_fields~}}
|
||||
{{field.editor_ue_cpp_save}}
|
||||
{{~end~}}
|
||||
result = _json;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool {{type.ue_fname}}::Load(FJsonObject* _json)
|
||||
{
|
||||
{{~for field in type.hierarchy_fields~}}
|
||||
{{field.editor_ue_cpp_load}}
|
||||
{{~end~}}
|
||||
return true;
|
||||
}
|
||||
{{~end~}}
|
||||
{{~else~}}
|
||||
|
||||
bool {{type.ue_fname}}ToString({{type.ue_fname}} value, FString& s)
|
||||
{
|
||||
{{~for item in type.items ~}}
|
||||
if (value == {{type.ue_fname}}::{{item.name}}) { s = ""{{item.name}}""; return true; }
|
||||
{{~end~}}
|
||||
return false;
|
||||
}
|
||||
bool {{type.ue_fname}}FromString(const FString& s, {{type.ue_fname}}& value)
|
||||
{
|
||||
{{~for item in type.items ~}}
|
||||
if (s == ""{{item.name}}"")
|
||||
{
|
||||
value = {{type.ue_fname}}::{{item.name}};
|
||||
return true;
|
||||
}
|
||||
{{~end~}}
|
||||
return false;
|
||||
}
|
||||
|
||||
{{~end~}}
|
||||
{{type.cpp_namespace_end}}
|
||||
{{~end~}}
|
||||
}
|
Reference in New Issue
Block a user