(&self)
| 194 | name: SharedString::from(script.name()), |
| 195 | }, |
| 196 | ); |
| 197 | fs::write( |
| 198 | format!("{}{}.toml", ENGINE_CONFIG.save_path(), index), |
| 199 | toml::to_string_pretty(&SaveData::new( |
| 200 | script.name().to_string(), |
| 201 | script.index(), |
| 202 | script.explain().to_string(), |
| 203 | bg.0.path().unwrap().to_str().unwrap().to_string(), |
| 204 | )) |
| 205 | .map_err(SaveError::from)?, |
| 206 | ) |
| 207 | .map_err(|e| SaveError::Write { |
| 208 | path: format!("{}{}.toml", ENGINE_CONFIG.save_path(), index), |
| 209 | source: e, |
| 210 | })?; |
| 211 | window.set_save_items(exists_save_items); |
| 212 | } |
| 213 | |
| 214 | Ok(()) |
| 215 | } |
| 216 | |
| 217 | pub(crate) fn execute_load(&mut self, name: String, index: i32) -> Result<(), EngineError> { |
| 218 | if !name.is_empty() { |
| 219 | let weak = self.weak.clone(); |
| 220 | if let Some(window) = weak.upgrade() { |
| 221 | window.set_current_screen(2); |
| 222 | window.set_current_choose(0); |
| 223 | } |
| 224 | self.execute_jump(Jump::Index((name, index - 1)))?; |
| 225 | self.execute_script()?; |
| 226 | } |
| 227 | |
| 228 | Ok(()) |
| 229 | } |
| 230 | |
| 231 | pub(crate) fn execute_get_ex(&self) -> Result<(), EngineError> { |
| 232 | let ex_items = Rc::new(VecModel::from(Vec::new())); |
| 233 | |
| 234 | let cgs = *self.cg.borrow(); |
| 235 | let mut i = 1; |
| 236 | while i <= 63 { |
| 237 | if cgs & (1 << i) != 0 { |
| 238 | if let Some((_, length)) = CG_LENGTH.find_by_id(i) { |
| 239 | let (mut images, mut l, is_lock) = (Vec::new(), *length, false); |
| 240 | for j in 1..=*length { |
| 241 | if cgs & (1 << (j + i - 1)) != 0 { |
| 242 | if let Some((name, _)) = CG_LENGTH.find_by_id(j + i - 1) { |
| 243 | images.push( |
| 244 | Image::load_from_path(Path::new(&format!( |
| 245 | "{}{}.png", |
| 246 | ENGINE_CONFIG.cg_path(), |
no test coverage detected