pub mod layout_picture;
pub mod markup;
pub mod recipe_area;
pub mod renderer;
pub mod state;
pub mod theme;
use yog_formats::book::BookEntry;
pub use renderer::{BOOK_PNG, BOOK_SHEET, BookRenderer, CRAFTING_PNG, CRAFTING_SHEET, LANG, PageDrawer};
pub use state::BookViewState;
pub use theme::BookTheme;
static UNLOCKED: std::sync::OnceLock<fn(&str) -> bool> = std::sync::OnceLock::new();
pub fn set_unlocked(check: fn(&str) -> bool) {
let _ = UNLOCKED.set(check);
}
static TAG_ITEMS: std::sync::OnceLock<fn(&str) -> Vec<String>> = std::sync::OnceLock::new();
pub fn set_tag_items(items: fn(&str) -> Vec<String>) {
let _ = TAG_ITEMS.set(items);
}
pub fn ingredient_items(ingredient: &[String]) -> Vec<String> {
let mut out = Vec::new();
for i in ingredient {
match i.strip_prefix(yog_ids::sep::TAG_SHOWN) {
Some(tag) => out.extend(TAG_ITEMS.get().map(|f| f(tag)).unwrap_or_default()),
None => out.push(i.clone()),
}
}
out
}
pub fn shown(entry: &BookEntry) -> bool {
!entry.secret && entry.advancement.as_deref().is_none_or(|a| UNLOCKED.get().is_none_or(|check| check(a)))
}