add a proper CLI
featuring skip order (left/right) and pause (space)! currently available on macOS and Linux only.
This commit is contained in:
parent
3183400019
commit
83386d082d
5 changed files with 229 additions and 15 deletions
40
src/main.cpp
40
src/main.cpp
|
|
@ -36,6 +36,8 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "cli/cli.h"
|
||||
|
||||
#ifdef HAVE_GUI
|
||||
#include "gui/gui.h"
|
||||
#endif
|
||||
|
|
@ -46,6 +48,8 @@ DivEngine e;
|
|||
FurnaceGUI g;
|
||||
#endif
|
||||
|
||||
FurnaceCLI cli;
|
||||
|
||||
String outName;
|
||||
String vgmOutName;
|
||||
int loops=1;
|
||||
|
|
@ -465,25 +469,39 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
if (consoleMode) {
|
||||
bool cliSuccess=false;
|
||||
cli.bindEngine(&e);
|
||||
if (!cli.init()) {
|
||||
reportError("error while starting CLI!");
|
||||
} else {
|
||||
cliSuccess=true;
|
||||
}
|
||||
logI("playing...");
|
||||
e.play();
|
||||
if (cliSuccess) {
|
||||
cli.loop();
|
||||
cli.finish();
|
||||
e.quit();
|
||||
return 0;
|
||||
} else {
|
||||
#ifdef HAVE_SDL2
|
||||
SDL_Event ev;
|
||||
while (true) {
|
||||
SDL_WaitEvent(&ev);
|
||||
if (ev.type==SDL_QUIT) break;
|
||||
}
|
||||
e.quit();
|
||||
return 0;
|
||||
SDL_Event ev;
|
||||
while (true) {
|
||||
SDL_WaitEvent(&ev);
|
||||
if (ev.type==SDL_QUIT) break;
|
||||
}
|
||||
e.quit();
|
||||
return 0;
|
||||
#else
|
||||
while (true) {
|
||||
while (true) {
|
||||
#ifdef _WIN32
|
||||
Sleep(500);
|
||||
Sleep(500);
|
||||
#else
|
||||
usleep(500000);
|
||||
usleep(500000);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_GUI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue