Debian Codegraph @

editor/icons/editor_icons_builders.py

raw symbols SCIP
1 """Functions used to generate source files during build time"""
2
3 import os
4
5 import methods
6
7
8 # See also `scene/theme/icons/default_theme_icons_builders.py`.
9 def make_editor_icons_action(target, source, env):
10 icons_names = []
11 icons_raw = []
12 icons_med = []
13 icons_big = []
14
15 for idx, svg in enumerate(source):
16 path = str(svg)
17 with open(path, encoding="utf-8", newline="\n") as file:
18 icons_raw.append(methods.to_raw_cstring(file.read()))
19
20 name = os.path.splitext(os.path.basename(path))[0]
21 icons_names.append(f'"{name}"')
22
23 if name.endswith("MediumThumb"):
24 icons_med.append(str(idx))
25 elif name.endswith(("BigThumb", "GodotFile")):
26 icons_big.append(str(idx))
27
28 icons_names_str = ",\n\t".join(icons_names)
29 icons_raw_str = ",\n\t".join(icons_raw)
30
31 with methods.generated_wrapper(str(target[0])) as file:
32 file.write(f"""\
33 inline constexpr int editor_icons_count = {len(icons_names)};
34 inline constexpr const char *editor_icons_sources[] = {{
35 {icons_raw_str}
36 }};
37
38 inline constexpr const char *editor_icons_names[] = {{
39 {icons_names_str}
40 }};
41
42 inline constexpr int editor_md_thumbs_count = {len(icons_med)};
43 inline constexpr int editor_md_thumbs_indices[] = {{ {", ".join(icons_med)} }};
44
45 inline constexpr int editor_bg_thumbs_count = {len(icons_big)};
46 inline constexpr int editor_bg_thumbs_indices[] = {{ {", ".join(icons_big)} }};
47 """)