Skip to content

Commit

Permalink
Fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Dove6 committed Aug 16, 2024
1 parent eb39604 commit feb06df
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 77 deletions.
69 changes: 24 additions & 45 deletions pixlib/src/plugins/sounds_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl SoundsState {
let Some(other) = other.position else {
return false;
};
return current > other;
current > other
}
}

Expand Down Expand Up @@ -342,55 +342,34 @@ fn update_sounds(
// info!("Updated data for sound {:?}", snd_source);
}
}
SoundEvent::SoundStarted(_) => {
let Some(instance) = (*handle)
.as_ref()
.map(|h| audio_instances.get_mut(h))
.flatten()
_ => {
let Some(instance) =
(*handle).as_ref().and_then(|h| audio_instances.get_mut(h))
else {
error!("Cannot retrieve audio instance for sound {:?}", snd_source);
break;
};
instance.resume(EASING);
// info!("Started sound {:?}", snd_source);
}
SoundEvent::SoundPaused(_) => {
let Some(instance) = (*handle)
.as_ref()
.map(|h| audio_instances.get_mut(h))
.flatten()
else {
error!("Cannot retrieve audio instance for sound {:?}", snd_source);
break;
};
instance.pause(EASING);
// info!("Paused sound {:?}", snd_source);
}
SoundEvent::SoundResumed(_) => {
let Some(instance) = (*handle)
.as_ref()
.map(|h| audio_instances.get_mut(h))
.flatten()
else {
error!("Cannot retrieve audio instance for sound {:?}", snd_source);
break;
};
instance.resume(EASING);
// info!("Resumed sound {:?}", snd_source);
}
SoundEvent::SoundStopped(_) => {
let Some(instance) = (*handle)
.as_ref()
.map(|h| audio_instances.get_mut(h))
.flatten()
else {
error!("Cannot retrieve audio instance for sound {:?}", snd_source);
break;
match &evt.0 {
SoundEvent::SoundStarted(_) => {
instance.resume(EASING);
// info!("Started sound {:?}", snd_source);
}
SoundEvent::SoundPaused(_) => {
instance.pause(EASING);
// info!("Paused sound {:?}", snd_source);
}
SoundEvent::SoundResumed(_) => {
instance.resume(EASING);
// info!("Resumed sound {:?}", snd_source);
}
SoundEvent::SoundStopped(_) => {
instance.pause(EASING);
instance.seek_to(0.0);
state.position = Some(0.0);
// info!("Stopped sound {:?}", snd_source);
}
_ => unreachable!(),
};
instance.pause(EASING);
instance.seek_to(0.0);
state.position = Some(0.0);
// info!("Stopped sound {:?}", snd_source);
}
};
}
Expand Down
25 changes: 3 additions & 22 deletions pixlib/src/plugins/ui_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ use bevy::{
hierarchy::{BuildChildren, Children, Parent},
input::ButtonInput,
log::info,
prelude::{
default, in_state, Camera, EventReader, Gizmos, GlobalTransform, IntoSystemConfigs,
KeyCode, OnEnter,
},
prelude::{default, in_state, EventReader, IntoSystemConfigs, KeyCode, OnEnter},
render::color::Color,
text::{Text, TextStyle},
ui::{
node_bundles::{ButtonBundle, NodeBundle, TextBundle},
widget::Button,
AlignItems, BackgroundColor, BorderColor, Interaction, JustifyContent, Style, UiRect, Val,
},
window::{FileDragAndDrop, Window},
window::FileDragAndDrop,
};

use crate::{
Expand All @@ -46,7 +43,7 @@ impl Plugin for UiPlugin {
(handle_dropped_iso, navigate_chooser, update_chooser_labels)
.run_if(in_state(AppState::SceneChooser)),
)
.add_systems(Update, draw_cursor)
// .add_systems(Update, draw_cursor)
.add_systems(OnEnter(AppState::SceneChooser), setup_chooser)
.add_systems(
Update,
Expand Down Expand Up @@ -261,22 +258,6 @@ pub fn handle_dropped_iso(
}
}

pub fn draw_cursor(
camera_query: Query<(&Camera, &GlobalTransform)>,
windows: Query<&Window>,
mut gizmos: Gizmos,
) {
let (camera, camera_transform) = camera_query.single();
let Some(cursor_position) = windows.single().cursor_position() else {
return;
};
let Some(point) = camera.viewport_to_world_2d(camera_transform, cursor_position) else {
return;
};

gizmos.circle_2d(point, 10., Color::WHITE);
}

pub fn detect_return_to_chooser(
keyboard: Res<ButtonInput<KeyCode>>,
mut next_state: ResMut<NextState<AppState>>,
Expand Down
10 changes: 2 additions & 8 deletions pixlib_parser/src/runner/classes/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,11 @@ impl Scene {
}

pub fn has_background_image(&self) -> bool {
match &self.state.borrow().background_data {
ImageFileData::NotLoaded(_) | ImageFileData::Loaded(_) => true,
_ => false,
}
!matches!(&self.state.borrow().background_data, ImageFileData::Empty)
}

pub fn has_background_music(&self) -> bool {
match &self.state.borrow().music_data {
SoundFileData::NotLoaded(_) | SoundFileData::Loaded(_) => true,
_ => false,
}
!matches!(&self.state.borrow().music_data, SoundFileData::Empty)
}

pub fn get_background_to_show(&self) -> RunnerResult<(ImageDefinition, ImageData)> {
Expand Down
4 changes: 2 additions & 2 deletions pixlib_parser/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ impl CnvRunner {
object_name,
} => {
let Some(sound_object) = self
.get_script(&script_path)
.and_then(|s| s.get_object(&object_name))
.get_script(script_path)
.and_then(|s| s.get_object(object_name))
else {
eprintln!(
"Object {} / {} not found for event {:?}",
Expand Down

0 comments on commit feb06df

Please sign in to comment.