add command line option to see song summary

This commit is contained in:
tildearrow 2023-10-17 14:11:35 -05:00
parent 94213d7cda
commit 06ba12b270
3 changed files with 85 additions and 4 deletions

View file

@ -78,6 +78,8 @@ bool vgmOutDirect=false;
bool safeMode=false;
bool safeModeWithAudio=false;
bool infoMode=false;
std::vector<TAParam> params;
TAParamResult pHelp(String) {
@ -161,6 +163,11 @@ TAParamResult pDirect(String val) {
return TA_PARAM_SUCCESS;
}
TAParamResult pInfo(String val) {
infoMode=true;
return TA_PARAM_SUCCESS;
}
TAParamResult pLogLevel(String val) {
if (val=="trace") {
logLevel=LOGLEVEL_TRACE;
@ -364,6 +371,7 @@ void initParams() {
params.push_back(TAParam("b","binary",false,pBinary,"","set command stream output format to binary"));
params.push_back(TAParam("L","loglevel",true,pLogLevel,"debug|info|warning|error","set the log level (info by default)"));
params.push_back(TAParam("v","view",true,pView,"pattern|commands|nothing","set visualization (pattern by default)"));
params.push_back(TAParam("i","info",false,pInfo,"","get info about a song"));
params.push_back(TAParam("c","console",false,pConsole,"","enable console mode"));
params.push_back(TAParam("l","loops",true,pLoops,"<count>","set number of loops (-1 means loop forever)"));
@ -525,9 +533,14 @@ int main(int argc, char** argv) {
return 1;
}
if (fileName.empty() && (benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
logE("provide a file!");
return 1;
}
#ifdef HAVE_GUI
if (e.preInit(false)) {
if (consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="") {
if (e.preInit(consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
if (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="") {
logW("engine wants safe mode, but Furnace GUI is not going to start.");
} else {
safeMode=true;
@ -539,7 +552,7 @@ int main(int argc, char** argv) {
}
#endif
if (safeMode && (consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
if (safeMode && (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
logE("you can't use safe mode and console/export mode together.");
return 0;
}
@ -548,7 +561,7 @@ int main(int argc, char** argv) {
e.setAudio(DIV_AUDIO_DUMMY);
}
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",false)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",false)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
logI("loading module...");
FILE* f=ps_fopen(fileName.c_str(),"rb");
if (f==NULL) {
@ -601,6 +614,12 @@ int main(int argc, char** argv) {
return 1;
}
}
if (infoMode) {
e.dumpSongInfo();
finishLogFile();
return 0;
}
if (!e.init()) {
if (consoleMode) {
reportError("could not initialize engine!");