Skip to content

Commit

Permalink
Disable visibility toggle for drums
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex committed Dec 5, 2023
1 parent 65da104 commit bd9d7c7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
16 changes: 11 additions & 5 deletions neothesia/src/scene/menu_scene/iced_menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl<'a> Step {
PlayerConfig::Human => 2,
};

let color = if (track.has_drums && !track.has_other_than_drums) || !visible {
let color = if !visible {
iced_core::Color::from_rgb8(102, 102, 102)
} else {
let color_id = track.track_color_id % target.config.color_schema.len();
Expand Down Expand Up @@ -500,14 +500,20 @@ impl<'a> Step {
.active(active)
.active_color(color)
.build();

let card = track_card::track_card()
.title(name)
.subtitle(format!("{} Notes", track.notes.len()))
.track_color(color)
.body(body)
.on_icon_press(Message::TrackVisibilityConfig(track.track_id, !visible))
.build();
tracks.push(card.into());
.body(body);

let card = if track.has_drums && !track.has_other_than_drums {
card
} else {
card.on_icon_press(Message::TrackVisibilityConfig(track.track_id, !visible))
};

tracks.push(card.build().into());
}
}

Expand Down
31 changes: 16 additions & 15 deletions neothesia/src/song.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[derive(Debug, Default, Clone)]
use midi_file::MidiTrack;

#[derive(Debug, Clone)]
pub enum PlayerConfig {
Mute,
#[default]
Auto,
Human,
}
Expand All @@ -13,24 +14,24 @@ pub struct TrackConfig {
pub visible: bool,
}

impl TrackConfig {
fn new(track_id: usize) -> Self {
Self {
track_id,
player: PlayerConfig::default(),
visible: true,
}
}
}

#[derive(Debug, Clone)]
pub struct SongConfig {
pub tracks: Box<[TrackConfig]>,
}

impl SongConfig {
fn new(tracks_count: usize) -> Self {
let tracks: Vec<_> = (0..tracks_count).map(TrackConfig::new).collect();
fn new(tracks: &[MidiTrack]) -> Self {
let tracks: Vec<_> = tracks
.iter()
.map(|t| {
let is_drums = t.has_drums && !t.has_other_than_drums;
TrackConfig {
track_id: t.track_id,
player: PlayerConfig::Auto,
visible: !is_drums,
}
})
.collect();
Self {
tracks: tracks.into(),
}
Expand All @@ -45,7 +46,7 @@ pub struct Song {

impl Song {
pub fn new(file: midi_file::MidiFile) -> Self {
let config = SongConfig::new(file.tracks.len());
let config = SongConfig::new(&file.tracks);
Self { file, config }
}
}

0 comments on commit bd9d7c7

Please sign in to comment.