2023-11-27 12:59:14 +00:00
|
|
|
use bevy::{
|
|
|
|
core_pipeline::{
|
|
|
|
tonemapping::Tonemapping,
|
|
|
|
},
|
2023-11-28 14:18:26 +00:00
|
|
|
window::*,
|
2023-11-27 12:59:14 +00:00
|
|
|
prelude::*,
|
2023-11-28 14:18:26 +00:00
|
|
|
winit::WinitSettings,
|
2023-11-27 12:59:14 +00:00
|
|
|
};
|
2023-11-27 10:45:07 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
use lazy_static::lazy_static;
|
|
|
|
|
2023-11-29 22:40:30 +00:00
|
|
|
mod helpers;
|
|
|
|
use crate::helpers::*;
|
|
|
|
|
2023-11-28 14:18:26 +00:00
|
|
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
|
|
const PKGNAME: &str = env!("CARGO_PKG_NAME");
|
|
|
|
|
2023-11-27 10:45:07 +00:00
|
|
|
// Create a map of the Hypernova colorscheme
|
|
|
|
lazy_static!{
|
|
|
|
static ref HYPERNOVA: HashMap<&'static str, Color> = vec![
|
|
|
|
("BLACK", Color::hex("0d0d0f").unwrap()),
|
|
|
|
("DARK_GRAY", Color::hex("151517").unwrap()),
|
|
|
|
("GRAY", Color::hex("27272b").unwrap()),
|
|
|
|
("LIGHT_GRAY", Color::hex("454449").unwrap()),
|
|
|
|
("SUBTEXT", Color::hex("d9d0d7").unwrap()),
|
2023-11-28 14:18:26 +00:00
|
|
|
("WHITE", Color::hex("ece5ea").unwrap()),
|
2023-11-27 10:45:07 +00:00
|
|
|
("RED", Color::hex("f06969").unwrap()),
|
|
|
|
("MAGENTA", Color::hex("e887bb").unwrap()),
|
|
|
|
("PURPLE", Color::hex("a292e8").unwrap()),
|
|
|
|
("BLUE", Color::hex("78b9c4").unwrap()),
|
|
|
|
("CYAN", Color::hex("7ee6ae").unwrap()),
|
|
|
|
("GREEN", Color::hex("91d65c").unwrap()),
|
|
|
|
("YELLOW", Color::hex("d9d564").unwrap()),
|
|
|
|
].iter().copied().collect();
|
|
|
|
}
|
2023-11-26 23:03:29 +00:00
|
|
|
|
2023-11-26 21:32:11 +00:00
|
|
|
fn main() {
|
2023-11-26 23:03:29 +00:00
|
|
|
App::new()
|
2023-11-28 14:18:26 +00:00
|
|
|
// Only run the app when there is user input, significantly reducing CPU/GPU usage
|
|
|
|
.insert_resource(WinitSettings::desktop_app())
|
|
|
|
.add_plugins(
|
|
|
|
DefaultPlugins.set(WindowPlugin {
|
|
|
|
primary_window: Some(Window {
|
|
|
|
title: format!("{} {}", titlecase(PKGNAME), VERSION).into(),
|
|
|
|
mode: WindowMode::Fullscreen,
|
|
|
|
..default()
|
|
|
|
}),
|
|
|
|
..default()
|
|
|
|
})
|
|
|
|
)
|
2023-11-27 21:45:11 +00:00
|
|
|
.add_systems(
|
|
|
|
Startup,
|
2023-11-28 14:18:26 +00:00
|
|
|
(setup, setup_ui)
|
2023-11-27 21:45:11 +00:00
|
|
|
)
|
2023-11-26 23:03:29 +00:00
|
|
|
.run();
|
2023-11-26 21:32:11 +00:00
|
|
|
}
|
2023-11-26 23:03:29 +00:00
|
|
|
|
2023-11-27 10:45:07 +00:00
|
|
|
fn setup(mut commands: Commands) {
|
|
|
|
commands.spawn(
|
2023-11-26 23:03:29 +00:00
|
|
|
Camera2dBundle {
|
|
|
|
camera: Camera {
|
2023-11-27 10:45:07 +00:00
|
|
|
hdr: true,
|
2023-11-26 23:03:29 +00:00
|
|
|
..default()
|
|
|
|
},
|
2023-11-27 12:59:14 +00:00
|
|
|
tonemapping: Tonemapping::TonyMcMapface,
|
2023-11-26 23:03:29 +00:00
|
|
|
..default()
|
2023-11-27 10:45:07 +00:00
|
|
|
}
|
2023-11-26 23:03:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-28 14:18:26 +00:00
|
|
|
fn setup_ui(
|
2023-11-27 12:59:14 +00:00
|
|
|
server: Res<AssetServer>,
|
|
|
|
mut commands: Commands
|
2023-11-26 23:03:29 +00:00
|
|
|
) {
|
2023-11-27 21:45:11 +00:00
|
|
|
let bold_font: Handle<Font> = server.load("fonts/VictorMono-Bold.otf");
|
|
|
|
let regular_font: Handle<Font> = server.load("fonts/VictorMono-Regular.otf");
|
2023-11-27 10:45:07 +00:00
|
|
|
|
2023-11-28 14:18:26 +00:00
|
|
|
let title_style = TextStyle {
|
|
|
|
font: bold_font.clone(),
|
|
|
|
font_size: 70.,
|
|
|
|
color: HYPERNOVA.get("WHITE").copied().unwrap(),
|
|
|
|
};
|
|
|
|
let login_style = TextStyle {
|
2023-11-27 21:45:11 +00:00
|
|
|
font: bold_font.clone(),
|
2023-11-28 14:18:26 +00:00
|
|
|
font_size: 30.,
|
|
|
|
color: HYPERNOVA.get("PURPLE").copied().unwrap(),
|
2023-11-27 10:45:07 +00:00
|
|
|
};
|
2023-11-28 14:18:26 +00:00
|
|
|
|
2023-11-27 21:45:11 +00:00
|
|
|
commands
|
|
|
|
.spawn(NodeBundle {
|
|
|
|
style: Style {
|
|
|
|
width: Val::Percent(100.),
|
2023-11-27 22:48:53 +00:00
|
|
|
height: Val::Percent(100.0),
|
2023-11-28 14:18:26 +00:00
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
..default()
|
2023-11-27 21:45:11 +00:00
|
|
|
},
|
2023-11-27 22:48:53 +00:00
|
|
|
background_color: BackgroundColor(HYPERNOVA.get("DARK_GRAY").copied().unwrap()),
|
2023-11-28 14:18:26 +00:00
|
|
|
..default()
|
2023-11-27 21:45:11 +00:00
|
|
|
})
|
2023-11-27 22:48:53 +00:00
|
|
|
.with_children(|parent| {
|
2023-11-28 14:18:26 +00:00
|
|
|
parent
|
|
|
|
.spawn(TextBundle::from_section("Ambition", title_style.clone())
|
|
|
|
.with_text_alignment(TextAlignment::Center)
|
|
|
|
.with_style(Style {
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
margin: UiRect {
|
|
|
|
top: Val::Vh(10.),
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
..default()
|
|
|
|
})
|
|
|
|
);
|
2023-11-27 22:48:53 +00:00
|
|
|
parent
|
|
|
|
.spawn(NodeBundle {
|
|
|
|
style: Style {
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
align_items: AlignItems::Center,
|
2023-11-28 14:18:26 +00:00
|
|
|
width: Val::Percent(50.),
|
|
|
|
height: Val::Percent(40.),
|
|
|
|
margin: UiRect {
|
|
|
|
top: Val::Vh(30.),
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
padding: UiRect {
|
|
|
|
top: Val::Percent(2.),
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
..default()
|
2023-11-27 22:48:53 +00:00
|
|
|
},
|
2023-11-28 14:18:26 +00:00
|
|
|
background_color: BackgroundColor(HYPERNOVA.get("GRAY").copied().unwrap()),
|
|
|
|
..default()
|
2023-11-27 22:48:53 +00:00
|
|
|
})
|
|
|
|
.with_children(|parent| {
|
|
|
|
parent
|
2023-11-28 14:18:26 +00:00
|
|
|
.spawn(TextBundle::from_section("Login", login_style.clone())
|
|
|
|
.with_text_alignment(TextAlignment::Center)
|
|
|
|
.with_style(Style {
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
..default()
|
|
|
|
}));
|
2023-11-27 22:48:53 +00:00
|
|
|
});
|
2023-11-28 14:18:26 +00:00
|
|
|
});
|
2023-11-26 23:03:29 +00:00
|
|
|
}
|