working on making the loading screen load a texture

This commit is contained in:
Evan Pratten 2021-09-30 09:47:07 -04:00
parent f0c6444f33
commit 76a94edde9
4 changed files with 31 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -75,10 +75,15 @@ use raylib::prelude::*;
use tracing::{error, info};
use utilities::discord::DiscordConfig;
use crate::{context::GameContext, discord_rpc::{maybe_set_discord_presence, try_connect_to_local_discord}, scenes::{Scenes, build_screen_state_machine}, utilities::shaders::{
use crate::{
context::GameContext,
discord_rpc::{maybe_set_discord_presence, try_connect_to_local_discord},
scenes::{build_screen_state_machine, Scenes},
utilities::shaders::{
shader::ShaderWrapper,
util::{dynamic_screen_texture::DynScreenTexture, render_texture::render_to_texture},
}};
},
};
#[macro_use]
extern crate thiserror;
@ -124,10 +129,6 @@ pub async fn game_begin(game_config: &GameConfig) -> Result<(), Box<dyn std::err
.await
.unwrap();
// Get the main state machine
let mut game_state_machine = build_screen_state_machine().unwrap();
game_state_machine.force_change_state(Scenes::LoadingScreen).unwrap();
let context;
let raylib_thread;
{
@ -149,6 +150,14 @@ pub async fn game_begin(game_config: &GameConfig) -> Result<(), Box<dyn std::err
context = Box::new(GameContext::new(RefCell::new(rl.into())));
}
// Get the main state machine
info!("Setting up the scene management state machine");
let mut game_state_machine =
build_screen_state_machine(&context.renderer.borrow_mut(), &raylib_thread).unwrap();
game_state_machine
.force_change_state(Scenes::LoadingScreen)
.unwrap();
// Create a dynamic texture to draw to for processing by shaders
info!("Allocating a SNOWZ7Zresizable texture for the screen");
let mut dynamic_texture =

View File

@ -1,7 +1,11 @@
use chrono::{DateTime, Utc};
use dirty_fsm::{Action, ActionFlag};
use raylib::RaylibThread;
use crate::{context::GameContext, utilities::render_layer::ScreenSpaceRender};
use crate::{
context::GameContext,
utilities::{non_ref_raylib::HackedRaylibHandle, render_layer::ScreenSpaceRender},
};
use super::{Scenes, ScreenError};
use tracing::{debug, info, trace};
@ -16,7 +20,13 @@ pub struct LoadingScreen {
impl LoadingScreen {
/// Construct a new `LoadingScreen`
pub fn new() -> Self {
pub fn new(raylib_handle: &HackedRaylibHandle, thread: &RaylibThread) -> Self {
// Load the game logo asset
// TODO: in-memory texture loading
// raylib_handle.load_texture_from_image(, image)
Self {
start_timestamp: None,
}
@ -78,8 +88,5 @@ impl ScreenSpaceRender for LoadingScreen {
// Calculate the loading screen fade in/out value
// This makes the loading screen fade in/out over the duration of the loading screen
}
}

View File

@ -1,5 +1,6 @@
use dirty_fsm::StateMachine;
use crate::context::GameContext;
use raylib::RaylibThread;
use crate::{context::GameContext, utilities::non_ref_raylib::HackedRaylibHandle};
use self::{fsm_error_screen::FsmErrorScreen, loading_screen::LoadingScreen};
pub mod fsm_error_screen;
@ -18,13 +19,13 @@ pub enum Scenes {
pub enum ScreenError {}
/// Build the state machine for all scenes
pub fn build_screen_state_machine() -> Result<
pub fn build_screen_state_machine(raylib_handle: &HackedRaylibHandle, thread: &RaylibThread) -> Result<
// StateMachine<Scenes, ScreenError, RefCell<(NonRefDrawHandle, Rc<RefCell<GameContext>>)>>,
StateMachine<Scenes, ScreenError, GameContext>,
ScreenError,
> {
let mut machine = StateMachine::new();
machine.add_action(Scenes::FsmErrorScreen, FsmErrorScreen::new())?;
machine.add_action(Scenes::LoadingScreen, LoadingScreen::new())?;
machine.add_action(Scenes::LoadingScreen, LoadingScreen::new(raylib_handle, thread))?;
Ok(machine)
}