remove unused things and fix warning

This commit is contained in:
2025-08-19 17:54:25 +02:00
parent 55d96d470d
commit b7db734cc7
4 changed files with 24 additions and 52 deletions

View File

@@ -17,9 +17,8 @@ use std::f32::consts::PI;
use crate::Polymusic; use crate::Polymusic;
pub fn music_view(app: &Polymusic) -> iced::Element<Message> { pub fn music_view(app: &Polymusic) -> iced::Element<'_, Message> {
let mut i = 0; let mut i = 0;
let entries = app.all_sounds.clone();
//Create all polygon options //Create all polygon options
let polygon_rows: Vec<Element<Message>> = app let polygon_rows: Vec<Element<Message>> = app
.music .music
@@ -202,7 +201,7 @@ pub fn music_view(app: &Polymusic) -> iced::Element<Message> {
.into() .into()
} }
pub fn load_file_view(app: &Polymusic) -> iced::Element<Message> { pub fn load_file_view() -> iced::Element<'static, Message> {
Container::new( Container::new(
column![ column![
text("Polymusic").size(42), text("Polymusic").size(42),

View File

@@ -75,7 +75,6 @@ struct Polymusic {
time_last_frame: Instant, time_last_frame: Instant,
paused: bool, paused: bool,
audio_manager: AudioManager, audio_manager: AudioManager,
all_sounds: Vec<String>,
all_saves: Vec<String>, all_saves: Vec<String>,
current_delta: f32, current_delta: f32,
str_music_length: String, str_music_length: String,
@@ -97,7 +96,6 @@ impl Polymusic {
time_last_frame: Instant::now(), time_last_frame: Instant::now(),
audio_manager: manager, audio_manager: manager,
paused: true, paused: true,
all_sounds: load_path_sounds(),
all_saves: load_path_saves(), all_saves: load_path_saves(),
music: Music::default(), music: Music::default(),
current_delta: 0.0, current_delta: 0.0,
@@ -178,8 +176,7 @@ impl Polymusic {
.add_filter("Audio Files", &["mp3", "wav", "ogg"]) .add_filter("Audio Files", &["mp3", "wav", "ogg"])
.set_directory("./") .set_directory("./")
.pick_file(); .pick_file();
match file { if let Some(s) = file {
Some(s) => {
let root_path = PathBuf::from(&self.root); let root_path = PathBuf::from(&self.root);
let relative_path = diff_paths(&s, &root_path) let relative_path = diff_paths(&s, &root_path)
.expect("Impossible de calculer le chemin relatif"); .expect("Impossible de calculer le chemin relatif");
@@ -200,8 +197,6 @@ impl Polymusic {
self.current_delta, self.current_delta,
); );
} }
none => eprintln!("fail to load file"),
}
} }
Message::Save => { Message::Save => {
let json = serde_json::to_string_pretty(&self.music).unwrap(); let json = serde_json::to_string_pretty(&self.music).unwrap();
@@ -422,11 +417,11 @@ impl Polymusic {
} }
} }
fn view(&self) -> iced::Element<Message> { fn view(&self) -> iced::Element<'_, Message> {
if !self.mode_file_load { if !self.mode_file_load {
music_view(self) music_view(self)
} else { } else {
load_file_view(self) load_file_view()
} }
} }
@@ -501,16 +496,6 @@ impl Polymusic {
} }
} }
fn load_path_sounds() -> Vec<String> {
let mut entries: Vec<String> = fs::read_dir("./assets")
.unwrap()
.filter_map(|res| res.ok())
.map(|e| e.path().file_name().unwrap().to_str().unwrap().to_string())
.collect();
entries.sort();
entries
}
fn load_path_saves() -> Vec<String> { fn load_path_saves() -> Vec<String> {
fs::create_dir_all("./saves").expect("fail to creat 'saves' !"); fs::create_dir_all("./saves").expect("fail to creat 'saves' !");
let mut saves: Vec<String> = fs::read_dir("./saves") let mut saves: Vec<String> = fs::read_dir("./saves")

View File

@@ -1,4 +1,3 @@
use crate::utils::string_to_color;
use crate::color::color_serde; use crate::color::color_serde;
use std::f32::consts::PI; use std::f32::consts::PI;

View File

@@ -1,5 +1,4 @@
use crate::Polygon; use crate::Polygon;
use iced::Color;
use kira::sound::static_sound::StaticSoundData; use kira::sound::static_sound::StaticSoundData;
use regex::Regex; use regex::Regex;
@@ -7,16 +6,6 @@ pub fn is_delta_format_valid(str: &str) -> bool {
let re = Regex::new(r"^\d{1,2}:\d{1,2}:\d{1,2}$").unwrap(); let re = Regex::new(r"^\d{1,2}:\d{1,2}:\d{1,2}$").unwrap();
re.is_match(str) re.is_match(str)
} }
pub fn string_to_color<S: AsRef<str>>(s: S) -> Color {
match s.as_ref() {
"Green" => Color::from_rgb(0.0, 1.0, 0.0),
"Blue" => Color::from_rgb(0.0, 0.0, 1.0),
"Cyan" => Color::from_rgb(0.0, 1.0, 1.0),
"Yellow" => Color::from_rgb(1.0, 1.0, 0.0),
"Pink" => Color::from_rgb(1.0, 0.0, 1.0),
_ => Color::BLACK,
}
}
pub fn delta_to_string(delta: f32) -> String { pub fn delta_to_string(delta: f32) -> String {
let time = [ let time = [