refactor(default): glsl cleaning (1/2)
This commit is contained in:
+12
-9
@@ -6,6 +6,8 @@ TARGET_FILE = os.path.join(
|
||||
os.path.dirname(__file__), "..", "default", "inc_sentences.glsl"
|
||||
)
|
||||
|
||||
SENTENCE_MAX_LENGTH = 20
|
||||
|
||||
SENTENCES = [
|
||||
"forge",
|
||||
"FORGE",
|
||||
@@ -37,25 +39,26 @@ def code(char: str) -> str:
|
||||
|
||||
def convert(txt: str) -> str:
|
||||
out = []
|
||||
for i in range(20):
|
||||
for i in range(SENTENCE_MAX_LENGTH):
|
||||
out += [code(txt[i]) if i < len(txt) else "0x00"]
|
||||
return f"{{{', '.join(out)}}}"
|
||||
return ', '.join(out)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
with open(TARGET_FILE, mode="w") as file:
|
||||
file.write("#ifndef INC_SENTENCES\n")
|
||||
file.write("#define INC_SENTENCES\n\n")
|
||||
file.write(f"#define SENTENCE_COUNT {len(SENTENCES)}\n\n")
|
||||
file.write("const int sentences[SENTENCE_COUNT][20] = {\n")
|
||||
for sentence in SENTENCES:
|
||||
file.write(" " + convert(sentence) + "," + "\n")
|
||||
file.write("};\n\n")
|
||||
file.write("const int lengths[SENTENCE_COUNT] = {\n")
|
||||
file.write(f"#define SENTENCE_COUNT {len(SENTENCES)}\n")
|
||||
file.write(f"#define SENTENCE_MAX_LENGTH {SENTENCE_MAX_LENGTH}\n\n")
|
||||
file.write("const int sentences[] = int[SENTENCE_COUNT * SENTENCE_MAX_LENGTH](\n")
|
||||
for i, sentence in enumerate(SENTENCES):
|
||||
file.write(" " + convert(sentence) + ("," if i < len(SENTENCES) - 1 else "") + "\n")
|
||||
file.write(");\n\n")
|
||||
file.write("const int lengths[] = int[SENTENCE_COUNT](\n")
|
||||
file.write(
|
||||
" " + ", ".join(str(len(sentence)) for sentence in SENTENCES) + "\n"
|
||||
)
|
||||
file.write("};\n")
|
||||
file.write(");\n")
|
||||
file.write("#endif")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user