diff --git a/src/config.rs b/src/config.rs index 46a509d..4bbb3b6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,7 @@ use bevy::prelude::*; +use crate::palette; + // tile pub const TILE_SIZE: f32 = 100.0; pub const TILE_SPACING: f32 = 10.0; @@ -16,12 +18,5 @@ pub const TILE_SOUND_T: &str = "sounds/letters/t.ogg"; pub const SPLASH_SCREEN_DURATION: f32 = 1.0; // game/menu screen -pub const WALL_COLOR: Color = Color::rgb(1.0, 1.0, 1.0); +pub const WALL_COLOR: Color = palette::WHITE; pub const WALL_THICKNESS: f32 = 4.0; - -// buttons -pub const NORMAL_BUTTON: Color = Color::rgb(0.16, 0.17, 0.18); -pub const HOVERED_BUTTON: Color = Color::rgb(0.20, 0.21, 0.22); -pub const PRESSED_BUTTON: Color = Color::rgb(1.0, 0.56, 0.0); -pub const BUTTON_BORDER_COLOR: Color = Color::rgb(1.0, 1.0, 1.0); -pub const PRESSED_BUTTON_BORDER_COLOR: Color = Color::rgb(1.0, 1.0, 1.0); diff --git a/src/game/ui/button.rs b/src/game/ui/button.rs index f49e54e..528b367 100644 --- a/src/game/ui/button.rs +++ b/src/game/ui/button.rs @@ -1,6 +1,12 @@ use bevy::prelude::*; -use crate::config; +use crate::palette; + +pub const NORMAL_BUTTON: Color = palette::SLATE_800; +pub const HOVERED_BUTTON: Color = palette::PURPLE_400; +pub const PRESSED_BUTTON: Color = palette::PURPLE_500; +pub const BUTTON_BORDER_COLOR: Color = palette::WHITE; +pub const PRESSED_BUTTON_BORDER_COLOR: Color = palette::WHITE; #[derive(Component)] pub struct Shortcut(pub KeyCode); @@ -39,16 +45,16 @@ fn button_system( for (interaction, mut color, mut border_color) in &mut query { match *interaction { Interaction::Pressed => { - *color = config::PRESSED_BUTTON.into(); - border_color.0 = config::BUTTON_BORDER_COLOR; + *color = PRESSED_BUTTON.into(); + border_color.0 = BUTTON_BORDER_COLOR; } Interaction::Hovered => { - *color = config::HOVERED_BUTTON.into(); - border_color.0 = config::BUTTON_BORDER_COLOR; + *color = HOVERED_BUTTON.into(); + border_color.0 = BUTTON_BORDER_COLOR; } Interaction::None => { - *color = config::NORMAL_BUTTON.into(); - border_color.0 = config::BUTTON_BORDER_COLOR; + *color = NORMAL_BUTTON.into(); + border_color.0 = BUTTON_BORDER_COLOR; } } } @@ -60,13 +66,13 @@ fn button_shortcut_system( ) { for (mut color, mut border_color, shortcut) in &mut query { if keyboard_input.pressed(shortcut.0) { - *color = config::PRESSED_BUTTON.into(); - border_color.0 = config::PRESSED_BUTTON_BORDER_COLOR; + *color = PRESSED_BUTTON.into(); + border_color.0 = PRESSED_BUTTON_BORDER_COLOR; } if keyboard_input.just_released(shortcut.0) { - *color = config::NORMAL_BUTTON.into(); - border_color.0 = config::BUTTON_BORDER_COLOR; + *color = NORMAL_BUTTON.into(); + border_color.0 = BUTTON_BORDER_COLOR; } } } diff --git a/src/game/ui/mod.rs b/src/game/ui/mod.rs index 1cf3a01..a35ed5b 100644 --- a/src/game/ui/mod.rs +++ b/src/game/ui/mod.rs @@ -1,10 +1,7 @@ use bevy::prelude::*; use bevy_egui::{egui, EguiContexts}; -use crate::{ - config, - state::{AppState, OnGameScreen}, -}; +use crate::state::{AppState, OnGameScreen}; use self::button::{GameButtonBundle, Shortcut}; @@ -54,8 +51,8 @@ pub fn setup(mut commands: Commands, asset_server: Res, settings: R align_items: AlignItems::Center, ..default() }, - border_color: config::BUTTON_BORDER_COLOR.into(), - background_color: config::NORMAL_BUTTON.into(), + border_color: button::BUTTON_BORDER_COLOR.into(), + background_color: button::NORMAL_BUTTON.into(), ..default() }, shortcut: Shortcut(KeyCode::KeyA), @@ -86,8 +83,8 @@ pub fn setup(mut commands: Commands, asset_server: Res, settings: R align_items: AlignItems::Center, ..default() }, - border_color: config::BUTTON_BORDER_COLOR.into(), - background_color: config::NORMAL_BUTTON.into(), + border_color: button::BUTTON_BORDER_COLOR.into(), + background_color: button::NORMAL_BUTTON.into(), ..default() }, shortcut: Shortcut(KeyCode::KeyS), @@ -118,8 +115,8 @@ pub fn setup(mut commands: Commands, asset_server: Res, settings: R align_items: AlignItems::Center, ..default() }, - border_color: config::BUTTON_BORDER_COLOR.into(), - background_color: config::NORMAL_BUTTON.into(), + border_color: button::BUTTON_BORDER_COLOR.into(), + background_color: button::NORMAL_BUTTON.into(), ..default() }, shortcut: Shortcut(KeyCode::KeyD), diff --git a/src/main.rs b/src/main.rs index eebc150..934edf9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,8 @@ use bevy_asset_loader::loading_state::{ use bevy_egui::EguiPlugin; use bevy_kira_audio::AudioPlugin; use nback::{ - asset::AudioAssets, game::GamePlugin, menu::MenuPlugin, splash::SplashPlugin, state::AppState, + asset::AudioAssets, game::GamePlugin, menu::MenuPlugin, palette, splash::SplashPlugin, + state::AppState, }; fn main() { @@ -16,6 +17,7 @@ fn main() { .continue_to_state(AppState::Menu) .load_collection::(), ) + .insert_resource(ClearColor(palette::SLATE_800)) .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { resolution: WindowResolution::new(1280., 720.),