Skip to content

Commit

Permalink
cli: support loading multiple roms at once and surpressing file dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeUsher committed Jul 17, 2023
1 parent cab7096 commit dafb570
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ Command-line options
When started from the command-line, ares accepts a few options.

```
Usage: ./ares [options] game
Usage: ./ares [options] game(s)
--help Displays available options and exit
--fullscreen Start in full screen mode
--system system Specify the system name
--shader shader Specify GLSL shader name to load (requires OpenGL driver)
--setting name=value Specify a value for a setting
--dump-all-settings Show a list of all existing settings and exit
--no-file-prompt Do not prompt to load (optional) additional roms (eg: 64DD)
```

The --system option is useful when the system type cannot be auto-detected.
Expand All @@ -121,6 +122,17 @@ The --system option is useful when the system type cannot be auto-detected.
Example:
`ares --system MSX examples.rom --fullscreen`

Specifying multiple games allows for multi-cart support. For example, to load
the Super GameBoy BIOS and a game in one command (to avoid a file prompt), you
can do:

`ares "Super GameBoy.sfc" "Super Mario Land.gb"`

The --no-file-prompt option is useful if you wish to launch a game from CLI
without being prompted to load additional roms. For example, some Nintendo 64
games optionally support 64DD expansion disks, so this option can be used to
suppress the "64DD Disk" file dialog, and assume any secondary content is
disconnected.

High-level Components
---------------------
Expand Down
10 changes: 8 additions & 2 deletions desktop-ui/desktop-ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ auto nall::main(Arguments arguments) -> void {
program.startShader = shader;
}

if(arguments.take("--no-file-prompt")) {
program.noFilePrompt = true;
}

inputManager.create();
Emulator::construct();
settings.load();
Expand All @@ -93,7 +97,7 @@ auto nall::main(Arguments arguments) -> void {
}

if(arguments.take("--help")) {
print("Usage: ares [OPTIONS]... game\n\n");
print("Usage: ares [OPTIONS]... game(s)\n\n");
print("Options:\n");
print(" --help Displays available options and exit\n");
#if defined(PLATFORM_WINDOWS)
Expand All @@ -104,6 +108,7 @@ auto nall::main(Arguments arguments) -> void {
print(" --shader name Specify the name of the shader to use\n");
print(" --setting name=value Specify a value for a setting\n");
print(" --dump-all-settings Show a list of all existing settings and exit\n");
print(" --no-file-prompt Do not prompt to load (optional) additional roms (eg: 64DD)\n");
print("\n");
print("Available Systems:\n");
print(" ");
Expand All @@ -126,8 +131,9 @@ auto nall::main(Arguments arguments) -> void {
return;
}

program.startGameLoad.reset();
for(auto argument : arguments) {
if(file::exists(argument)) program.startGameLoad = argument;
if(file::exists(argument)) program.startGameLoad.append(argument);
}

Instances::presentation.construct();
Expand Down
4 changes: 3 additions & 1 deletion desktop-ui/emulator/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ auto Emulator::load(shared_pointer<mia::Pak> pak, string& path) -> string {
string location;
if(locationQueue) {
location = locationQueue.takeFirst(); //pull from the game queue if an entry is available
} else {
} else if(program.startGameLoad) {
location = program.startGameLoad.takeFirst(); //pull from the command line if an entry is available
} else if(!program.noFilePrompt) {
BrowserDialog dialog;
dialog.setTitle({"Load ", pak->name(), " Game"});
dialog.setPath(path ? path : Path::desktop());
Expand Down
7 changes: 4 additions & 3 deletions desktop-ui/program/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ auto Program::create() -> void {
driverSettings.inputRefresh();

if(startGameLoad) {
auto gameToLoad = startGameLoad.takeFirst();
if(startSystem) {
for(auto &emulator: emulators) {
if(emulator->name == startSystem) {
if(load(emulator, startGameLoad)) {
if(load(emulator, gameToLoad)) {
if(startFullScreen) videoFullScreenToggle();
}
return;
}
}
}

if(auto emulator = identify(startGameLoad)) {
if(load(emulator, startGameLoad)) {
if(auto emulator = identify(gameToLoad)) {
if(load(emulator, gameToLoad)) {
if(startFullScreen) videoFullScreenToggle();
}
}
Expand Down
4 changes: 3 additions & 1 deletion desktop-ui/program/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ struct Program : ares::Platform {
auto inputDriverUpdate() -> void;

bool startFullScreen = false;
string startGameLoad;
vector<string> startGameLoad;
bool noFilePrompt = false;

string startSystem;
string startShader;

Expand Down

0 comments on commit dafb570

Please sign in to comment.