reorganized resource loaders

This commit is contained in:
Dmitry
2023-04-25 10:40:00 +03:00
parent 99b39aa28f
commit d1e17caaf1
20 changed files with 40 additions and 43 deletions
+1 -2
View File
@@ -1,13 +1,12 @@
use crate::asset::inspector::handlers::ImportOptionsHandler;
use fyrox::scene::sound::SoundBuffer;
use fyrox::{
asset::{
manager::ResourceManager,
options::{try_get_import_settings, ImportOptions},
},
core::{append_extension, futures::executor::block_on, reflect::prelude::*},
engine::resource_loaders::sound::SoundBufferImportOptions,
gui::inspector::{PropertyAction, PropertyChanged},
scene::sound::{SoundBuffer, SoundBufferImportOptions},
utils::log::Log,
};
use std::path::{Path, PathBuf};
+1 -3
View File
@@ -3,15 +3,13 @@
//! Just shows two textures with compression. Engine compresses textures automatically,
//! based on compression options.
use fyrox::engine::resource_loaders::texture::TextureLoader;
use fyrox::resource::texture::Texture;
use fyrox::{
core::{algebra::Vector2, color::Color, pool::Handle},
engine::{executor::Executor, GraphicsContextParams},
event_loop::ControlFlow,
gui::{image::ImageBuilder, widget::WidgetBuilder},
plugin::{Plugin, PluginConstructor, PluginContext},
resource::texture::{CompressionOptions, TextureImportOptions},
resource::texture::{loader::TextureLoader, CompressionOptions, Texture, TextureImportOptions},
scene::Scene,
utils::into_gui_texture,
window::WindowAttributes,
+4 -3
View File
@@ -9,8 +9,6 @@
pub mod shared;
use crate::shared::create_camera;
use fyrox::resource::model::{Model, ModelResourceExtension};
use fyrox::resource::texture::Texture;
use fyrox::{
asset::{
loader::{BoxedLoaderFuture, ResourceLoader},
@@ -23,13 +21,16 @@ use fyrox::{
instant::Instant,
sstorage::ImmutableString,
},
engine::resource_loaders::{model::ModelLoader, texture::TextureLoader},
engine::{
Engine, EngineInitParams, GraphicsContext, GraphicsContextParams, SerializationContext,
},
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
material::{shader::SamplerFallback, Material, PropertyValue, SharedMaterial},
resource::{
model::{loader::ModelLoader, Model, ModelResourceExtension},
texture::{loader::TextureLoader, Texture},
},
scene::{
base::BaseBuilder,
light::{point::PointLightBuilder, BaseLightBuilder},
+2 -1
View File
@@ -23,4 +23,5 @@ hrtf = "0.8.0"
hound = "3.4.0"
strum = "0.24.0"
strum_macros = "0.24.0"
tinyaudio = "0.1.0"
tinyaudio = "0.1.0"
serde = { version = "1", features = ["derive"] }
@@ -1,16 +1,13 @@
//! Sound buffer loader.
use crate::{
asset::{
loader::{BoxedLoaderFuture, ResourceLoader},
options::{try_get_import_settings, ImportOptions},
},
core::reflect::prelude::*,
utils::log::Log,
use crate::buffer::{DataSource, SoundBuffer, SoundBufferResourceLoadError};
use fyrox_core::reflect::prelude::*;
use fyrox_resource::{
event::ResourceEventBroadcaster,
loader::{BoxedLoaderFuture, ResourceLoader},
options::{try_get_import_settings, ImportOptions},
untyped::UntypedResource,
};
use fyrox_resource::event::ResourceEventBroadcaster;
use fyrox_resource::untyped::UntypedResource;
use fyrox_sound::buffer::{DataSource, SoundBuffer, SoundBufferResourceLoadError};
use serde::{Deserialize, Serialize};
use std::any::Any;
@@ -70,7 +67,8 @@ impl ResourceLoader for SoundBufferLoader {
event_broadcaster.broadcast_loaded_or_reloaded(resource, reload);
Log::info(format!("Sound buffer {:?} is loaded!", path));
// TODO: Replace with log.
println!("Sound buffer {:?} is loaded!", path);
}
Err(_) => {
resource.0.lock().commit_error(
@@ -78,12 +76,14 @@ impl ResourceLoader for SoundBufferLoader {
SoundBufferResourceLoadError::UnsupportedFormat,
);
Log::err(format!("Unable to load sound buffer from {:?}!", path));
// TODO: Replace with log.
eprintln!("Unable to load sound buffer from {:?}!", path);
}
}
}
Err(e) => {
Log::err(format!("Invalid data source for sound buffer: {:?}", e));
// TODO: Replace with log.
eprintln!("Invalid data source for sound buffer: {:?}", e);
resource
.0
+1
View File
@@ -25,6 +25,7 @@ use std::{
};
pub mod generic;
pub mod loader;
pub mod streaming;
/// Data source enumeration. Provides unified way of selecting data source for sound buffers. It can be either
+6 -13
View File
@@ -5,28 +5,21 @@
pub mod error;
pub mod executor;
pub mod resource_loaders;
use crate::{
asset::{manager::ResourceManager, manager::ResourceWaitContext},
core::{algebra::Vector2, futures::executor::block_on, instant, pool::Handle},
engine::{
error::EngineError,
resource_loaders::{
curve::CurveLoader, model::ModelLoader, shader::ShaderLoader, sound::SoundBufferLoader,
texture::TextureLoader,
},
},
engine::error::EngineError,
event::Event,
event_loop::ControlFlow,
gui::UserInterface,
material::shader::Shader,
material::shader::{loader::ShaderLoader, Shader},
plugin::{Plugin, PluginConstructor, PluginContext, PluginRegistrationContext},
renderer::{framework::error::FrameworkError, Renderer},
resource::{
curve::CurveResourceState,
model::{Model, ModelResource},
texture::{Texture, TextureKind},
curve::{loader::CurveLoader, CurveResourceState},
model::{loader::ModelLoader, Model, ModelResource},
texture::{loader::TextureLoader, Texture, TextureKind},
},
scene::{
base::NodeScriptMessage,
@@ -46,7 +39,7 @@ use crate::{
use fxhash::{FxHashMap, FxHashSet};
use fyrox_resource::event::ResourceEvent;
use fyrox_resource::ResourceStateRef;
use fyrox_sound::buffer::SoundBuffer;
use fyrox_sound::buffer::{loader::SoundBufferLoader, SoundBuffer};
#[cfg(not(target_arch = "wasm32"))]
use glutin::{
config::ConfigTemplateBuilder,
-7
View File
@@ -1,7 +0,0 @@
//! Contains resource loaders for built-in engine resources.
pub mod curve;
pub mod model;
pub mod shader;
pub mod sound;
pub mod texture;
@@ -249,6 +249,8 @@ use std::{
path::{Path, PathBuf},
};
pub mod loader;
/// A name of the standard shader.
pub const STANDARD_SHADER_NAME: &str = "Standard";
@@ -16,6 +16,8 @@ use std::{
path::{Path, PathBuf},
};
pub mod loader;
/// An error that may occur during curve resource loading.
#[derive(Debug)]
pub enum CurveResourceError {
@@ -51,6 +51,8 @@ use std::{
};
use strum_macros::{AsRefStr, EnumString, EnumVariantNames};
pub mod loader;
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub(crate) enum NodeMapping {
@@ -47,6 +47,8 @@ use std::{
};
use strum_macros::{AsRefStr, EnumString, EnumVariantNames};
pub mod loader;
/// Texture kind.
#[derive(Copy, Clone, Debug)]
pub enum TextureKind {
+4 -1
View File
@@ -21,7 +21,10 @@ use crate::{
// Re-export some the fyrox_sound entities.
pub use fyrox_sound::{
buffer::{DataSource, SoundBuffer, SoundBufferResource, SoundBufferResourceLoadError},
buffer::{
loader::{SoundBufferImportOptions, SoundBufferLoader},
DataSource, SoundBuffer, SoundBufferResource, SoundBufferResourceLoadError,
},
bus::*,
context::{DistanceModel, SAMPLE_RATE},
dsp::{filters::*, DelayLine},