Skip to content

Commit

Permalink
It's beginning to look a lot like xmas. haha
Browse files Browse the repository at this point in the history
  • Loading branch information
abuteler committed Jul 18, 2024
1 parent 17d872c commit 375e653
Show file tree
Hide file tree
Showing 11 changed files with 404 additions and 114 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "micronos"
name = "micronos" #Time-hold?
version = "0.2.0"
authors = ["Alejandro R. Buteler <[email protected]>"]
edition = "2021"
Expand Down
3 changes: 0 additions & 3 deletions src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ use bevy::prelude::*;

#[derive(Component)]
pub struct ResolutionText;

#[derive(Component)]
pub struct CurrentTimeText;
10 changes: 3 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use bevy::{
},
winit::WinitSettings,
};
use micronos::{plugins::Timeline, resources::ChronoSphere, systems::print_chrono_sphere};
use micronos::{plugins::Timeline, resources::ChronoSphere};

fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "micronos".into(),
name: Some("micronos".into()),
resolution: WindowResolution::new(700., 208.).with_scale_factor_override(1.0),
resolution: WindowResolution::new(850., 450.).with_scale_factor_override(1.0),
window_theme: Some(WindowTheme::Dark),
decorations: true,
transparent: true,
Expand All @@ -33,15 +33,11 @@ fn main() {
.insert_resource(ChronoSphere::new())
.add_plugins(Timeline)
.add_systems(Startup, setup_camera)
.add_systems(Update, print_chrono_sphere)
// .add_systems(Update, print_chrono_sphere)
.run();
}

// Spawns the camera that draws UI
fn setup_camera(mut cmd: Commands) {
cmd.spawn(Camera2dBundle::default());
}

fn _toggle_window_decorations(mut window: Query<&mut Window>) {
window.single_mut().decorations = !window.single_mut().decorations;
}
111 changes: 111 additions & 0 deletions src/plugins/timeline/components/hour.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
use std::fmt;
use bevy::prelude::*;

#[derive(Debug)]
pub enum Hour {
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Eleven,
Twelve,
Thirteen,
Fourteen,
Fifteen,
Sixteen,
Seventeen,
Eighteen,
Nineteen,
Twenty,
TwentyOne,
TwentyTwo,
TwentyThree
}

impl Hour {
pub const VALUES: [Self; 24] = [
Self::Zero,
Self::One,
Self::Two,
Self::Three,
Self::Four,
Self::Five,
Self::Six,
Self::Seven,
Self::Eight,
Self::Nine,
Self::Ten,
Self::Eleven,
Self::Twelve,
Self::Thirteen,
Self::Fourteen,
Self::Fifteen,
Self::Sixteen,
Self::Seventeen,
Self::Eighteen,
Self::Nineteen,
Self::Twenty,
Self::TwentyOne,
Self::TwentyTwo,
Self::TwentyThree
];
}

impl fmt::Display for Hour {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
match self {
Self::Zero => "00",
Self::One => "01",
Self::Two => "02",
Self::Three => "03",
Self::Four => "04",
Self::Five => "05",
Self::Six => "06",
Self::Seven => "07",
Self::Eight => "08",
Self::Nine => "09",
Self::Ten => "10",
Self::Eleven => "11",
Self::Twelve => "12",
Self::Thirteen => "13",
Self::Fourteen => "14",
Self::Fifteen => "15",
Self::Sixteen => "16",
Self::Seventeen => "17",
Self::Eighteen => "18",
Self::Nineteen => "19",
Self::Twenty => "20",
Self::TwentyOne => "21",
Self::TwentyTwo => "22",
Self::TwentyThree => "23",
}
)
}
}

#[derive(Component)]
pub struct HourBox {
pub hour: Hour,
pub active: bool,
}
impl HourBox {
pub fn new(hour: Hour, active: bool) -> Self {
Self {
hour,
active,
}
}
}

#[derive(Component)]
pub struct CurrentTimeText;
7 changes: 7 additions & 0 deletions src/plugins/timeline/components/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub mod hour;

pub use hour::{
Hour,
HourBox,
CurrentTimeText
};
10 changes: 7 additions & 3 deletions src/plugins/timeline/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
mod resources;
pub mod components;
pub mod resources;
mod systems;
use systems::layout::spawn_ui;

use systems::layout::spawn_ui;
use resources::TimelineAssets;
use bevy::prelude::*;

pub struct Timeline;

impl Plugin for Timeline {
fn build(&self, app: &mut App) {
app.insert_resource(TimelineAssets::default());
app.add_systems(Startup, spawn_ui);
app.add_systems(Update, crate::systems::print_chrono_sphere);
}
}
}
6 changes: 6 additions & 0 deletions src/plugins/timeline/resources.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use bevy::prelude::*;

#[derive(Resource, Default)]
pub struct TimelineAssets {
pub background_handle: Option<Handle<Image>>,
}
Loading

0 comments on commit 375e653

Please sign in to comment.