pub unsafe fn load_variant_mesh(&self, data: &HashMap<String, String>, key: Option<String>) {

        // If it's the initial load to detailed view (not edition of path), check if we have edited data already.
        if key.is_none() {
            if let Some(data) = data.get(VARIANT_MESH_DATA) {
                if !data.is_empty() {
                    set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str(data).into_ptr(), &QString::from_std_str("XML").as_ptr());
                    return;
                }
            }
        }

        // If not, load it from the backend.
        let variant = if let Some(variant) = key { Some(variant.to_owned()) }
        else if let Some(variant) = data.get("variants_variant_filename") { Some(variant.to_owned()) }
        else { None };

        // The variant needs to be pulled up from the dependencies cache on load.
        if let Some(variant) = variant {
            let variant_path = format!("{}{}.{}", VARIANT_MESH_PATH, variant, VARIANT_MESH_EXTENSION).split('/').map(|x| x.to_owned()).collect::<Vec<String>>();
            let variant_paths = vec![
                PathType::File(variant_path.to_vec()),
            ];

            let receiver = CENTRAL_COMMAND.send_background(Command::GetPackedFilesFromAllSources(variant_paths));
            let response = CentralCommand::recv(&receiver);
            let variant_data = if let Response::HashMapDataSourceHashMapVecStringPackedFile(data) = response { data } else { panic!("{}{:?}", THREADS_COMMUNICATION_ERROR, response); };
            let file = if let Some(file) = Tool::get_most_relevant_file(&variant_data, &variant_path) {
                Some(file)
            } else {
                None
            };

            if let Some(mut file) = file {
                if let Ok(DecodedPackedFile::Text(data)) = file.decode_return_ref() {
                    set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str(data.get_ref_contents()).as_ptr(), &QString::from_std_str("XML").as_ptr());
                } else {
                    set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str("").as_ptr(), &QString::from_std_str("XML").as_ptr());
                }
            } else {
                set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str("").as_ptr(), &QString::from_std_str("XML").as_ptr());
            }
        } else {
            set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str("").as_ptr(), &QString::from_std_str("XML").as_ptr());
        }
    }
/// This function loads the variantmesh of a unit into the tool. If provided with a key, it uses it. If not, it uses whatever key the unit has.
This function loads the variantmesh of a unit into the tool. If provided with a key, it uses it. If not, it uses whatever key the unit has.
This function loads the variantmesh of a unit into the tool . If provided with a key it uses it . If not it uses whatever key the unit has .
pub unsafe fn load_variant_mesh(&self, data: &HashMap<String, String>, key: Option<String>) {
        // If it's the initial load to detailed view (not edition of path), check if we have edited data already.
        if key.is_none() {
            if let Some(data) = data.get(VARIANT_MESH_DATA) {
                if !data.is_empty() {
                    set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str(data).into_ptr(), &QString::from_std_str("XML").as_ptr());
                    return;
                }
            }
        }
        // If not, load it from the backend.
        let variant = if let Some(variant) = key { Some(variant.to_owned()) }
        else if let Some(variant) = data.get("variants_variant_filename") { Some(variant.to_owned()) }
        else { None };
        // The variant needs to be pulled up from the dependencies cache on load.
        if let Some(variant) = variant {
            let variant_path = format!("{}{}.{}", VARIANT_MESH_PATH, variant, VARIANT_MESH_EXTENSION).split('/').map(|x| x.to_owned()).collect::<Vec<String>>();
            let variant_paths = vec![
                PathType::File(variant_path.to_vec()),
            ];
            let receiver = CENTRAL_COMMAND.send_background(Command::GetPackedFilesFromAllSources(variant_paths));
            let response = CentralCommand::recv(&receiver);
            let variant_data = if let Response::HashMapDataSourceHashMapVecStringPackedFile(data) = response { data } else { panic!("{}{:?}", THREADS_COMMUNICATION_ERROR, response); };
            let file = if let Some(file) = Tool::get_most_relevant_file(&variant_data, &variant_path) {
                Some(file)
            } else {
                None
            };
            if let Some(mut file) = file {
                if let Ok(DecodedPackedFile::Text(data)) = file.decode_return_ref() {
                    set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str(data.get_ref_contents()).as_ptr(), &QString::from_std_str("XML").as_ptr());
                } else {
                    set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str("").as_ptr(), &QString::from_std_str("XML").as_ptr());
                }
            } else {
                set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str("").as_ptr(), &QString::from_std_str("XML").as_ptr());
            }
        } else {
            set_text_safe(&self.variants_mesh_editor.static_upcast(), &QString::from_std_str("").as_ptr(), &QString::from_std_str("XML").as_ptr());
        }
    }
pub unsafe fn load_variant_mesh ( & self , data : & HashMap < String , String > , key : Option < String > ) { // If it's the initial load to detailed view (not edition of path), check if we have edited data already. if key . is_none ( ) { if let Some ( data ) = data . get ( VARIANT_MESH_DATA ) { if ! data . is_empty ( ) { set_text_safe ( & self . variants_mesh_editor . static_upcast ( ) , & QString :: from_std_str ( data ) . into_ptr ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) ) ; return ; } } } // If not, load it from the backend. let variant = if let Some ( variant ) = key { Some ( variant . to_owned ( ) ) } else if let Some ( variant ) = data . get ( " " ) { Some ( variant . to_owned ( ) ) } else { None } ; // The variant needs to be pulled up from the dependencies cache on load. if let Some ( variant ) = variant { let variant_path = format ! ( " " VARIANT_MESH_PATH variant VARIANT_MESH_EXTENSION ) . split ( '/' ) . map ( | x | x . to_owned ( ) ) . collect :: < Vec < String > > ( ) ; let variant_paths = vec ! [ PathType File ( variant_path to_vec ( ) ) ] ; let receiver = CENTRAL_COMMAND . send_background ( Command :: GetPackedFilesFromAllSources ( variant_paths ) ) ; let response = CentralCommand :: recv ( & receiver ) ; let variant_data = if let Response :: HashMapDataSourceHashMapVecStringPackedFile ( data ) = response { data } else { panic ! ( " " THREADS_COMMUNICATION_ERROR response ) ; } ; let file = if let Some ( file ) = Tool :: get_most_relevant_file ( & variant_data , & variant_path ) { Some ( file ) } else { None } ; if let Some ( mut file ) = file { if let Ok ( DecodedPackedFile :: Text ( data ) ) = file . decode_return_ref ( ) { set_text_safe ( & self . variants_mesh_editor . static_upcast ( ) , & QString :: from_std_str ( data . get_ref_contents ( ) ) . as_ptr ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) ) ; } else { set_text_safe ( & self . variants_mesh_editor . static_upcast ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) ) ; } } else { set_text_safe ( & self . variants_mesh_editor . static_upcast ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) ) ; } } else { set_text_safe ( & self . variants_mesh_editor . static_upcast ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) , & QString :: from_std_str ( " " ) . as_ptr ( ) ) ; } }
This function loads the variantmesh of a unit into the tool.
This function loads the variantmesh of a unit into the tool .
&self
data
&HashMap<String, String>
key
Option<String>
&self
data
&HashMap<String, String>
key
Option<String>