Revert "switched from strange function to as_bool"

This reverts commit a33a6f7b37.
This commit is contained in:
Nickiel12 2022-01-05 17:44:26 -08:00
parent 849d73d4a8
commit 5915c5406f

View file

@ -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 //SubScenes
"SubScene" => { "SubScene" => {
@ -55,22 +55,22 @@ impl StateUpdate {
} }
//Slide changing behavior //Slide changing behavior
"Timer_Can_Run" => {StateUpdate::TimerCanRun(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(incoming_json["data"].as_bool().unwrap())}, "Change_With_Clicker" => {StateUpdate::ChangeSceneOnChangeSlide(string_to_bool(incoming_json["data"].as_str().unwrap()))},
"Timer_Length" => { "Timer_Length" => {
let new_timer_length = &incoming_json["data"]; let new_timer_length = &incoming_json["data"];
StateUpdate::TimerLength(new_timer_length.as_str().unwrap().parse::<f32>().unwrap()) StateUpdate::TimerLength(new_timer_length.as_str().unwrap().parse::<f32>().unwrap())
}, },
//Extra Toggles //Extra Toggles
"Toggle_Computer_Volume" => {StateUpdate::ToggleComputerSoundOn(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(incoming_json["data"].as_bool().unwrap())}, "Toggle_Stream_Volume" => {StateUpdate::StreamSoundToggleOn(string_to_bool(incoming_json["data"].as_str().unwrap()))},
"Media_Pause_Play" => {StateUpdate::ComputerMediaDoPause}, "Media_Pause_Play" => {StateUpdate::ComputerMediaDoPause},
"Timer_Text" => {StateUpdate::TimerText(incoming_json["data"].as_str().unwrap().to_string())} "Timer_Text" => {StateUpdate::TimerText(incoming_json["data"].as_str().unwrap().to_string())}
"all" => {StateUpdate::UpdateClient}, "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" => { "Next_Slide" => {
if incoming_json["data"] == "hotkey" {StateUpdate::ChangeSlide(SlideChange::NextHotkey)} if incoming_json["data"] == "hotkey" {StateUpdate::ChangeSlide(SlideChange::NextHotkey)}
@ -131,3 +131,13 @@ impl StateUpdate {
}) })
} }
} }
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);
}
}