This commit is contained in:
2025-01-07 09:18:28 -05:00
parent 327e4b2739
commit 8e2dc04a6f
4 changed files with 36 additions and 21 deletions

View File

@@ -2,9 +2,7 @@ use bevy::core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAn
use bevy::core_pipeline::prepass::DepthPrepass;
use bevy::input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel};
use bevy::prelude::*;
use bevy::render::view::RenderLayers;
use bevy::window::{CursorGrabMode, PrimaryWindow};
use bevy_lunex::prelude::MainUi;
use shared::sets::GameplaySet;
use shared::tags::MainCamera;
use world_generation::hex_utils::HexCoord;
@@ -22,13 +20,9 @@ impl Plugin for PhosCameraPlugin {
app.add_systems(PreStartup, setup);
// app.add_systems(Update, rts_camera_system.in_set(GameplaySet));
// app.add_systems(PostUpdate, limit_camera_bounds.in_set(GameplaySet));
app.add_systems(Update, orbit_camera_upate.in_set(GameplaySet));
app.add_systems(Update, init_bounds.run_if(in_state(GeneratorState::SpawnMap)));
//Free Cam
//app.add_systems(Update, (grab_mouse, (update_camera, update_camera_mouse).chain()));
app.add_plugins(TemporalAntiAliasPlugin);
}

View File

@@ -1,4 +1,4 @@
use bevy::{prelude::*, sprite::Anchor};
use bevy::{prelude::*, render::view::RenderLayers, sprite::Anchor};
use bevy_lunex::prelude::*;
pub struct BuildUiPlugin;
@@ -18,6 +18,7 @@ fn setup_ui(mut commands: Commands, assets: Res<AssetServer>, mut material: ResM
},
Name::new("Build UI"),
SourceFromCamera,
RenderLayers::layer(1),
))
.with_children(|ui| {
ui.spawn((
@@ -26,6 +27,7 @@ fn setup_ui(mut commands: Commands, assets: Res<AssetServer>, mut material: ResM
.pos1((Rl(0.), Rl(0.)))
.pos2((Rl(100.), Rl(100.)))
.pack::<Base>(),
RenderLayers::layer(1),
));
ui.spawn((
@@ -35,6 +37,7 @@ fn setup_ui(mut commands: Commands, assets: Res<AssetServer>, mut material: ResM
.size((Ab(800.), Rl(100.)))
.pos((Rl(50.), Rl(100.)))
.pack::<Base>(),
RenderLayers::layer(1),
));
ui.spawn((
@@ -43,21 +46,29 @@ fn setup_ui(mut commands: Commands, assets: Res<AssetServer>, mut material: ResM
.align_y(Align::END)
.size((Rl(100.), Ab(30.)))
.pack::<Base>(),
RenderLayers::layer(1),
));
for i in 1..5 {
for i in 0..5 {
let path = format!("Root/MainRect/Categories/Button{}", i);
ui.spawn((
UiLink::<MainUi>::path(path),
UiLayout::div()
.margin_x(Ab(5.))
.height(Sizing::Max)
.min_height(Ab(30.))
.min_width(Sp(10.))
.max_width(Sp(100.))
UiLayout::window()
.size((Rl(100. / 5.), Ab(30.)))
.x(Rl((100. / 5.) * i as f32))
.pack::<Base>(),
UiLayout::window()
.size((Rl(100. / 5.), Ab(20.)))
.x(Rl((100. / 5.) * i as f32))
.pack::<Hover>(),
UiImage2dBundle::from(assets.load("textures/world/test2.png")),
RenderLayers::layer(1),
));
// ui.spawn((
// UiLink::<MainUi>::path(format!("{}/img", path)),
// UiLayout::solid().size((Ab(30.), Ab(100.))).pack::<Base>(),
// UiImage2dBundle::from(assets.load("textures/world/test2.png")),
// ));
}
});
}

View File

@@ -1,6 +1,9 @@
use bevy::{
prelude::*,
render::render_resource::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages},
render::{
render_resource::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages},
view::RenderLayers,
},
window::PrimaryWindow,
};
use bevy_lunex::prelude::*;
@@ -21,7 +24,7 @@ impl Plugin for LunexSetupPlugin {
fn setup_cameras(
mut commands: Commands,
assets: Res<AssetServer>,
mut camera_query: Query<&mut Camera, With<MainCamera>>,
mut main_3d_camera_q: Query<&mut Camera, With<MainCamera>>,
window_query: Query<&Window, With<PrimaryWindow>>,
) {
//Prepare Render Texture
@@ -48,7 +51,7 @@ fn setup_cameras(
image.resize(size);
//Configure 3D Camera
let mut cam = camera_query.single_mut();
let mut cam = main_3d_camera_q.single_mut();
let render_image = assets.add(image);
cam.target = render_image.clone().into();
cam.order = -1;
@@ -56,20 +59,26 @@ fn setup_cameras(
//Add Render Texture image
commands
.spawn((UiTreeBundle::<MainUi>::from(UiTree::new2d("Main UI")), SourceFromCamera))
.spawn((
UiTreeBundle::<MainUi>::from(UiTree::new2d("Main UI")),
SourceFromCamera,
RenderLayers::layer(1),
))
.with_children(|ui| {
ui.spawn((
UiLink::<MainUi>::path("Root"),
UiLayout::window_full().size((win.width(), win.height())).pack::<Base>(),
UiLayout::window_full().size((Rl(100.), Rl(100.))).pack::<Base>(),
RenderLayers::layer(1),
));
ui.spawn((
UiLink::<MainUi>::path("Root/Camera3D"),
UiLayout::solid()
.size((win.width(), win.height()))
.size((Rl(100.), Rl(100.)))
.scaling(Scaling::Fill)
.pack::<Base>(),
UiImage2dBundle::from(render_image),
PickingPortal,
RenderLayers::layer(1),
));
});
@@ -80,5 +89,6 @@ fn setup_cameras(
transform: Transform::from_xyz(0.0, 0.0, 1000.0),
..default()
},
RenderLayers::from_layers(&[1]),
));
}

View File

@@ -29,7 +29,7 @@ impl Plugin for DebugPlugin {
.run_if(in_state(DebugState::Verbose)),
);
app.add_systems(Update, camera_debug.in_set(GameplaySet));
// app.add_systems(Update, camera_debug.in_set(GameplaySet));
app.add_systems(Update, regenerate_map.run_if(in_state(GeneratorState::Idle)));
app.insert_resource(Shape(Polyline3d::new([