mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 18:08:55 +03:00
put editor sound behind feature
This commit is contained in:
parent
197970185d
commit
8580fb41a1
@ -79,11 +79,11 @@ test-rust:
|
||||
# not pre-compiling the host can cause race conditions
|
||||
RUN echo "4" | cargo run --release examples/benchmarks/NQueens.roc
|
||||
RUN --mount=type=cache,target=$SCCACHE_DIR \
|
||||
cargo test --release && sccache --show-stats
|
||||
cargo test --release --features with_sound && sccache --show-stats
|
||||
# run i386 (32-bit linux) cli tests
|
||||
RUN echo "4" | cargo run --release -- --backend=x86_32 examples/benchmarks/NQueens.roc
|
||||
RUN --mount=type=cache,target=$SCCACHE_DIR \
|
||||
cargo test --release --test cli_run i386 --features="i386-cli-run" && sccache --show-stats
|
||||
cargo test --release --features with_sound --test cli_run i386 --features="i386-cli-run" && sccache --show-stats
|
||||
|
||||
verify-no-git-changes:
|
||||
FROM +test-rust
|
||||
@ -109,7 +109,7 @@ build-nightly-release:
|
||||
# version.txt is used by the CLI: roc --version
|
||||
RUN printf "nightly pre-release, built from commit " > version.txt
|
||||
RUN git log --pretty=format:'%h' -n 1 >> version.txt
|
||||
RUN cargo build --release
|
||||
RUN cargo build --features with_sound --release
|
||||
RUN cd ./target/release && tar -czvf roc_linux_x86_64.tar.gz ./roc
|
||||
SAVE ARTIFACT ./target/release/roc_linux_x86_64.tar.gz AS LOCAL roc_linux_x86_64.tar.gz
|
||||
|
||||
|
@ -12,6 +12,10 @@ normal = ["confy"]
|
||||
#development = []
|
||||
#build = []
|
||||
|
||||
[features]
|
||||
default = []
|
||||
with_sound = ["rodio"]
|
||||
|
||||
[dependencies]
|
||||
roc_ast = { path = "../ast" }
|
||||
roc_collections = { path = "../compiler/collections" }
|
||||
@ -54,7 +58,7 @@ confy = { git = 'https://github.com/rust-cli/confy', features = [
|
||||
serde = { version = "1.0.123", features = ["derive"] }
|
||||
nonempty = "0.6.0"
|
||||
fs_extra = "1.2.0"
|
||||
rodio = "0.14.0"
|
||||
rodio = { version = "0.14.0", optional = true } # to play sounds
|
||||
threadpool = "1.8.1"
|
||||
|
||||
[dependencies.bytemuck]
|
||||
|
@ -8,6 +8,7 @@ mod mvc;
|
||||
mod render_ast;
|
||||
mod render_debug;
|
||||
mod resources;
|
||||
#[cfg(feature = "with_sound")]
|
||||
mod sound;
|
||||
mod theme;
|
||||
mod util;
|
||||
|
@ -22,6 +22,7 @@ use crate::editor::mvc::string_update::start_new_string;
|
||||
use crate::editor::mvc::string_update::update_small_string;
|
||||
use crate::editor::mvc::string_update::update_string;
|
||||
use crate::editor::mvc::tld_value_update::{start_new_tld_value, update_tld_val_name};
|
||||
#[cfg(feature = "with_sound")]
|
||||
use crate::editor::sound::play_sound;
|
||||
use crate::ui::text::caret_w_select::CaretWSelect;
|
||||
use crate::ui::text::lines::MoveCaretFun;
|
||||
@ -521,7 +522,7 @@ impl<'a> EdModel<'a> {
|
||||
&mut self,
|
||||
modifiers: &Modifiers,
|
||||
virtual_keycode: VirtualKeyCode,
|
||||
sound_thread_pool: &mut ThreadPool,
|
||||
_sound_thread_pool: &mut ThreadPool,
|
||||
) -> EdResult<()> {
|
||||
match virtual_keycode {
|
||||
Left => self.move_caret_left(modifiers)?,
|
||||
@ -560,9 +561,13 @@ impl<'a> EdModel<'a> {
|
||||
self.dirty = true;
|
||||
}
|
||||
F12 => {
|
||||
sound_thread_pool.execute(move || {
|
||||
play_sound("./editor/src/editor/resources/sounds/bell_sound.mp3");
|
||||
});
|
||||
#[cfg(feature = "with_sound")]
|
||||
{
|
||||
println!("playing sound...");
|
||||
_sound_thread_pool.execute(move || {
|
||||
play_sound("./editor/src/editor/resources/sounds/bell_sound.mp3");
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user