main menu
This commit is contained in:
parent
dccd6d319e
commit
c6d9a002b6
9 changed files with 280 additions and 6 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -2056,6 +2056,7 @@ dependencies = [
|
||||||
"ui_debug",
|
"ui_debug",
|
||||||
"ui_health_bar",
|
"ui_health_bar",
|
||||||
"ui_ingame",
|
"ui_ingame",
|
||||||
|
"ui_menu",
|
||||||
"ui_pause",
|
"ui_pause",
|
||||||
"ui_range_indicator",
|
"ui_range_indicator",
|
||||||
"ui_state",
|
"ui_state",
|
||||||
|
|
@ -5403,6 +5404,16 @@ dependencies = [
|
||||||
"upgrade",
|
"upgrade",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ui_menu"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bevy",
|
||||||
|
"bevy_egui",
|
||||||
|
"combat",
|
||||||
|
"state",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ui_pause"
|
name = "ui_pause"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
||||||
|
|
@ -63,4 +63,5 @@ inhabitant_endrake = { path = "crates/inhabitant_endrake" }
|
||||||
resource_soul_spot = { path = "crates/resource_soul_spot" }
|
resource_soul_spot = { path = "crates/resource_soul_spot" }
|
||||||
building_ramtower = { path = "crates/building_ramtower" }
|
building_ramtower = { path = "crates/building_ramtower" }
|
||||||
building_suncannon = { path = "crates/building_suncannon" }
|
building_suncannon = { path = "crates/building_suncannon" }
|
||||||
|
ui_menu = { path = "crates/ui_menu" }
|
||||||
#new internal crates go here
|
#new internal crates go here
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
(
|
(
|
||||||
map: {
|
map: {
|
||||||
MouseButton(Middle): [
|
|
||||||
CameraOrbitEnable,
|
|
||||||
],
|
|
||||||
KeyCode(ShiftLeft): [
|
KeyCode(ShiftLeft): [
|
||||||
MultiPlaceTower,
|
MultiPlaceTower,
|
||||||
],
|
],
|
||||||
|
MouseButton(Middle): [
|
||||||
|
CameraOrbitEnable,
|
||||||
|
],
|
||||||
KeyCode(F1): [
|
KeyCode(F1): [
|
||||||
ToggleDebugUI,
|
ToggleDebugUI,
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ fn setup(
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
StateScoped(AppState::Game),
|
||||||
Camera3d::default(),
|
Camera3d::default(),
|
||||||
Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ fn start_loading(mut next_state: ResMut<NextState<LoadState>>) {
|
||||||
|
|
||||||
fn finish_loading(mut next_state: ResMut<NextState<AppState>>) {
|
fn finish_loading(mut next_state: ResMut<NextState<AppState>>) {
|
||||||
info!("finished loading");
|
info!("finished loading");
|
||||||
next_state.set(AppState::Game);
|
next_state.set(AppState::Menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, SubStates, Default)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash, SubStates, Default)]
|
||||||
|
|
|
||||||
13
crates/ui_menu/Cargo.toml
Normal file
13
crates/ui_menu/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "ui_menu"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = { workspace = true }
|
||||||
|
bevy_egui = { workspace = true }
|
||||||
|
state = { path = "../state" }
|
||||||
|
combat = { path = "../combat" }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
247
crates/ui_menu/src/lib.rs
Normal file
247
crates/ui_menu/src/lib.rs
Normal file
|
|
@ -0,0 +1,247 @@
|
||||||
|
//bevy system signatures often violate these rules
|
||||||
|
#![allow(clippy::type_complexity)]
|
||||||
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
|
use bevy::{audio::Volume, prelude::*};
|
||||||
|
use bevy_egui::{
|
||||||
|
EguiContexts, EguiPrimaryContextPass, PrimaryEguiContext,
|
||||||
|
egui::{self, Align2, RichText},
|
||||||
|
};
|
||||||
|
use combat::Difficulty;
|
||||||
|
use state::AppState;
|
||||||
|
|
||||||
|
pub struct UiMenuPlugin;
|
||||||
|
|
||||||
|
impl Plugin for UiMenuPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.add_systems(OnEnter(AppState::Menu), setup_menu)
|
||||||
|
.add_systems(
|
||||||
|
EguiPrimaryContextPass,
|
||||||
|
(
|
||||||
|
main_screen.run_if(in_state(MenuScreen::Main)),
|
||||||
|
difficulty_screen.run_if(in_state(MenuScreen::Difficulty)),
|
||||||
|
info_screen.run_if(in_state(MenuScreen::Info)),
|
||||||
|
settings_screen.run_if(in_state(MenuScreen::Settings)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.add_sub_state::<MenuScreen>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const VERY_LARGE_FONT_SIZE: f32 = 48.;
|
||||||
|
const FONT_SIZE: f32 = 16.;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Hash, SubStates, Default)]
|
||||||
|
#[source(AppState = AppState::Menu)]
|
||||||
|
enum MenuScreen {
|
||||||
|
#[default]
|
||||||
|
Main,
|
||||||
|
Info,
|
||||||
|
Difficulty,
|
||||||
|
Settings,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setup_menu(mut commands: Commands) {
|
||||||
|
commands.spawn((
|
||||||
|
StateScoped(AppState::Menu),
|
||||||
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
|
hdr: true,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
PrimaryEguiContext,
|
||||||
|
Transform::default(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<MenuScreen>>) {
|
||||||
|
let ctx = contexts.ctx_mut().unwrap();
|
||||||
|
egui::Window::new("Title")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::CENTER_TOP, [0., 48.])
|
||||||
|
.fixed_size([600., 100.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label(RichText::new("COREHEART").size(72.));
|
||||||
|
});
|
||||||
|
egui::Window::new("MainScreen")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::CENTER_CENTER, [0., 0.])
|
||||||
|
.fixed_size([600., 100.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.centered_and_justified(|ui| {
|
||||||
|
if ui
|
||||||
|
.button(RichText::new("CONNECT").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
next_screen.set(MenuScreen::Difficulty);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui.centered_and_justified(|ui| {
|
||||||
|
if ui
|
||||||
|
.button(RichText::new("INFO").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
next_screen.set(MenuScreen::Info);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui.centered_and_justified(|ui| {
|
||||||
|
if ui
|
||||||
|
.button(RichText::new("SETTINGS").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
next_screen.set(MenuScreen::Settings);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn difficulty_screen(
|
||||||
|
mut contexts: EguiContexts,
|
||||||
|
mut next_screen: ResMut<NextState<MenuScreen>>,
|
||||||
|
mut next_state: ResMut<NextState<AppState>>,
|
||||||
|
mut difficulty: ResMut<Difficulty>,
|
||||||
|
) {
|
||||||
|
let ctx = contexts.ctx_mut().unwrap();
|
||||||
|
egui::Window::new("DifficultyScreen")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::CENTER_CENTER, [0., 0.])
|
||||||
|
.fixed_size([600., 100.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.columns(2, |columns| {
|
||||||
|
if columns[0]
|
||||||
|
.button(RichText::new("STANDARD").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
*difficulty = Difficulty::Standard;
|
||||||
|
next_state.set(AppState::Game);
|
||||||
|
}
|
||||||
|
columns[1].label("The intended experience, which is quite difficult.")
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.centered_and_justified(|ui| {
|
||||||
|
ui.label("——————————");
|
||||||
|
});
|
||||||
|
ui.columns(2, |columns| {
|
||||||
|
if columns[0]
|
||||||
|
.button(RichText::new("CHILL").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
*difficulty = Difficulty::Chill;
|
||||||
|
next_state.set(AppState::Game);
|
||||||
|
}
|
||||||
|
columns[1].label(
|
||||||
|
"Enemies deal significantly less damage. Good to chill and check out the game!",
|
||||||
|
)
|
||||||
|
});
|
||||||
|
ui.columns(2, |columns| {
|
||||||
|
if columns[0]
|
||||||
|
.button(RichText::new("CASUAL").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
*difficulty = Difficulty::Casual;
|
||||||
|
next_state.set(AppState::Game);
|
||||||
|
}
|
||||||
|
columns[1].label(
|
||||||
|
"Enemies deal less damage. Good for players who don't want to sweat as much.",
|
||||||
|
)
|
||||||
|
});
|
||||||
|
ui.columns(2, |columns| {
|
||||||
|
if columns[0]
|
||||||
|
.button(RichText::new("INSTENSE").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
*difficulty = Difficulty::Intense;
|
||||||
|
next_state.set(AppState::Game);
|
||||||
|
}
|
||||||
|
columns[1].label("Enemies deal more damage. Significantly harder.")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
egui::Window::new("DifficultyBack")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::LEFT_TOP, [0., 0.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
if ui
|
||||||
|
.button(RichText::new("BACK").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
next_screen.set(MenuScreen::Main);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn info_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<MenuScreen>>) {
|
||||||
|
let ctx = contexts.ctx_mut().unwrap();
|
||||||
|
egui::Window::new("InfoScreen")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::CENTER_CENTER, [0., 0.])
|
||||||
|
.fixed_size([800., 100.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label(RichText::new("You must place the Core and increase its reach as much as possible. Keep the Core alive as long as you can.\n").size(FONT_SIZE));
|
||||||
|
ui.label(RichText::new("Left click and drag to move the camera around. Middle click to rotate the camera. \nRight click to place buildings. Left click to view information about objects. \nEscape will cancel your current selection or pause the game.\n").size(FONT_SIZE));
|
||||||
|
ui.label(RichText::new("You will see different boxes places on the map. You can asssign workers to harvest them for resources. Upgrading the Core will form more workers to gather more resources.\n").size(FONT_SIZE));
|
||||||
|
ui.label(RichText::new("Upgrading towers increases their strength dramatically and heals them.\n").size(FONT_SIZE));
|
||||||
|
ui.label(RichText::new("Defeating an Inhabitants will grant you its soul. Use these, along with the bones you harvest from the environment, to build your strength. \n\n").size(FONT_SIZE));
|
||||||
|
ui.label(RichText::new("TIP: Holding shift allows you to place multiple buildings. It is very nice.").size(FONT_SIZE));
|
||||||
|
});
|
||||||
|
egui::Window::new("InfoBack")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::LEFT_TOP, [0., 0.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
if ui
|
||||||
|
.button(RichText::new("BACK").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
next_screen.set(MenuScreen::Main);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn settings_screen(
|
||||||
|
mut contexts: EguiContexts,
|
||||||
|
mut next_screen: ResMut<NextState<MenuScreen>>,
|
||||||
|
mut global_volume: ResMut<GlobalVolume>,
|
||||||
|
mut volume: Local<f32>,
|
||||||
|
mut init: Local<bool>,
|
||||||
|
) {
|
||||||
|
if !*init {
|
||||||
|
*init = true;
|
||||||
|
*volume = 100.;
|
||||||
|
}
|
||||||
|
let ctx = contexts.ctx_mut().unwrap();
|
||||||
|
egui::Window::new("SettingsScreen")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::CENTER_CENTER, [0., 0.])
|
||||||
|
.fixed_size([800., 100.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label(RichText::new("Volume").size(FONT_SIZE));
|
||||||
|
ui.add(egui::Slider::new(&mut *volume, 0.0..=100.));
|
||||||
|
global_volume.volume = Volume::Linear(*volume / 100.);
|
||||||
|
});
|
||||||
|
egui::Window::new("SettingsBack")
|
||||||
|
.resizable(false)
|
||||||
|
.collapsible(false)
|
||||||
|
.title_bar(false)
|
||||||
|
.anchor(Align2::LEFT_TOP, [0., 0.])
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
if ui
|
||||||
|
.button(RichText::new("BACK").size(VERY_LARGE_FONT_SIZE))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
next_screen.set(MenuScreen::Main);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -46,6 +46,7 @@ fn main() {
|
||||||
),
|
),
|
||||||
building_ramtower::BuildingRamtowerPlugin,
|
building_ramtower::BuildingRamtowerPlugin,
|
||||||
building_suncannon::BuildingSuncannonPlugin,
|
building_suncannon::BuildingSuncannonPlugin,
|
||||||
|
ui_menu::UiMenuPlugin,
|
||||||
// new internal crates go here
|
// new internal crates go here
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
||||||
4
todo.txt
4
todo.txt
|
|
@ -3,7 +3,7 @@
|
||||||
- sound
|
- sound
|
||||||
- music
|
- music
|
||||||
x limit workers per resource deposit
|
x limit workers per resource deposit
|
||||||
- main menu
|
x main menu
|
||||||
x improve enemy AI
|
x improve enemy AI
|
||||||
x balance (maybe)
|
x balance (maybe)
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ x More towers
|
||||||
x More upgrades
|
x More upgrades
|
||||||
x More enemy types
|
x More enemy types
|
||||||
x More resource deposit types
|
x More resource deposit types
|
||||||
- Improve wave generation
|
x Improve wave generation
|
||||||
|
|
||||||
--- STILL PRETTY IMPORTANT ---
|
--- STILL PRETTY IMPORTANT ---
|
||||||
~~Building repair: actually not doing this as it would be very hard to balance~~
|
~~Building repair: actually not doing this as it would be very hard to balance~~
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue