pre-refactor-prep
This commit is contained in:
parent
53e85dbcd0
commit
f25596e3fb
|
@ -1,7 +1,7 @@
|
|||
use bevy::{
|
||||
app::{Startup, Update}, asset::{AssetServer, Assets, Handle}, ecs::{
|
||||
entity::Entity, event::EventWriter, query::With, system::{Commands, Query, Res, ResMut, Resource}
|
||||
}, hierarchy::BuildChildren, math::Vec3, pbr::{PointLight, PointLightBundle}, prelude::{default, SpatialBundle}, render::{camera::Camera, color::Color}, transform::{components::{GlobalTransform, Transform}, TransformBundle}, window::{PrimaryWindow, Window, WindowResolution}
|
||||
}, hierarchy::BuildChildren, math::Vec3, pbr::{PointLight, PointLightBundle}, prelude::{default, SpatialBundle}, render::{camera::Camera, color::Color, view::Visibility}, transform::{commands, components::{GlobalTransform, Transform}, TransformBundle}, window::{PrimaryWindow, Window, WindowResolution}
|
||||
};
|
||||
use bevy_egui::{
|
||||
egui::{self, color_picker, epaint::Hsva, Id, Pos2, Rect, ScrollArea},
|
||||
|
@ -52,7 +52,12 @@ pub struct EditWindowUIState {
|
|||
pub selected_structure: String,
|
||||
pub selected_grid: String,
|
||||
pub display_state: DisplayState,
|
||||
pub display_root: Entity,
|
||||
}
|
||||
// SELECTION REWORK:
|
||||
// hashmap keeps track of what the selected element was per-structure
|
||||
// Option (Enum(Grid OR Structure)) < early fail out support
|
||||
|
||||
impl Default for EditWindowUIState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
@ -64,7 +69,8 @@ impl Default for EditWindowUIState {
|
|||
selected_structure_element: "".into(),
|
||||
selected_structure: "".into(),
|
||||
selected_grid: "".into(),
|
||||
display_state: Default::default()
|
||||
display_root: Entity::PLACEHOLDER,
|
||||
display_state: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +80,7 @@ pub enum PopupWindowMode {
|
|||
None,
|
||||
EditStructureElement(String, String, String), // structure subject, rename from and to, otherwise second string is unused
|
||||
CreateStructureElement(String, String, String), // structure subject, node name, parent node
|
||||
LoadFile(String, i32, Vec<String>), // string is current selection from list discovered from disk, number is a timer for refreshing asset list via disk scan
|
||||
LoadFile(String, i32, Vec<String>), // string is current selection from list discovered from disk, number is a timer for refreshing asset list via disk scan, last is aforementioned list
|
||||
}
|
||||
impl PopupWindowMode {
|
||||
pub fn is_none(&self) -> bool {
|
||||
|
@ -199,12 +205,9 @@ pub fn register_edit_ui(
|
|||
}
|
||||
|
||||
pub fn startup_system_edit_ui(
|
||||
// formatting comment
|
||||
mut commands: Commands,
|
||||
mut shared_ui_state: ResMut<EditWindowUIState>,
|
||||
asset_server: ResMut<AssetServer>,
|
||||
//mut pairs: ResMut<MeshingOctTreePairs>,
|
||||
//mesh_assets: ResMut<Assets<Mesh>>,
|
||||
mut event_writer: EventWriter<StructureUpdateMessage>,
|
||||
) {
|
||||
spawn_camera(&mut commands);
|
||||
|
@ -212,16 +215,20 @@ pub fn startup_system_edit_ui(
|
|||
let handle = asset_server.load::<StructureAsset>(str);
|
||||
|
||||
//let id = OctTreeAsset::load(&mut pairs, asset_server.into(), mesh_assets, "test.vvg".into());
|
||||
let parent = commands
|
||||
let display_parent = commands
|
||||
.spawn(TransformBundle {
|
||||
local: Transform::from_scale(Vec3::splat(1f32)),
|
||||
..Default::default()
|
||||
})
|
||||
.id();
|
||||
let id = commands.spawn((SpatialBundle::from_transform(Transform::IDENTITY), StructureComponent {
|
||||
let id = commands.spawn((SpatialBundle {
|
||||
visibility: Visibility::Visible,
|
||||
..Default::default()
|
||||
}, StructureComponent {
|
||||
asset: handle.clone(),
|
||||
nodes: Default::default(),
|
||||
})).id();
|
||||
shared_ui_state.display_root = display_parent;
|
||||
let data = StructureEditData {
|
||||
path: str.into(),
|
||||
id: handle.clone(),
|
||||
|
@ -229,21 +236,7 @@ pub fn startup_system_edit_ui(
|
|||
edit_entity: id.clone(),
|
||||
};
|
||||
shared_ui_state.structures.push(data);
|
||||
/*let child = commands
|
||||
.spawn((
|
||||
PbrBundle {
|
||||
mesh: id.clone(),
|
||||
material: materials.add(Color::rgb(1., 1., 1.)),
|
||||
|
||||
..default()
|
||||
},
|
||||
OctAssetMarker {
|
||||
oct_handle: pairs.oct_handle_for(id, &mut oct_assets),
|
||||
},
|
||||
))
|
||||
.id();
|
||||
commands.entity(parent).add_child(child);*/
|
||||
commands.entity(parent).add_child(id.clone());
|
||||
commands.entity(display_parent).add_child(id.clone());
|
||||
event_writer.send(StructureUpdateMessage {
|
||||
update_type: StructureUpdateType::Rebuild,
|
||||
entity: id,
|
||||
|
@ -420,6 +413,7 @@ pub fn edit_window_ui(
|
|||
window: Query<&Window>,
|
||||
mut asset_server: ResMut<AssetServer>,
|
||||
mut event_writer: EventWriter<StructureUpdateMessage>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
shared_ui_state.egui.windows.clear();
|
||||
let title = String::from("VVEdit");
|
||||
|
@ -736,5 +730,6 @@ pub fn edit_window_ui(
|
|||
&mut asset_server,
|
||||
&mut structure_assets,
|
||||
&mut event_writer,
|
||||
&mut commands
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue