/* Hurry Curry! - a game about cooking Copyright (C) 2025 Hurry Curry! Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License only. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ use hurrycurry_protocol::{ Gamedata, Message, book::{Book, BookPage, Diagram}, }; pub fn render_html_book(data: &Gamedata, book: &Book) -> String { BookR { book, data }.to_string() } markup::define! { BookR<'a>(data: &'a Gamedata, book: &'a Book) { @markup::doctype() html { head { style { @include_str!("book_html.css") } title { "Recipe Book - Hurry Curry!" } } body { @for page in &book.pages { @PageR { data, page } } } } } PageR<'a>(data: &'a Gamedata, page: &'a BookPage) { section.pagegroup { @match page { BookPage::Cover => { div.page {} div.page {} } BookPage::Recipe { description, instruction, diagram } => { div.page { p { @MessageR { data, message: description } } p { @MessageR { data, message: instruction } } } div.page { @DiagramR { data, diagram } } } BookPage::Text { .. } => { div.page {} div.page {} } BookPage::Contents { .. } => { div.page {} div.page {} } } } } MessageR<'a>(data: &'a Gamedata, message: &'a Message) { @match message { Message::Translation { id, params } => {} Message::Text(t) => { @t } Message::Item(i) => { @data.item_name(*i) } Message::Tile(i) => { @data.tile_name(*i) } } } DiagramR<'a>(data: &'a Gamedata, diagram: &'a Diagram) { div.diagram[style="position: absolute;"] { @for node in &diagram.nodes { div.node[style=format!("position: relative; left: {}px; top: {}px;", node.position.x, 350. - node.position.y / 2.)] { @MessageR { data, message: &node.label } } } @for edge in &diagram.edges { } } } }