(&self, fg: &Command)
| 647 | }; |
| 648 | |
| 649 | if let Some(window) = weak.upgrade() { |
| 650 | let image = Image::load_from_path(Path::new(&format!("{path}{name}.png"))).unwrap(); |
| 651 | window.set_bg(( |
| 652 | image, |
| 653 | x_offset.unwrap_or(0.0), |
| 654 | y_offset.unwrap_or(0.0), |
| 655 | zoom.unwrap_or(1.0), |
| 656 | )); |
| 657 | } |
| 658 | |
| 659 | Ok(()) |
| 660 | } |
| 661 | |
| 662 | pub(crate) fn show_fg(&self, fg: &Command) -> Result<(), EngineError> { |
| 663 | let Command::Figure { |
| 664 | name, |
| 665 | distance, |
| 666 | body, |
| 667 | face, |
| 668 | position, |
| 669 | delay, |
| 670 | } = fg |
| 671 | else { |
| 672 | unreachable!() |
| 673 | }; |
| 674 | |
| 675 | if delay.is_some() { |
| 676 | self.delay_channels.as_ref().unwrap().send_delay(fg)?; |
| 677 | return Ok(()); |
| 678 | } |
| 679 | |
| 680 | if let (Some(body_para), Some(face_para), Some(offset)) = FIGURE_CONFIG.find(name) { |
| 681 | let rate = *body_para.get(body).unwrap(); |
| 682 | let body_img = Image::load_from_path(Path::new(&format!( |
| 683 | "{}{}/{}/{}.png", |
| 684 | ENGINE_CONFIG.figure_path(), |
| 685 | name, |
| 686 | distance, |
| 687 | body |
| 688 | ))) |
| 689 | .unwrap(); |
| 690 | let (face_x, face_y) = face_para.get(face).unwrap(); |
| 691 | let face_img = Image::load_from_path(Path::new(&format!( |
| 692 | "{}{}/{}/{}.png", |
| 693 | ENGINE_CONFIG.figure_path(), |
| 694 | name, |
| 695 | distance, |
| 696 | face |
| 697 | ))) |
| 698 | .unwrap(); |
| 699 | |
| 700 | let (base_x, base_y, width_ratio) = parse_position(position, distance); |
| 701 | |
| 702 | let model = self.figure_items.clone(); |
| 703 | let mut found_idx = None; |
| 704 | for i in 0..model.row_count() { |
| 705 | let item = model.row_data(i).unwrap(); |
| 706 | if item.name == name { |
no test coverage detected