fixed selection swapper and vvg loader. (also a stray bug that added an extra .vvg to grid files)

This commit is contained in:
Lillian Vixe 2024-06-17 14:41:42 -07:00
parent 6c289f30f9
commit a51dab6691
2 changed files with 24 additions and 9 deletions

View file

@ -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}
}, math::Vec3, pbr::{PointLight, PointLightBundle}, prelude::{default, Resource, SpatialBundle}, render::{camera::Camera, color::Color, view::Visibility}, transform::components::{GlobalTransform, Transform}, utils::{hashbrown::hash_map::Entry, HashMap}, window::{PrimaryWindow, Window, WindowResolution}
}, math::Vec3, pbr::{PointLight, PointLightBundle, StandardMaterial}, prelude::{default, Resource, SpatialBundle}, render::{camera::Camera, color::Color, mesh::Mesh, view::Visibility}, transform::components::{GlobalTransform, Transform}, utils::{hashbrown::hash_map::Entry, HashMap}, window::{PrimaryWindow, Window, WindowResolution}
};
use bevy_egui::{
egui::{self, color_picker, epaint::Hsva, Id, Pos2, Rect, ScrollArea},
@ -428,6 +428,8 @@ pub fn edit_window_ui(
mut asset_server: ResMut<AssetServer>,
mut event_writer: EventWriter<StructureUpdateMessage>,
mut commands: Commands,
mut materials: ResMut<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
) {
shared_ui_state.egui.windows.clear();
let title = String::from("VVEdit");
@ -745,7 +747,12 @@ pub fn edit_window_ui(
for each in &mut shared_ui_state.grids {
if each.has_changed_since_last_save {
let handle = each.id.clone();
let path = each.path.clone() + ".vvg";
let path = if each.path.clone().to_lowercase().ends_with(".vvg")
{
each.path.clone()
} else {
each.path.clone() + ".vvg"
};
let asset = grid_assets.get(handle);
if asset.is_some() {
let result =
@ -782,6 +789,9 @@ pub fn edit_window_ui(
&mut asset_server,
&mut structure_assets,
&mut event_writer,
&mut commands
&mut commands,
&mut pairs,
&mut materials,
&mut meshes,
);
}

View file

@ -9,8 +9,9 @@ use bevy::{
ecs::{entity::Entity, event::EventWriter, system::ResMut},
hierarchy::BuildChildren,
math::{Quat, Vec3},
prelude::{Commands, Query, SpatialBundle},
render::{color::Color, view::Visibility},
pbr::{PbrBundle, StandardMaterial},
prelude::{default, Commands, Query, SpatialBundle},
render::{color::Color, mesh::Mesh, view::Visibility},
utils::hashbrown::hash_map::Entry,
};
use bevy_egui::{
@ -27,7 +28,7 @@ use crate::{
vvedit::s_editor_ui::{GridEditData, Selection, StructureEditData},
vvlib::{
s_identifier_validation::{self, is_valid},
s_oct_asset::{OctAssetMarker, OctTreeAsset},
s_oct_asset::{MeshingOctTreePairs, OctAssetMarker, OctTreeAsset},
s_octtree::OctTree,
s_structure_asset::{
StructureAsset, StructureComponent, StructureUpdateMessage, StructureUpdateType,
@ -91,6 +92,9 @@ pub fn show_popup(
structure_assets: &mut ResMut<Assets<StructureAsset>>,
event_writer: &mut EventWriter<StructureUpdateMessage>,
commands: &mut Commands,
pairs: &mut ResMut<MeshingOctTreePairs>,
materials: &mut ResMut<Assets<StandardMaterial>>,
meshes: &mut ResMut<Assets<Mesh>>,
) {
enum PopupStateChange {
None,
@ -350,9 +354,10 @@ pub fn show_popup(
let handle = asset_server.load::<OctTreeAsset>(path_pre.clone());
let id = commands
.spawn((
SpatialBundle {
visibility: Visibility::Visible,
..Default::default()
PbrBundle {
mesh: pairs.mesh_handle_for(handle.clone(), meshes),
material: materials.add(Color::rgb(1., 1., 1.)),
..default()
},
OctAssetMarker {
oct_handle: handle.clone(),