mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 15:28:58 -04:00
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:
@@ -89,7 +89,7 @@ struct VagFileHeader {
|
||||
/*!
|
||||
* Read the DIR file into an AudioDir
|
||||
*/
|
||||
AudioDir read_audio_dir(const std::string& path) {
|
||||
AudioDir read_audio_dir(const std::filesystem::path& path) {
|
||||
// matches the format in file.
|
||||
struct DirEntry {
|
||||
char name[8];
|
||||
@@ -145,7 +145,8 @@ struct AudioFileInfo {
|
||||
double length_seconds;
|
||||
};
|
||||
|
||||
AudioFileInfo process_audio_file(const std::vector<u8>& data,
|
||||
AudioFileInfo process_audio_file(const std::filesystem::path& output_folder,
|
||||
const std::vector<u8>& data,
|
||||
const std::string& name,
|
||||
const std::string& suffix) {
|
||||
BinaryReader reader(data);
|
||||
@@ -168,10 +169,9 @@ AudioFileInfo process_audio_file(const std::vector<u8>& data,
|
||||
ASSERT(reader.read<u8>() == 0);
|
||||
}
|
||||
|
||||
file_util::create_dir_if_needed(file_util::get_file_path({"assets", "streaming_audio", suffix}));
|
||||
file_util::create_dir_if_needed(output_folder / suffix);
|
||||
auto file_name = fmt::format("{}.wav", remove_trailing_spaces(name));
|
||||
write_wave_file_mono(decoded_samples, header.sample_rate,
|
||||
file_util::get_file_path({"assets", "streaming_audio", suffix, file_name}));
|
||||
write_wave_file_mono(decoded_samples, header.sample_rate, output_folder / suffix / file_name);
|
||||
|
||||
std::string vag_filename;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
@@ -182,11 +182,10 @@ AudioFileInfo process_audio_file(const std::vector<u8>& data,
|
||||
return {vag_filename, (double)decoded_samples.size() / header.sample_rate};
|
||||
}
|
||||
|
||||
void process_streamed_audio(const std::string& dir, const std::vector<std::string>& audio_files) {
|
||||
auto dir_file_name = file_util::combine_path(dir, "VAGDIR.AYB");
|
||||
lg::info("Streaming audio: {}\n", dir_file_name);
|
||||
file_util::create_dir_if_needed(file_util::get_file_path({"assets", "streaming_audio"}));
|
||||
auto dir_data = read_audio_dir(file_util::get_file_path({"iso_data", dir_file_name}));
|
||||
void process_streamed_audio(const std::filesystem::path& output_path,
|
||||
const std::filesystem::path& input_dir,
|
||||
const std::vector<std::string>& audio_files) {
|
||||
auto dir_data = read_audio_dir(input_dir / "VAG" / "VAGDIR.AYB");
|
||||
double audio_len = 0.f;
|
||||
|
||||
std::vector<std::string> langs;
|
||||
@@ -201,14 +200,14 @@ void process_streamed_audio(const std::string& dir, const std::vector<std::strin
|
||||
|
||||
for (size_t lang_id = 0; lang_id < audio_files.size(); lang_id++) {
|
||||
auto& file = audio_files[lang_id];
|
||||
auto wad_data = file_util::read_binary_file(file_util::get_file_path({"iso_data", dir, file}));
|
||||
auto wad_data = file_util::read_binary_file(input_dir / "VAG" / file);
|
||||
auto suffix = std::filesystem::path(file).extension().u8string().substr(1);
|
||||
langs.push_back(suffix);
|
||||
dir_data.set_file_size(wad_data.size());
|
||||
for (int i = 0; i < dir_data.entry_count(); i++) {
|
||||
auto audio_data = read_entry(dir_data, wad_data, i);
|
||||
lg::info("File {}, total {:.2f} minutes", dir_data.entries.at(i).name, audio_len / 60.0);
|
||||
auto info = process_audio_file(audio_data, dir_data.entries.at(i).name, suffix);
|
||||
auto info = process_audio_file(output_path, audio_data, dir_data.entries.at(i).name, suffix);
|
||||
audio_len += info.length_seconds;
|
||||
filename_data[i][lang_id + 1] = info.filename;
|
||||
}
|
||||
@@ -218,8 +217,7 @@ void process_streamed_audio(const std::string& dir, const std::vector<std::strin
|
||||
file_list["names"] = filename_data;
|
||||
file_list["languages"] = langs;
|
||||
|
||||
file_util::write_text_file(
|
||||
file_util::get_file_path({"assets", "streaming_audio", "file_list.txt"}), file_list.dump(2));
|
||||
file_util::write_text_file(output_path / "file_list.txt", file_list.dump(2));
|
||||
}
|
||||
|
||||
} // namespace decompiler
|
||||
|
||||
Reference in New Issue
Block a user