BIN
crates/border-wars/assets/border_wars.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
crates/border-wars/assets/button.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 205 KiB |
BIN
crates/border-wars/assets/bw_menu_bg.png
Normal file
After Width: | Height: | Size: 309 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
crates/border-wars/assets/host_icon.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
crates/border-wars/assets/info.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 1.9 KiB |
BIN
crates/border-wars/assets/join_icon.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
crates/border-wars/assets/setting.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
crates/border-wars/assets/trait.png
Normal file
After Width: | Height: | Size: 728 B |
|
@ -10,9 +10,9 @@ pub struct MenuPlugin;
|
||||||
impl Plugin for MenuPlugin {
|
impl Plugin for MenuPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(OnEnter(CurrentScene::Menu), menu_ui);
|
app.add_systems(OnEnter(CurrentScene::Menu), menu_ui);
|
||||||
app.add_systems(Update, change_scaling);
|
// app.add_systems(Update, change_scaling);
|
||||||
app.add_systems(Update, hover_system);
|
// app.add_systems(Update, hover_system);
|
||||||
app.add_systems(Update, pressed_system);
|
// app.add_systems(Update, pressed_system);
|
||||||
app.add_systems(OnExit(CurrentScene::Menu), destroy_menu);
|
app.add_systems(OnExit(CurrentScene::Menu), destroy_menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,8 @@ struct MenuEntity;
|
||||||
|
|
||||||
/// Display the UI of the menu to host a game or join one.
|
/// Display the UI of the menu to host a game or join one.
|
||||||
fn menu_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn menu_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn(NodeBundle {
|
.spawn(ImageBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
margin: UiRect::all(Val::Auto),
|
margin: UiRect::all(Val::Auto),
|
||||||
width: Val::Px(1280.),
|
width: Val::Px(1280.),
|
||||||
|
@ -43,6 +42,7 @@ fn menu_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
flex_direction: FlexDirection::Column,
|
flex_direction: FlexDirection::Column,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
image: asset_server.load("bw_menu_bg.png").into(),
|
||||||
z_index: ZIndex::Local(0),
|
z_index: ZIndex::Local(0),
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
|
@ -59,8 +59,8 @@ fn menu_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
CurrentScene::Setting,
|
CurrentScene::Setting,
|
||||||
&mut commands,
|
&mut commands,
|
||||||
HoveredTexture {
|
HoveredTexture {
|
||||||
texture: asset_server.load("button_settings_icon.png"),
|
texture: asset_server.load("setting.png"),
|
||||||
hovered_texture: asset_server.load("button_settings_icon_hover.png"),
|
hovered_texture: asset_server.load("setting.png"),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ fn menu_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
CurrentScene::Lobby,
|
CurrentScene::Lobby,
|
||||||
&mut commands,
|
&mut commands,
|
||||||
HoveredTexture {
|
HoveredTexture {
|
||||||
texture: asset_server.load("button_menu_icon.png"),
|
texture: asset_server.load("info.png"),
|
||||||
hovered_texture: asset_server.load("button_menu_icon_hover.png"),
|
hovered_texture: asset_server.load("info.png"),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ fn create_side_button(
|
||||||
commands
|
commands
|
||||||
.spawn(ButtonBundle {
|
.spawn(ButtonBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::Px(75.),
|
width: Val::Px(53.),
|
||||||
aspect_ratio: Some(1.),
|
aspect_ratio: Some(1.),
|
||||||
margin,
|
margin,
|
||||||
..default()
|
..default()
|
||||||
|
@ -111,8 +111,8 @@ fn create_button(
|
||||||
commands
|
commands
|
||||||
.spawn(ButtonBundle {
|
.spawn(ButtonBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::Px(266.),
|
width: Val::Px(297.),
|
||||||
height: Val::Px(70.),
|
height: Val::Px(40.),
|
||||||
margin: UiRect::all(Val::Auto),
|
margin: UiRect::all(Val::Auto),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
@ -156,7 +156,7 @@ fn default_style() -> Style {
|
||||||
Style {
|
Style {
|
||||||
flex_direction: FlexDirection::Column,
|
flex_direction: FlexDirection::Column,
|
||||||
width: Val::Percent(100.),
|
width: Val::Percent(100.),
|
||||||
height: Val::Percent(55.),
|
height: Val::Percent(40.),
|
||||||
margin: UiRect::all(Val::Auto),
|
margin: UiRect::all(Val::Auto),
|
||||||
..default()
|
..default()
|
||||||
}
|
}
|
||||||
|
@ -167,17 +167,17 @@ fn main_node(main_node: &mut ChildBuilder<'_, '_, '_>, asset_server: &Res<AssetS
|
||||||
main_node
|
main_node
|
||||||
.spawn(ImageBundle {
|
.spawn(ImageBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
height: Val::Px(150.),
|
height: Val::Px(78.),
|
||||||
width: Val::Px(613.5),
|
width: Val::Px(614.),
|
||||||
margin: UiRect {
|
margin: UiRect {
|
||||||
left: Val::Auto,
|
left: Val::Auto,
|
||||||
right: Val::Auto,
|
right: Val::Auto,
|
||||||
top: Val::Px(25.),
|
top: Val::Px(25.),
|
||||||
bottom: Val::Px(50.),
|
bottom: Val::Px(25.),
|
||||||
},
|
},
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
image: asset_server.load("bw.png").into(),
|
image: asset_server.load("border_wars.png").into(),
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.insert(MenuEntity);
|
.insert(MenuEntity);
|
||||||
|
@ -189,8 +189,8 @@ fn main_node(main_node: &mut ChildBuilder<'_, '_, '_>, asset_server: &Res<AssetS
|
||||||
margin: UiRect {
|
margin: UiRect {
|
||||||
left: (Val::Auto),
|
left: (Val::Auto),
|
||||||
right: (Val::Auto),
|
right: (Val::Auto),
|
||||||
top: (Val::Auto),
|
top: (Val::Px(25.)),
|
||||||
bottom: (Val::Px(25.)),
|
bottom: (Val::Auto),
|
||||||
},
|
},
|
||||||
width: Val::Px(500.),
|
width: Val::Px(500.),
|
||||||
height: Val::Percent(65.),
|
height: Val::Percent(65.),
|
||||||
|
@ -208,16 +208,58 @@ fn main_node(main_node: &mut ChildBuilder<'_, '_, '_>, asset_server: &Res<AssetS
|
||||||
.with_children(|host| {
|
.with_children(|host| {
|
||||||
host.spawn(NodeBundle {
|
host.spawn(NodeBundle {
|
||||||
style: default_style(),
|
style: default_style(),
|
||||||
background_color: BackgroundColor(Color::YELLOW),
|
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.insert(MenuEntity);
|
.insert(MenuEntity)
|
||||||
|
.with_children(|ui| {
|
||||||
|
ui.spawn(NodeBundle {
|
||||||
|
style: Style {
|
||||||
|
flex_direction: FlexDirection::Row,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
})
|
||||||
|
.with_children(|ui2| {
|
||||||
|
ui2.spawn(ImageBundle {
|
||||||
|
style: Style {
|
||||||
|
height: Val::Px(41.),
|
||||||
|
width: Val::Px(51.),
|
||||||
|
margin: UiRect {
|
||||||
|
left: Val::Px(0.),
|
||||||
|
right: Val::Px(15.),
|
||||||
|
top: Val::Px(0.),
|
||||||
|
bottom: Val::Px(0.),
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
image: asset_server.load("host_icon.png").into(),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
ui2.spawn(ImageBundle {
|
||||||
|
style: Style {
|
||||||
|
height: Val::Px(41.),
|
||||||
|
width: Val::Px(115.),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
image: asset_server.load("host.png").into(),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
ui.spawn(ImageBundle {
|
||||||
|
style: Style {
|
||||||
|
margin: UiRect::all(Val::Auto),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
image: asset_server.load("trait.png").into(),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
});
|
||||||
create_button(
|
create_button(
|
||||||
CurrentScene::Lobby,
|
CurrentScene::Lobby,
|
||||||
host,
|
host,
|
||||||
HoveredTexture {
|
HoveredTexture {
|
||||||
texture: asset_server.load("host.png"),
|
texture: asset_server.load("button.png"),
|
||||||
hovered_texture: asset_server.load("host.png"),
|
hovered_texture: asset_server.load("button.png"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -231,16 +273,58 @@ fn main_node(main_node: &mut ChildBuilder<'_, '_, '_>, asset_server: &Res<AssetS
|
||||||
.with_children(|join| {
|
.with_children(|join| {
|
||||||
join.spawn(NodeBundle {
|
join.spawn(NodeBundle {
|
||||||
style: default_style(),
|
style: default_style(),
|
||||||
background_color: BackgroundColor(Color::YELLOW),
|
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.insert(MenuEntity);
|
.insert(MenuEntity)
|
||||||
|
.with_children(|ui| {
|
||||||
|
ui.spawn(NodeBundle {
|
||||||
|
style: Style {
|
||||||
|
flex_direction: FlexDirection::Row,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
})
|
||||||
|
.with_children(|ui2| {
|
||||||
|
ui2.spawn(ImageBundle {
|
||||||
|
style: Style {
|
||||||
|
height: Val::Px(33.),
|
||||||
|
width: Val::Px(51.),
|
||||||
|
margin: UiRect {
|
||||||
|
left: Val::Px(0.),
|
||||||
|
right: Val::Px(15.),
|
||||||
|
top: Val::Auto,
|
||||||
|
bottom: Val::Auto,
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
image: asset_server.load("join_icon.png").into(),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
ui2.spawn(ImageBundle {
|
||||||
|
style: Style {
|
||||||
|
height: Val::Px(41.),
|
||||||
|
width: Val::Px(115.),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
image: asset_server.load("join.png").into(),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
ui.spawn(ImageBundle {
|
||||||
|
style: Style {
|
||||||
|
margin: UiRect::all(Val::Auto),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
image: asset_server.load("trait.png").into(),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
});
|
||||||
create_button(
|
create_button(
|
||||||
CurrentScene::Game,
|
CurrentScene::Game,
|
||||||
join,
|
join,
|
||||||
HoveredTexture {
|
HoveredTexture {
|
||||||
texture: asset_server.load("join.png"),
|
texture: asset_server.load("button.png"),
|
||||||
hovered_texture: asset_server.load("join.png"),
|
hovered_texture: asset_server.load("button.png"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|