Merge branch 'main' of http://188.166.59.26/brossferatu/coven
This commit is contained in:
@@ -81,6 +81,42 @@ should_serialize :: (type: *Type_Info_Struct, member: Type_Info_Struct_Member) -
|
||||
return true;
|
||||
}
|
||||
|
||||
generate_member_ui :: (type: *Type_Info_Struct, builder: *String_Builder, path: string = "") {
|
||||
for type.members {
|
||||
if should_serialize(type, it) {
|
||||
new_path : string;
|
||||
if path.count == 0 {
|
||||
new_path = it.name;
|
||||
} else {
|
||||
new_path = tprint("%1.%2", path, it.name);
|
||||
}
|
||||
|
||||
if it.type.type == {
|
||||
case .STRUCT; {
|
||||
info_struct := cast(*Type_Info_Struct) it.type;
|
||||
if info_struct.name == "Vector3" {
|
||||
print_to_builder(builder, "\tui_vector_field(tprint(\"%\"), *e.%);\n", new_path, new_path);
|
||||
} else {
|
||||
generate_member_ui(info_struct, builder, new_path);
|
||||
}
|
||||
}
|
||||
//case .BOOL; #through;
|
||||
case .STRING; {
|
||||
print_to_builder(builder, "\tui_textfield(tprint(\"%\"), *e.%);\n", new_path, new_path);
|
||||
//ui_textfield :: (label: string, text: *string, identifier: s64 = 0, loc := #caller_location) {
|
||||
}
|
||||
case .FLOAT; {
|
||||
print_to_builder(builder, "\tui_float_field(tprint(\"%\"), *e.%);\n", new_path, new_path);
|
||||
}
|
||||
//case .ENUM; #through;
|
||||
case .INTEGER; {
|
||||
print_to_builder(builder, "\tui_int_field(tprint(\"%\"), *e.%);\n", new_path, new_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generate_member_serialization :: (type: *Type_Info_Struct, builder: *String_Builder, path: string = "") {
|
||||
for type.members {
|
||||
if should_serialize(type, it) {
|
||||
@@ -96,6 +132,9 @@ generate_member_serialization :: (type: *Type_Info_Struct, builder: *String_Buil
|
||||
info_struct := cast(*Type_Info_Struct) it.type;
|
||||
generate_member_serialization(info_struct, builder, new_path);
|
||||
}
|
||||
case .STRING; {
|
||||
print_to_builder(builder, "\tprint_to_builder(builder, \"%: \%\\n\", e.%);\n", new_path, new_path);
|
||||
}
|
||||
case .BOOL; #through;
|
||||
case .FLOAT; #through;
|
||||
case .ENUM; #through;
|
||||
@@ -121,6 +160,10 @@ generate_member_deserialization :: (type: *Type_Info_Struct, builder: *String_Bu
|
||||
info_struct := cast(*Type_Info_Struct) it.type;
|
||||
generate_member_deserialization(info_struct, builder, new_path);
|
||||
}
|
||||
case .STRING; {
|
||||
print_to_builder(builder, "\t\t\t\tcase \"%\";\n", new_path);
|
||||
print_to_builder(builder, "\t\t\t\tif values[1].count > 0 { e.%1 = copy_string(trim(values[1])); }\n", new_path);
|
||||
}
|
||||
case .BOOL; #through;
|
||||
case .FLOAT; #through;
|
||||
case .ENUM; #through;
|
||||
@@ -159,6 +202,18 @@ generate_member_copy :: (type: *Type_Info_Struct, builder: *String_Builder, path
|
||||
}
|
||||
}
|
||||
|
||||
generate_ui_procedure_for_entity :: (code_struct: *Code_Struct) {
|
||||
name := code_struct.defined_type.name;
|
||||
|
||||
// Serialize
|
||||
ui : String_Builder;
|
||||
print_to_builder(*ui, "entity_ui_proc :: (e: *%) {\n", name);
|
||||
generate_member_ui(code_struct.defined_type, *ui);
|
||||
print_to_builder(*ui, "}\n");
|
||||
|
||||
array_add(*entity_serialize_proc_string, builder_to_string(*ui));
|
||||
}
|
||||
|
||||
generate_serialize_procedure_for_entity :: (code_struct: *Code_Struct) {
|
||||
name := code_struct.defined_type.name;
|
||||
|
||||
@@ -213,6 +268,7 @@ note_struct :: (code_struct: *Code_Struct) {
|
||||
print("Detected entity '%'.\n", name);
|
||||
|
||||
generate_serialize_procedure_for_entity(code_struct);
|
||||
generate_ui_procedure_for_entity(code_struct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,6 +420,17 @@ generate_code :: (w: Workspace) {
|
||||
add_build_string(build_string, w);
|
||||
}
|
||||
|
||||
{
|
||||
builder: String_Builder;
|
||||
|
||||
for entity_type_names {
|
||||
print_to_builder(*builder, "\tcase %1; entity_ui_proc(cast(*%1)e);\n", it);
|
||||
}
|
||||
|
||||
build_string := sprint(ENTITY_UI, builder_to_string(*builder));
|
||||
add_build_string(build_string, w);
|
||||
}
|
||||
|
||||
{
|
||||
builder: String_Builder;
|
||||
|
||||
@@ -386,7 +453,7 @@ generate_code :: (w: Workspace) {
|
||||
add_build_string(build_string, w);
|
||||
|
||||
// We'll print out the added code just to show at compile-time what we are doing:
|
||||
print("Adding build string:\n%\n", build_string);
|
||||
//print("Adding build string:\n%\n", build_string);
|
||||
}
|
||||
|
||||
generated_code := false;
|
||||
@@ -470,6 +537,14 @@ duplicate_entity :: (e: *Entity) -> *Entity {
|
||||
}
|
||||
DONE
|
||||
|
||||
ENTITY_UI :: #string DONE
|
||||
entity_ui :: (e: *Entity) {
|
||||
if e.type == {
|
||||
%1
|
||||
}
|
||||
}
|
||||
DONE
|
||||
|
||||
INIT_SCENE :: #string DONE
|
||||
init_scene :: (scene: *Scene) {
|
||||
%1
|
||||
|
||||
Reference in New Issue
Block a user