feat: include which occurence of a group a file is from
This commit is contained in:
parent
f745ef8288
commit
17d28d3774
|
@ -1,4 +1,5 @@
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
|
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
|
||||||
|
|
||||||
use flate2::read::DeflateDecoder;
|
use flate2::read::DeflateDecoder;
|
||||||
|
@ -90,13 +91,18 @@ impl<R: Read + Seek> TtmpExtractor<R> {
|
||||||
pub fn all_files_sorted(&self) -> Vec<ModFile> {
|
pub fn all_files_sorted(&self) -> Vec<ModFile> {
|
||||||
let mut all_files = Vec::new();
|
let mut all_files = Vec::new();
|
||||||
|
|
||||||
|
let mut seen_groups: HashMap<&str, usize> = HashMap::new();
|
||||||
if let Some(pages) = &self.manifest.mod_pack_pages {
|
if let Some(pages) = &self.manifest.mod_pack_pages {
|
||||||
for page in pages {
|
for page in pages {
|
||||||
for group in &page.mod_groups {
|
for group in &page.mod_groups {
|
||||||
|
let seen = seen_groups.entry(&group.group_name).or_default();
|
||||||
|
*seen += 1;
|
||||||
|
|
||||||
for option in &group.option_list {
|
for option in &group.option_list {
|
||||||
for file in &option.mods_jsons {
|
for file in &option.mods_jsons {
|
||||||
all_files.push(ModFile {
|
all_files.push(ModFile {
|
||||||
group: Some(&*option.group_name),
|
group: Some(&*option.group_name),
|
||||||
|
group_occurence: *seen,
|
||||||
option: Some(&*option.name),
|
option: Some(&*option.name),
|
||||||
file,
|
file,
|
||||||
});
|
});
|
||||||
|
@ -109,6 +115,7 @@ impl<R: Read + Seek> TtmpExtractor<R> {
|
||||||
if let Some(list) = &self.manifest.simple_mods_list {
|
if let Some(list) = &self.manifest.simple_mods_list {
|
||||||
all_files.extend(list.iter().map(|file| ModFile {
|
all_files.extend(list.iter().map(|file| ModFile {
|
||||||
group: None,
|
group: None,
|
||||||
|
group_occurence: 0,
|
||||||
option: None,
|
option: None,
|
||||||
file,
|
file,
|
||||||
}));
|
}));
|
||||||
|
@ -414,6 +421,7 @@ impl<R: Read> TtmpExtractor<R> {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ModFile<'a> {
|
pub struct ModFile<'a> {
|
||||||
pub group: Option<&'a str>,
|
pub group: Option<&'a str>,
|
||||||
|
pub group_occurence: usize,
|
||||||
pub option: Option<&'a str>,
|
pub option: Option<&'a str>,
|
||||||
pub file: &'a SimpleMod,
|
pub file: &'a SimpleMod,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue