/* * Copyright (C) 2022 The V-Gears Team * * This file is part of V-Gears * * V-Gears is free software: you can redistribute it and/or modify it under * terms of the GNU General Public License as published by the Free Software * Foundation, version 3.0 (GPLv3) of the License. * * V-Gears is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #pragma once #include #include "data/VGearsLGPArchive.h" #include "common/BinGZipFile.h" #include "TexFile.h" /** * The media data installer. */ class MediaDataInstaller{ public: /** * Constructor * * @param[in] input_dir Path to the directory containing the original data to parse. * @param[out] input_dir Path to the directory of the installation data. */ MediaDataInstaller(const std::string input_dir, const std::string output_dir); /** * Destructor. */ ~MediaDataInstaller(); /** * Populates the audio name maps. */ void PopulateMaps(); /** * Extracts all images contained in the menu LGP file and installs them. * * For composed textures, it extracts individual images. All images are saved under the * "images" directory. This also includes font maps. */ void InstallSprites(); /** * Prepares the installer for the sounds extraction. * * @return The total number of sounds to process. */ int InstallSoundsInit(); /** * Extracts the next sound file contained in the audio.dat file and installs it. * * @return True if there are no more sounds to extract, false otherwise. */ bool InstallSounds(); /** * Writes the XML file with all audio entries. */ void WriteSoundIndex(); /** * Prepares the installer for the sounds extraction. * * @return The total number of sounds to process. */ int InstallMusicsInit(); /** * Extracts the next music file contained in the midi.lgp, converts it and installs it. * * @return True if there are no more musics to extract, false otherwise. */ bool InstallMusics(); /** * Converts high quality musiscs to OGG. * * There are four of them. */ void InstallHQMusics(); /** * Writes the XML file with all music tracks. */ void WriteMusicsIndex(); private: /** * Number of sound files to extract. */ static int TOTAL_SOUNDS; /** * The standard WAV header. * * 78 bytes to be written to every wav file before anything else. */ static u8 WAV_HEADER[78]; /** * The structure of each audio file pointer in a sound FMT file. 74 bytes. */ struct FmtFile{ /** * Size of the wav file in the dat. 4 bytes. */ u32 size; /** * Offset of the wav file in the dat. 4 bytes. */ u32 offset; /** * Information for sound looping. 12 bytes. */ u8 loop_metadata[16]; /** * Microsoft WAVFORMATEX header for the wav file. 44 bytes. */ u8 wav_header[18]; /** * Samples per block. 2 bytes. */ u16 samples_per_block; /** * Number of ADPCM coefficients (used for compression, should always be 7). 2 bytes. */ u16 adpcm; /** * Standard Microsoft ADPCMCoefSets. 28 bytes. */ u8 adpcm_sets[28]; }; /** * The path to the directory from which to read the PC game data. */ std::string input_dir_; /** * The path to the directory where to save the V-Gears data. */ std::string output_dir_; /** * The menu.lgp file. */ VGears::LGPArchive menu_; /** * The WINDOW.BIN file. */ BinGZipFile window_; /** * The sounds .fmt file. */ File fmt_; /** * The sounds .dat file. */ File dat_; /** * Number of sounds already processed. */ int processed_sounds_; /** * Map for sound files with descriptive names. */ std::unordered_map sound_map_; /** * Sound data for each entry to write to the XML file */ std::vector sounds_; /** * The midi.lgp file. */ VGears::LGPArchive midi_; /** * Number of music tracks already processed. */ int processed_musics_; /** * Map for music files with descriptive names. */ std::unordered_map musics_map_; /** * Sound data for each entry to write to the XML file */ std::vector musics_; };