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.
This commit is contained in:
Misa authored and Ethan Lee committed 2020-06-21 20:25:22 -04:00
1 parent d45ff4c269
commit 93b13cadac
3 files changed
+20 -1

No files matched your search

+1
View File
@@ -382,6 +382,7 @@ public:
int playrx;
int playry;
int playgc;
std::string playassets;
void quittomenu();
void returntolab();
+8 -1
View File
@@ -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))
+11
View File
@@ -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);