ui testing
Some checks failed
Rust / build (push) Failing after 4s

This commit is contained in:
2026-03-16 22:58:12 -04:00
parent fca907aee4
commit f342970228
3 changed files with 26 additions and 13 deletions

View File

@@ -45,8 +45,8 @@ impl Plugin for PhosGamePlugin
// UnitsPlugin, // UnitsPlugin,
DespawnPuglin, DespawnPuglin,
TileSelectionPlugin, TileSelectionPlugin,
#[cfg(debug_assertions)] // #[cfg(debug_assertions)]
EditorPlugin, // EditorPlugin,
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
DebugPlugin, DebugPlugin,
)); ));

View File

@@ -33,10 +33,6 @@ fn setup_cameras(mut commands: Commands)
order: 1, order: 1,
clear_color: ClearColorConfig::None, clear_color: ClearColorConfig::None,
msaa_writeback: MsaaWriteback::Always, msaa_writeback: MsaaWriteback::Always,
// viewport: Some(Viewport {
// physical_size: UVec2::new(800, 800),
// ..default()
// }),
output_mode: CameraOutputMode::Write { output_mode: CameraOutputMode::Write {
blend_state: Some(BlendState::ALPHA_BLENDING), blend_state: Some(BlendState::ALPHA_BLENDING),
clear_color: ClearColorConfig::None, clear_color: ClearColorConfig::None,
@@ -83,9 +79,11 @@ fn spawn_ui(mut commands: Commands, mut next_state: ResMut<NextState<BuildUIStat
Name::new("Toolbar"), Name::new("Toolbar"),
Node { Node {
width: Val::Percent(100.), width: Val::Percent(100.),
height: Val::Px(80.), height: Val::Px(30.),
column_gap: Val::Px(5.),
padding: UiRect::horizontal(Val::Px(10.)), padding: UiRect::horizontal(Val::Px(10.)),
justify_content: JustifyContent::Stretch, justify_content: JustifyContent::Stretch,
align_self: AlignSelf::End,
..default() ..default()
}, },
BackgroundColor(LinearRgba::BLUE.into()), BackgroundColor(LinearRgba::BLUE.into()),
@@ -95,12 +93,27 @@ fn spawn_ui(mut commands: Commands, mut next_state: ResMut<NextState<BuildUIStat
{ {
toolbar.spawn(( toolbar.spawn((
Name::new(format!("Button {}", i)), Name::new(format!("Button {}", i)),
Button,
Node { Node {
height: Val::Percent(100.), height: Val::Percent(100.),
width: Val::Auto, width: Val::Percent(100.),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default() ..default()
}, },
BackgroundColor(LinearRgba::WHITE.into()), BackgroundColor(LinearRgba::WHITE.into()),
children![(
Text::new(format!("Button {}", i)),
TextFont {
font_size: 15.,
..default()
},
TextColor(LinearRgba::BLACK.into()),
TextShadow {
offset: Vec2::splat(2.),
..default()
}
)],
)); ));
} }
}); });

View File

@@ -18,10 +18,10 @@ impl Plugin for EditorPlugin
app.init_resource::<UIState>(); app.init_resource::<UIState>();
app.add_systems(PostUpdate, prepare_image.run_if(in_state(GeneratorState::SpawnMap))); app.add_systems(PostUpdate, prepare_image.run_if(in_state(GeneratorState::SpawnMap)));
// app.add_systems( app.add_systems(
// Update, Update,
// (render_map_ui, update_map_render, asset_reloaded).run_if(in_state(GeneratorState::Idle)), (render_map_ui, update_map_render, asset_reloaded).run_if(in_state(GeneratorState::Idle)),
// ); );
} }
} }
@@ -99,7 +99,7 @@ fn render_map_ui(
mut state: ResMut<UIState>, mut state: ResMut<UIState>,
) )
{ {
let id = contexts.add_image(EguiTextureHandle::Strong(image.0.clone())); let id = contexts.add_image(EguiTextureHandle::Weak(image.0.id()));
let mut map_type = state.target_map_type; let mut map_type = state.target_map_type;
let ctx = contexts.ctx_mut().expect("Failed to get egui context"); let ctx = contexts.ctx_mut().expect("Failed to get egui context");
egui::Window::new("Map").open(&mut state.is_open).show(ctx, |ui| { egui::Window::new("Map").open(&mut state.is_open).show(ctx, |ui| {