-
Notifications
You must be signed in to change notification settings - Fork 0
/
configs.lua
70 lines (56 loc) · 1.87 KB
/
configs.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
dofile_once("mods/component-explorer/component_fields.lua")
{% set supported_fields = [
"bool",
"float",
"int", "unsignedint", "int32", "uint32",
"types_vector2",
"ValueRange", "ValueRangeInt",
"std_string",
"EntityID",
] -%}
{% set used_configs = [
"ConfigDamageCritical",
"ConfigDamagesByType",
"ConfigDrugFx",
"ConfigExplosion",
"ConfigGun",
"ConfigGunActionInfo",
"ConfigLaser",
] -%}
{% for config in configs %}
{% if config.name in used_configs %}
function show_{{ config.name }}_fields(field_name, description, component_id)
{%- set sections = {
"Members": config.members,
"Privates": config.privates,
"Custom data types": config.custom_data_types,
} %}
local function get(component_id, name)
return ComponentObjectGetValue2(component_id, field_name, name)
end
local function set(component_id, name, ...)
return ComponentObjectSetValue2(component_id, field_name, name, ...)
end
{%- for section_name, fields in sections.items() -%}
{%- if fields %}
{% if config.privates or config.custom_data_types %}
if imgui.TreeNode("{{ section_name }}") then
{% endif %}
{% for field in fields -%}
{%- set field_type = field.type|replace("::", "_")|replace("<", "_")|replace(">", "") -%}
{%- set description = '"' ~ field.description ~ '"' if field.description else "nil" -%}
{% if field_type in supported_fields %}
show_field_{{ field_type }}("{{ field.name }}", {{ description }}, component_id, get, set)
{% else %}
-- show_field_{{ field_type }}("{{ field.name }}", {{ description }}, component_id)
{% endif -%}
{% endfor %}
{% if config.privates or config.custom_data_types %}
imgui.TreePop()
end
{% endif %}
{% endif -%}
{% endfor -%}
end
{% endif %}
{% endfor %}