generated from CoolLibs/library-template
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerate_flags_checkbox.py
55 lines (47 loc) · 1.52 KB
/
generate_flags_checkbox.py
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
# ---HOW TO---
# Modify `all_flags()` and `includes()`, then run this script.
# ------------
def all_flags():
return {
"ImGG::Flag::NoTooltip": ["isNoTooltip"],
"ImGG::Flag::NoResetButton": ["isNoResetButton"],
"ImGG::Flag::NoLabel": ["isNoLabel"],
"ImGG::Flag::NoAddButton": ["isNoAddButton"],
"ImGG::Flag::NoRemoveButton": ["isNoRemoveButton"],
"ImGG::Flag::NoPositionSlider": ["isNoPositionSlider"],
"ImGG::Flag::NoColorEdit": ["isNoColorEdit"],
"ImGG::Flag::NoDragDownToDelete": ["isNoDragDownToDelete"],
"ImGG::Flag::NoBorder": ["isNoBorder"],
"ImGG::Flag::NoAddAndRemoveButtons": ["isNoAddAndRemoveButtons"],
"ImGG::Flag::NoMarkOptions": ["isNoMarkOptions"],
}
def checkboxes_for_all_flags():
out = f"""
#include <imgui/imgui.h>
#include "../src/Flags.hpp"
auto checkboxes_for_all_flags() -> ImGG::Flags
{{
ImGG::Flags options = ImGG::Flag::None;
"""
for key, values in all_flags().items():
for value in values:
out += f"""
static auto {value} = false;
ImGui::Checkbox("{key}", &{value});
if ({value})
{{
options|={key};
}}
"""
out += f"""
return options;
}}"""
return out
if __name__ == '__main__':
from tooling.generate_files import generate
generate(
folder="generated",
files=[
checkboxes_for_all_flags,
],
)