Skip to content

Commit

Permalink
[emucontrol] Use real ace config file, not a hardcoded one ...
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty/Benediction committed Aug 18, 2024
1 parent a9343b6 commit f31bef1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
9 changes: 5 additions & 4 deletions cpclib-runner/src/ace_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ pub struct AceConfig {


impl AceConfig {
pub fn open(path: &Utf8Path) -> Self {
let ini = Ini::load_from_file(path).unwrap();
pub fn open<P: AsRef<Utf8Path>>(path: P) -> Self {
dbg!(&path.as_ref());
let ini = Ini::load_from_file(path.as_ref()).unwrap();
AceConfig { ini }
}

pub fn save(&self, path: &Utf8Path) {
self.ini.write_to_file(path).unwrap();
pub fn save<P: AsRef<Utf8Path>>(&self, path: P) {
self.ini.write_to_file(path.as_ref()).unwrap();
}

pub fn remove(&mut self, key: &str) {
Expand Down
7 changes: 4 additions & 3 deletions cpclib-runner/src/emucontrol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ impl<E: UsedEmulator> RobotImpl<E> {
self.enigo.text(dbg!(&format!("{v}"))).unwrap();
},
_ => {
dbg!(key);
self.enigo.key(key, enigo::Direction::Press).unwrap();
Self::wait_a_bit();
self.enigo.key(key, enigo::Direction::Release).unwrap();
Expand Down Expand Up @@ -736,8 +737,8 @@ pub fn handle_arguments(mut cli: Cli) -> Result<(), String> {

// setup emulator
// copy the non standard roms and configure the emu (at least ace)
let ace_conf_path = dbg!(Utf8Path::new("/home/romain/.config/ACE-DL_futuristics/config.cfg")); // todo get it programmatically
let mut ace_conf = AceConfig::open(ace_conf_path);
let ace_conf_path = emu.ace_version().unwrap().config_file(); // todo get it programmatically
let mut ace_conf = AceConfig::open(&ace_conf_path);

let extra_roms: &[(AmstradRom, &[(&str, usize)])] = &[
(AmstradRom::Unidos, &[
Expand Down Expand Up @@ -786,7 +787,7 @@ pub fn handle_arguments(mut cli: Cli) -> Result<(), String> {


}
ace_conf.save(ace_conf_path);
ace_conf.save(&ace_conf_path);



Expand Down
24 changes: 24 additions & 0 deletions cpclib-runner/src/runner/emulator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::path::PathBuf;

use cpclib_common::camino::Utf8PathBuf;
use directories::BaseDirs;

use crate::delegated::{ArchiveFormat, DelegateApplicationDescription};

Expand All @@ -20,6 +23,13 @@ impl Default for Emulator {
}

impl Emulator {

pub fn ace_version(&self) -> Option<&AceVersion> {
match self {
Emulator::Ace(v) => Some(v),
_ => None
}
}
pub fn is_ace(&self) -> bool {
match self {
Emulator::Ace(_) => true,
Expand Down Expand Up @@ -74,6 +84,20 @@ pub enum AceVersion {
WakePoint // 2024/06/21
}


impl AceVersion {
pub fn config_file(&self) -> Utf8PathBuf {
let p = match self {
Self::ZenSummer => {

BaseDirs::new().unwrap().config_local_dir().join("ACE-DL_futuristics/config.cfg")
}
_ => unimplemented!()
};

Utf8PathBuf::from_path_buf(p).unwrap()
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
pub enum CpcecVersion {
#[default]
Expand Down

0 comments on commit f31bef1

Please sign in to comment.