| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- /*
- * 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 <string>
- #include <vector>
- #include <iostream>
- #include "common/VGearsApplication.h"
- #include "FieldDataInstaller.h"
- #include "KernelDataInstaller.h"
- #include "MediaDataInstaller.h"
- #include "ModelsAndAnimationsDb.h"
- /**
- * The data installer.
- */
- class DataInstaller{
- public:
- /**
- * Advanced options available in the installer.
- */
- struct AdvancedOptions{
- /**
- * Option to skip kernel data installation.
- */
- bool skip_kernel;
- /**
- * Option to skip image installation.
- */
- bool skip_images;
- /**
- * Option to skip sound effects installation.
- */
- bool skip_sounds;
- /**
- * Option to skip music tracks installation.
- */
- bool skip_music;
- /**
- * Option to skip field maps installation.
- */
- bool skip_fields;
- /**
- * Option to skip field models installation.
- */
- bool skip_field_models;
- /**
- * Option to keep original data after installation.
- */
- bool keep_originals;
- /**
- * Option to avoid calls to the ffmpeg executable.
- */
- bool no_ffmpeg;
- /**
- * Option to avoid calls to the timidity executable
- */
- bool no_timidity;
- };
- /**
- * The scale factor for line point coordinates.
- *
- * When a LINE opcode is found in the game scripts, the line points X and Y coordinates
- * must be scaled down by this factor.
- */
- static float LINE_SCALE_FACTOR;
- /**
- * Installer constructor
- *
- * @param[in] input_dir Path to the directory containing the original data to parse.
- * @param[in] output_dir Path to the directory to write generated data to.
- * @param[in] options Adavanced options for the installer.
- * @param[in] write_output_line Pointer to function to write output.
- */
- DataInstaller(
- const std::string input_dir, const std::string output_dir, AdvancedOptions options,
- std::function<void(std::string, int, bool)> write_output_line
- );
- /**
- * Installer destructor.
- */
- ~DataInstaller();
- /**
- * Handle the installation progress.
- *
- * @return Installation progress [0-100].
- */
- float Progress();
- private:
- /**
- * Calculates the installation progress.
- *
- * @return Installation progress [0-100]
- */
- const float CalcProgress();
- /**
- * Creates a directory in the outputh path.
- *
- * @param[in] dir Path of the directory to create, relative to the output path.
- * @throws std::runtime_error If the directory can't be created.
- */
- void CreateDir(const std::string& dir);
- /**
- * Creates all directories required for the installation.
- *
- * It also adds certain location to the resource group manager.
- */
- void CreateDirectories();
- /**
- * Cleans up after the installation is complete.
- */
- void CleanInstall();
- /**
- * Installation steps.
- */
- enum InstallationSteps{
- /**
- * Installation not started.
- */
- IDLE = 0,
- /**
- * Create all directories required for the installation.
- */
- CREATE_DIRECTORIES,
- /**
- * Initialize data for installation.
- */
- INITIALIZE,
- /**
- * Parses item and materia prices from ff7.exe.
- */
- KERNEL_PRICES,
- /**
- * Parses command data from KERNEL.BIN.
- */
- KERNEL_COMMANDS,
- /**
- * Parses attack data from KERNEL.BIN.
- */
- KERNEL_ATTACKS,
- /**
- * Parses characters data from KERNEL.BIN.
- */
- KERNEL_CHARACTERS,
- /**
- * Parses item data from KERNEL.BIN.
- */
- KERNEL_ITEMS,
- /**
- * Parses growth data from KERNEL.BIN.
- */
- KERNEL_GROWTH,
- /**
- * Parses weapon data from KERNEL.BIN.
- */
- KERNEL_WEAPONS,
- /**
- * Parses armor data from KERNEL.BIN.
- */
- KERNEL_ARMORS,
- /**
- * Parses accessory data from KERNEL.BIN.
- */
- KERNEL_ACCESSORIES,
- /**
- * Parses materia data from KERNEL.BIN.
- */
- KERNEL_MATERIA,
- /**
- * Parses key item data data from KERNEL.BIN.
- */
- KERNEL_KEY_ITEMS,
- /**
- * Parses summon names data from KERNEL.BIN.
- */
- KERNEL_SUMMON_NAMES,
- /**
- * Parses the initial savemap from KERNEL.BIN.
- */
- KERNEL_SAVEMAP,
- /**
- * Extract game images and icons from menu.lgp.
- */
- MEDIA_IMAGES,
- /**
- * Prepares the installer for sound extraction.
- */
- MEDIA_SOUNDS_INIT,
- /**
- * Extract game sounds.
- */
- MEDIA_SOUNDS,
- /**
- * Build sounds index.
- */
- MEDIA_SOUNDS_INDEX,
- /**
- * Prepares the installer for music extraction.
- */
- MEDIA_MUSICS_INIT,
- /**
- * Extracts the game music.
- */
- MEDIA_MUSICS,
- /**
- * Extracts the game high quality music.
- */
- MEDIA_MUSICS_HQ,
- /**
- * Build the music index.
- */
- MEDIA_MUSICS_INDEX,
- /**
- * Initializer for {@see SPAWN_POINTS_AND_SCALE_FACTORS}.
- */
- FIELD_SPAWN_POINTS_AND_SCALE_FACTORS_INIT,
- /**
- * Step that collects spawn points and sclae factors.
- */
- FIELD_SPAWN_POINTS_AND_SCALE_FACTORS,
- /**
- * Step that convets fields to V-Gears format.
- */
- FIELD_CONVERT,
- /**
- * Initializer for {@see WRITE_MAPS}.
- */
- FIELD_WRITE_INIT,
- /**
- * Step that writes XML maps.
- */
- FIELD_WRITE,
- /**
- * Clean up after {@see WRITE_MAPS}.
- */
- FIELD_WRITE_END,
- /**
- * Initializer for {@see CONVERT_FIELD_MODELS}.
- */
- FIELD_CONVERT_MODELS_INIT,
- /**
- * Step that converts field models.
- */
- FIELD_CONVERT_MODELS,
- /**
- * Cleans up after the installation.
- */
- CLEAN,
- /**
- * Number of installation steps.
- */
- STATE_COUNT,
- /**
- * Installation finished.
- */
- DONE = 100,
- };
- /**
- * Current installation status.
- */
- InstallationSteps installation_state_ = IDLE;
- /**
- * Substeps in the current installation step.
- */
- int substeps_;
- /**
- * Current substep in the current installation step.
- */
- int cur_substep_;
- /**
- * Weight of each installation step.
- *
- * Used to calculate current progress.
- */
- int step_weight_[STATE_COUNT];
- /**
- * List of field model names.
- */
- std::vector<std::string> field_model_names_;
- /**
- * 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_;
- /**
- * Advanced options.
- */
- AdvancedOptions options_;
- /**
- * The installer application.
- *
- * It's a singleton so it can't be recreated. It will crash the second
- * time round.
- */
- VGears::Application application_;
- /**
- * LGP archive with field data.
- */
- std::unique_ptr<ScopedLgp> fields_lgp_;
- /**
- * The installer for fiel maps data.
- */
- std::unique_ptr<FieldDataInstaller> field_installer_;
- /**
- * The installer for kernel data.
- */
- std::unique_ptr<KernelDataInstaller> kernel_installer_;
- /**
- * The installer for media files.
- */
- std::unique_ptr<MediaDataInstaller> media_installer_;
- /**
- * Function used to print text to the log output, line by line.
- *
- * @param[in] msg the message to write.
- * @param[in] level Log level for the message.
- * @param[in] as_progress If true, the text will also be set as the current text behind the
- * progress bar.
- */
- std::function<void(std::string msg, int level, bool progress)> write_output_line_;
- };
|