working on loading screen
This commit is contained in:
parent
de4491c9f3
commit
e950489081
@ -1,28 +1,62 @@
|
||||
use dirty_fsm::Action;
|
||||
use chrono::{DateTime, Utc};
|
||||
use dirty_fsm::{Action, ActionFlag};
|
||||
|
||||
use crate::context::GameContext;
|
||||
use crate::{context::GameContext, gfx::render_layer::ScreenSpaceRender};
|
||||
|
||||
use super::{Scenes, ScreenError};
|
||||
use tracing::{debug, error, info, trace};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LoadingScreen {
|
||||
start_timestamp: Option<DateTime<Utc>>
|
||||
}
|
||||
|
||||
impl LoadingScreen {
|
||||
/// Construct a new LoadingScreen
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
start_timestamp: None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Action<Scenes, ScreenError, GameContext> for LoadingScreen {
|
||||
fn on_register(&mut self) -> Result<(), ScreenError> {
|
||||
todo!()
|
||||
debug!("Registered");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_first_run(&mut self, context: &mut GameContext) -> Result<(), ScreenError> {
|
||||
todo!()
|
||||
fn on_first_run(&mut self, context: &GameContext) -> Result<(), ScreenError> {
|
||||
debug!("Running LoadingScreen for the first time");
|
||||
|
||||
// Keep track of when this screen is opened
|
||||
self.start_timestamp = Some(Utc::now());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn execute(&mut self, delta: &chrono::Duration, context: &mut GameContext) -> Result<dirty_fsm::ActionFlag<Scenes>, ScreenError> {
|
||||
todo!()
|
||||
fn execute(
|
||||
&mut self,
|
||||
delta: &chrono::Duration,
|
||||
context: &GameContext,
|
||||
) -> Result<dirty_fsm::ActionFlag<Scenes>, ScreenError> {
|
||||
trace!("execute() called on LoadingScreen");
|
||||
self.render_screen_space(&mut context.renderer.borrow_mut());
|
||||
Ok(ActionFlag::Continue)
|
||||
}
|
||||
|
||||
fn on_finish(&mut self, interrupted: bool) -> Result<(), ScreenError> {
|
||||
debug!("Finished LoadingScreen");
|
||||
|
||||
// Reset the start timestamp
|
||||
self.start_timestamp = None;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ScreenSpaceRender for LoadingScreen {
|
||||
fn render_screen_space(&self, raylib: &mut crate::utilities::non_ref_raylib::HackedRaylibHandle) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,9 @@
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
cell::{Cell, RefCell, RefMut},
|
||||
rc::Rc,
|
||||
};
|
||||
|
||||
use dirty_fsm::{Action, StateMachine};
|
||||
use raylib::{
|
||||
prelude::{RaylibDraw, RaylibDrawHandle},
|
||||
RaylibHandle,
|
||||
};
|
||||
|
||||
use crate::{context::GameContext, gfx::render_layer::{FrameUpdate, ScreenSpaceRender, WorldSpaceRender}, utilities::non_ref_raylib::HackedRaylibHandle};
|
||||
|
||||
use self::fsm_error_screen::FsmErrorScreen;
|
||||
use dirty_fsm::StateMachine;
|
||||
use crate::context::GameContext;
|
||||
use self::{fsm_error_screen::FsmErrorScreen, loading_screen::LoadingScreen};
|
||||
|
||||
pub mod fsm_error_screen;
|
||||
// pub mod loading_screen;
|
||||
|
||||
/// Data passed to all scenes upon render
|
||||
// pub type RenderContext<'a, 'b> = (&'b mut RaylibDrawHandle<'a>, &'b mut GameContext);
|
||||
pub mod loading_screen;
|
||||
|
||||
/// Defines all scenes
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash)]
|
||||
@ -40,5 +25,6 @@ pub fn build_screen_state_machine() -> Result<
|
||||
> {
|
||||
let mut machine = StateMachine::new();
|
||||
machine.add_action(Scenes::FsmErrorScreen, FsmErrorScreen::new())?;
|
||||
machine.add_action(Scenes::LoadingScreen, LoadingScreen::new())?;
|
||||
Ok(machine)
|
||||
}
|
||||
|
Reference in New Issue
Block a user