fixed dyn type editor + tests

This commit is contained in:
Dmitry Stepanov
2026-09-03 23:45:38 +03:00
parent 0b7412f395
commit b248ee996c
+40 -11
View File
@@ -20,13 +20,16 @@
use crate::{
fyrox::{
core::dyntype::{DynTypeConstructorContainer, DynTypeContainer},
core::{
dyntype::{DynTypeConstructorContainer, DynTypeContainer, DynTypeWrapper},
reflect::Reflect,
visitor::Visit,
},
graph::SceneGraph,
gui::{
core::{pool::Handle, reflect::prelude::*, visitor::prelude::*},
dropdown_list::{DropdownList, DropdownListBuilder, DropdownListMessage},
grid::{GridBuilder, GridDimension},
inspector::InspectorContextArgs,
inspector::{
editors::{
PropertyEditorBuildContext, PropertyEditorDefinition,
@@ -34,21 +37,17 @@ use crate::{
PropertyEditorMessageContext, PropertyEditorTranslationContext,
},
make_expander_container, FieldAction, Inspector, InspectorBuilder,
InspectorContext, InspectorError, InspectorMessage, PropertyChanged,
PropertyFilter,
InspectorContext, InspectorContextArgs, InspectorEnvironmentContainer,
InspectorError, InspectorMessage, PropertyChanged, PropertyFilter,
},
message::MessageData,
message::{MessageDirection, UiMessage},
message::{MessageData, MessageDirection, UiMessage},
utils::make_dropdown_list_option,
widget::{Widget, WidgetBuilder},
widget::{UserData, Widget, WidgetBuilder},
BuildContext, Control, UiNode, UserInterface,
},
},
plugins::inspector::EditorEnvironment,
};
use fyrox::core::dyntype::DynTypeWrapper;
use fyrox::gui::inspector::InspectorEnvironmentContainer;
use fyrox::gui::widget::UserData;
use std::{
any::TypeId,
cell::Cell,
@@ -56,6 +55,8 @@ use std::{
sync::Arc,
};
const INTERNALS_PATH: &'static str = "[email protected]";
#[derive(Debug, PartialEq, Clone)]
pub enum DynTypePropertyEditorMessage {
Value(Option<Uuid>),
@@ -412,7 +413,7 @@ impl PropertyEditorDefinition for DynTypePropertyEditorDefinition {
}
DynTypePropertyEditorMessage::PropertyChanged(property_changed) => {
return Some(PropertyChanged {
name: ctx.name.to_string() + "[email protected]",
name: ctx.name.to_string() + "." + INTERNALS_PATH,
action: FieldAction::InspectableAction(Box::new(
property_changed.clone(),
)),
@@ -424,3 +425,31 @@ impl PropertyEditorDefinition for DynTypePropertyEditorDefinition {
None
}
}
#[cfg(test)]
mod test {
use super::INTERNALS_PATH;
use crate::fyrox::core::{
dyntype::{DynTypeContainer, DynTypeWrapper},
reflect::prelude::*,
visitor::prelude::*,
};
#[test]
fn ensure_internals_path_exists() {
#[derive(Debug, Default, Reflect, Visit, Clone, PartialEq)]
#[reflect(type_uuid = "609c9249-b853-484e-97d6-3519ae7cd474")]
struct Foobar {
foo: u32,
}
let w = DynTypeContainer {
0: Some(DynTypeWrapper(Box::new(Foobar { foo: 123 }))),
};
w.resolve_path(INTERNALS_PATH, &mut |result| {
assert_eq!(
result.unwrap().downcast_ref::<Foobar>().unwrap().foo,
123u32
);
})
}
}