pub struct BookRenderer {
pub book: Book,
pub state: BookViewState,
pub theme: BookTheme,
pub ui: Option<UiRoot>,
/* private fields */
}Fields§
§book: Book§state: BookViewState§theme: BookTheme§ui: Option<UiRoot>Implementations§
Source§impl BookRenderer
impl BookRenderer
pub fn new(book: Book) -> BookRenderer
Sourcepub fn set_translator(&mut self, tr: fn(&str) -> Option<String>)
pub fn set_translator(&mut self, tr: fn(&str) -> Option<String>)
The game’s translations: items’ names in recipe titles, and, for
Book::i18n books, the book’s texts — translation keys, looked up
with tr (unknown keys stay as they are) and re-looked up whenever
the language changes.
pub fn handle_event(&mut self, ev: &str)
Sourcepub fn add_recipe(&mut self, id: impl Into<String>, recipe: &Value)
pub fn add_recipe(&mut self, id: impl Into<String>, recipe: &Value)
Register a recipe (Yog’s recipe, as Yog Data) so recipe pages can render it visually. Unknown recipe types are ignored.
Sourcepub fn render(&mut self, ctx: &GfxContext, sw: f32, sh: f32)
pub fn render(&mut self, ctx: &GfxContext, sw: f32, sh: f32)
Draws the book into a sw×sh screen — all of it through
draw2d (its sprite sheets as the image sources BOOK_SHEET and
CRAFTING_SHEET).
Draws the book; mods’ pictures (BookPage::Drawn) are left empty —
see BookRenderer::render_with.
Sourcepub fn render_with(
&mut self,
ctx: &GfxContext,
sw: f32,
sh: f32,
draw: &mut dyn FnMut(&GfxContext, &str, &Value, [f32; 4]),
)
pub fn render_with( &mut self, ctx: &GfxContext, sw: f32, sh: f32, draw: &mut dyn FnMut(&GfxContext, &str, &Value, [f32; 4]), )
Draws the book, mods’ pictures with draw(ctx, drawer, data, [x, y, w, h]) (screen pixels) — the game calls the mod that registered
drawer.
Sourcepub fn animated(&self) -> bool
pub fn animated(&self) -> bool
The page shown moves by itself (an entity, a structure, an ingredient’s alternatives): the host should keep redrawing it.
Sourcepub fn click(&mut self, x: f32, y: f32) -> Option<String>
pub fn click(&mut self, x: f32, y: f32) -> Option<String>
A click at (x, y) (screen GUI pixels, as last rendered): what it
hit does its thing. The action it was ("next_page", "entry:3",
…), if any.
Sourcepub fn show(&mut self, entry: &str, page: usize) -> bool
pub fn show(&mut self, entry: &str, page: usize) -> bool
Shows entry (an entry id) at page — its page as written, not
counting the pages long text flowed onto — as a reader would have
got there; false if there’s no such entry.
Auto Trait Implementations§
impl Freeze for BookRenderer
impl RefUnwindSafe for BookRenderer
impl Send for BookRenderer
impl Sync for BookRenderer
impl Unpin for BookRenderer
impl UnsafeUnpin for BookRenderer
impl UnwindSafe for BookRenderer
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.