Update dependencies, set audio volume
This commit is contained in:
parent
38baa566b4
commit
70072b5e1a
8 changed files with 1213 additions and 1004 deletions
2111
Cargo.lock
generated
2111
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
16
Cargo.toml
16
Cargo.toml
|
@ -16,17 +16,17 @@ members = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.38"
|
||||
anyhow = "1.0.52"
|
||||
bass-sys = { path = "bass-sys" }
|
||||
ggez = { git = "https://github.com/ggez/ggez", branch = "devel" }
|
||||
log = "0.4.13"
|
||||
log = "0.4.14"
|
||||
stderrlog = "0.5.1"
|
||||
num = "0.3.1"
|
||||
ordered-float = "2.0.1"
|
||||
structopt = "0.3.21"
|
||||
image = "0.23.12"
|
||||
imgui = "0.6.1"
|
||||
imgui-winit-support = "0.6.1"
|
||||
num = "0.4.0"
|
||||
ordered-float = "2.10.0"
|
||||
structopt = "0.3.25"
|
||||
image = "0.23.14"
|
||||
imgui = "0.8.2"
|
||||
imgui-winit-support = "0.8.2"
|
||||
framework = { path = "framework" }
|
||||
|
||||
[dependencies.libosu]
|
||||
|
|
|
@ -100,4 +100,10 @@ impl Sound {
|
|||
bass::BASS_ChannelSetAttribute(self.handle, BASS_ATTRIB_FREQ, val * rate as f32);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_volume(&self, volume: f32) {
|
||||
unsafe {
|
||||
bass::BASS_ChannelSetAttribute(self.handle, BASS_ATTRIB_MUSIC_VOL_GLOBAL, volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,25 @@ impl EventHandler for Game {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn mouse_motion_event(&mut self, _: &mut Context, x: f32, y: f32, _: f32, _: f32) {
|
||||
fn mouse_motion_event(
|
||||
&mut self,
|
||||
_: &mut Context,
|
||||
x: f32,
|
||||
y: f32,
|
||||
_: f32,
|
||||
_: f32,
|
||||
) -> GameResult {
|
||||
self.mouse_pos = (x, y);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mouse_button_down_event(&mut self, _: &mut Context, btn: MouseButton, x: f32, y: f32) {
|
||||
fn mouse_button_down_event(
|
||||
&mut self,
|
||||
_: &mut Context,
|
||||
btn: MouseButton,
|
||||
x: f32,
|
||||
y: f32,
|
||||
) -> GameResult {
|
||||
match btn {
|
||||
MouseButton::Left => {
|
||||
use super::seeker::BOUNDS;
|
||||
|
@ -33,9 +47,16 @@ impl EventHandler for Game {
|
|||
MouseButton::Right => self.right_drag_start = Some((x, y)),
|
||||
_ => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mouse_button_up_event(&mut self, _: &mut Context, btn: MouseButton, x: f32, y: f32) {
|
||||
fn mouse_button_up_event(
|
||||
&mut self,
|
||||
_: &mut Context,
|
||||
btn: MouseButton,
|
||||
x: f32,
|
||||
y: f32,
|
||||
) -> GameResult {
|
||||
match btn {
|
||||
MouseButton::Left => {
|
||||
if let Some((px, py)) = self.left_drag_start {
|
||||
|
@ -55,14 +76,17 @@ impl EventHandler for Game {
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mouse_wheel_event(&mut self, _: &mut Context, x: f32, y: f32) {
|
||||
fn mouse_wheel_event(&mut self, _: &mut Context, x: f32, y: f32) -> GameResult {
|
||||
self.seek_by_steps(-y as i32);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn key_up_event(&mut self, _: &mut Context, keycode: KeyCode, _: KeyMods) {
|
||||
fn key_up_event(&mut self, _: &mut Context, keycode: KeyCode, _: KeyMods) -> GameResult {
|
||||
use KeyCode::*;
|
||||
|
||||
match keycode {
|
||||
Space => self.toggle_playing(),
|
||||
Colon => {}
|
||||
|
@ -71,10 +95,19 @@ impl EventHandler for Game {
|
|||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn key_down_event(&mut self, _: &mut Context, keycode: KeyCode, mods: KeyMods, _: bool) {
|
||||
fn key_down_event(
|
||||
&mut self,
|
||||
_: &mut Context,
|
||||
keycode: KeyCode,
|
||||
mods: KeyMods,
|
||||
_: bool,
|
||||
) -> GameResult {
|
||||
use KeyCode::*;
|
||||
|
||||
self.keymap.insert(keycode);
|
||||
match keycode {
|
||||
Key1 => self.switch_tool_to(Tool::Select),
|
||||
|
@ -111,6 +144,8 @@ impl EventHandler for Game {
|
|||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn draw(&mut self, ctx: &mut Context) -> GameResult {
|
||||
|
|
|
@ -17,7 +17,7 @@ use ggez::{
|
|||
event::{KeyCode, MouseButton},
|
||||
graphics::{
|
||||
self, CanvasGeneric, Color, DrawMode, DrawParam, FilterMode, GlBackendSpec, Image, Mesh,
|
||||
Rect, StrokeOptions, Text, WHITE,
|
||||
Rect, StrokeOptions, Text,
|
||||
},
|
||||
Context,
|
||||
};
|
||||
|
@ -175,6 +175,7 @@ impl Game {
|
|||
}
|
||||
|
||||
let song = Sound::create(dir.join(&self.beatmap.inner.audio_filename))?;
|
||||
song.set_volume(0.1);
|
||||
self.song = Some(song);
|
||||
self.timestamp_changed()?;
|
||||
|
||||
|
@ -215,7 +216,7 @@ impl Game {
|
|||
)
|
||||
.as_ref(),
|
||||
);
|
||||
graphics::queue_text(ctx, &text, [0.0, 0.0], Some(WHITE));
|
||||
graphics::queue_text(ctx, &text, [0.0, 0.0], Some(Color::WHITE));
|
||||
graphics::draw_queued_text(ctx, DrawParam::default(), None, FilterMode::Linear)?;
|
||||
|
||||
struct DrawInfo<'a> {
|
||||
|
@ -399,7 +400,7 @@ impl Game {
|
|||
ctx,
|
||||
DrawMode::Stroke(StrokeOptions::default()),
|
||||
drag_rect,
|
||||
WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::draw(ctx, &drag_rect, DrawParam::default())?;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ impl Game {
|
|||
Point2::from([BOUNDS.w, line_y]),
|
||||
],
|
||||
1.0,
|
||||
graphics::WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::draw(ctx, &line, DrawParam::default())?;
|
||||
|
||||
|
@ -75,7 +75,7 @@ impl Game {
|
|||
Point2::from([x, 0.8 * BOUNDS.h]),
|
||||
],
|
||||
4.0,
|
||||
graphics::WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::draw(ctx, &line, DrawParam::default())?;
|
||||
}
|
||||
|
@ -85,7 +85,13 @@ impl Game {
|
|||
};
|
||||
|
||||
if let Some(canvas) = &self.seeker_cache {
|
||||
graphics::draw(ctx, canvas, DrawParam::default().dest([BOUNDS.x, BOUNDS.y]).scale([1.0, 10.0]))?;
|
||||
graphics::draw(
|
||||
ctx,
|
||||
canvas,
|
||||
DrawParam::default()
|
||||
.dest([BOUNDS.x, BOUNDS.y])
|
||||
.scale([1.0, 10.0]),
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -50,13 +50,13 @@ impl Game {
|
|||
ctx,
|
||||
DrawMode::Stroke(opts),
|
||||
spline_mapped.as_ref(),
|
||||
graphics::WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::set_canvas(ctx, Some(&canvas));
|
||||
graphics::clear(ctx, Color::new(0.0, 0.0, 0.0, 0.0));
|
||||
graphics::draw(ctx, &body, DrawParam::default())?;
|
||||
graphics::set_canvas(ctx, None);
|
||||
let mut border_color = graphics::WHITE;
|
||||
let mut border_color = Color::WHITE;
|
||||
border_color.a = color.a;
|
||||
graphics::draw(ctx, &canvas, DrawParam::default().color(border_color))?;
|
||||
|
||||
|
@ -70,7 +70,7 @@ impl Game {
|
|||
ctx,
|
||||
DrawMode::Stroke(opts),
|
||||
spline_mapped.as_ref(),
|
||||
graphics::WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::set_canvas(ctx, Some(&canvas));
|
||||
graphics::clear(ctx, Color::new(0.0, 0.0, 0.0, 0.0));
|
||||
|
@ -151,7 +151,7 @@ impl Game {
|
|||
ctx,
|
||||
DrawMode::Stroke(StrokeOptions::default()),
|
||||
&points_mapped,
|
||||
graphics::WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::draw(ctx, &frame, DrawParam::default())?;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ impl Game {
|
|||
let mut i = 0;
|
||||
while i < points_mapped.len() {
|
||||
let fst = points_mapped[i];
|
||||
let mut color = graphics::WHITE;
|
||||
let mut color = Color::WHITE;
|
||||
if i < points_mapped.len() - 1 {
|
||||
let snd = points_mapped[i + 1];
|
||||
if fst.eq(&snd) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use ggez::{
|
||||
graphics::{self, Color, DrawMode, DrawParam, LineCap, Mesh, Rect, StrokeOptions, WHITE},
|
||||
graphics::{self, Color, DrawMode, DrawParam, LineCap, Mesh, Rect, StrokeOptions},
|
||||
mint::Point2,
|
||||
Context,
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ pub const TICKS: &[&[(Color, f32)]] = &[
|
|||
&[],
|
||||
&[],
|
||||
&[],
|
||||
&[(WHITE, 1.0), (BLUE, 0.5), (RED, 0.5), (BLUE, 0.5)],
|
||||
&[(Color::WHITE, 1.0), (BLUE, 0.5), (RED, 0.5), (BLUE, 0.5)],
|
||||
];
|
||||
|
||||
impl Game {
|
||||
|
@ -37,7 +37,7 @@ impl Game {
|
|||
Point2::from([timeline_current_line_x, BOUNDS.y + BOUNDS.h]),
|
||||
],
|
||||
2.0,
|
||||
graphics::WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::draw(ctx, ¤t_line, DrawParam::default())?;
|
||||
|
||||
|
@ -136,7 +136,7 @@ impl Game {
|
|||
Point2::from([BOUNDS.x + BOUNDS.w, BOUNDS.y + BOUNDS.h]),
|
||||
],
|
||||
2.0,
|
||||
graphics::WHITE,
|
||||
Color::WHITE,
|
||||
)?;
|
||||
graphics::draw(ctx, &bottom_line, DrawParam::default())?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue