From 340ee4e332d8f0a8b40c4c872f7f902284880adb Mon Sep 17 00:00:00 2001
From: pizzart <7o7goo7o7@gmail.com>
Date: Thu, 26 Oct 2023 23:53:42 +0300
Subject: [PATCH] proper resource dumping in gui

---
 bff-gui/src/panels/top.rs | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/bff-gui/src/panels/top.rs b/bff-gui/src/panels/top.rs
index 7a4c1f6..11bef5b 100644
--- a/bff-gui/src/panels/top.rs
+++ b/bff-gui/src/panels/top.rs
@@ -8,7 +8,6 @@ use bff::class::Class;
 use bff::names::Name;
 use bff::traits::TryIntoVersionPlatform;
 use egui;
-use image::EncodableLayout;
 
 use crate::{load_bigfile, Artifact};
 
@@ -106,17 +105,19 @@ pub fn menubar(
                         .add_filter("raw", &[resource.class_name.to_string()])
                         .save_file()
                     {
-                        let data = match &resource.data {
-                            bff::bigfile::resource::ResourceData::Data(data) => data.clone(),
-                            bff::bigfile::resource::ResourceData::SplitData {
-                                link_header,
-                                body,
-                            } => [link_header.clone(), body.clone()].concat(),
-                        };
-                        File::create(path)
+                        let mut w = File::create(path).unwrap();
+                        bigfile
+                            .as_ref()
                             .unwrap()
-                            .write_all(data.as_bytes())
+                            .dump_resource(resource, &mut w)
                             .unwrap();
+                        // let data = match &resource.data {
+                        //     bff::bigfile::resource::ResourceData::Data(data) => data.clone(),
+                        //     bff::bigfile::resource::ResourceData::SplitData {
+                        //         link_header,
+                        //         body,
+                        //     } => [link_header.clone(), body.clone()].concat(),
+                        // };
                     }
                 }
             });