From 93b13cadac400a59a044381d778d90fce1abe798 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 21 Jun 2020 15:56:31 -0700 Subject: [PATCH] Add -playassets command-line option This is used if you're loading a level file from STDIN. The game needs to know the actual level assets directory you're referring to, since when it gets the level from STDIN, it doesn't know the actual filename of the level. Fixes #309. --- desktop_version/src/Game.h | 1 + desktop_version/src/editor.cpp | 9 ++++++++- desktop_version/src/main.cpp | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index b2cc0d65..86b83d6d 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -382,6 +382,7 @@ public: int playrx; int playry; int playgc; + std::string playassets; void quittomenu(); void returntolab(); diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index ccb2c964..f74fc897 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -1623,7 +1623,14 @@ bool editorclass::load(std::string& _path) } FILESYSTEM_unmountassets(); - FILESYSTEM_mountassets(_path.c_str()); + if (game.playassets != "") + { + FILESYSTEM_mountassets(game.playassets.c_str()); + } + else + { + FILESYSTEM_mountassets(_path.c_str()); + } tinyxml2::XMLDocument doc; if (!FILESYSTEM_loadTiXml2Document(_path.c_str(), doc)) diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 90324fb5..dee8ee92 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -53,6 +53,7 @@ int saverx = 0; int savery = 0; int savegc = 0; int savemusic = 0; +std::string playassets; std::string playtestname; @@ -113,6 +114,15 @@ int main(int argc, char *argv[]) printf("-playing option requires one argument.\n"); return 1; } + } else if (strcmp(argv[i], "-playassets") == 0) { + if (i + 1 < argc) { + i++; + // Even if this is a directory, FILESYSTEM_mountassets() expects '.vvvvvv' on the end + playassets = "levels/" + std::string(argv[i]) + ".vvvvvv"; + } else { + printf("%s option requires one argument.\n", argv[i]); + return 1; + } } } @@ -280,6 +290,7 @@ int main(int argc, char *argv[]) if (startinplaytest) { game.levelpage = 0; game.playcustomlevel = 0; + game.playassets = playassets; ed.directoryList.clear(); ed.directoryList.push_back(playtestname);