use folder manager for load, save and sound

This commit is contained in:
2025-08-19 17:45:42 +02:00
parent b258d86e47
commit e2902f91e3
9 changed files with 743 additions and 161 deletions

View File

@@ -3,11 +3,11 @@ use crate::utils::string_to_color;
use crate::color::color_serde;
use std::f32::consts::PI;
use iced::Size;
use iced::Vector;
use iced::mouse;
use iced::widget::canvas;
use iced::widget::canvas::{Frame, Stroke, Style};
use iced::Size;
use iced::Vector;
use iced::{Color, Point, Rectangle, Renderer, Theme};
use kira::sound::static_sound::StaticSoundData;
use serde::{Deserialize, Serialize};
@@ -38,9 +38,9 @@ impl PolygonFrame {
}
all_sound
}
pub fn update(&mut self) {
pub fn update(&mut self, path_of_project: &str) {
for poly in &mut self.polygons {
poly.update();
poly.update(path_of_project);
}
}
@@ -199,9 +199,10 @@ pub struct Polygon {
}
#[warn(dead_code)]
impl Polygon {
pub fn update(&mut self) {
let path = format!("./assets/{0}", &self.sound_name);
self.sound = StaticSoundData::from_file(&path).expect("fail to load the sound");
pub fn update(&mut self, path_of_project: &str) {
let path = format!("{0}", &self.sound_name);
self.sound = StaticSoundData::from_file(format!("{0}/{1}", path_of_project, path))
.expect("fail to load the sound");
}
pub fn sound_to_play_btw(&self, before: f32, after: f32) -> Vec<&StaticSoundData> {
let mut sound_to_play: Vec<&StaticSoundData> = vec![];
@@ -224,7 +225,7 @@ impl Polygon {
global_teta: 0.,
points_teta: vec![],
sound: sound,
sound_name: "tick.ogg".to_string(),
sound_name: "Default_Sound.ogg".to_string(),
name: "".to_string(),
color: Color::BLACK,
show_color_picker: false,