diff options
| author | inspectredc <inspectredc@gmail.com> | 2025-01-09 00:15:16 +0000 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2025-01-08 20:37:42 -0600 |
| commit | 94be71101cf5a81685949a6025a3870f2d798284 (patch) | |
| tree | f57c33ac67292a463273c3d04979294ee6f8ddc6 /src/main.cpp | |
| parent | ef48a4bf5c8731c1cb5120e2deb64eaa05551ad4 (diff) | |
O2R Support
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp index d3b6ffb..53c2c52 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,9 @@ int main(int argc, char *argv[]) { std::string filename; std::string target; std::string folder; - bool otrMode = false; + std::string archive; + ArchiveType otrMode = ArchiveType::None; + bool otrModeSelected = false; bool xmlMode = false; bool debug = false; @@ -28,7 +30,18 @@ int main(int argc, char *argv[]) { otr->add_flag("-v,--verbose", debug, "Verbose Debug Mode"); otr->parse_complete_callback([&] { - const auto instance = Companion::Instance = new Companion(filename, true, debug); + const auto instance = Companion::Instance = new Companion(filename, ArchiveType::OTR, debug); + instance->Init(ExportType::Binary); + }); + + /* Generate an O2R */ + const auto o2r = app.add_subcommand("o2r", "O2R - Generates an o2r\n"); + + o2r->add_option("<baserom.z64>", filename, "")->required()->check(CLI::ExistingFile); + o2r->add_flag("-v,--verbose", debug, "Verbose Debug Mode"); + + o2r->parse_complete_callback([&] { + const auto instance = Companion::Instance = new Companion(filename, ArchiveType::O2R, debug); instance->Init(ExportType::Binary); }); @@ -39,7 +52,7 @@ int main(int argc, char *argv[]) { code->add_flag("-v,--verbose", debug, "Verbose Debug Mode; adds offsets to C code"); code->parse_complete_callback([&]() { - const auto instance = Companion::Instance = new Companion(filename, false, debug); + const auto instance = Companion::Instance = new Companion(filename, ArchiveType::None, debug); instance->Init(ExportType::Code); }); @@ -49,7 +62,7 @@ int main(int argc, char *argv[]) { binary->add_option("<baserom.z64>", filename, "")->required()->check(CLI::ExistingFile); binary->parse_complete_callback([&] { - const auto instance = Companion::Instance = new Companion(filename, false, debug); + const auto instance = Companion::Instance = new Companion(filename, ArchiveType::None, debug); instance->Init(ExportType::Binary); }); @@ -57,22 +70,36 @@ int main(int argc, char *argv[]) { const auto header = app.add_subcommand("header", "Header - Generates headers only\n"); header->add_option("<baserom.z64>", filename, "")->required()->check(CLI::ExistingFile); - header->add_flag("-o,--otr", otrMode, "OTR Mode"); + header->add_flag("-o,--otr", otrModeSelected, "OTR/O2R Mode"); + + if (otrModeSelected) { + otrMode = ArchiveType::OTR; + } header->parse_complete_callback([&] { const auto instance = Companion::Instance = new Companion(filename, otrMode, debug); instance->Init(ExportType::Header); }); - /* Pack an otr from a folder */ - const auto pack = app.add_subcommand("pack", "Pack - Packs an otr from a folder\n"); + /* Pack an archive from a folder */ + const auto pack = app.add_subcommand("pack", "Pack - Packs an archive from a folder\n"); pack->add_option("<folder>", folder, "Generate OTR from a directory of assets")->required()->check(CLI::ExistingDirectory); - pack->add_option("<target>", target, "OTR output destination")->required(); + pack->add_option("<target>", target, "Archive output destination")->required(); + pack->add_option("<archive-type>", archive, "Archive type: otr or o2r")->required(); + pack->parse_complete_callback([&] { + if (archive == "otr") { + otrMode = ArchiveType::OTR; + } else if (archive == "o2r") { + otrMode = ArchiveType::O2R; + } else { + std::cout << "Invalid archive type" << std::endl; + } + if (!folder.empty()) { - Companion::Pack(folder, target); + Companion::Pack(folder, target, otrMode); } else { std::cout << "The folder is empty" << std::endl; } @@ -87,7 +114,7 @@ int main(int argc, char *argv[]) { modding_import->add_option("<baserom.z64>", filename, "")->required()->check(CLI::ExistingFile); modding_import->parse_complete_callback([&] { - const auto instance = Companion::Instance = new Companion(filename, false, debug, true); + const auto instance = Companion::Instance = new Companion(filename, ArchiveType::None, debug, true); if (mode == "code") { instance->Init(ExportType::Code); } else if (mode == "binary") { @@ -103,7 +130,7 @@ int main(int argc, char *argv[]) { modding_export->add_option("<baserom.z64>", filename, "")->required()->check(CLI::ExistingFile); modding_export->parse_complete_callback([&] { - const auto instance = Companion::Instance = new Companion(filename, false, debug); + const auto instance = Companion::Instance = new Companion(filename, ArchiveType::None, debug); if (xmlMode) { instance->Init(ExportType::XML); } else { |
