Remove assets folder, use more std::filesystem (#1575)

* Remove assets folder, use more std::filesystem

* windows fix

* another one for windows

* another one

* better system for different folders

* rm debugging stuff

* let extractor override everything

* dont revert jak1 change
This commit is contained in:
water111
2022-06-29 23:32:46 -04:00
committed by GitHub
parent 36dc015d62
commit 1e33dcda4b
36 changed files with 486 additions and 344 deletions
+15 -11
View File
@@ -202,7 +202,8 @@ std::vector<level_tools::TextureRemap> extract_bsp_from_level(const ObjectFileDB
void extract_common(const ObjectFileDB& db,
const TextureDB& tex_db,
const std::string& dgo_name,
bool dump_levels) {
bool dump_levels,
const std::filesystem::path& output_folder) {
if (db.obj_files_by_dgo.count(dgo_name) == 0) {
lg::warn("Skipping common extract for {} because the DGO was not part of the input", dgo_name);
return;
@@ -227,9 +228,9 @@ void extract_common(const ObjectFileDB& db,
print_memory_usage(tfrag_level, ser.get_save_result().second);
fmt::print("compressed: {} -> {} ({:.2f}%)\n", ser.get_save_result().second, compressed.size(),
100.f * compressed.size() / ser.get_save_result().second);
file_util::write_binary_file(file_util::get_file_path({fmt::format(
"assets/{}.fr3", dgo_name.substr(0, dgo_name.length() - 4))}),
compressed.data(), compressed.size());
file_util::write_binary_file(
output_folder / fmt::format("{}.fr3", dgo_name.substr(0, dgo_name.length() - 4)),
compressed.data(), compressed.size());
}
void extract_from_level(const ObjectFileDB& db,
@@ -237,7 +238,8 @@ void extract_from_level(const ObjectFileDB& db,
const std::string& dgo_name,
const DecompileHacks& hacks,
bool dump_level,
bool extract_collision) {
bool extract_collision,
const std::filesystem::path& output_folder) {
if (db.obj_files_by_dgo.count(dgo_name) == 0) {
lg::warn("Skipping extract for {} because the DGO was not part of the input", dgo_name);
return;
@@ -258,9 +260,9 @@ void extract_from_level(const ObjectFileDB& db,
print_memory_usage(level_data, ser.get_save_result().second);
fmt::print("compressed: {} -> {} ({:.2f}%)\n", ser.get_save_result().second, compressed.size(),
100.f * compressed.size() / ser.get_save_result().second);
file_util::write_binary_file(file_util::get_file_path({fmt::format(
"assets/{}.fr3", dgo_name.substr(0, dgo_name.length() - 4))}),
compressed.data(), compressed.size());
file_util::write_binary_file(
output_folder / fmt::format("{}.fr3", dgo_name.substr(0, dgo_name.length() - 4)),
compressed.data(), compressed.size());
}
void extract_all_levels(const ObjectFileDB& db,
@@ -269,12 +271,14 @@ void extract_all_levels(const ObjectFileDB& db,
const std::string& common_name,
const DecompileHacks& hacks,
bool debug_dump_level,
bool extract_collision) {
extract_common(db, tex_db, common_name, debug_dump_level);
bool extract_collision,
const std::filesystem::path& output_path) {
extract_common(db, tex_db, common_name, debug_dump_level, output_path);
SimpleThreadGroup threads;
threads.run(
[&](int idx) {
extract_from_level(db, tex_db, dgo_names[idx], hacks, debug_dump_level, extract_collision);
extract_from_level(db, tex_db, dgo_names[idx], hacks, debug_dump_level, extract_collision,
output_path);
},
dgo_names.size());
threads.join();