restructured UI details file to extrapolate out editing the tree from the primary act of selecting objects within the structure tree
This commit is contained in:
parent
2f8afb8403
commit
8c7fba2a04
|
@ -496,7 +496,46 @@ pub fn edit_window_ui(
|
|||
}
|
||||
}
|
||||
});
|
||||
show_editable_stringtree(ui, &mut shared_ui_state);
|
||||
ui.collapsing("Model Structure", |ui| {
|
||||
ui.vertical(|ui| {
|
||||
if shared_ui_state.selected_structure_element != "" {
|
||||
if ui.button("...").clicked() {
|
||||
let selection = shared_ui_state.selected_structure_element.clone();
|
||||
let mut should_close = false;
|
||||
if let PopupWindowMode::EditStructureElement(val, _) =
|
||||
&shared_ui_state.popup
|
||||
{
|
||||
if val == &selection {
|
||||
should_close = true;
|
||||
}
|
||||
}
|
||||
if should_close {
|
||||
shared_ui_state.popup = PopupWindowMode::None;
|
||||
} else {
|
||||
shared_ui_state.popup = PopupWindowMode::EditStructureElement(
|
||||
shared_ui_state.selected_structure_element.clone(),
|
||||
shared_ui_state.selected_structure_element.clone(),
|
||||
)
|
||||
}
|
||||
ui.label(
|
||||
"Tree Element Selection: ".to_owned()
|
||||
+ &shared_ui_state.selected_structure_element,
|
||||
);
|
||||
}
|
||||
if ui.button("deselect").clicked() {
|
||||
shared_ui_state.selected_structure_element = "".into();
|
||||
}
|
||||
ui.separator();
|
||||
}
|
||||
let mut string_selection = shared_ui_state.selected_structure_element.clone();
|
||||
show_stringtree_selector(
|
||||
ui,
|
||||
&mut shared_ui_state.structure,
|
||||
&mut string_selection,
|
||||
);
|
||||
shared_ui_state.selected_structure_element = string_selection;
|
||||
})
|
||||
});
|
||||
if ui.button("Save Any Changes").clicked() {
|
||||
for each in &mut shared_ui_state.meshes {
|
||||
if each.has_changed_since_last_save {
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::vvlib::s_identifier_validation;
|
|||
|
||||
use super::{
|
||||
s_editor_ui::{EditWindowUIState, PopupWindowMode},
|
||||
s_string_tree::StringTreeElement,
|
||||
s_string_tree::{StringTree, StringTreeElement},
|
||||
};
|
||||
|
||||
pub fn color_from(egui_color: Hsva) -> Color {
|
||||
|
@ -142,60 +142,27 @@ pub fn show_popup(state: &mut EditWindowUIState, contexts: &mut EguiContexts) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn show_editable_stringtree(ui: &mut egui::Ui, state: &mut EditWindowUIState) {
|
||||
let mut string_selected = state.selected_structure_element.clone();
|
||||
ui.collapsing("Model Structure", |ui| {
|
||||
ui.vertical(|ui| {
|
||||
if state.selected_structure_element != "" {
|
||||
ui.label("Tree Element Selection: ".to_owned() + &state.selected_structure_element);
|
||||
if ui.button("deselect").clicked() {
|
||||
state.selected_structure_element = "".into();
|
||||
}
|
||||
ui.separator();
|
||||
}
|
||||
for each in &state.structure.root {
|
||||
match each {
|
||||
super::s_string_tree::StringTreeElement::None => {}
|
||||
super::s_string_tree::StringTreeElement::Element(name, children) => {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(">".to_owned());
|
||||
//ui.label(name.clone());
|
||||
ui.radio_value(&mut string_selected, name.clone(), name.clone());
|
||||
let but = egui::Button::new("...");
|
||||
|
||||
if ui.add_enabled(true, but).clicked() {
|
||||
let mut should_close = false;
|
||||
if let PopupWindowMode::EditStructureElement(val, _) = &state.popup
|
||||
{
|
||||
if val == name {
|
||||
should_close = true;
|
||||
}
|
||||
}
|
||||
if should_close {
|
||||
state.popup = PopupWindowMode::None;
|
||||
} else {
|
||||
state.popup = PopupWindowMode::EditStructureElement(
|
||||
name.clone(),
|
||||
name.clone(),
|
||||
)
|
||||
}
|
||||
}
|
||||
});
|
||||
for each in children.as_ref() {
|
||||
show_child(ui, each, 1, &mut state.popup, &mut string_selected);
|
||||
}
|
||||
}
|
||||
pub fn show_stringtree_selector(ui: &mut egui::Ui, tree: &StringTree, selection: &mut String) {
|
||||
for each in &tree.root {
|
||||
match each {
|
||||
super::s_string_tree::StringTreeElement::None => {}
|
||||
super::s_string_tree::StringTreeElement::Element(name, children) => {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(">".to_owned());
|
||||
//ui.label(name.clone());
|
||||
ui.radio_value(selection, name.clone(), name.clone());
|
||||
});
|
||||
for each in children.as_ref() {
|
||||
show_child(ui, each, 1, selection);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
state.selected_structure_element = string_selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn show_child(
|
||||
ui: &mut egui::Ui,
|
||||
subject: &StringTreeElement,
|
||||
depth: usize,
|
||||
state: &mut PopupWindowMode,
|
||||
selection: &mut String,
|
||||
) {
|
||||
match subject {
|
||||
|
@ -212,9 +179,8 @@ pub fn show_child(
|
|||
prec = prec + ">";
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(prec);
|
||||
//ui.label(name.clone());
|
||||
ui.radio_value(selection, name.clone(), name.clone());
|
||||
if ui.button("...").clicked() {
|
||||
/* if ui.button("...").clicked() {
|
||||
let mut should_close = false;
|
||||
if let PopupWindowMode::EditStructureElement(val, _) = state {
|
||||
if val == name {
|
||||
|
@ -226,10 +192,10 @@ pub fn show_child(
|
|||
} else {
|
||||
*state = PopupWindowMode::EditStructureElement(name.clone(), name.clone())
|
||||
}
|
||||
}
|
||||
} */
|
||||
});
|
||||
for each in children.as_ref() {
|
||||
show_child(ui, each, depth + 1, state, selection);
|
||||
show_child(ui, each, depth + 1, selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
|
||||
use bevy::{
|
||||
asset::{Asset, AssetLoader, AsyncReadExt},
|
||||
reflect::TypePath,
|
||||
transform::components::Transform,
|
||||
utils::{hashbrown::HashMap, thiserror},
|
||||
};
|
||||
use s_string_tree::StringTree;
|
||||
use bevy::{asset::{Asset, AssetLoader, AsyncReadExt}, reflect::TypePath, transform::components::Transform, utils::{hashbrown::HashMap, thiserror}};
|
||||
|
||||
|
||||
use thiserror::Error;
|
||||
use crate::vvedit::s_string_tree;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Asset, TypePath)]
|
||||
pub struct StructureAsset {
|
||||
|
@ -36,10 +39,10 @@ pub mod serialization {
|
|||
tasks::block_on,
|
||||
};
|
||||
|
||||
use super::super::{StructureLoadError, StructureAsset};
|
||||
use super::super::{StructureAsset, StructureLoadError};
|
||||
|
||||
pub fn load_detect_version(bytes: Vec<u8>) -> Result<StructureAsset, StructureLoadError> {
|
||||
return Err(StructureLoadError::FileDataInvalid("".to_string()));
|
||||
pub fn load_detect_version(_bytes: Vec<u8>) -> Result<StructureAsset, StructureLoadError> {
|
||||
return Err(StructureLoadError::FileDataInvalid("".to_string()));
|
||||
}
|
||||
|
||||
pub fn write_latest_version(path: &String, asset: &StructureAsset) -> bool {
|
||||
|
@ -91,12 +94,13 @@ pub mod serialization {
|
|||
|
||||
pub mod version_1 {
|
||||
|
||||
use super::super::super::super::{StructureLoadError, StructureAsset};
|
||||
pub fn load(data: std::str::Lines<'_>) -> Result<StructureAsset, StructureLoadError> {
|
||||
|
||||
Err(StructureLoadError::FileDataInvalid("".to_string()))
|
||||
use super::super::super::super::{StructureAsset, StructureLoadError};
|
||||
pub fn load(
|
||||
_data: std::str::Lines<'_>,
|
||||
) -> Result<StructureAsset, StructureLoadError> {
|
||||
Err(StructureLoadError::FileDataInvalid("".to_string()))
|
||||
}
|
||||
pub fn save(asset: &StructureAsset) -> Option<Vec<u8>> {
|
||||
pub fn save(_asset: &StructureAsset) -> Option<Vec<u8>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -142,4 +146,4 @@ impl AssetLoader for StructureLoader {
|
|||
return serialization::meshes::load_detect_version(bytes);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue