Skip to content

Commit

Permalink
remove hardcoded soh assets and allow custom assets to be passed in (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez authored Oct 25, 2023
1 parent 89de147 commit f1bc0a7
Show file tree
Hide file tree
Showing 111 changed files with 51 additions and 3,734 deletions.
45 changes: 32 additions & 13 deletions OTRExporter/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include <mutex>

std::string otrFileName = "oot.otr";
std::string customOtrFileName = "";
std::string customAssetsPath = "";

std::shared_ptr<LUS::Archive> otrArchive;
BinaryWriter* fileWriter;
std::chrono::steady_clock::time_point fileStart, resStart;
Expand Down Expand Up @@ -114,12 +117,18 @@ static void ExporterProgramEnd()
delete fileWriter;
files.clear();

// Add any additional files that need to be manually copied...
if (DiskFile::Exists("soh.otr")) {
// Generate custom otr file for extra assets
if (customAssetsPath == "" || customOtrFileName == "" || DiskFile::Exists(customOtrFileName)) {
printf("No Custom Assets path or otr file name provided, otr file already exists. Nothing to do.\n");
return;
}
const auto& lst = Directory::ListFiles("Extract");
std::shared_ptr<LUS::Archive> sohOtr = LUS::Archive::CreateArchive("soh.otr", 4096);

if (!customAssetsPath.ends_with("/")) {
customAssetsPath += "/";
}

const auto& lst = Directory::ListFiles(customAssetsPath);
std::shared_ptr<LUS::Archive> customOtr = LUS::Archive::CreateArchive(customOtrFileName, 4096);
//sohOtr->AddFile("version", (uintptr_t)versionStream->ToVector().data(), versionStream->GetLength());

for (const auto& item : lst)
Expand All @@ -138,7 +147,7 @@ static void ExporterProgramEnd()
ZTexture tex(nullptr);
Globals::Instance->buildRawTexture = true;
tex.FromPNG(item, ZTexture::GetTextureTypeFromString(format));
printf("sohOtr->AddFile(%s)\n", StringHelper::Split(afterPath, "Extract/")[1].c_str());
printf("customOtr->AddFile(%s)\n", StringHelper::Split(afterPath, customAssetsPath)[1].c_str());

OTRExporter_Texture exporter;

Expand All @@ -151,7 +160,7 @@ static void ExporterProgramEnd()
writer.Write((char *)src.c_str(), src.size());

std::vector<char> fileData = stream->ToVector();
sohOtr->AddFile(StringHelper::Split(afterPath, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size());
customOtr->AddFile(StringHelper::Split(afterPath, customAssetsPath)[1], (uintptr_t)fileData.data(), fileData.size());
continue;
}
}
Expand All @@ -163,28 +172,38 @@ static void ExporterProgramEnd()
if (extension == "json")
{
const auto &fileData = DiskFile::ReadAllBytes(item);
printf("Adding accessibility texts %s\n", StringHelper::Split(item, "texts/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size());
printf("Adding accessibility texts %s\n", StringHelper::Split(item, customAssetsPath)[1].c_str());
customOtr->AddFile(StringHelper::Split(item, customAssetsPath)[1], (uintptr_t)fileData.data(), fileData.size());
}
continue;
}

const auto& fileData = DiskFile::ReadAllBytes(item);
printf("sohOtr->AddFile(%s)\n", StringHelper::Split(item, "Extract/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, item.find("Extract/assets/") != std::string::npos ? "Extract/assets/" : "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
printf("customOtr->AddFile(%s)\n", StringHelper::Split(item, customAssetsPath)[1].c_str());
customOtr->AddFile(StringHelper::Split(item, customAssetsPath)[1], (uintptr_t)fileData.data(), fileData.size());
}
sohOtr = nullptr;

customOtr = nullptr;
}

static void ExporterParseArgs(int argc, char* argv[], int& i)
{
std::string arg = argv[i];

if (arg == "--otrfile")
{
if (arg == "--otrfile") {
otrFileName = argv[i + 1];
i++;
}

if (arg == "--customOtrFile") {
customOtrFileName = argv[i + 1];
i++;
}

if (arg == "--customAssetsPath") {
customAssetsPath = argv[i + 1];
i++;
}
}

static bool ExporterProcessFileMode(ZFileMode fileMode)
Expand Down
29 changes: 0 additions & 29 deletions assets/accessibility/texts/filechoose_eng.json

This file was deleted.

29 changes: 0 additions & 29 deletions assets/accessibility/texts/filechoose_fra.json

This file was deleted.

29 changes: 0 additions & 29 deletions assets/accessibility/texts/filechoose_ger.json

This file was deleted.

Loading

0 comments on commit f1bc0a7

Please sign in to comment.