pre-refactor-prep
This commit is contained in:
parent
53e85dbcd0
commit
f25596e3fb
|
@ -1,7 +1,7 @@
|
||||||
use bevy::{
|
use bevy::{
|
||||||
app::{Startup, Update}, asset::{AssetServer, Assets, Handle}, ecs::{
|
app::{Startup, Update}, asset::{AssetServer, Assets, Handle}, ecs::{
|
||||||
entity::Entity, event::EventWriter, query::With, system::{Commands, Query, Res, ResMut, Resource}
|
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::{
|
use bevy_egui::{
|
||||||
egui::{self, color_picker, epaint::Hsva, Id, Pos2, Rect, ScrollArea},
|
egui::{self, color_picker, epaint::Hsva, Id, Pos2, Rect, ScrollArea},
|
||||||
|
@ -52,7 +52,12 @@ pub struct EditWindowUIState {
|
||||||
pub selected_structure: String,
|
pub selected_structure: String,
|
||||||
pub selected_grid: String,
|
pub selected_grid: String,
|
||||||
pub display_state: DisplayState,
|
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 {
|
impl Default for EditWindowUIState {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -64,7 +69,8 @@ impl Default for EditWindowUIState {
|
||||||
selected_structure_element: "".into(),
|
selected_structure_element: "".into(),
|
||||||
selected_structure: "".into(),
|
selected_structure: "".into(),
|
||||||
selected_grid: "".into(),
|
selected_grid: "".into(),
|
||||||
display_state: Default::default()
|
display_root: Entity::PLACEHOLDER,
|
||||||
|
display_state: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +80,7 @@ pub enum PopupWindowMode {
|
||||||
None,
|
None,
|
||||||
EditStructureElement(String, String, String), // structure subject, rename from and to, otherwise second string is unused
|
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
|
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 {
|
impl PopupWindowMode {
|
||||||
pub fn is_none(&self) -> bool {
|
pub fn is_none(&self) -> bool {
|
||||||
|
@ -199,12 +205,9 @@ pub fn register_edit_ui(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn startup_system_edit_ui(
|
pub fn startup_system_edit_ui(
|
||||||
// formatting comment
|
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut shared_ui_state: ResMut<EditWindowUIState>,
|
mut shared_ui_state: ResMut<EditWindowUIState>,
|
||||||
asset_server: ResMut<AssetServer>,
|
asset_server: ResMut<AssetServer>,
|
||||||
//mut pairs: ResMut<MeshingOctTreePairs>,
|
|
||||||
//mesh_assets: ResMut<Assets<Mesh>>,
|
|
||||||
mut event_writer: EventWriter<StructureUpdateMessage>,
|
mut event_writer: EventWriter<StructureUpdateMessage>,
|
||||||
) {
|
) {
|
||||||
spawn_camera(&mut commands);
|
spawn_camera(&mut commands);
|
||||||
|
@ -212,16 +215,20 @@ pub fn startup_system_edit_ui(
|
||||||
let handle = asset_server.load::<StructureAsset>(str);
|
let handle = asset_server.load::<StructureAsset>(str);
|
||||||
|
|
||||||
//let id = OctTreeAsset::load(&mut pairs, asset_server.into(), mesh_assets, "test.vvg".into());
|
//let id = OctTreeAsset::load(&mut pairs, asset_server.into(), mesh_assets, "test.vvg".into());
|
||||||
let parent = commands
|
let display_parent = commands
|
||||||
.spawn(TransformBundle {
|
.spawn(TransformBundle {
|
||||||
local: Transform::from_scale(Vec3::splat(1f32)),
|
local: Transform::from_scale(Vec3::splat(1f32)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.id();
|
.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(),
|
asset: handle.clone(),
|
||||||
nodes: Default::default(),
|
nodes: Default::default(),
|
||||||
})).id();
|
})).id();
|
||||||
|
shared_ui_state.display_root = display_parent;
|
||||||
let data = StructureEditData {
|
let data = StructureEditData {
|
||||||
path: str.into(),
|
path: str.into(),
|
||||||
id: handle.clone(),
|
id: handle.clone(),
|
||||||
|
@ -229,21 +236,7 @@ pub fn startup_system_edit_ui(
|
||||||
edit_entity: id.clone(),
|
edit_entity: id.clone(),
|
||||||
};
|
};
|
||||||
shared_ui_state.structures.push(data);
|
shared_ui_state.structures.push(data);
|
||||||
/*let child = commands
|
commands.entity(display_parent).add_child(id.clone());
|
||||||
.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());
|
|
||||||
event_writer.send(StructureUpdateMessage {
|
event_writer.send(StructureUpdateMessage {
|
||||||
update_type: StructureUpdateType::Rebuild,
|
update_type: StructureUpdateType::Rebuild,
|
||||||
entity: id,
|
entity: id,
|
||||||
|
@ -420,6 +413,7 @@ pub fn edit_window_ui(
|
||||||
window: Query<&Window>,
|
window: Query<&Window>,
|
||||||
mut asset_server: ResMut<AssetServer>,
|
mut asset_server: ResMut<AssetServer>,
|
||||||
mut event_writer: EventWriter<StructureUpdateMessage>,
|
mut event_writer: EventWriter<StructureUpdateMessage>,
|
||||||
|
mut commands: Commands,
|
||||||
) {
|
) {
|
||||||
shared_ui_state.egui.windows.clear();
|
shared_ui_state.egui.windows.clear();
|
||||||
let title = String::from("VVEdit");
|
let title = String::from("VVEdit");
|
||||||
|
@ -736,5 +730,6 @@ pub fn edit_window_ui(
|
||||||
&mut asset_server,
|
&mut asset_server,
|
||||||
&mut structure_assets,
|
&mut structure_assets,
|
||||||
&mut event_writer,
|
&mut event_writer,
|
||||||
|
&mut commands
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue