split scenes and subscenes enum
This commit is contained in:
parent
8f48d213bc
commit
f26b7b8a5e
4 changed files with 75 additions and 60 deletions
|
@ -1,6 +1,6 @@
|
|||
|
||||
#[derive(PartialEq, Debug, Clone, Copy)]
|
||||
pub enum Scenes {
|
||||
pub enum SubScenes {
|
||||
CameraDefault,
|
||||
CameraWithUpperRight,
|
||||
CameraWithLargeUpperRight,
|
||||
|
@ -10,6 +10,12 @@ pub enum Scenes {
|
|||
ScreenWithUpperRight,
|
||||
ScreenWithLowerRight,
|
||||
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone, Copy)]
|
||||
pub enum Scenes {
|
||||
Camera,
|
||||
Screen,
|
||||
Augmented
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::enums::Scenes;
|
||||
use super::enums::{SubScenes, Scenes};
|
||||
use super::state_update::StateUpdate;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -15,8 +15,8 @@ pub struct StreamState {
|
|||
pub timer_text: String,
|
||||
|
||||
pub current_scene: Scenes,
|
||||
pub camera_sub_scene: Scenes,
|
||||
pub screen_sub_scene: Scenes,
|
||||
pub camera_sub_scene: SubScenes,
|
||||
pub screen_sub_scene: SubScenes,
|
||||
}
|
||||
|
||||
impl Default for StreamState {
|
||||
|
@ -33,9 +33,9 @@ impl Default for StreamState {
|
|||
timer_length: 15.0,
|
||||
timer_text: String::from("0.0"),
|
||||
|
||||
current_scene: Scenes::CameraDefault,
|
||||
camera_sub_scene: Scenes::CameraDefault,
|
||||
screen_sub_scene: Scenes::ScreenDefault,
|
||||
current_scene: Scenes::Camera,
|
||||
camera_sub_scene: SubScenes::CameraDefault,
|
||||
screen_sub_scene: SubScenes::ScreenDefault,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,33 +53,42 @@ impl StreamState {
|
|||
StateUpdate::ChangeSceneOnChangeSlideHotkey(new_val) => {self.change_scene_on_change_slide_hotkey = new_val;},
|
||||
StateUpdate::TimerCanRun(new_val) => {self.timer_can_run = new_val;},
|
||||
StateUpdate::TimerLength(new_val) => {self.timer_length = new_val;},
|
||||
StateUpdate::TimerText(new_val) => {self.timer_text = new_val;},
|
||||
StateUpdate::Scene(new_val) => {self.change_scene(&new_val)},
|
||||
StateUpdate::TimerText(new_val) => {self.timer_text = new_val;},
|
||||
StateUpdate::Scene(new_val) => {self.change_scene(&new_val)},
|
||||
StateUpdate::SubScene(new_val) => {self.change_sub_scene(&new_val)},
|
||||
StateUpdate::SceneIsAugmented(new_val) => {
|
||||
self.scene_is_augmented = new_val;
|
||||
self.change_scene(&Scenes::Augmented)},
|
||||
StateUpdate::UpdateClient => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn change_scene(&mut self, scene: &Scenes) {
|
||||
match scene {
|
||||
Scenes::CameraDefault | Scenes::CameraWithUpperRight |
|
||||
Scenes::CameraWithLargeUpperRight | Scenes::CameraWithLowerRight
|
||||
=> {StreamState::set_camera_scene(self, scene)},
|
||||
Scenes::ScreenDefault | Scenes::ScreenWithUpperRight |
|
||||
Scenes::ScreenWithLowerRight
|
||||
=> {StreamState::set_screen_scene(self, scene)},
|
||||
Scenes::Augmented => {self.current_scene = *scene;}
|
||||
Scenes::Camera => {self.current_scene = *scene},
|
||||
Scenes::Screen => {self.current_scene = *scene},
|
||||
}
|
||||
}
|
||||
|
||||
fn set_camera_scene(&mut self, scene: &Scenes) {
|
||||
self.camera_sub_scene = scene.clone();
|
||||
self.current_scene = scene.clone();
|
||||
pub fn change_sub_scene(&mut self, scene: &SubScenes) {
|
||||
match scene {
|
||||
SubScenes::CameraDefault | SubScenes::CameraWithUpperRight |
|
||||
SubScenes::CameraWithLargeUpperRight | SubScenes::CameraWithLowerRight
|
||||
=> {StreamState::set_camera_scene(self, scene)},
|
||||
SubScenes::ScreenDefault | SubScenes::ScreenWithUpperRight |
|
||||
SubScenes::ScreenWithLowerRight
|
||||
=> {StreamState::set_screen_scene(self, scene)},
|
||||
}
|
||||
}
|
||||
|
||||
fn set_screen_scene(&mut self, scene: &Scenes) {
|
||||
fn set_camera_scene(&mut self, scene: &SubScenes) {
|
||||
self.camera_sub_scene = scene.clone();
|
||||
self.current_scene = Scenes::Camera;
|
||||
}
|
||||
|
||||
fn set_screen_scene(&mut self, scene: &SubScenes) {
|
||||
self.screen_sub_scene = scene.clone();
|
||||
self.current_scene = scene.clone();
|
||||
self.current_scene = Scenes::Screen;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{sync::mpsc::{self, Receiver}, thread::{self, JoinHandle}};
|
||||
|
||||
use crate::modules::{message_handler::{MessageHandler, StateMessage}, stream_states::{state_update::StateUpdate, enums::Scenes, stream_states_class::StreamState}};
|
||||
use crate::modules::{message_handler::{MessageHandler, StateMessage}, stream_states::{state_update::StateUpdate, enums::SubScenes, stream_states_class::StreamState}};
|
||||
|
||||
|
||||
#[test]
|
||||
|
@ -53,7 +53,7 @@ fn message_handler_can_handle_multiple_messages() {
|
|||
assert_eq!(handler.computer_sound_is_on, false);
|
||||
assert_eq!(handler.scene_is_augmented, true);
|
||||
assert_eq!(handler.scene_is_augmented, true);
|
||||
assert_eq!(handler.current_scene, Scenes::Augmented);
|
||||
assert_eq!(handler.current_scene, SubScenes::Augmented);
|
||||
assert_eq!(handler.timer_can_run, false);
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,18 +8,18 @@ use crate::modules::stream_states::state_update::StateUpdate;
|
|||
fn has_all_enums() {
|
||||
{
|
||||
let members = [
|
||||
s_s::enums::Scenes::CameraDefault,
|
||||
s_s::enums::Scenes::CameraWithUpperRight,
|
||||
s_s::enums::Scenes::CameraWithLowerRight,
|
||||
s_s::enums::Scenes::CameraWithLargeUpperRight,
|
||||
s_s::enums::SubScenes::CameraDefault,
|
||||
s_s::enums::SubScenes::CameraWithUpperRight,
|
||||
s_s::enums::SubScenes::CameraWithLowerRight,
|
||||
s_s::enums::SubScenes::CameraWithLargeUpperRight,
|
||||
];
|
||||
assert_eq!(members.len(), 4);
|
||||
}
|
||||
{
|
||||
let members = [
|
||||
s_s::enums::Scenes::ScreenDefault,
|
||||
s_s::enums::Scenes::ScreenWithUpperRight,
|
||||
s_s::enums::Scenes::ScreenWithLowerRight,
|
||||
s_s::enums::SubScenes::ScreenDefault,
|
||||
s_s::enums::SubScenes::ScreenWithUpperRight,
|
||||
s_s::enums::SubScenes::ScreenWithLowerRight,
|
||||
];
|
||||
assert_eq!(members.len(), 3);
|
||||
}
|
||||
|
@ -38,54 +38,54 @@ fn create_stream_states_class() {
|
|||
assert_eq!(stream_state.timer_length, 15.0);
|
||||
assert_eq!(stream_state.timer_can_run, true);
|
||||
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::CameraDefault);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraDefault);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::CameraDefault);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraDefault);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenDefault);
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scene_correctness(){
|
||||
let mut stream_state = s_s::stream_states_class::StreamState::new();
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::CameraDefault);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraDefault);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::CameraDefault);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraDefault);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenDefault);
|
||||
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::CameraWithUpperRight));
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::SubScenes::CameraWithUpperRight));
|
||||
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::CameraWithUpperRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraWithUpperRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::CameraWithUpperRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraWithUpperRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenDefault);
|
||||
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::CameraWithLargeUpperRight));
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::SubScenes::CameraWithLargeUpperRight));
|
||||
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::CameraWithLargeUpperRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraWithLargeUpperRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::CameraWithLargeUpperRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraWithLargeUpperRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenDefault);
|
||||
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::CameraWithLowerRight));
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::SubScenes::CameraWithLowerRight));
|
||||
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenDefault);
|
||||
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::ScreenDefault));
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::SubScenes::ScreenDefault));
|
||||
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenDefault);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::ScreenDefault);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenDefault);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraWithLowerRight);
|
||||
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::ScreenWithLowerRight));
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::SubScenes::ScreenWithLowerRight));
|
||||
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::ScreenWithLowerRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenWithLowerRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::ScreenWithLowerRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenWithLowerRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraWithLowerRight);
|
||||
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::Scenes::ScreenWithUpperRight));
|
||||
stream_state.update(StateUpdate::Scene(s_s::enums::SubScenes::ScreenWithUpperRight));
|
||||
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::Scenes::ScreenWithUpperRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::Scenes::ScreenWithUpperRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::Scenes::CameraWithLowerRight);
|
||||
assert_eq!(stream_state.current_scene, s_s::enums::SubScenes::ScreenWithUpperRight);
|
||||
assert_eq!(stream_state.screen_sub_scene, s_s::enums::SubScenes::ScreenWithUpperRight);
|
||||
assert_eq!(stream_state.camera_sub_scene, s_s::enums::SubScenes::CameraWithLowerRight);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue