UI fun
This commit is contained in:
@@ -119,9 +119,18 @@ should_make_ui :: (type: *Type_Info_Struct, member: Type_Info_Struct_Member) ->
|
||||
return true;
|
||||
}
|
||||
|
||||
is_readonly :: (type: *Type_Info_Struct, member: Type_Info_Struct_Member) -> bool {
|
||||
for member.notes {
|
||||
if to_lower_copy(it,, allocator = temp) == "readonly" return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
generate_member_ui :: (type: *Type_Info_Struct, builder: *String_Builder, path: string = "") {
|
||||
for type.members {
|
||||
if should_make_ui(type, it) && should_serialize(type, it) {
|
||||
readonly := is_readonly(type, it);
|
||||
if should_make_ui(type, it) && (should_serialize(type, it) || readonly) {
|
||||
new_path : string;
|
||||
if it.name != "entity" {
|
||||
if path.count == 0 {
|
||||
@@ -131,39 +140,43 @@ generate_member_ui :: (type: *Type_Info_Struct, builder: *String_Builder, path:
|
||||
}
|
||||
}
|
||||
|
||||
type : Type_Info_Tag;
|
||||
tag : Type_Info_Tag;
|
||||
if it.type.type == .VARIANT {
|
||||
info_variant := cast(*Type_Info_Variant)it.type;
|
||||
type = info_variant.variant_of.type;
|
||||
tag = info_variant.variant_of.type;
|
||||
} else {
|
||||
type = it.type.type;
|
||||
tag = it.type.type;
|
||||
}
|
||||
|
||||
if type == {
|
||||
case .STRUCT; {
|
||||
info_struct := cast(*Type_Info_Struct) it.type;
|
||||
if info_struct.name == "Quaternion" {
|
||||
if readonly {
|
||||
print_to_builder(builder, "\tui_field_label(\"%\", e.%);\n", new_path, new_path);
|
||||
} else {
|
||||
if tag == {
|
||||
case .STRUCT; {
|
||||
info_struct := cast(*Type_Info_Struct) it.type;
|
||||
if info_struct.name == "Quaternion" {
|
||||
|
||||
}
|
||||
else 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);
|
||||
}
|
||||
}
|
||||
else 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; {
|
||||
print_to_builder(builder, "\tui_checkbox_field(tprint(\"%\"), *e.%);\n", new_path, new_path);
|
||||
}
|
||||
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(\"%\"), cast(*int)*e.%);\n", new_path, new_path);
|
||||
}
|
||||
}
|
||||
case .BOOL; {
|
||||
print_to_builder(builder, "\tui_checkbox_field(tprint(\"%\"), *e.%);\n", new_path, new_path);
|
||||
}
|
||||
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(\"%\"), cast(*int)*e.%);\n", new_path, new_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user