bit more env var stuff
This commit is contained in:
parent
2259265107
commit
b8cc606bd5
|
@ -119,13 +119,15 @@ pub fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||
emu.register_component(StderrSysInfoLogComponent::default())?;
|
||||
}
|
||||
|
||||
let mut variables = VariableStoreComponent::default();
|
||||
emu.register_component(EnvironmentVariableComponent::default())?;
|
||||
|
||||
let mut var_store = VariableStoreComponent::default();
|
||||
// TODO: load a config file specified on the CLI
|
||||
variables.insert("mgba_skip_bios", "ON");
|
||||
variables.insert("gpsp_drc", "enabled");
|
||||
variables.insert("gpsp_frame_mixing", "enabled");
|
||||
variables.insert("gpsp_save_method", "libretro");
|
||||
emu.register_component(variables)?;
|
||||
var_store.insert("mgba_skip_bios", "ON");
|
||||
var_store.insert("gpsp_drc", "enabled");
|
||||
var_store.insert("gpsp_frame_mixing", "enabled");
|
||||
var_store.insert("gpsp_save_method", "libretro");
|
||||
emu.register_component(var_store)?;
|
||||
|
||||
emu.init()?;
|
||||
emu.load_game(&opt.rom)?;
|
||||
|
|
|
@ -16,4 +16,4 @@ pub use input::StatefulInputComponent;
|
|||
pub use paths::PathBufComponent;
|
||||
pub use print::*;
|
||||
pub use saves::LocalFileSaveComponent;
|
||||
pub use variables::VariableStoreComponent;
|
||||
pub use variables::*;
|
||||
|
|
|
@ -15,19 +15,22 @@ impl RetroCallbacks for EnvironmentVariableComponent {
|
|||
|
||||
fn set_variables(&mut self, variables: &[Variable2]) -> Option<bool> {
|
||||
for v in variables {
|
||||
println!("# {}", v.description);
|
||||
let value = if let Ok(x) = std::env::var(&v.key) {
|
||||
if !v.options.contains(&x) {
|
||||
panic!("Invalid value {:?} for variable {:?} (expected one of {:?})", x, v.key, v.options);
|
||||
} else if x != v.options[0] {
|
||||
println!(
|
||||
"# {}: {}",
|
||||
v.description,
|
||||
v.options.iter().map(String::as_str).collect::<Vec<_>>().join(", ")
|
||||
);
|
||||
if let Ok(value) = std::env::var(&v.key) {
|
||||
if !v.options.contains(&value) {
|
||||
panic!("Invalid value {:?} for variable {:?} (expected one of {:?})", value, v.key, v.options);
|
||||
} else if value != v.options[0] {
|
||||
println!("# (overridden, default {})", v.options[0]);
|
||||
}
|
||||
x
|
||||
} else {
|
||||
v.options[0].clone()
|
||||
};
|
||||
println!("{}={} # {:?}", v.key, value, v.options);
|
||||
println!("{}={}", v.key, value);
|
||||
self.variables.insert(v.key.to_owned(), value);
|
||||
} else {
|
||||
println!("{}=", v.key);
|
||||
}
|
||||
}
|
||||
Some(true)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue