From 0ae6ca062f5936ae6f595f45ca0a78ed049452bc Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Sun, 9 Apr 2023 19:11:39 +0200 Subject: =?UTF-8?q?=E2=9C=A8=20Add=20scene=20controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wanted to be able to for example move around freely in the scene but also have something that would for example follow key frames and render a gif. Abstracted it with a scene controller. You can hook up keybinds and other thigns for it as well. Right now there is only the interactive scene controller which keep the behaviours previous to this change. Now I could possibly switch it out with something that uses key frames to render several images to create for example a gif. List of other Misc changes: - Add configuration setting for scene controller (`scene_controller`) - Add configuration setting for renderer - Add configuration setting for preview renderer (`preview_renderer`) - Add clone to Config. - Add from implementation for Renderer to be created from the config object. - Add cancel event to image action. An action could be blocking when the application wants to exit. Actions can now listen to the cancel event to exit early and not block. - Fixed bug where WaitForSignal action would block after application tries to exit. - Add method to KeyInputs to be able to take a list of callbacks instead of manually registering every callback one at the time. --- racer-tracer/src/image_action/png.rs | 1 + racer-tracer/src/image_action/wait_for_signal.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'racer-tracer/src/image_action') diff --git a/racer-tracer/src/image_action/png.rs b/racer-tracer/src/image_action/png.rs index dbed285..5b2bf1a 100644 --- a/racer-tracer/src/image_action/png.rs +++ b/racer-tracer/src/image_action/png.rs @@ -14,6 +14,7 @@ impl ImageAction for SavePng { fn action( &self, screen_buffer: &RwLock>, + _cancel_event: &SignalEvent, event: &SignalEvent, config: &Config, log: Logger, diff --git a/racer-tracer/src/image_action/wait_for_signal.rs b/racer-tracer/src/image_action/wait_for_signal.rs index 0ffe5e7..1e31200 100644 --- a/racer-tracer/src/image_action/wait_for_signal.rs +++ b/racer-tracer/src/image_action/wait_for_signal.rs @@ -1,4 +1,4 @@ -use std::sync::RwLock; +use std::{sync::RwLock, time::Duration}; use slog::Logger; use synchronoise::SignalEvent; @@ -17,6 +17,7 @@ impl ImageAction for WaitForSignal { fn action( &self, _screen_buffer: &RwLock>, + cancel_event: &SignalEvent, event: &SignalEvent, _config: &Config, _log: Logger, @@ -24,7 +25,7 @@ impl ImageAction for WaitForSignal { ) -> Result<(), TracerError> { if !event.status() { write_term!(term, "Press R to resume."); - event.wait(); + while !event.wait_timeout(Duration::from_secs(1)) && !cancel_event.status() {} } event.reset(); Ok(()) -- cgit v1.2.3