#pragma once

/*
	GameEngine and Editor
	by John Ryland
	Copyright (c) 2023
*/

////////////////////////////////////////////////////////////////////////////////////
//	Schema Edit

#include "SchemaFile.h"
#include "XmlParser.h"
#include <string>
#include <vector>

// TODO: remove using
using namespace GameRuntime;

struct DynNameValue
{
    std::string                          name;  // dynamic name which is baked in to the NameValue name
    NameValue                            desc;
};

struct DynVariableDescription
{
    std::string                          name;  // dynamic name which is baked in to the VariableDescription name
    VariableDescription                  desc;
};

struct DynSchema
{
    std::vector<DynNameValue>            enums;
    std::vector<DynVariableDescription>  variables;
};

DynNameValue CreateEnumValue(std::string name, uint64_t value);

EnumDescription CreateEnum(DynSchema* schema, std::vector<DynNameValue> enumValues);
StructDescription CreateStruct(DynSchema* schema, std::vector<DynVariableDescription> fields);

DynVariableDescription AddNumber(DynSchema* schema, std::string name, NumberDescription numberDescription);
// DynVariableDescription AddEncodedNumber(DynSchema* schema, std::string name, EncodedNumberDescription encodedNumberDescription);
DynVariableDescription AddString(DynSchema* schema, std::string name, StringDescription stringDescription);
DynVariableDescription AddEnum(DynSchema* schema, std::string name, EnumDescription enumDescription);
DynVariableDescription AddBool(DynSchema* schema, std::string name);
DynVariableDescription AddColor(DynSchema* schema, std::string name, ColorDescription colorDescription);
DynVariableDescription AddStruct(DynSchema* schema, std::string name, StructDescription structDescription);
DynVariableDescription AddComponent(DynSchema* schema, std::string name, StructDescription structDescription);

std::string ConvertRuntimeString(Schema* schema, String str);
void DumpSchema(Schema* schema);
void ConvertXmlToSchema(XmlTag* rootTag, DynSchema* dynSchema);
bool WriteSchemeFile(DynSchema* schema, const char* schemaFileName);
