(&mut self, text: &str)
| 128 | use Commands::*; |
| 129 | |
| 130 | let mut block_commands = Vec::new(); |
| 131 | |
| 132 | for (index, (line_num, line)) in lines.iter().enumerate() { |
| 133 | if let Some(line) = line.strip_prefix('@') { |
| 134 | if let Some((cmd, arg)) = line.split_once(' ') { |
| 135 | let cmd = match cmd { |
| 136 | "bg" | "cg" => { |
| 137 | let mut parts = arg.split('|').map(str::trim); |
| 138 | let bg = Background { |
| 139 | name: parts.next().unwrap_or("").to_string(), |
| 140 | x_offset: parts.next().and_then(|s| s.parse::<f32>().ok()), |
| 141 | y_offset: parts.next().and_then(|s| s.parse::<f32>().ok()), |
| 142 | zoom: parts.next().and_then(|s| s.parse::<f32>().ok()), |
| 143 | is_cg: cmd == "cg", |
| 144 | }; |
| 145 | self.insert_background(*block_index, bg.clone()); |
| 146 | bg |
| 147 | } |
| 148 | "bgm" => { |
| 149 | self.insert_bgm(*block_index, arg.to_string()); |
| 150 | PlayBgm(arg.to_string()) |
| 151 | } |
| 152 | "choose" => { |
| 153 | let num = arg.parse::<usize>().map_err(ScriptError::from)?; |
| 154 | let mut choose_branch = HashMap::with_capacity(num); |
no test coverage detected