use reflection for texture import options handler
@@ -5,8 +5,9 @@ use fyrox::{
options::{try_get_import_settings, ImportOptions},
ResourceManager,
},
- gui::inspector::{FieldKind, PropertyChanged},
+ gui::inspector::{PropertyAction, PropertyChanged},
resource::texture::TextureImportOptions,
+ utils::log::Log,
};
use std::path::{Path, PathBuf};
@@ -46,28 +47,9 @@ impl ImportOptionsHandler for TextureImportOptionsHandler {
}
fn handle_property_changed(&mut self, property_changed: &PropertyChanged) {
- if let FieldKind::Object(ref args) = property_changed.value {
- match property_changed.name.as_ref() {
- TextureImportOptions::MINIFICATION_FILTER => self
- .options
- .set_minification_filter(args.cast_clone().unwrap()),
- TextureImportOptions::MAGNIFICATION_FILTER => self
- .options
- .set_magnification_filter(args.cast_clone().unwrap()),
- TextureImportOptions::S_WRAP_MODE => {
- self.options.set_s_wrap_mode(args.cast_clone().unwrap())
- }
- TextureImportOptions::T_WRAP_MODE => {
- self.options.set_t_wrap_mode(args.cast_clone().unwrap())
- }
- TextureImportOptions::ANISOTROPY => {
- self.options.set_anisotropy(args.cast_clone().unwrap())
- }
- TextureImportOptions::COMPRESSION => {
- self.options.set_compression(args.cast_clone().unwrap())
- }
- _ => (),
- }
- }
+ Log::verify(
+ PropertyAction::from_field_kind(&property_changed.value)
+ .apply(&property_changed.path(), &mut self.options),
+ )
}
}
