fix options for main emu

This commit is contained in:
Alex Janka 2023-03-16 10:52:18 +11:00
parent 7dc6295ee8
commit 5f2a6ed14d
2 changed files with 26 additions and 12 deletions

View file

@ -9,7 +9,9 @@ use cpal::{
};
use futures::executor;
use gb_emu_lib::{
connect::{AudioOutput, DownsampleType, EmulatorMessage, JoypadState, Renderer, RomFile},
connect::{
AudioOutput, DownsampleType, EmulatorMessage, JoypadState, Renderer, RomFile, SerialTarget,
},
util::scale_buffer,
EmulatorCore,
};
@ -75,14 +77,16 @@ fn main() {
3
};
let options = gb_emu_lib::Options {
rom: RomFile::Path(args.rom),
save_path: args.save,
no_save: args.no_save,
bootrom: args.bootrom.map(RomFile::Path),
connect_serial: args.connect_serial,
verbose: args.verbose,
};
let options = gb_emu_lib::Options::new(RomFile::Path(args.rom))
.with_save_path(args.save)
.with_serial_target(if args.connect_serial {
SerialTarget::Stdout
} else {
SerialTarget::None
})
.with_bootrom(args.bootrom.map(RomFile::Path))
.with_no_save(args.no_save)
.with_verbose(args.verbose);
let tile_window: Option<Box<dyn Renderer<u32>>> = if args.tile_window {
Some(Box::new(WindowRenderer::new(factor, None)))

View file

@ -44,8 +44,8 @@ impl Options {
}
}
pub fn with_save_path(mut self, path: String) -> Self {
self.save_path = Some(path);
pub fn with_save_path(mut self, path: Option<String>) -> Self {
self.save_path = path;
self
}
@ -54,6 +54,16 @@ impl Options {
self
}
pub fn with_no_save(mut self, no_save: bool) -> Self {
self.no_save = no_save;
self
}
pub fn with_verbose(mut self, verbose: bool) -> Self {
self.verbose = verbose;
self
}
pub fn with_bootrom(mut self, bootrom: Option<RomFile>) -> Self {
self.bootrom = bootrom;
self
@ -69,7 +79,7 @@ impl Options {
self
}
pub fn with_verbose(mut self) -> Self {
pub fn verbose(mut self) -> Self {
self.verbose = true;
self
}