| 132 | } |
| 133 | |
| 134 | fn value_input(&mut self, name: &str, value: &Value) -> io::Result<()> { |
| 135 | match value { |
| 136 | Value::Boolean(boolean) => { |
| 137 | write!(self, "[1,[4,{}]]", json!(*boolean as i64)) |
| 138 | } |
| 139 | Value::Number(number) if number.fract() == 0.0 => { |
| 140 | write!(self, "[1,[4,{}]]", json!(number)) |
| 141 | } |
| 142 | Value::Number(number) => { |
| 143 | write!(self, "[1,[4,{}]]", json!(number)) |
| 144 | } |
| 145 | Value::String(string) => { |
| 146 | let color = ["COLOR", "COLOR2"] |
| 147 | .contains(&name) |
| 148 | .then(|| { |
| 149 | csscolorparser::parse(string) |
| 150 | .ok() |
| 151 | .filter(|color| color.a == 1.0) |
| 152 | }) |
| 153 | .flatten(); |
| 154 | if name == "BROADCAST_INPUT" { |
| 155 | write!(self, "[1,[11,{},{}]]", json!(**string), json!(**string)) |
| 156 | } else if let Some(color) = color { |
| 157 | write!(self, "[1,[9,{}]]", json!(color.to_hex_string())) |
| 158 | } else { |
| 159 | write!(self, "[1,[10,{}]]", json!(**string)) |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | fn name_input( |
| 166 | &mut self, |