From a4b1206cb0f8b2c6a4dafecfc0e6c90d3897db1b Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 8 Apr 2024 21:31:12 +0200 Subject: [PATCH] Adds more parsing --- src/parser.rs | 6 +- src/skills_structures.rs | 116 +++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 70 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 2e2ee1b..e269493 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -3,7 +3,7 @@ use std::{fs, path::Path}; use crate::{ loader::LoadError, - skills_structures::{Renderable, Section, Skill, SkillList, SkillTypes, SubSection, SubSkill}, + skills_structures::{Section, Skill, SkillList, SkillTypes, SubSection, SubSkill}, }; /// Defines a parser, able to extract a character sheet @@ -55,7 +55,7 @@ impl Parser for SkillList { } let list_sect = globlist.make_skilllist()?; // Make a skillist with the given vec - let ls = SkillList::from_vec(&path.to_string(), 0, 0, Some(list_sect)); + let ls = SkillList::from_vec(&path.to_string(), 0, 0, list_sect); // let ls = SkillList::with_config(&ConfigList::new(path.to_string(), 0, 0, global_id)); // ls.populate(globlist); Ok(ls) @@ -159,7 +159,7 @@ impl ListId { return Err(LoadError::WrongHierarchy); } *index += 1; - let sec = SubSkill::from_vec::(name, id, global_id, None); + let sec = SubSkill::from_vec(name, id, global_id); Ok(sec) } diff --git a/src/skills_structures.rs b/src/skills_structures.rs index e656deb..12bfde9 100644 --- a/src/skills_structures.rs +++ b/src/skills_structures.rs @@ -35,11 +35,6 @@ impl ConfigList { } } -// trait NewTrait { -// /// Creates a new [`ConfigList`]. -// fn new(name: String, id: usize, global_id: usize, capacity: usize) -> Self; -// } - /// The global list of skills pub struct SkillList { /// The list of all section in this skilllist @@ -56,6 +51,20 @@ impl SkillList { data: DataCell::new(&cfg.name, cfg.id, cfg.global_id), } } + + pub fn from_vec(name: &str, id: usize, global_id: usize, list_sect: Vec
) -> SkillList { + Self { + list: list_sect, + data: DataCell::new(name, id, global_id), + } + } +} + +/// A node, with a level instead of a hierarchy +pub struct Node { + list: Option>, + data: DataCell, + level: SkillTypes, } /// A section, marked by @ @@ -64,12 +73,16 @@ pub struct Section { pub list: Vec, /// The name of the cell data: DataCell, - // /// The identifier number of the cell - // id: usize, - // /// The global identifier of the cell - // global_id: usize, - // /// The various fields needed to transform a skill Section html - // vars: HashReplace, +} +impl Section { + pub(crate) fn from_vec( + name: &str, + id: usize, + global_id: usize, + list_subsection: Option>, + ) -> Section { + todo!() + } } /// A subsection, marked by + @@ -78,12 +91,16 @@ pub struct SubSection { pub list: Vec, /// The name of the cell data: DataCell, - // /// The identifier number of the cell - // id: usize, - // /// The global identifier of the cell - // global_id: usize, - // /// The various fields needed to transform a subsection into html - // vars: HashReplace, +} +impl SubSection { + pub(crate) fn from_vec( + name: &str, + id: usize, + global_id: usize, + list_skills: Option>, + ) -> SubSection { + todo!() + } } /// A skill, marked by = @@ -92,20 +109,27 @@ pub struct Skill { pub list: Vec, /// The name of the cell data: DataCell, - // /// The identifier number of the cell - // id: usize, - // /// The global identifier of the cell - // global_id: usize, - // /// The various fields needed to transform a skill into html - // vars: HashMap, +} +impl Skill { + pub(crate) fn from_vec( + name: &str, + id: usize, + global_id: usize, + list_subskills: Option>, + ) -> Skill { + todo!() + } } /// A subskill, marked by - pub struct SubSkill { /// The name of the cell data: DataCell, - // /// The various fields needed to transform a subskill into html - // vars: HashMap, +} +impl SubSkill { + pub(crate) fn from_vec(name: &str, id: usize, global_id: usize) -> SubSkill { + todo!() + } } /// The data of a cell @@ -187,8 +211,6 @@ pub(crate) trait Renderable { fn get_mut_data(&mut self) -> &DataCell; /// Create a new renderable fn new(name: &str, id: usize, global_id: usize, size_hint: usize) -> Self; - /// Create a renderable with a given vector - fn from_vec(name: &str, id: usize, global_id: usize, data: Option) -> Self; /// Get the vars hashmap fn get_vars(&self) -> HashReplace; // /// Render the element and all sub elements @@ -229,14 +251,6 @@ impl Renderable for Section { data: DataCell::new(name, id, global_id), } } - - fn from_vec(name: &str, id: usize, global_id: usize, data: Option) -> Self { - let _ = id; - let _ = data; - let _ = global_id; - let _ = name; - todo!() - } } impl Renderable for SkillList { @@ -256,14 +270,6 @@ impl Renderable for SkillList { fn get_vars(&self) -> HashReplace { todo!() } - - fn from_vec(name: &str, id: usize, global_id: usize, data: Option) -> Self { - let _ = data; - let _ = global_id; - let _ = id; - let _ = name; - todo!() - } } impl Renderable for SubSection { @@ -279,14 +285,6 @@ impl Renderable for SubSection { fn get_vars(&self) -> HashReplace { todo!() } - - fn from_vec(name: &str, id: usize, global_id: usize, data: Option) -> Self { - let _ = data; - let _ = global_id; - let _ = id; - let _ = name; - todo!() - } } impl Renderable for Skill { fn get_data(&self) -> &DataCell { @@ -304,14 +302,6 @@ impl Renderable for Skill { fn get_vars(&self) -> HashReplace { todo!() } - - fn from_vec(name: &str, id: usize, global_id: usize, data: Option) -> Self { - let _ = id; - let _ = global_id; - let _ = data; - let _ = name; - todo!() - } } impl Renderable for SubSkill { fn get_data(&self) -> &DataCell { @@ -329,14 +319,6 @@ impl Renderable for SubSkill { fn get_vars(&self) -> HashReplace { todo!() } - - fn from_vec(name: &str, id: usize, global_id: usize, data: Option) -> Self { - let _ = id; - let _ = global_id; - let _ = data; - let _ = name; - todo!() - } } /// A parsable type for dispatch