mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
fixed usages of ResourceKind
- previously it contained a path, now its just a enum with two variants - the path is now stored in the registry, so it has to be extracted from there
This commit is contained in:
@@ -39,6 +39,7 @@ use crate::fyrox::{
|
||||
VerticalAlignment,
|
||||
},
|
||||
};
|
||||
use fyrox::asset::manager::ResourceManager;
|
||||
|
||||
pub struct DependencyViewer {
|
||||
pub window: Handle<UiNode>,
|
||||
@@ -48,16 +49,23 @@ pub struct DependencyViewer {
|
||||
resource_graph: Option<ResourceDependencyGraph>,
|
||||
}
|
||||
|
||||
fn build_tree_recursively(node: &ResourceGraphNode, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn build_tree_recursively(
|
||||
node: &ResourceGraphNode,
|
||||
resource_manager: &ResourceManager,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
let children = node
|
||||
.children
|
||||
.iter()
|
||||
.map(|c| build_tree_recursively(c, ctx))
|
||||
.map(|c| build_tree_recursively(c, resource_manager, ctx))
|
||||
.collect();
|
||||
|
||||
let data_type = node.resource.data_type_name_or_unknown();
|
||||
|
||||
let name = node.resource.kind().to_string();
|
||||
let name = resource_manager
|
||||
.resource_path(&node.resource)
|
||||
.map(|path| path.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "Embedded".to_string());
|
||||
|
||||
TreeBuilder::new(WidgetBuilder::new())
|
||||
.with_items(children)
|
||||
@@ -140,9 +148,15 @@ impl DependencyViewer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open(&mut self, resource: &UntypedResource, ui: &mut UserInterface) {
|
||||
pub fn open(
|
||||
&mut self,
|
||||
resource: &UntypedResource,
|
||||
resource_manager: &ResourceManager,
|
||||
ui: &mut UserInterface,
|
||||
) {
|
||||
let resource_graph = ResourceDependencyGraph::new(resource);
|
||||
let root = build_tree_recursively(&resource_graph.root, &mut ui.build_ctx());
|
||||
let root =
|
||||
build_tree_recursively(&resource_graph.root, resource_manager, &mut ui.build_ctx());
|
||||
ui.send_message(TreeRootMessage::items(
|
||||
self.tree_root,
|
||||
MessageDirection::ToWidget,
|
||||
|
||||
@@ -1203,8 +1203,11 @@ impl AssetBrowser {
|
||||
if let Ok(resource) =
|
||||
block_on(engine.resource_manager.request_untyped(&item.path))
|
||||
{
|
||||
self.dependency_viewer
|
||||
.open(&resource, engine.user_interfaces.first_mut());
|
||||
self.dependency_viewer.open(
|
||||
&resource,
|
||||
&engine.resource_manager,
|
||||
engine.user_interfaces.first_mut(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::{
|
||||
preview::AssetPreviewTexture,
|
||||
},
|
||||
fyrox::{
|
||||
asset::untyped::{ResourceKind, UntypedResource},
|
||||
asset::untyped::UntypedResource,
|
||||
core::pool::Handle,
|
||||
engine::Engine,
|
||||
fxhash::FxHashMap,
|
||||
|
||||
@@ -18,37 +18,40 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::fyrox::graph::BaseSceneGraph;
|
||||
use crate::fyrox::{
|
||||
asset::{manager::ResourceManager, state::LoadError, Resource, TypedResourceData},
|
||||
core::{
|
||||
color::Color, parking_lot::Mutex, pool::Handle, reflect::prelude::*,
|
||||
type_traits::prelude::*, uuid::uuid, visitor::prelude::*,
|
||||
},
|
||||
gui::{
|
||||
brush::Brush,
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
define_constructor,
|
||||
draw::{CommandTexture, Draw, DrawingContext},
|
||||
grid::{Column, GridBuilder, Row},
|
||||
image::ImageBuilder,
|
||||
inspector::{
|
||||
editors::{
|
||||
PropertyEditorBuildContext, PropertyEditorDefinition, PropertyEditorInstance,
|
||||
PropertyEditorMessageContext, PropertyEditorTranslationContext,
|
||||
use crate::{
|
||||
asset::item::AssetItem,
|
||||
fyrox::{
|
||||
asset::{manager::ResourceManager, state::LoadError, Resource, TypedResourceData},
|
||||
core::{
|
||||
color::Color, parking_lot::Mutex, pool::Handle, reflect::prelude::*,
|
||||
type_traits::prelude::*, uuid::uuid, visitor::prelude::*, PhantomDataSendSync,
|
||||
},
|
||||
graph::BaseSceneGraph,
|
||||
gui::{
|
||||
brush::Brush,
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
define_constructor,
|
||||
draw::{CommandTexture, Draw, DrawingContext},
|
||||
grid::{Column, GridBuilder, Row},
|
||||
image::ImageBuilder,
|
||||
inspector::{
|
||||
editors::{
|
||||
PropertyEditorBuildContext, PropertyEditorDefinition, PropertyEditorInstance,
|
||||
PropertyEditorMessageContext, PropertyEditorTranslationContext,
|
||||
},
|
||||
FieldKind, InspectorError, PropertyChanged,
|
||||
},
|
||||
FieldKind, InspectorError, PropertyChanged,
|
||||
message::{MessageDirection, UiMessage},
|
||||
text::{TextBuilder, TextMessage},
|
||||
widget::{Widget, WidgetBuilder, WidgetMessage},
|
||||
BuildContext, Control, Thickness, UiNode, UserInterface, VerticalAlignment,
|
||||
},
|
||||
message::{MessageDirection, UiMessage},
|
||||
text::{TextBuilder, TextMessage},
|
||||
widget::{Widget, WidgetBuilder, WidgetMessage},
|
||||
BuildContext, Control, Thickness, UiNode, UserInterface, VerticalAlignment,
|
||||
},
|
||||
load_image,
|
||||
message::MessageSender,
|
||||
plugins::inspector::EditorEnvironment,
|
||||
Message,
|
||||
};
|
||||
use crate::plugins::inspector::EditorEnvironment;
|
||||
use crate::{asset::item::AssetItem, load_image, message::MessageSender, Message};
|
||||
|
||||
use fyrox::core::PhantomDataSendSync;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
fmt::{Debug, Formatter},
|
||||
@@ -57,13 +60,17 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
fn resource_path<T>(resource: &Option<Resource<T>>) -> String
|
||||
fn resource_path<T>(resource_manager: &ResourceManager, resource: &Option<Resource<T>>) -> String
|
||||
where
|
||||
T: TypedResourceData,
|
||||
{
|
||||
resource
|
||||
.as_ref()
|
||||
.map(|m| m.kind().to_string())
|
||||
.and_then(|m| {
|
||||
resource_manager
|
||||
.resource_path(m.as_ref())
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
})
|
||||
.unwrap_or_else(|| "None".to_string())
|
||||
}
|
||||
|
||||
@@ -222,7 +229,7 @@ where
|
||||
ui.send_message(TextMessage::text(
|
||||
self.name,
|
||||
MessageDirection::ToWidget,
|
||||
resource_path(resource),
|
||||
resource_path(&self.resource_manager, resource),
|
||||
));
|
||||
|
||||
ui.send_message(message.reverse());
|
||||
@@ -298,7 +305,7 @@ where
|
||||
.with_margin(Thickness::uniform(1.0))
|
||||
.with_vertical_alignment(VerticalAlignment::Center),
|
||||
)
|
||||
.with_text(resource_path(&self.resource))
|
||||
.with_text(resource_path(&resource_manager, &self.resource))
|
||||
.build(ctx);
|
||||
name
|
||||
})
|
||||
|
||||
@@ -131,16 +131,19 @@ impl Control for SurfaceDataPropertyEditor {
|
||||
ui.send_message(TextMessage::text(
|
||||
self.text,
|
||||
MessageDirection::ToWidget,
|
||||
surface_data_info(value),
|
||||
surface_data_info(&self.resource_manager, value),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn surface_data_info(data: &SurfaceResource) -> String {
|
||||
fn surface_data_info(resource_manager: &ResourceManager, data: &SurfaceResource) -> String {
|
||||
let use_count = data.use_count();
|
||||
let kind = data.kind();
|
||||
let kind = resource_manager
|
||||
.resource_path(data.as_ref())
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "External".to_string());
|
||||
let guard = data.data_ref();
|
||||
format!(
|
||||
"{}\nVertices: {}\nTriangles: {}\nUse Count: {}",
|
||||
@@ -175,7 +178,7 @@ impl SurfaceDataPropertyEditor {
|
||||
.on_column(0)
|
||||
.with_margin(Thickness::uniform(1.0)),
|
||||
)
|
||||
.with_text(surface_data_info(&data))
|
||||
.with_text(surface_data_info(&resource_manager, &data))
|
||||
.build(ctx);
|
||||
|
||||
let widget = WidgetBuilder::new()
|
||||
|
||||
@@ -2571,8 +2571,8 @@ impl Engine {
|
||||
|
||||
for resource_to_reload in resources_to_reload.iter() {
|
||||
Log::info(format!(
|
||||
"Reloading {} resource, because it is used in plugin {plugin_assembly_name}",
|
||||
resource_to_reload.kind()
|
||||
"Reloading {:?} resource, because it is used in plugin {plugin_assembly_name}",
|
||||
state.resource_path(resource_to_reload)
|
||||
));
|
||||
|
||||
state.reload_resource(resource_to_reload.clone());
|
||||
|
||||
@@ -497,8 +497,8 @@ impl RenderDataBundle {
|
||||
let Some(shader_set) = shader_cache.get(server, material.shader()) else {
|
||||
err_once!(
|
||||
self.data.key() as usize,
|
||||
"Unable to get a compiled shader set for material {}!",
|
||||
material.shader().kind()
|
||||
"Unable to get a compiled shader set for material {:?}!",
|
||||
material.shader().resource_uuid()
|
||||
);
|
||||
return Ok(stats);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user