Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prpr/locales/en-US/scene.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ input-hint = Input text.

read-file-failed = Failed to read file.
pasted = Pasted from clipboard.
audio-backend-init-failed = Failed to initialize audio backend, running in silent mode.
1 change: 1 addition & 0 deletions prpr/locales/zh-CN/scene.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ input-hint = 文字

read-file-failed = 读取文件失败
pasted = 从剪贴板加载成功
audio-backend-init-failed = 无法初始化音频后端,将静音运行
54 changes: 38 additions & 16 deletions prpr/src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! UI utilities.

prpr_l10n::tl_file!("scene" ttl);
mod billboard;
pub use billboard::{BillBoard, Message, MessageHandle, MessageKind};

Expand All @@ -25,9 +25,9 @@ pub use glyph_brush::ab_glyph::FontArc;

use crate::{
core::{Matrix, Point, Vector},
ext::{get_viewport, nalgebra_to_glm, semi_black, semi_white, source_of_image, RectExt, SafeTexture, ScaleType},
ext::{get_viewport, nalgebra_to_glm, RectExt, SafeTexture, ScaleType, semi_black, semi_white, source_of_image},
judge::Judge,
scene::{request_input_full, return_input, take_input},
scene::{request_input_full, return_input, show_error, take_input},
};
use lyon::{
lyon_tessellation::{
Expand Down Expand Up @@ -1183,20 +1183,42 @@ impl<'a> From<(Option<f32>, &'a mut f32)> for LoadingParams<'a> {
}

fn build_audio() -> AudioManager {
#[cfg(target_os = "android")]
{
use sasa::backend::oboe::*;
AudioManager::new(OboeBackend::new(OboeSettings {
performance_mode: PerformanceMode::PowerSaving,
usage: Usage::Game,
..Default::default()
}))
.unwrap()
match {
#[cfg(target_os = "android")]
{
use sasa::backend::oboe::*;
AudioManager::new(OboeBackend::new(OboeSettings {
performance_mode: PerformanceMode::PowerSaving,
usage: Usage::Game,
..Default::default()
}))
}
#[cfg(not(target_os = "android"))]
{
use sasa::backend::cpal::*;
AudioManager::new(CpalBackend::new(CpalSettings::default()))
}
} {
Ok(manager) => manager,
Err(e) => {
show_error(e.context(ttl!("audio-backend-init-failed")));
AudioManager::new(DummyBackend).expect("Failed to create dummy audio backend, this should not happen")
}
}
#[cfg(not(target_os = "android"))]
{
use sasa::backend::cpal::*;
AudioManager::new(CpalBackend::new(CpalSettings::default())).unwrap()
}

struct DummyBackend;

impl sasa::backend::Backend for DummyBackend {
fn setup(&mut self, setup: sasa::backend::BackendSetup) -> anyhow::Result<()> {
let _ = setup;
Ok(())
}
fn start(&mut self) -> anyhow::Result<()> {
Ok(())
}
fn consume_broken(&self) -> bool {
false
}
}

Expand Down