fixed structure loading error. added change tracking to structure editing. save all changes button now saves structures
This commit is contained in:
parent
b6a2fbb82c
commit
26d0b1627b
|
@ -613,6 +613,19 @@ pub fn edit_window_ui(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for each in &mut shared_ui_state.structures {
|
||||||
|
if each.has_changed_since_last_save {
|
||||||
|
let handle = each.id.clone();
|
||||||
|
let path = each.path.clone();
|
||||||
|
let asset = structure_assets.get(handle);
|
||||||
|
if asset.is_some() {
|
||||||
|
let result = crate::vvlib::s_structure_asset::serialization::structures::write_latest_version(&path, asset.unwrap());
|
||||||
|
if result {
|
||||||
|
each.has_changed_since_last_save = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -413,6 +413,34 @@ impl StringTree {
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
pub fn depth_of(&self, subject: &String) -> Option<i32> {
|
||||||
|
fn recursive_depth_search(el: &StringTreeElement, subject: &String, depth: i32) -> i32 {
|
||||||
|
match el {
|
||||||
|
StringTreeElement::None => {}
|
||||||
|
StringTreeElement::Element(name, children) => {
|
||||||
|
for each in children.as_ref() {
|
||||||
|
if subject == name {
|
||||||
|
return depth;
|
||||||
|
} else {
|
||||||
|
let res = recursive_depth_search(each, subject, depth + 1);
|
||||||
|
if res != -1 {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
for each in &self.root {
|
||||||
|
let res = recursive_depth_search(each, subject, 0);
|
||||||
|
if res != -1 {
|
||||||
|
return Some(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -482,7 +482,8 @@ pub mod serialization {
|
||||||
data += NEWLINE;
|
data += NEWLINE;
|
||||||
let mut to_process = Vec::<String>::new();
|
let mut to_process = Vec::<String>::new();
|
||||||
for each in &asset.layout.root {
|
for each in &asset.layout.root {
|
||||||
if let Some(name) = each.name_of() {
|
to_process.push(each.name_of().unwrap().clone());
|
||||||
|
/*if let Some(name) = each.name_of() {
|
||||||
//
|
//
|
||||||
if !is_first {
|
if !is_first {
|
||||||
data += "|";
|
data += "|";
|
||||||
|
@ -492,7 +493,7 @@ pub mod serialization {
|
||||||
data += name.clone().as_str();
|
data += name.clone().as_str();
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
}
|
}*/
|
||||||
if let Some(children) = each.children() {
|
if let Some(children) = each.children() {
|
||||||
for each in children {
|
for each in children {
|
||||||
to_process.push(each);
|
to_process.push(each);
|
||||||
|
@ -515,12 +516,11 @@ pub mod serialization {
|
||||||
}
|
}
|
||||||
// ^ HELPER FUNCTION
|
// ^ HELPER FUNCTION
|
||||||
while !to_process.is_empty() {
|
while !to_process.is_empty() {
|
||||||
if let Some(next) = to_process.pop() {
|
let next = to_process.remove(0);
|
||||||
save_child(&next, &asset.layout, &mut data);
|
save_child(&next, &asset.layout, &mut data);
|
||||||
if let Some(children) = asset.layout.children_of(&next) {
|
if let Some(children) = asset.layout.children_of(&next) {
|
||||||
for each in children {
|
for each in children {
|
||||||
to_process.push(each);
|
to_process.push(each);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue