PkmnLibTools/src/main.cpp

71 lines
3.2 KiB
C++

#include <iostream>
#include "../extern/args.hpp"
#include "BuildData/BuildItems.hpp"
#include "BuildData/BuildMoves.hpp"
#include "BuildData/BuildNatures.hpp"
#include "BuildData/BuildSpecies.hpp"
#include "BuildData/BuildTypes.hpp"
#include "BuildData/GrowthRatesBuilder.hpp"
#include "Tools/ScriptCompiler.hpp"
#include "Tools/ScriptHeadersExporter.hpp"
[[maybe_unused]] static PkmnLib::Library::PokemonLibrary* BuildDataLibrary() {
std::string typesFile = "Types.csv";
std::string naturesFile = "Natures.csv";
std::string pokemonFile = "Pokemon.json";
std::string moveFile = "Moves.json";
std::string itemsFile = "Items.json";
std::string growthRatesFile = "GrowthRates.json";
std::string scriptsPath = "Scripts";
auto typesLibrary = BuildTypes::Build(typesFile);
auto natureLibrary = BuildNatures::Build(naturesFile);
auto speciesLibrary = BuildSpecies::BuildLibrary(pokemonFile, typesLibrary);
auto movesLibrary = BuildMoves::Build(moveFile, typesLibrary);
auto itemsLibrary = BuildItems::Build(itemsFile);
auto growthRates = GrowthRatesBuilder::Build(growthRatesFile);
if (typesLibrary == nullptr || speciesLibrary == nullptr || natureLibrary == nullptr || movesLibrary == nullptr ||
itemsLibrary == nullptr || growthRates == nullptr)
return nullptr;
auto settings = new PkmnLib::Library::LibrarySettings(100, 4, 4096);
return new PkmnLib::Library::PokemonLibrary(settings, speciesLibrary, movesLibrary, itemsLibrary, growthRates,
typesLibrary, natureLibrary);
};
int main(int argc, const char* argv[]) {
args::ArgumentParser parser("PkmnLib tool executable.", "");
args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"});
args::Group tools(parser, "Tools");
args::Command exportScriptHeaders(tools, "export-script-headers", "Exports the Angelscript script headers");
args::Command compileScripts(tools, "compile-scripts", "Compile the given scripts");
args::ValueFlag<std::string> outPathExportScriptHeaders(exportScriptHeaders, "outpath", "The path to output to.",
{'o'});
args::ValueFlag<std::string> inPathCompileScripts(compileScripts, "inpath", "The path to read scripts from.",
{'i'});
args::ValueFlag<std::string> outPathCompileScripts(compileScripts, "outpath", "The path to output to.", {'o'});
try {
parser.ParseCLI(argc, argv);
} catch (const args::Help&) {
std::cout << parser;
return 0;
} catch (const args::ParseError& e) {
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
if (exportScriptHeaders) {
std::string outPathValue = args::get(outPathExportScriptHeaders);
ScriptHeadersExporter::Export(outPathValue);
} else if (compileScripts) {
std::string inPathValue = args::get(inPathCompileScripts);
std::string outPathValue = args::get(outPathCompileScripts);
ScriptCompiler::Compile(inPathValue, outPathValue);
} else {
std::stringstream ss;
return 1;
}
return 0;
}