Create shared resources header file

cpp
Elnu 3 years ago
parent 48886ecfd8
commit e88ff1ebe6

@ -2,6 +2,7 @@ import os, shutil
RES_DIR = "../res/"
PACKED_DIR = "../include/packed/"
SHARED_HEADER_PATH = f"{PACKED_DIR}/SharedResources.hpp"
resources = os.fsencode(RES_DIR)
os.makedirs(PACKED_DIR, exist_ok=True)
@ -14,6 +15,8 @@ for filename in os.listdir(packed_dir):
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
shared_header = "#pragma once\n\n"
for folder in os.listdir(resources):
folder_path = os.path.join(resources, folder)
if os.path.isfile(folder_path):
@ -23,7 +26,7 @@ for folder in os.listdir(resources):
for resource in os.listdir(folder_path):
resource_path = os.path.join(folder_path, resource)
res = ""
res = "#pragma once\n\n"
splitext = os.path.splitext(resource)
name = splitext[0].decode()
@ -45,5 +48,10 @@ for folder in os.listdir(resources):
bytes_processed += 1
encoded = encoded[:-2] + "\n};"
res += encoded + "\n"
with open(os.path.join(packed_path.decode(), f"{name}.hpp"), "w") as f:
f.write(res)
header_name = f"{name}.hpp"
with open(os.path.join(packed_path.decode(), header_name), "w") as f:
f.write(res)
shared_header += f'#include "{folder.decode()}/{header_name}"\n'
with open(SHARED_HEADER_PATH, "w") as f:
f.write(shared_header)

@ -8,16 +8,7 @@
#include <unistd.h>
#include <pwd.h>
#include <packed/audio/game_over_audio_data.hpp>
#include <packed/audio/level_up_audio_data.hpp>
#include <packed/audio/new_highscore_audio_data.hpp>
#include <packed/audio/rotate_audio_data.hpp>
#include <packed/audio/row_clear_audio_data.hpp>
#include <packed/audio/snap_audio_data.hpp>
#include <packed/textures/background_texture_data.hpp>
#include <packed/textures/blocks_texture_data.hpp>
#include <packed/textures/numerals_texture_data.hpp>
#include <packed/SharedResources.hpp>
#include <Config.hpp>
#include <NumberRenderer.hpp>

Loading…
Cancel
Save