mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix the obvious problems, still recipe book isn't hot reloading any more
This commit is contained in:
parent
cc93474c2f
commit
b407a2b186
@ -129,7 +129,7 @@ pub trait AssetCombined: AssetExt {
|
|||||||
|
|
||||||
/// Load combined table without hot-reload support
|
/// Load combined table without hot-reload support
|
||||||
fn load_and_combine_static(specifier: &str) -> Result<AssetHandle<Self>, Error> {
|
fn load_and_combine_static(specifier: &str) -> Result<AssetHandle<Self>, Error> {
|
||||||
Self::load_and_combine(ASSETS.filesystem_cache(), specifier)
|
Self::load_and_combine(ASSETS.non_reloading_cache(), specifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
@ -149,7 +149,7 @@ pub trait AssetCombined: AssetExt {
|
|||||||
/// Load combined table without hot-reload support, panic on error
|
/// Load combined table without hot-reload support, panic on error
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn load_expect_combined_static(specifier: &str) -> AssetHandle<Self> {
|
fn load_expect_combined_static(specifier: &str) -> AssetHandle<Self> {
|
||||||
Self::load_expect_combined(ASSETS.filesystem_cache(), specifier)
|
Self::load_expect_combined(ASSETS.non_reloading_cache(), specifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,6 @@ pub trait AssetCombined: AssetExt {
|
|||||||
pub trait CacheCombined<'a> {
|
pub trait CacheCombined<'a> {
|
||||||
fn load_and_combine<A: Compound + Concatenate>(
|
fn load_and_combine<A: Compound + Concatenate>(
|
||||||
self,
|
self,
|
||||||
// reloading_cache: AnyCache,
|
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<&'a assets_manager::Handle<A>, Error>;
|
) -> Result<&'a assets_manager::Handle<A>, Error>;
|
||||||
}
|
}
|
||||||
@ -188,20 +187,14 @@ impl<T: Compound> AssetExt for T {
|
|||||||
impl<'a> CacheCombined<'a> for AnyCache<'a> {
|
impl<'a> CacheCombined<'a> for AnyCache<'a> {
|
||||||
fn load_and_combine<A: Compound + Concatenate>(
|
fn load_and_combine<A: Compound + Concatenate>(
|
||||||
self,
|
self,
|
||||||
// reloading_cache: AnyCache,
|
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
) -> Result<&'a assets_manager::Handle<A>, Error> {
|
) -> Result<&'a assets_manager::Handle<A>, Error> {
|
||||||
#[cfg(feature = "plugins")]
|
#[cfg(feature = "plugins")]
|
||||||
{
|
{
|
||||||
self.get_cached(specifier).map_or_else(
|
tracing::info!("combine {specifier}");
|
||||||
|| {
|
let data: Result<A, _> =
|
||||||
tracing::info!("combine {specifier}");
|
ASSETS.combine(self, |cache: AnyCache| cache.load_owned::<A>(specifier));
|
||||||
let data: Result<A, _> =
|
data.map(|data| self.get_or_insert(specifier, data))
|
||||||
ASSETS.combine(self, |cache: AnyCache| cache.load_owned::<A>(specifier));
|
|
||||||
data.map(|data| self.get_or_insert(specifier, data))
|
|
||||||
},
|
|
||||||
Ok,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "plugins"))]
|
#[cfg(not(feature = "plugins"))]
|
||||||
{
|
{
|
||||||
@ -210,7 +203,6 @@ impl<'a> CacheCombined<'a> for AnyCache<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function bypasses hot-reloading!
|
|
||||||
impl<T: Compound + Concatenate> AssetCombined for T {
|
impl<T: Compound + Concatenate> AssetCombined for T {
|
||||||
fn load_and_combine(
|
fn load_and_combine(
|
||||||
reloading_cache: AnyCache<'static>,
|
reloading_cache: AnyCache<'static>,
|
||||||
|
@ -133,8 +133,11 @@ impl CombinedCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
// when not using a compound
|
// Provide a cache to the "combine_static" functions as they omit
|
||||||
pub(crate) fn filesystem_cache(&self) -> AnyCache<'_> { self.0.raw_source().fs.as_any_cache() }
|
// wrapping in a Compound (which enables hot-reload)
|
||||||
|
pub(crate) fn non_reloading_cache(&self) -> AnyCache<'_> {
|
||||||
|
self.0.raw_source().fs.as_any_cache()
|
||||||
|
}
|
||||||
|
|
||||||
/// Combine objects from filesystem and plugins
|
/// Combine objects from filesystem and plugins
|
||||||
pub fn combine<T: Concatenate>(
|
pub fn combine<T: Concatenate>(
|
||||||
@ -200,6 +203,7 @@ impl CombinedCache {
|
|||||||
|
|
||||||
// Just forward these methods to the cache
|
// Just forward these methods to the cache
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[cfg(feature = "hot-reloading")]
|
||||||
pub fn enhance_hot_reloading(&'static self) { self.0.enhance_hot_reloading(); }
|
pub fn enhance_hot_reloading(&'static self) { self.0.enhance_hot_reloading(); }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user