pub unsafe fn load_unit_icon(&self, data: &HashMap<String, String>, key: Option<String>) {
        let unit_card = if let Some(unit_card) = key { Some(unit_card.to_owned()) }
        else if let Some(unit_card) = data.get("unit_variants_unit_card") { Some(unit_card.to_owned()) }
        else { None };

        // The icon needs to be pulled up from the dependencies cache on load.
        if let Some(unit_card) = unit_card {
            let icon_path_png_lowres = format!("{}{}.png", UNIT_ICONS_PATH.to_owned(), unit_card).split('/').map(|x| x.to_owned()).collect::<Vec<String>>();
            let icon_path_tga_lowres = format!("{}{}.tga", UNIT_ICONS_PATH.to_owned(), unit_card).split('/').map(|x| x.to_owned()).collect::<Vec<String>>();

            let icon_paths = vec![
                PathType::File(icon_path_png_lowres.to_vec()),
                PathType::File(icon_path_tga_lowres.to_vec()),
            ];

            let receiver = CENTRAL_COMMAND.send_background(Command::GetPackedFilesFromAllSources(icon_paths));
            let response = CentralCommand::recv(&receiver);
            let images_data = if let Response::HashMapDataSourceHashMapVecStringPackedFile(data) = response { data } else { panic!("{}{:?}", THREADS_COMMUNICATION_ERROR, response); };
            let image_file = if let Some(image_file) = Tool::get_most_relevant_file(&images_data, &icon_path_png_lowres) {
                Some(image_file)
            } else if let Some(image_file) = Tool::get_most_relevant_file(&images_data, &icon_path_tga_lowres) {
                Some(image_file)
            } else {
                None
            };

            if let Some(image_file) = image_file {
                let image_data = image_file.get_raw_data().unwrap();
                let byte_array = QByteArray::from_slice(&image_data);
                let image = QPixmap::new();
                image.load_from_data_q_byte_array(&byte_array);
                self.unit_variants_unit_card_preview_label.set_pixmap(&image);
            } else {
                self.unit_variants_unit_card_preview_label.set_text(&QString::from_std_str("No image available"));
            }
        } else {
            self.unit_variants_unit_card_preview_label.set_text(&QString::from_std_str("No image available"));
        }
    }
/// This function loads the unit icon into the tool. If provided with a key, it uses it. If not, it uses whatever key the unit has.
This function loads the unit icon into the tool. If provided with a key, it uses it. If not, it uses whatever key the unit has.
This function loads the unit icon into the tool . If provided with a key it uses it . If not it uses whatever key the unit has .
pub unsafe fn load_unit_icon(&self, data: &HashMap<String, String>, key: Option<String>) {
        let unit_card = if let Some(unit_card) = key { Some(unit_card.to_owned()) }
        else if let Some(unit_card) = data.get("unit_variants_unit_card") { Some(unit_card.to_owned()) }
        else { None };
        // The icon needs to be pulled up from the dependencies cache on load.
        if let Some(unit_card) = unit_card {
            let icon_path_png_lowres = format!("{}{}.png", UNIT_ICONS_PATH.to_owned(), unit_card).split('/').map(|x| x.to_owned()).collect::<Vec<String>>();
            let icon_path_tga_lowres = format!("{}{}.tga", UNIT_ICONS_PATH.to_owned(), unit_card).split('/').map(|x| x.to_owned()).collect::<Vec<String>>();
            let icon_paths = vec![
                PathType::File(icon_path_png_lowres.to_vec()),
                PathType::File(icon_path_tga_lowres.to_vec()),
            ];
            let receiver = CENTRAL_COMMAND.send_background(Command::GetPackedFilesFromAllSources(icon_paths));
            let response = CentralCommand::recv(&receiver);
            let images_data = if let Response::HashMapDataSourceHashMapVecStringPackedFile(data) = response { data } else { panic!("{}{:?}", THREADS_COMMUNICATION_ERROR, response); };
            let image_file = if let Some(image_file) = Tool::get_most_relevant_file(&images_data, &icon_path_png_lowres) {
                Some(image_file)
            } else if let Some(image_file) = Tool::get_most_relevant_file(&images_data, &icon_path_tga_lowres) {
                Some(image_file)
            } else {
                None
            };
            if let Some(image_file) = image_file {
                let image_data = image_file.get_raw_data().unwrap();
                let byte_array = QByteArray::from_slice(&image_data);
                let image = QPixmap::new();
                image.load_from_data_q_byte_array(&byte_array);
                self.unit_variants_unit_card_preview_label.set_pixmap(&image);
            } else {
                self.unit_variants_unit_card_preview_label.set_text(&QString::from_std_str("No image available"));
            }
        } else {
            self.unit_variants_unit_card_preview_label.set_text(&QString::from_std_str("No image available"));
        }
    }
pub unsafe fn load_unit_icon ( & self , data : & HashMap < String , String > , key : Option < String > ) { let unit_card = if let Some ( unit_card ) = key { Some ( unit_card . to_owned ( ) ) } else if let Some ( unit_card ) = data . get ( " " ) { Some ( unit_card . to_owned ( ) ) } else { None } ; // The icon needs to be pulled up from the dependencies cache on load. if let Some ( unit_card ) = unit_card { let icon_path_png_lowres = format ! ( " " UNIT_ICONS_PATH to_owned ( ) unit_card ) . split ( '/' ) . map ( | x | x . to_owned ( ) ) . collect :: < Vec < String > > ( ) ; let icon_path_tga_lowres = format ! ( " " UNIT_ICONS_PATH to_owned ( ) unit_card ) . split ( '/' ) . map ( | x | x . to_owned ( ) ) . collect :: < Vec < String > > ( ) ; let icon_paths = vec ! [ PathType File ( icon_path_png_lowres to_vec ( ) ) PathType File ( icon_path_tga_lowres to_vec ( ) ) ] ; let receiver = CENTRAL_COMMAND . send_background ( Command :: GetPackedFilesFromAllSources ( icon_paths ) ) ; let response = CentralCommand :: recv ( & receiver ) ; let images_data = if let Response :: HashMapDataSourceHashMapVecStringPackedFile ( data ) = response { data } else { panic ! ( " " THREADS_COMMUNICATION_ERROR response ) ; } ; let image_file = if let Some ( image_file ) = Tool :: get_most_relevant_file ( & images_data , & icon_path_png_lowres ) { Some ( image_file ) } else if let Some ( image_file ) = Tool :: get_most_relevant_file ( & images_data , & icon_path_tga_lowres ) { Some ( image_file ) } else { None } ; if let Some ( image_file ) = image_file { let image_data = image_file . get_raw_data ( ) . unwrap ( ) ; let byte_array = QByteArray :: from_slice ( & image_data ) ; let image = QPixmap :: new ( ) ; image . load_from_data_q_byte_array ( & byte_array ) ; self . unit_variants_unit_card_preview_label . set_pixmap ( & image ) ; } else { self . unit_variants_unit_card_preview_label . set_text ( & QString :: from_std_str ( " " ) ) ; } } else { self . unit_variants_unit_card_preview_label . set_text ( & QString :: from_std_str ( " " ) ) ; } }
This function loads the unit icon into the tool.
This function loads the unit icon into the tool .
&self
data
&HashMap<String, String>
key
Option<String>
&self
data
&HashMap<String, String>
key
Option<String>