pub struct Renderer<'a> {
roots: Vec<EntryPoint<'a>>,
depth_map: HashMap<EntityRef, usize>,
path: &'a Path,
data: &'a GameData,
grapher: Option<&'a Grapher>,
state: &'a GameState,
initial_depth: usize,
}
Expand description
A struct that renders objects into html pages. It is meant to be used as a worker object that collects objects and renders them all at once. The objects are rendered in a BFS order, with the depth of the objects being determined by the BFS algorithm.
Fields§
§roots: Vec<EntryPoint<'a>>
§depth_map: HashMap<EntityRef, usize>
§path: &'a Path
The path where the objects will be rendered to. This usually takes the form of ’./{username}‘s history/’.
data: &'a GameData
The loaded game data object.
grapher: Option<&'a Grapher>
The grapher object, if it exists. It may be utilized during the rendering process to render a variety of graphs.
state: &'a GameState
The game state object. It is used to access the game state during rendering, especially for gathering of data for rendering of optional graphs.
initial_depth: usize
Implementations§
Source§impl<'a> Renderer<'a>
impl<'a> Renderer<'a>
Sourcepub fn new(
path: &'a Path,
state: &'a GameState,
data: &'a GameData,
grapher: Option<&'a Grapher>,
initial_depth: usize,
) -> Self
pub fn new( path: &'a Path, state: &'a GameState, data: &'a GameData, grapher: Option<&'a Grapher>, initial_depth: usize, ) -> Self
Create a new Renderer. create_dir_maybe is called on the path to ensure that the directory exists, and the subdirectories are created.
§Arguments
path
- The root path where the objects will be rendered to. Usually takes the form of ’./{username}‘s history/’.state
- The game state object.game_map
- The game map object, if it exists.grapher
- The grapher object, if it exists.initial_depth
- The initial depth of the objects that are added to the renderer.
§Returns
A new Renderer object.
Sourcefn render<T: Renderable, D: Deref<Target = T>>(
&self,
obj: D,
env: &Environment<'_>,
)
fn render<T: Renderable, D: Deref<Target = T>>( &self, obj: D, env: &Environment<'_>, )
Renders the Renderable object.
Sourcefn render_enum(&self, obj: &RenderableType, env: &Environment<'_>)
fn render_enum(&self, obj: &RenderableType, env: &Environment<'_>)
Renders the RenderableType object.
Sourcepub fn add_object<G: GameObjectDerived + Renderable>(
&mut self,
obj: &'a G,
) -> usize
pub fn add_object<G: GameObjectDerived + Renderable>( &mut self, obj: &'a G, ) -> usize
Adds an object to the renderer, and returns the number of objects that were added. This method uses a BFS algorithm to determine the depth of the object.
Sourcepub fn render_all(self, env: &mut Environment<'_>) -> usize
pub fn render_all(self, env: &mut Environment<'_>) -> usize
Auto Trait Implementations§
impl<'a> Freeze for Renderer<'a>
impl<'a> !RefUnwindSafe for Renderer<'a>
impl<'a> !Send for Renderer<'a>
impl<'a> !Sync for Renderer<'a>
impl<'a> Unpin for Renderer<'a>
impl<'a> !UnwindSafe for Renderer<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more