Skip to content

Commit

Permalink
Implemented serialize and deserialize for all commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frodo45127 committed Dec 25, 2024
1 parent f7e0b79 commit 5f2f96b
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 27 deletions.
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/anim_fragment_battle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//---------------------------------------------------------------------------//

use getset::{Getters, MutGetters};
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::anim_fragment_battle::AnimFragmentBattle;

Expand All @@ -19,7 +20,7 @@ use super::{find_in_string, MatchingMode, replace_match_string, Replaceable, Sea
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within an Anim Fragment Battle File.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct AnimFragmentBattleMatches {

Expand All @@ -31,7 +32,7 @@ pub struct AnimFragmentBattleMatches {
}

/// This struct represents a match within an Anim Fragment Battle File.
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct AnimFragmentBattleMatch {

Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//---------------------------------------------------------------------------//

use getset::{Getters, MutGetters};
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::atlas::Atlas;

Expand All @@ -19,7 +20,7 @@ use super::{find_in_string, MatchingMode, replace_match_string, Replaceable, Sea
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within an Atlas File.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct AtlasMatches {

Expand All @@ -31,7 +32,7 @@ pub struct AtlasMatches {
}

/// This struct represents a match within an Atlas File.
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct AtlasMatch {

Expand Down
11 changes: 6 additions & 5 deletions rpfm_extensions/src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This module contains the code needed to get a `GlobalSearch` over an entire `Pac
use getset::*;
use regex::{RegexBuilder, Regex};
use rayon::prelude::*;
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::error::{Result, RLibError};
use rpfm_lib::files::{Container, ContainerPath, DecodeableExtraData, FileType, pack::Pack, RFile, RFileDecoded};
Expand Down Expand Up @@ -97,7 +98,7 @@ pub trait Replaceable: Searchable {
//-------------------------------------------------------------------------------//

/// This struct contains the information needed to perform a global search, and the results of said search.
#[derive(Default, Debug, Clone, Getters, MutGetters, Setters)]
#[derive(Default, Debug, Clone, Getters, MutGetters, Setters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub", set = "pub")]
pub struct GlobalSearch {

Expand Down Expand Up @@ -135,7 +136,7 @@ pub enum MatchingMode {
}

/// This enum is a way to put together all kind of matches.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MatchHolder {
Anim(UnknownMatches),
AnimFragmentBattle(AnimFragmentBattleMatches),
Expand Down Expand Up @@ -163,7 +164,7 @@ pub enum MatchHolder {
}

/// This enum is specifies the source where the search should be performed.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Default)]
pub enum SearchSource {
#[default] Pack,
Expand All @@ -173,7 +174,7 @@ pub enum SearchSource {
}

/// This struct specifies in what file types is the search going to be performed.
#[derive(Default, Debug, Clone, Getters, Setters)]
#[derive(Default, Debug, Clone, Getters, Setters, Serialize, Deserialize)]
#[getset(get = "pub", set = "pub")]
pub struct SearchOn {
anim: bool,
Expand Down Expand Up @@ -202,7 +203,7 @@ pub struct SearchOn {
}

/// This struct stores the search matches, separated by file type.
#[derive(Default, Debug, Clone, Getters)]
#[derive(Default, Debug, Clone, Getters, Serialize, Deserialize)]
#[getset(get = "pub")]
pub struct Matches {
anim: Vec<UnknownMatches>,
Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/portrait_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//---------------------------------------------------------------------------//

use getset::{Getters, MutGetters};
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::portrait_settings::PortraitSettings;

Expand All @@ -19,7 +20,7 @@ use super::{find_in_string, MatchingMode, Replaceable, Searchable, replace_match
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within an PortraitSettings File.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct PortraitSettingsMatches {

Expand All @@ -31,7 +32,7 @@ pub struct PortraitSettingsMatches {
}

/// This struct represents a match within an PortraitSettings File.
#[derive(Debug, Default, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct PortraitSettingsMatch {

Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/rigid_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use getset::{Getters, MutGetters};
use regex::bytes::RegexBuilder;
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::rigidmodel::RigidModel;

Expand All @@ -20,7 +21,7 @@ use super::{find_in_bytes, MatchingMode, Replaceable, Searchable, replace_match_
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within an RigidModel File.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct RigidModelMatches {

Expand All @@ -32,7 +33,7 @@ pub struct RigidModelMatches {
}

/// This struct represents a match within an RigidModel File.
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct RigidModelMatch {

Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This module contains the code needed to get schema matches from a `GlobalSearch`
!*/

use getset::{Getters, MutGetters};
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::schema::Schema;

Expand All @@ -25,7 +26,7 @@ use super::{MatchingMode, Searchable};
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within a Schema.
#[derive(Debug, Default, Clone, Getters, MutGetters)]
#[derive(Debug, Default, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct SchemaMatches {

Expand All @@ -34,7 +35,7 @@ pub struct SchemaMatches {
}

/// This struct represents a match on a column name within a Schema.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct SchemaMatch {

Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This module contains the code needed to get table matches from a `GlobalSearch`.
!*/

use getset::{Getters, MutGetters};
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::{db::DB, loc::Loc, table::DecodedData};
use rpfm_lib::schema::Field;
Expand All @@ -26,7 +27,7 @@ use super::{find_in_string, MatchingMode, Replaceable, Searchable, replace_match
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within a table.
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct TableMatches {

Expand All @@ -38,7 +39,7 @@ pub struct TableMatches {
}

/// This struct represents a match on a row of a Table PackedFile (DB & Loc).
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct TableMatch {

Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This module contains the code needed to get text matches from a `GlobalSearch`.

use getset::{Getters, MutGetters};
use itertools::Itertools;
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::text::Text;

Expand All @@ -26,7 +27,7 @@ use super::{find_in_string, MatchingMode, Replaceable, Searchable, replace_match
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within a text PackedFile.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct TextMatches {

Expand All @@ -38,7 +39,7 @@ pub struct TextMatches {
}

/// This struct represents a match on a piece of text within a Text PackedFile.
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct TextMatch {

Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/unit_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//---------------------------------------------------------------------------//

use getset::{Getters, MutGetters};
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::unit_variant::UnitVariant;

Expand All @@ -19,7 +20,7 @@ use super::{find_in_string, MatchingMode, Replaceable, Searchable, replace_match
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within an UnitVariant File.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct UnitVariantMatches {

Expand All @@ -31,7 +32,7 @@ pub struct UnitVariantMatches {
}

/// This struct represents a match within an UnitVariant File.
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct UnitVariantMatch {

Expand Down
5 changes: 3 additions & 2 deletions rpfm_extensions/src/search/unknown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use getset::{Getters, MutGetters};
use regex::bytes::RegexBuilder;
use serde_derive::{Deserialize, Serialize};

use rpfm_lib::files::unknown::Unknown;

Expand All @@ -20,7 +21,7 @@ use super::{find_in_bytes, MatchingMode, Replaceable, Searchable, replace_match_
//-------------------------------------------------------------------------------//

/// This struct represents all the matches of the global search within an Unknown File.
#[derive(Debug, Clone, Getters, MutGetters)]
#[derive(Debug, Clone, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct UnknownMatches {

Expand All @@ -32,7 +33,7 @@ pub struct UnknownMatches {
}

/// This struct represents a match within an Unknown File.
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters)]
#[derive(Debug, Clone, Eq, PartialEq, Getters, MutGetters, Serialize, Deserialize)]
#[getset(get = "pub", get_mut = "pub")]
pub struct UnknownMatch {

Expand Down
2 changes: 1 addition & 1 deletion rpfm_lib/src/files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ pub enum FileType {
}

/// This enum represents a ***Path*** inside a [Container].
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub enum ContainerPath {

/// This variant represents the path of a single file.
Expand Down
3 changes: 2 additions & 1 deletion rpfm_ui/src/app_ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ use anyhow::{anyhow, Result};
use getset::Getters;
use itertools::Itertools;
use self_update::cargo_crate_version;
use serde_derive::{Deserialize, Serialize};
use time::OffsetDateTime;

use std::cell::RefCell;
Expand Down Expand Up @@ -377,7 +378,7 @@ pub struct AppUI {
}

/// This enum contains the data needed to create a new PackedFile.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum NewFile {

/// Name of the PackedFile.
Expand Down
3 changes: 2 additions & 1 deletion rpfm_ui/src/communications/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use qt_core::QEventLoop;

use anyhow::Error;
use crossbeam::channel::{Receiver, Sender, unbounded};
use serde_derive::{Deserialize, Serialize};

use std::collections::{BTreeMap, HashMap, HashSet};
use std::fmt::Debug;
Expand Down Expand Up @@ -64,7 +65,7 @@ pub struct CentralCommand<T: Send + Sync + Debug> {
///
/// Each command should include the data needed for his own execution. For a more detailed explanation, check the
/// docs of each command.
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub enum Command {

/// This command is used to close a thread.
Expand Down
3 changes: 2 additions & 1 deletion rpfm_ui/src/packedfile_views/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use qt_core::{CheckState, QBox};

use anyhow::{anyhow, Result};
use getset::Getters;
use serde_derive::{Deserialize, Serialize};

use std::{fmt, fmt::Display};
use std::rc::Rc;
Expand Down Expand Up @@ -132,7 +133,7 @@ pub enum ViewType {
}

/// This enum represents the source of the data in the view.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd, Serialize, Deserialize)]
pub enum DataSource {

/// This means the data is from somewhere in our PackFile.
Expand Down

0 comments on commit 5f2f96b

Please sign in to comment.