summaryrefslogtreecommitdiff
path: root/tools/ZAPD/ExporterTest/Main.cpp
diff options
context:
space:
mode:
authorlouist103 <35883445+louist103@users.noreply.github.com>2021-10-17 07:32:09 -0400
committerGitHub <noreply@github.com>2021-10-17 13:32:09 +0200
commit750c0cab351cc331b07af3f5c064fa85055b172e (patch)
tree2f81efecb3b4a9cce174b38a1aaf6bd9d653e420 /tools/ZAPD/ExporterTest/Main.cpp
parented487b4bb849b027481c2d52b06aa5bec9d44f2c (diff)
Update ZAPD (#1001)
* remove fake match * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "3e9ed72e2" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "3e9ed72e2" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * new extraction script and a hack to make clear tag work * fix clear tag again * remove static from clear tag DLists * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "e7a8a48cf" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e7a8a48cf" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "e243634e5" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e243634e5" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "d0cd6b397" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "d0cd6b397" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Update ovl_En_Clear_Tag.xml
Diffstat (limited to 'tools/ZAPD/ExporterTest/Main.cpp')
-rw-r--r--tools/ZAPD/ExporterTest/Main.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/tools/ZAPD/ExporterTest/Main.cpp b/tools/ZAPD/ExporterTest/Main.cpp
new file mode 100644
index 000000000..732dcedc2
--- /dev/null
+++ b/tools/ZAPD/ExporterTest/Main.cpp
@@ -0,0 +1,79 @@
+#include <CollisionExporter.h>
+#include <Globals.h>
+#include <RoomExporter.h>
+#include <TextureExporter.h>
+
+enum class ExporterFileMode
+{
+ ModeExample1 = (int)ZFileMode::Custom + 1,
+ ModeExample2 = (int)ZFileMode::Custom + 2,
+ ModeExample3 = (int)ZFileMode::Custom + 3,
+};
+
+static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileMode)
+{
+ if (buildMode == "me1")
+ fileMode = (ZFileMode)ExporterFileMode::ModeExample1;
+ else if (buildMode == "me2")
+ fileMode = (ZFileMode)ExporterFileMode::ModeExample2;
+ else if (buildMode == "me3")
+ fileMode = (ZFileMode)ExporterFileMode::ModeExample3;
+}
+
+static void ExporterParseArgs([[maybe_unused]] int argc, char* argv[], int& i)
+{
+ std::string arg = argv[i];
+
+ if (arg == "--do-x")
+ {
+ }
+ else if (arg == "--do-y")
+ {
+ }
+}
+
+static bool ExporterProcessFileMode(ZFileMode fileMode)
+{
+ // Do whatever work is associated with these custom file modes...
+ // Return true to indicate one of our own file modes is being processed
+ if (fileMode == (ZFileMode)ExporterFileMode::ModeExample1)
+ return true;
+ else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample2)
+ return true;
+ else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample3)
+ return true;
+
+ return false;
+}
+
+static void ExporterFileBegin(ZFile* file)
+{
+ printf("ExporterFileBegin() called on ZFile %s.\n", file->GetName().c_str());
+}
+
+static void ExporterFileEnd(ZFile* file)
+{
+ printf("ExporterFileEnd() called on ZFile %s.\n", file->GetName().c_str());
+}
+
+static void ImportExporters()
+{
+ // In this example we set up a new exporter called "EXAMPLE".
+ // By running ZAPD with the argument -se EXAMPLE, we tell it that we want to use this exporter
+ // for our resources.
+ ExporterSet* exporterSet = new ExporterSet();
+ exporterSet->processFileModeFunc = ExporterProcessFileMode;
+ exporterSet->parseFileModeFunc = ExporterParseFileMode;
+ exporterSet->parseArgsFunc = ExporterParseArgs;
+ exporterSet->beginFileFunc = ExporterFileBegin;
+ exporterSet->endFileFunc = ExporterFileEnd;
+ exporterSet->exporters[ZResourceType::Texture] = new ExporterExample_Texture();
+ exporterSet->exporters[ZResourceType::Room] = new ExporterExample_Room();
+ exporterSet->exporters[ZResourceType::CollisionHeader] = new ExporterExample_Collision();
+
+ Globals::AddExporter("EXAMPLE", exporterSet);
+}
+
+// When ZAPD starts up, it will automatically call the below function, which in turn sets up our
+// exporters.
+REGISTER_EXPORTER(ImportExporters) \ No newline at end of file