From 5915c5406ff139cf956d5b3b09fcd1e986cc0fdf Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Wed, 5 Jan 2022 17:44:26 -0800 Subject: [PATCH] Revert "switched from strange function to as_bool" This reverts commit a33a6f7b37563b887cde9bcd7e5082ac852371df. --- src/modules/stream_states/state_update.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/modules/stream_states/state_update.rs b/src/modules/stream_states/state_update.rs index c66b8f1..fa87dc0 100644 --- a/src/modules/stream_states/state_update.rs +++ b/src/modules/stream_states/state_update.rs @@ -37,7 +37,7 @@ impl StateUpdate { } } - "Scene_Is_Augmented" => {StateUpdate::SceneIsAugmented(incoming_json["data"].as_bool().unwrap())}, + "Scene_Is_Augmented" => {StateUpdate::SceneIsAugmented(string_to_bool(incoming_json["data"].as_str().unwrap()))}, //SubScenes "SubScene" => { @@ -55,22 +55,22 @@ impl StateUpdate { } //Slide changing behavior - "Timer_Can_Run" => {StateUpdate::TimerCanRun(incoming_json["data"].as_bool().unwrap())} - "Change_With_Clicker" => {StateUpdate::ChangeSceneOnChangeSlide(incoming_json["data"].as_bool().unwrap())}, + "Timer_Can_Run" => {StateUpdate::TimerCanRun(string_to_bool(incoming_json["data"].as_str().unwrap()))} + "Change_With_Clicker" => {StateUpdate::ChangeSceneOnChangeSlide(string_to_bool(incoming_json["data"].as_str().unwrap()))}, "Timer_Length" => { let new_timer_length = &incoming_json["data"]; StateUpdate::TimerLength(new_timer_length.as_str().unwrap().parse::().unwrap()) }, //Extra Toggles - "Toggle_Computer_Volume" => {StateUpdate::ToggleComputerSoundOn(incoming_json["data"].as_bool().unwrap())}, - "Toggle_Stream_Volume" => {StateUpdate::StreamSoundToggleOn(incoming_json["data"].as_bool().unwrap())}, + "Toggle_Computer_Volume" => {StateUpdate::ToggleComputerSoundOn(string_to_bool(incoming_json["data"].as_str().unwrap()))}, + "Toggle_Stream_Volume" => {StateUpdate::StreamSoundToggleOn(string_to_bool(incoming_json["data"].as_str().unwrap()))}, "Media_Pause_Play" => {StateUpdate::ComputerMediaDoPause}, "Timer_Text" => {StateUpdate::TimerText(incoming_json["data"].as_str().unwrap().to_string())} "all" => {StateUpdate::UpdateClient}, - "Stream_Running" => {StateUpdate::StreamRunning(incoming_json["data"].as_bool().unwrap())} + "Stream_Running" => {StateUpdate::StreamRunning(string_to_bool(incoming_json["data"].as_str().unwrap()))} "Next_Slide" => { if incoming_json["data"] == "hotkey" {StateUpdate::ChangeSlide(SlideChange::NextHotkey)} @@ -130,4 +130,14 @@ impl StateUpdate { "data": data, }) } +} + +fn string_to_bool(input: &str) -> bool{ + if input == "true" { + true + } else if input == "false" { + false + } else { + panic!("string to bool doesn't recognize the input: {}", input); + } } \ No newline at end of file