Save/load more config

This commit is contained in:
2024-12-14 23:14:13 -05:00
parent 6e2d70abd7
commit e31269368d
5 changed files with 148 additions and 52 deletions
+15 -3
View File
@@ -38,6 +38,7 @@ pub struct Application {
proxy: EventLoopProxy<UserEvent>,
mappings: MappingProvider,
controllers: ControllerManager,
persistence: Persistence,
viewports: HashMap<ViewportId, Viewport>,
focused: Option<ViewportId>,
}
@@ -46,7 +47,7 @@ impl Application {
pub fn new(client: EmulatorClient, proxy: EventLoopProxy<UserEvent>) -> Self {
let icon = load_icon().ok().map(Arc::new);
let persistence = Persistence::new();
let mappings = MappingProvider::new(persistence);
let mappings = MappingProvider::new(persistence.clone());
let controllers = ControllerManager::new(client.clone(), &mappings);
{
let mappings = mappings.clone();
@@ -59,6 +60,7 @@ impl Application {
proxy,
mappings,
controllers,
persistence,
viewports: HashMap::new(),
focused: None,
}
@@ -78,7 +80,12 @@ impl Application {
impl ApplicationHandler<UserEvent> for Application {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let app = GameWindow::new(self.client.clone(), self.proxy.clone(), SimId::Player1);
let app = GameWindow::new(
self.client.clone(),
self.proxy.clone(),
self.persistence.clone(),
SimId::Player1,
);
let wrapper = Viewport::new(event_loop, self.icon.clone(), Box::new(app));
self.focused = Some(wrapper.id());
self.viewports.insert(wrapper.id(), wrapper);
@@ -177,7 +184,12 @@ impl ApplicationHandler<UserEvent> for Application {
self.open(event_loop, Box::new(input));
}
UserEvent::OpenPlayer2 => {
let p2 = GameWindow::new(self.client.clone(), self.proxy.clone(), SimId::Player2);
let p2 = GameWindow::new(
self.client.clone(),
self.proxy.clone(),
self.persistence.clone(),
SimId::Player2,
);
self.open(event_loop, Box::new(p2));
}
}