diff --git a/data-prepper/src/extract/mod.rs b/data-prepper/src/extract.rs similarity index 90% rename from data-prepper/src/extract/mod.rs rename to data-prepper/src/extract.rs index e17a4ab..346545d 100644 --- a/data-prepper/src/extract/mod.rs +++ b/data-prepper/src/extract.rs @@ -1,7 +1,3 @@ -pub mod ryza3; -pub mod sophie; -mod util; - use std::{ fs::File, path::{Path, PathBuf}, @@ -60,8 +56,10 @@ impl Args { // extract data from game files match game_version { - GameVersion::A17 => sophie::extract(pak_index, &output_directory), - GameVersion::A24 => ryza3::extract(&self.game_directory, pak_index, &output_directory), + GameVersion::A17 => super::sophie::extract(pak_index, &output_directory), + GameVersion::A24 => { + super::ryza3::extract(&self.game_directory, pak_index, &output_directory) + } _ => bail!("Unsupported game version {:?}", game_version), } } diff --git a/data-prepper/src/extract/util/mod.rs b/data-prepper/src/extract/util/mod.rs deleted file mode 100644 index 9dd9032..0000000 --- a/data-prepper/src/extract/util/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod xml_reader; - -pub use xml_reader::{read_xml, read_xml_shift_jis, ElementReader}; diff --git a/data-prepper/src/main.rs b/data-prepper/src/main.rs index c3abf9b..6928766 100644 --- a/data-prepper/src/main.rs +++ b/data-prepper/src/main.rs @@ -1,5 +1,6 @@ mod extract; -mod extract_images; +pub mod ryza3; +pub mod sophie; mod typedefs; mod utils; @@ -26,7 +27,7 @@ struct CliArgs { #[argh(subcommand)] enum Subcommand { Extract(extract::Args), - ExtractImages(extract_images::Args), + ExtractImages(ryza3::extract_images::Args), // TODO: allow extracting images from other games TypeDefs(typedefs::Args), } diff --git a/data-prepper/src/extract/ryza3/data/enemies/data.rs b/data-prepper/src/ryza3/data/enemies/data.rs similarity index 93% rename from data-prepper/src/extract/ryza3/data/enemies/data.rs rename to data-prepper/src/ryza3/data/enemies/data.rs index b535c24..717e9ed 100644 --- a/data-prepper/src/extract/ryza3/data/enemies/data.rs +++ b/data-prepper/src/ryza3/data/enemies/data.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; #[derive(Debug)] pub struct EnemyData { @@ -21,7 +18,7 @@ pub struct EnemyData { impl EnemyData { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\enemy\enemy_data.xml", |d| { + utils::read_xml(pak_index, r"\saves\enemy\enemy_data.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/enemies/drop.rs b/data-prepper/src/ryza3/data/enemies/drop.rs similarity index 97% rename from data-prepper/src/extract/ryza3/data/enemies/drop.rs rename to data-prepper/src/ryza3/data/enemies/drop.rs index 01caede..efcce3e 100644 --- a/data-prepper/src/extract/ryza3/data/enemies/drop.rs +++ b/data-prepper/src/ryza3/data/enemies/drop.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; #[derive(Debug)] pub struct DropData { @@ -39,7 +36,7 @@ pub struct DropData { impl DropData { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\enemy\drop_data.xml", |d| { + utils::read_xml(pak_index, r"\saves\enemy\drop_data.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/enemies/library_monster.rs b/data-prepper/src/ryza3/data/enemies/library_monster.rs similarity index 86% rename from data-prepper/src/extract/ryza3/data/enemies/library_monster.rs rename to data-prepper/src/ryza3/data/enemies/library_monster.rs index 1646a05..5ade1b7 100644 --- a/data-prepper/src/extract/ryza3/data/enemies/library_monster.rs +++ b/data-prepper/src/ryza3/data/enemies/library_monster.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub struct LibraryMonster { pub monster_tag: String, @@ -12,7 +9,7 @@ pub struct LibraryMonster { impl LibraryMonster { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\library\librarymonster.xml", |d| { + utils::read_xml(pak_index, r"\saves\library\librarymonster.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/enemies/mod.rs b/data-prepper/src/ryza3/data/enemies/mod.rs similarity index 100% rename from data-prepper/src/extract/ryza3/data/enemies/mod.rs rename to data-prepper/src/ryza3/data/enemies/mod.rs diff --git a/data-prepper/src/extract/ryza3/data/enemies/status.rs b/data-prepper/src/ryza3/data/enemies/status.rs similarity index 95% rename from data-prepper/src/extract/ryza3/data/enemies/status.rs rename to data-prepper/src/ryza3/data/enemies/status.rs index 82496df..4bf368d 100644 --- a/data-prepper/src/extract/ryza3/data/enemies/status.rs +++ b/data-prepper/src/ryza3/data/enemies/status.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; #[derive(Debug, Clone)] pub struct EnemyStatus { @@ -33,7 +30,7 @@ pub struct EnemyStatus { impl EnemyStatus { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\enemy\enemy_status.xml", |d| { + utils::read_xml(pak_index, r"\saves\enemy\enemy_status.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/feeding/mod.rs b/data-prepper/src/ryza3/data/feeding/mod.rs similarity index 100% rename from data-prepper/src/extract/ryza3/data/feeding/mod.rs rename to data-prepper/src/ryza3/data/feeding/mod.rs diff --git a/data-prepper/src/extract/ryza3/data/feeding/species.rs b/data-prepper/src/ryza3/data/feeding/species.rs similarity index 96% rename from data-prepper/src/extract/ryza3/data/feeding/species.rs rename to data-prepper/src/ryza3/data/feeding/species.rs index 50c0ee6..e293a53 100644 --- a/data-prepper/src/extract/ryza3/data/feeding/species.rs +++ b/data-prepper/src/ryza3/data/feeding/species.rs @@ -1,9 +1,6 @@ //! Data from `\saves\feeding\feedingspecies.xml` -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub struct Species { pub no: usize, @@ -35,7 +32,7 @@ pub struct Species { impl Species { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml( + utils::read_xml( pak_index, r"\saves\feeding\feedingspecies.xml", Self::read_from_doc, diff --git a/data-prepper/src/extract/ryza3/data/feeding/unique_item_event.rs b/data-prepper/src/ryza3/data/feeding/unique_item_event.rs similarity index 92% rename from data-prepper/src/extract/ryza3/data/feeding/unique_item_event.rs rename to data-prepper/src/ryza3/data/feeding/unique_item_event.rs index f53a400..833466e 100644 --- a/data-prepper/src/extract/ryza3/data/feeding/unique_item_event.rs +++ b/data-prepper/src/ryza3/data/feeding/unique_item_event.rs @@ -1,9 +1,6 @@ //! Data from `\saves\feeding\feedinguniqueitemevent.xml` -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub struct FeedingUniqueItemEvent { pub no: usize, @@ -15,7 +12,7 @@ pub struct FeedingUniqueItemEvent { impl FeedingUniqueItemEvent { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml( + utils::read_xml( pak_index, r"\saves\feeding\feedinguniqueitemevent.xml", Self::read_from_doc, diff --git a/data-prepper/src/extract/ryza3/data/field_data/field_data_types.rs b/data-prepper/src/ryza3/data/field_data/field_data_types.rs similarity index 100% rename from data-prepper/src/extract/ryza3/data/field_data/field_data_types.rs rename to data-prepper/src/ryza3/data/field_data/field_data_types.rs diff --git a/data-prepper/src/extract/ryza3/data/field_data/gimmick.rs b/data-prepper/src/ryza3/data/field_data/gimmick.rs similarity index 96% rename from data-prepper/src/extract/ryza3/data/field_data/gimmick.rs rename to data-prepper/src/ryza3/data/field_data/gimmick.rs index a9f6316..e84a619 100644 --- a/data-prepper/src/extract/ryza3/data/field_data/gimmick.rs +++ b/data-prepper/src/ryza3/data/field_data/gimmick.rs @@ -3,10 +3,7 @@ use std::collections::BTreeMap; use anyhow::Context; use tracing::debug; -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; #[derive(Debug)] pub struct GimmickProperty { @@ -48,7 +45,7 @@ impl GimmickProperty { let stripped = file_name.trim_start_matches(PREFIX); debug_assert!(stripped.ends_with(".xml")); - let parsed = util::read_xml(pak_index, file_name, Self::read_from_doc) + let parsed = utils::read_xml(pak_index, file_name, Self::read_from_doc) .with_context(|| format!("parse gimmick doc '{file_name}'"))?; Ok((stripped.to_owned(), parsed)) diff --git a/data-prepper/src/extract/ryza3/data/field_data/mod.rs b/data-prepper/src/ryza3/data/field_data/mod.rs similarity index 98% rename from data-prepper/src/extract/ryza3/data/field_data/mod.rs rename to data-prepper/src/ryza3/data/field_data/mod.rs index 008b492..5d9570c 100644 --- a/data-prepper/src/extract/ryza3/data/field_data/mod.rs +++ b/data-prepper/src/ryza3/data/field_data/mod.rs @@ -11,7 +11,7 @@ use serde::Serialize; use tracing::trace; use typescript_type_def::TypeDef; -use crate::extract::ryza3::data::field_data::gimmick::GimmickProperty; +use crate::ryza3::data::field_data::gimmick::GimmickProperty; use crate::utils::PakIndex; pub use field_data_types::*; diff --git a/data-prepper/src/extract/ryza3/data/field_map/fm_info.rs b/data-prepper/src/ryza3/data/field_map/fm_info.rs similarity index 93% rename from data-prepper/src/extract/ryza3/data/field_map/fm_info.rs rename to data-prepper/src/ryza3/data/field_map/fm_info.rs index 194d55b..5d11f85 100644 --- a/data-prepper/src/extract/ryza3/data/field_map/fm_info.rs +++ b/data-prepper/src/ryza3/data/field_map/fm_info.rs @@ -1,5 +1,4 @@ -use crate::extract::util::{self, ElementReader}; -use crate::utils::PakIndex; +use crate::utils::{self, ElementReader, PakIndex}; use anyhow::Context; pub struct FieldMapInfo { @@ -18,7 +17,7 @@ pub struct FieldMapInfo { impl FieldMapInfo { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\fieldmap\info\fm_info.xml", |d| { + utils::read_xml(pak_index, r"\saves\fieldmap\info\fm_info.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/field_map/fm_info2.rs b/data-prepper/src/ryza3/data/field_map/fm_info2.rs similarity index 91% rename from data-prepper/src/extract/ryza3/data/field_map/fm_info2.rs rename to data-prepper/src/ryza3/data/field_map/fm_info2.rs index c4ea0c0..0f8faf5 100644 --- a/data-prepper/src/extract/ryza3/data/field_map/fm_info2.rs +++ b/data-prepper/src/ryza3/data/field_map/fm_info2.rs @@ -1,5 +1,4 @@ -use crate::extract::util::{self, ElementReader}; -use crate::utils::PakIndex; +use crate::utils::{self, ElementReader, PakIndex}; use anyhow::Context; pub struct FieldMapInfo2 { @@ -16,7 +15,7 @@ pub struct FieldMapInfo2 { impl FieldMapInfo2 { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { // NOTE: reading as shift_jis - util::read_xml_shift_jis(pak_index, r"\saves\fieldmap\info\fm_info2.xml", |d| { + utils::read_xml_shift_jis(pak_index, r"\saves\fieldmap\info\fm_info2.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/field_map/mod.rs b/data-prepper/src/ryza3/data/field_map/mod.rs similarity index 98% rename from data-prepper/src/extract/ryza3/data/field_map/mod.rs rename to data-prepper/src/ryza3/data/field_map/mod.rs index ed38d50..b9ec517 100644 --- a/data-prepper/src/extract/ryza3/data/field_map/mod.rs +++ b/data-prepper/src/ryza3/data/field_map/mod.rs @@ -1,4 +1,4 @@ -use crate::extract::ryza3::data::strings_table::StringsTable; +use crate::ryza3::data::strings_table::StringsTable; use crate::utils::PakIndex; use serde::Serialize; use std::collections::BTreeMap; diff --git a/data-prepper/src/extract/ryza3/data/field_map/region_maps.rs b/data-prepper/src/ryza3/data/field_map/region_maps.rs similarity index 93% rename from data-prepper/src/extract/ryza3/data/field_map/region_maps.rs rename to data-prepper/src/ryza3/data/field_map/region_maps.rs index 36b1230..4720b04 100644 --- a/data-prepper/src/extract/ryza3/data/field_map/region_maps.rs +++ b/data-prepper/src/ryza3/data/field_map/region_maps.rs @@ -1,5 +1,4 @@ -use crate::extract::util::{self, ElementReader}; -use crate::utils::PakIndex; +use crate::utils::{self, ElementReader, PakIndex}; use anyhow::Context; pub struct RegionMap { @@ -12,7 +11,7 @@ pub struct RegionMap { impl RegionMap { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml( + utils::read_xml( pak_index, r"\saves\ui_cmn\a24_map\uil_a24_overall_map.xml", Self::read_from_doc, diff --git a/data-prepper/src/extract/ryza3/data/item_categories/mod.rs b/data-prepper/src/ryza3/data/item_categories/mod.rs similarity index 94% rename from data-prepper/src/extract/ryza3/data/item_categories/mod.rs rename to data-prepper/src/ryza3/data/item_categories/mod.rs index 32a79e9..50aee5d 100644 --- a/data-prepper/src/extract/ryza3/data/item_categories/mod.rs +++ b/data-prepper/src/ryza3/data/item_categories/mod.rs @@ -4,7 +4,7 @@ use anyhow::Context; use serde::Serialize; use typescript_type_def::TypeDef; -use crate::extract::ryza3::executable::Ryza3ExecutableData; +use crate::ryza3::executable::Ryza3ExecutableData; use super::strings_table::StringsTable; diff --git a/data-prepper/src/extract/ryza3/data/item_effects/item_effect.rs b/data-prepper/src/ryza3/data/item_effects/item_effect.rs similarity index 93% rename from data-prepper/src/extract/ryza3/data/item_effects/item_effect.rs rename to data-prepper/src/ryza3/data/item_effects/item_effect.rs index 3436b94..041b38f 100644 --- a/data-prepper/src/extract/ryza3/data/item_effects/item_effect.rs +++ b/data-prepper/src/ryza3/data/item_effects/item_effect.rs @@ -1,10 +1,7 @@ use anyhow::Context; use roxmltree::Node; -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub struct ItemEffect { pub name_id: Option, @@ -23,7 +20,7 @@ pub struct ItemEffect { impl ItemEffect { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\item\item_effect.xml", |d| { + utils::read_xml(pak_index, r"\saves\item\item_effect.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/item_effects/mod.rs b/data-prepper/src/ryza3/data/item_effects/mod.rs similarity index 98% rename from data-prepper/src/extract/ryza3/data/item_effects/mod.rs rename to data-prepper/src/ryza3/data/item_effects/mod.rs index 11af609..dbd1400 100644 --- a/data-prepper/src/extract/ryza3/data/item_effects/mod.rs +++ b/data-prepper/src/ryza3/data/item_effects/mod.rs @@ -7,7 +7,7 @@ use serde::Serialize; use tracing::debug; use typescript_type_def::TypeDef; -use crate::{extract::ryza3::executable::Ryza3ExecutableData, utils::PakIndex}; +use crate::{ryza3::executable::Ryza3ExecutableData, utils::PakIndex}; use super::strings_table::StringsTable; diff --git a/data-prepper/src/extract/ryza3/data/items/item_data.rs b/data-prepper/src/ryza3/data/items/item_data.rs similarity index 96% rename from data-prepper/src/extract/ryza3/data/items/item_data.rs rename to data-prepper/src/ryza3/data/items/item_data.rs index 975b43a..899f185 100644 --- a/data-prepper/src/extract/ryza3/data/items/item_data.rs +++ b/data-prepper/src/ryza3/data/items/item_data.rs @@ -1,9 +1,6 @@ use tracing::trace; -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub struct ItemData { pub name_id: Option, @@ -48,7 +45,7 @@ pub struct ItemData { impl ItemData { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\item\itemdata.xml", |d| { + utils::read_xml(pak_index, r"\saves\item\itemdata.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/items/library_item.rs b/data-prepper/src/ryza3/data/items/library_item.rs similarity index 86% rename from data-prepper/src/extract/ryza3/data/items/library_item.rs rename to data-prepper/src/ryza3/data/items/library_item.rs index bc94289..c49e11d 100644 --- a/data-prepper/src/extract/ryza3/data/items/library_item.rs +++ b/data-prepper/src/ryza3/data/items/library_item.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub struct LibraryItem { pub item_tag: String, @@ -12,7 +9,7 @@ pub struct LibraryItem { impl LibraryItem { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\library\libraryitem.xml", |d| { + utils::read_xml(pak_index, r"\saves\library\libraryitem.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/items/mod.rs b/data-prepper/src/ryza3/data/items/mod.rs similarity index 100% rename from data-prepper/src/extract/ryza3/data/items/mod.rs rename to data-prepper/src/ryza3/data/items/mod.rs diff --git a/data-prepper/src/extract/ryza3/data/mod.rs b/data-prepper/src/ryza3/data/mod.rs similarity index 100% rename from data-prepper/src/extract/ryza3/data/mod.rs rename to data-prepper/src/ryza3/data/mod.rs diff --git a/data-prepper/src/extract/ryza3/data/recipes/itemrecipedata.rs b/data-prepper/src/ryza3/data/recipes/itemrecipedata.rs similarity index 95% rename from data-prepper/src/extract/ryza3/data/recipes/itemrecipedata.rs rename to data-prepper/src/ryza3/data/recipes/itemrecipedata.rs index 2a2b03f..7bcbd51 100644 --- a/data-prepper/src/extract/ryza3/data/recipes/itemrecipedata.rs +++ b/data-prepper/src/ryza3/data/recipes/itemrecipedata.rs @@ -2,10 +2,7 @@ use anyhow::{bail, Context}; -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub enum ItemRecipeData { Header(RecipeHeader), @@ -86,7 +83,7 @@ impl IngredientData { impl ItemRecipeData { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\saves\item\itemrecipedata.xml", |d| { + utils::read_xml(pak_index, r"\saves\item\itemrecipedata.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/recipes/mixfielddata.rs b/data-prepper/src/ryza3/data/recipes/mixfielddata.rs similarity index 97% rename from data-prepper/src/extract/ryza3/data/recipes/mixfielddata.rs rename to data-prepper/src/ryza3/data/recipes/mixfielddata.rs index c8114f1..9751876 100644 --- a/data-prepper/src/extract/ryza3/data/recipes/mixfielddata.rs +++ b/data-prepper/src/ryza3/data/recipes/mixfielddata.rs @@ -2,10 +2,7 @@ use std::collections::HashMap; use anyhow::{bail, Context}; -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; /// A hash map of `tag` to `ExtendedFieldData`. pub struct ExtendedFieldData(pub HashMap>); @@ -74,7 +71,7 @@ pub struct RingParam { impl ExtendedFieldData { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result { - util::read_xml(pak_index, r"\saves\mix\mixfielddata.xml", |d| { + utils::read_xml(pak_index, r"\saves\mix\mixfielddata.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/ryza3/data/recipes/mod.rs b/data-prepper/src/ryza3/data/recipes/mod.rs similarity index 100% rename from data-prepper/src/extract/ryza3/data/recipes/mod.rs rename to data-prepper/src/ryza3/data/recipes/mod.rs diff --git a/data-prepper/src/extract/ryza3/data/strings_table.rs b/data-prepper/src/ryza3/data/strings_table.rs similarity index 92% rename from data-prepper/src/extract/ryza3/data/strings_table.rs rename to data-prepper/src/ryza3/data/strings_table.rs index 2ecfce9..3adb2d2 100644 --- a/data-prepper/src/extract/ryza3/data/strings_table.rs +++ b/data-prepper/src/ryza3/data/strings_table.rs @@ -2,10 +2,7 @@ use std::collections::HashMap; use anyhow::Context; -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; pub struct StringsTable { pub id_lookup: HashMap, @@ -14,7 +11,7 @@ pub struct StringsTable { impl StringsTable { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result { - util::read_xml( + utils::read_xml( pak_index, r"\saves\text_en\strcombineall.xml", Self::read_from_doc, diff --git a/data-prepper/src/extract/ryza3/executable/mod.rs b/data-prepper/src/ryza3/executable/mod.rs similarity index 100% rename from data-prepper/src/extract/ryza3/executable/mod.rs rename to data-prepper/src/ryza3/executable/mod.rs diff --git a/data-prepper/src/extract_images/extract_maps.rs b/data-prepper/src/ryza3/extract_images/extract_maps.rs similarity index 97% rename from data-prepper/src/extract_images/extract_maps.rs rename to data-prepper/src/ryza3/extract_images/extract_maps.rs index 11a39ef..706f82c 100644 --- a/data-prepper/src/extract_images/extract_maps.rs +++ b/data-prepper/src/ryza3/extract_images/extract_maps.rs @@ -6,10 +6,7 @@ use serde::Serialize; use tracing::{debug, info}; use typescript_type_def::TypeDef; -use crate::{ - extract_images::rgba8_image::Rgba8Image, - utils::{match_pattern_str, PakIndex}, -}; +use crate::utils::{images::rgba8_image::Rgba8Image, match_pattern_str, PakIndex}; const MAP_PATTERN_MINIMAP: &str = r"\data\x64\res_cmn\ui\neo\neo_minimap_ta_*.g1t"; const MAP_PATTERN_FULL: &str = r"\data\x64\res_cmn\ui\neo\neo_a24_minimap_all_*.g1t"; @@ -88,11 +85,8 @@ pub fn extract_map_textures( }; // write to disk - super::super::extract::write_data_to_file( - &image_output_folder.join("map_data.json"), - &map_info_list, - ) - .context("write map_data.json")?; + crate::extract::write_data_to_file(&image_output_folder.join("map_data.json"), &map_info_list) + .context("write map_data.json")?; Ok(()) } diff --git a/data-prepper/src/extract_images/mod.rs b/data-prepper/src/ryza3/extract_images/mod.rs similarity index 96% rename from data-prepper/src/extract_images/mod.rs rename to data-prepper/src/ryza3/extract_images/mod.rs index 1e3df51..f2b8c2b 100644 --- a/data-prepper/src/extract_images/mod.rs +++ b/data-prepper/src/ryza3/extract_images/mod.rs @@ -1,18 +1,16 @@ -mod extract_maps; -mod rgba8_image; -mod texture_atlas; +pub mod extract_maps; use std::path::{Path, PathBuf}; use std::str::FromStr; use anyhow::{bail, Context}; use argh::FromArgs; -pub use texture_atlas::UniformTextureAtlasInfo; use tracing::{debug, info}; -use crate::{ - extract_images::{rgba8_image::Rgba8Image, texture_atlas::UniformTextureAtlas}, - utils::{extract_game_version, game_slug, match_pattern, PakIndex}, +use crate::utils::{ + extract_game_version, game_slug, + images::{rgba8_image::Rgba8Image, texture_atlas::UniformTextureAtlas}, + match_pattern, PakIndex, }; pub use extract_maps::MapInfoList; @@ -203,7 +201,7 @@ impl Args { // save the texture atlas info let atlas_directory = output_directory.join("texture-atlasses"); std::fs::create_dir_all(&atlas_directory).context("create atlas directory")?; - super::extract::write_data_to_file( + crate::extract::write_data_to_file( &atlas_directory.join(format!("{subdirectory}.json")), &texture_atlas.create_info(), ) diff --git a/data-prepper/src/extract/ryza3/mod.rs b/data-prepper/src/ryza3/mod.rs similarity index 98% rename from data-prepper/src/extract/ryza3/mod.rs rename to data-prepper/src/ryza3/mod.rs index 23d5756..3182fd8 100644 --- a/data-prepper/src/extract/ryza3/mod.rs +++ b/data-prepper/src/ryza3/mod.rs @@ -1,5 +1,6 @@ pub mod data; pub mod executable; +pub mod extract_images; use std::path::Path; diff --git a/data-prepper/src/extract/sophie/data/doll_making/dollmake_change.rs b/data-prepper/src/sophie/data/doll_making/dollmake_change.rs similarity index 94% rename from data-prepper/src/extract/sophie/data/doll_making/dollmake_change.rs rename to data-prepper/src/sophie/data/doll_making/dollmake_change.rs index ba8df6a..78787ac 100644 --- a/data-prepper/src/extract/sophie/data/doll_making/dollmake_change.rs +++ b/data-prepper/src/sophie/data/doll_making/dollmake_change.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; /// `dollmake_change` from `r\Saves\dollmake\dollmake_change.xml` pub struct DollmakeChange { @@ -33,7 +30,7 @@ pub struct DollmakeChange { impl DollmakeChange { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\Saves\dollmake\dollmake_change.xml", |d| { + utils::read_xml(pak_index, r"\Saves\dollmake\dollmake_change.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/sophie/data/doll_making/mod.rs b/data-prepper/src/sophie/data/doll_making/mod.rs similarity index 100% rename from data-prepper/src/extract/sophie/data/doll_making/mod.rs rename to data-prepper/src/sophie/data/doll_making/mod.rs diff --git a/data-prepper/src/extract/sophie/data/items/item_data.rs b/data-prepper/src/sophie/data/items/item_data.rs similarity index 96% rename from data-prepper/src/extract/sophie/data/items/item_data.rs rename to data-prepper/src/sophie/data/items/item_data.rs index 022b11b..341a926 100644 --- a/data-prepper/src/extract/sophie/data/items/item_data.rs +++ b/data-prepper/src/sophie/data/items/item_data.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; /// `itemData` from `\Saves\item\itemData.xml` pub struct ItemData { @@ -41,7 +38,7 @@ pub struct ItemData { impl ItemData { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\Saves\item\itemData.xml", |d| { + utils::read_xml(pak_index, r"\Saves\item\itemData.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/sophie/data/items/mod.rs b/data-prepper/src/sophie/data/items/mod.rs similarity index 100% rename from data-prepper/src/extract/sophie/data/items/mod.rs rename to data-prepper/src/sophie/data/items/mod.rs diff --git a/data-prepper/src/extract/sophie/data/mod.rs b/data-prepper/src/sophie/data/mod.rs similarity index 100% rename from data-prepper/src/extract/sophie/data/mod.rs rename to data-prepper/src/sophie/data/mod.rs diff --git a/data-prepper/src/extract/sophie/data/presents/mod.rs b/data-prepper/src/sophie/data/presents/mod.rs similarity index 100% rename from data-prepper/src/extract/sophie/data/presents/mod.rs rename to data-prepper/src/sophie/data/presents/mod.rs diff --git a/data-prepper/src/extract/sophie/data/presents/point.rs b/data-prepper/src/sophie/data/presents/point.rs similarity index 90% rename from data-prepper/src/extract/sophie/data/presents/point.rs rename to data-prepper/src/sophie/data/presents/point.rs index 892916e..b2b2b44 100644 --- a/data-prepper/src/extract/sophie/data/presents/point.rs +++ b/data-prepper/src/sophie/data/presents/point.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; /// `point` from `\Saves\Friend\point.xml` pub struct Point { @@ -15,7 +12,7 @@ pub struct Point { impl Point { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\Saves\Friend\point.xml", |d| { + utils::read_xml(pak_index, r"\Saves\Friend\point.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/sophie/data/presents/present_base.rs b/data-prepper/src/sophie/data/presents/present_base.rs similarity index 91% rename from data-prepper/src/extract/sophie/data/presents/present_base.rs rename to data-prepper/src/sophie/data/presents/present_base.rs index a91749c..55bf633 100644 --- a/data-prepper/src/extract/sophie/data/presents/present_base.rs +++ b/data-prepper/src/sophie/data/presents/present_base.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; /// `present_base` from `\Saves\Friend\present_base.xml` pub struct PresentBase { @@ -20,7 +17,7 @@ pub struct PresentBase { impl PresentBase { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\Saves\Friend\present_base.xml", |d| { + utils::read_xml(pak_index, r"\Saves\Friend\present_base.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/sophie/data/presents/present_ex.rs b/data-prepper/src/sophie/data/presents/present_ex.rs similarity index 86% rename from data-prepper/src/extract/sophie/data/presents/present_ex.rs rename to data-prepper/src/sophie/data/presents/present_ex.rs index 0e7cd05..f81911b 100644 --- a/data-prepper/src/extract/sophie/data/presents/present_ex.rs +++ b/data-prepper/src/sophie/data/presents/present_ex.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; /// `present_ex` from `\Saves\Friend\present_ex.xml` pub struct PresentEx { @@ -12,7 +9,7 @@ pub struct PresentEx { impl PresentEx { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\Saves\Friend\present_ex.xml", |d| { + utils::read_xml(pak_index, r"\Saves\Friend\present_ex.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/sophie/data/rumors/mod.rs b/data-prepper/src/sophie/data/rumors/mod.rs similarity index 100% rename from data-prepper/src/extract/sophie/data/rumors/mod.rs rename to data-prepper/src/sophie/data/rumors/mod.rs diff --git a/data-prepper/src/extract/sophie/data/rumors/rumor.rs b/data-prepper/src/sophie/data/rumors/rumor.rs similarity index 95% rename from data-prepper/src/extract/sophie/data/rumors/rumor.rs rename to data-prepper/src/sophie/data/rumors/rumor.rs index dd11299..5053ae0 100644 --- a/data-prepper/src/extract/sophie/data/rumors/rumor.rs +++ b/data-prepper/src/sophie/data/rumors/rumor.rs @@ -1,7 +1,4 @@ -use crate::{ - extract::util::{self, ElementReader}, - utils::PakIndex, -}; +use crate::utils::{self, ElementReader, PakIndex}; /// `rumor` from `\Saves\rumor\rumor.xml` pub struct Rumor { @@ -32,7 +29,7 @@ pub struct Rumor { impl Rumor { pub fn read(pak_index: &mut PakIndex) -> anyhow::Result> { - util::read_xml(pak_index, r"\Saves\rumor\rumor.xml", |d| { + utils::read_xml(pak_index, r"\Saves\rumor\rumor.xml", |d| { Self::read_from_doc(d) }) } diff --git a/data-prepper/src/extract/sophie/mod.rs b/data-prepper/src/sophie/mod.rs similarity index 100% rename from data-prepper/src/extract/sophie/mod.rs rename to data-prepper/src/sophie/mod.rs diff --git a/data-prepper/src/typedefs/mod.rs b/data-prepper/src/typedefs/mod.rs index 50cb85f..9972b4f 100644 --- a/data-prepper/src/typedefs/mod.rs +++ b/data-prepper/src/typedefs/mod.rs @@ -25,22 +25,22 @@ impl Args { debug!(?output_folder); debug!("Generating typedefs"); - gen_typedefs::( + gen_typedefs::( &output_folder, &format!("{}.d.ts", game_slug(GameVersion::A17)), ) .context("generate typedefs for sophie")?; - gen_typedefs::( + gen_typedefs::( &output_folder, &format!("{}.d.ts", game_slug(GameVersion::A24)), ) .context("generate typedefs for ryza3")?; - gen_typedefs::( + gen_typedefs::( &output_folder, "texture_atlas.d.ts", ) .context("generate texture atlas typedefs")?; - gen_typedefs::(&output_folder, "map_data.d.ts") + gen_typedefs::(&output_folder, "map_data.d.ts") .context("generate map data typedefs")?; info!("Wrote all typedefs to {:?}", output_folder); diff --git a/data-prepper/src/utils/images/mod.rs b/data-prepper/src/utils/images/mod.rs new file mode 100644 index 0000000..60c9ed7 --- /dev/null +++ b/data-prepper/src/utils/images/mod.rs @@ -0,0 +1,2 @@ +pub mod rgba8_image; +pub mod texture_atlas; diff --git a/data-prepper/src/extract_images/rgba8_image.rs b/data-prepper/src/utils/images/rgba8_image.rs similarity index 100% rename from data-prepper/src/extract_images/rgba8_image.rs rename to data-prepper/src/utils/images/rgba8_image.rs diff --git a/data-prepper/src/extract_images/texture_atlas.rs b/data-prepper/src/utils/images/texture_atlas.rs similarity index 100% rename from data-prepper/src/extract_images/texture_atlas.rs rename to data-prepper/src/utils/images/texture_atlas.rs diff --git a/data-prepper/src/utils/mod.rs b/data-prepper/src/utils/mod.rs index a4f5ac5..82e4de9 100644 --- a/data-prepper/src/utils/mod.rs +++ b/data-prepper/src/utils/mod.rs @@ -1,4 +1,8 @@ +pub mod images; mod pak_index; +mod xml_reader; + +pub use xml_reader::{read_xml, read_xml_shift_jis, ElementReader}; use std::{path::Path, str::FromStr}; diff --git a/data-prepper/src/extract/util/xml_reader.rs b/data-prepper/src/utils/xml_reader.rs similarity index 100% rename from data-prepper/src/extract/util/xml_reader.rs rename to data-prepper/src/utils/xml_reader.rs