Fix audio feature
This commit is contained in:
parent
b09ec887ab
commit
c8b0c46d0e
5 changed files with 15 additions and 15 deletions
|
@ -20,7 +20,7 @@ impl GuiSnippet {
|
|||
pub fn new(gui_handler: &mut GuiHandler, path: &AssetPath) -> Result<Arc<Self>> {
|
||||
let validator = Validator::new(
|
||||
#[cfg(feature = "audio")]
|
||||
&gui_handler,
|
||||
gui_handler,
|
||||
path,
|
||||
)?;
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ pub struct ButtonInfo {
|
|||
|
||||
impl ButtonInfo {
|
||||
pub fn new<'a>(
|
||||
#[cfg(feature = "audio")] gui_handler: &Arc<GuiHandler>,
|
||||
#[cfg(feature = "audio")] gui_handler: &GuiHandler,
|
||||
attributes: quick_xml::events::attributes::Attributes<'a>,
|
||||
grid: &Arc<GridInfo>,
|
||||
) -> Result<ButtonInfo> {
|
||||
|
|
|
@ -6,11 +6,11 @@ use assetpath::AssetPath;
|
|||
use serde_json::from_str;
|
||||
use utilities::prelude::*;
|
||||
|
||||
use quick_xml::{events::Event, Reader};
|
||||
use quick_xml::{Reader, events::Event};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::str::from_utf8;
|
||||
use std::str::FromStr;
|
||||
use std::str::from_utf8;
|
||||
use std::{convert::TryFrom, io::BufRead, sync::Arc};
|
||||
|
||||
use super::buttoninfo::ButtonInfo;
|
||||
|
@ -63,7 +63,7 @@ enum CurrentElement {
|
|||
|
||||
impl Validator {
|
||||
pub fn from_str(
|
||||
#[cfg(feature = "audio")] gui_handler: &Arc<GuiHandler>,
|
||||
#[cfg(feature = "audio")] gui_handler: &GuiHandler,
|
||||
s: &str,
|
||||
) -> Result<Validator> {
|
||||
Self::_new(
|
||||
|
@ -74,7 +74,7 @@ impl Validator {
|
|||
}
|
||||
|
||||
pub fn new(
|
||||
#[cfg(feature = "audio")] gui_handler: &Arc<GuiHandler>,
|
||||
#[cfg(feature = "audio")] gui_handler: &GuiHandler,
|
||||
path: &AssetPath,
|
||||
) -> Result<Validator> {
|
||||
Self::_new(
|
||||
|
@ -86,7 +86,7 @@ impl Validator {
|
|||
|
||||
#[inline]
|
||||
fn _new<T: BufRead>(
|
||||
#[cfg(feature = "audio")] gui_handler: &Arc<GuiHandler>,
|
||||
#[cfg(feature = "audio")] gui_handler: &GuiHandler,
|
||||
mut reader: Reader<T>,
|
||||
) -> Result<Validator> {
|
||||
// removes white spaces in texts
|
||||
|
@ -312,13 +312,13 @@ impl Validator {
|
|||
}
|
||||
Ok(Event::Text(ref e)) => match current_element {
|
||||
CurrentElement::Root => {
|
||||
return Err(anyhow::Error::msg("Text inside root not allowed"))
|
||||
return Err(anyhow::Error::msg("Text inside root not allowed"));
|
||||
}
|
||||
CurrentElement::None => {
|
||||
return Err(anyhow::Error::msg("Text outside root not allowed"))
|
||||
return Err(anyhow::Error::msg("Text outside root not allowed"));
|
||||
}
|
||||
CurrentElement::Grid(_) => {
|
||||
return Err(anyhow::Error::msg("Text inside grid not allowed"))
|
||||
return Err(anyhow::Error::msg("Text inside grid not allowed"));
|
||||
}
|
||||
CurrentElement::Icon(ref icon) => {
|
||||
*icon.text.write().unwrap() = e.unescape()?.to_string();
|
||||
|
@ -365,7 +365,7 @@ impl Validator {
|
|||
}
|
||||
|
||||
fn process_start<'a>(
|
||||
#[cfg(feature = "audio")] gui_handler: &Arc<GuiHandler>,
|
||||
#[cfg(feature = "audio")] gui_handler: &GuiHandler,
|
||||
element: &quick_xml::events::BytesStart<'a>,
|
||||
handle: &CurrentElement,
|
||||
) -> Result<StartResult> {
|
||||
|
@ -479,7 +479,7 @@ impl Validator {
|
|||
return Err(anyhow::Error::msg(format!(
|
||||
"Unexpected tag: {}",
|
||||
from_utf8(element.name().into_inner())?
|
||||
)))
|
||||
)));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -140,13 +140,13 @@ impl ButtonBuilder {
|
|||
#[cfg(feature = "audio")]
|
||||
let click_sound = self
|
||||
.click_sound
|
||||
.map(|path| Audible::new(gui_handler.clone(), path))
|
||||
.map(|path| Audible::new(gui_handler, path))
|
||||
.transpose()?;
|
||||
|
||||
#[cfg(feature = "audio")]
|
||||
let hover_sound = self
|
||||
.hover_sound
|
||||
.map(|path| Audible::new(gui_handler.clone(), path))
|
||||
.map(|path| Audible::new(gui_handler, path))
|
||||
.transpose()?;
|
||||
|
||||
let clickable = Clickable::new(framable.clone(), click_executable.clone());
|
||||
|
|
|
@ -16,7 +16,7 @@ pub struct Audible {
|
|||
}
|
||||
|
||||
impl Audible {
|
||||
pub fn new(gui_handler: Arc<GuiHandler>, mut path: AssetPath) -> Result<Arc<Self>> {
|
||||
pub fn new(gui_handler: &GuiHandler, mut path: AssetPath) -> Result<Arc<Self>> {
|
||||
if !path.has_prefix() {
|
||||
path.set_prefix(
|
||||
&gui_handler
|
||||
|
|
Loading…
Reference in a new issue