generated from tipragot/rust
This commit is contained in:
parent
69ccefd601
commit
9307223a13
48
crates/border-wars/src/ui/game_ui.rs
Normal file
48
crates/border-wars/src/ui/game_ui.rs
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
//! ToDo
|
||||||
|
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use crate::CurrentScene;
|
||||||
|
|
||||||
|
pub struct GameUiPlugin;
|
||||||
|
|
||||||
|
impl Plugin for GameUiPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.add_systems(OnEnter(CurrentScene::Game), setup_ui);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets up the UI for the game.
|
||||||
|
fn setup_ui(mut commands: Commands) {
|
||||||
|
commands.spawn(NodeBundle {
|
||||||
|
style: Style {
|
||||||
|
margin: UiRect {
|
||||||
|
left: Val::Auto,
|
||||||
|
right: Val::Auto,
|
||||||
|
top: Val::Auto,
|
||||||
|
bottom: Val::Px(25.),
|
||||||
|
},
|
||||||
|
width: Val::Px(1000.),
|
||||||
|
height: Val::Px(150.),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
background_color: Color::BLUE.into(),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
|
commands.spawn(NodeBundle {
|
||||||
|
style: Style {
|
||||||
|
margin: UiRect {
|
||||||
|
left: Val::Px(10.),
|
||||||
|
right: Val::Auto,
|
||||||
|
top: Val::Px(10.),
|
||||||
|
bottom: Val::Auto,
|
||||||
|
},
|
||||||
|
width: Val::Px(200.),
|
||||||
|
height: Val::Px(200.),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
background_color: Color::BLUE.into(),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
//! The file that contains the UI logic.
|
//! The file that contains the UI logic.
|
||||||
|
|
||||||
|
pub mod game_ui;
|
||||||
pub mod hover;
|
pub mod hover;
|
||||||
pub mod responsive_scale;
|
pub mod responsive_scale;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use self::game_ui::GameUiPlugin;
|
||||||
use self::hover::HoverPlugin;
|
use self::hover::HoverPlugin;
|
||||||
use self::responsive_scale::ResponsiveScalingPlugin;
|
use self::responsive_scale::ResponsiveScalingPlugin;
|
||||||
|
|
||||||
|
@ -14,6 +16,7 @@ pub struct UiPlugin;
|
||||||
impl Plugin for UiPlugin {
|
impl Plugin for UiPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugins(HoverPlugin)
|
app.add_plugins(HoverPlugin)
|
||||||
.add_plugins(ResponsiveScalingPlugin);
|
.add_plugins(ResponsiveScalingPlugin)
|
||||||
|
.add_plugins(GameUiPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue