aboutsummaryrefslogtreecommitdiff
path: root/server/tools/src/recipe_diagram.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-09-26 17:34:24 +0200
committermetamuffin <metamuffin@disroot.org>2025-09-27 00:55:23 +0200
commitcb434ae50fe7b0ad5df4b600da062623a272ba59 (patch)
tree71ed96fd72d5075199d42104e11b9491baf81e19 /server/tools/src/recipe_diagram.rs
parentfd7c0cf155760353b877c1f1551e872e1aca0401 (diff)
downloadhurrycurry-cb434ae50fe7b0ad5df4b600da062623a272ba59.tar
hurrycurry-cb434ae50fe7b0ad5df4b600da062623a272ba59.tar.bz2
hurrycurry-cb434ae50fe7b0ad5df4b600da062623a272ba59.tar.zst
diagram dot output
Diffstat (limited to 'server/tools/src/recipe_diagram.rs')
-rw-r--r--server/tools/src/recipe_diagram.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/server/tools/src/recipe_diagram.rs b/server/tools/src/recipe_diagram.rs
index 7dc42c1e..453fedc6 100644
--- a/server/tools/src/recipe_diagram.rs
+++ b/server/tools/src/recipe_diagram.rs
@@ -18,7 +18,7 @@
use anyhow::Result;
use hurrycurry_protocol::{
- Gamedata, ItemIndex, Message, RecipeIndex,
+ Gamedata, ItemIndex, Message, Recipe, RecipeIndex,
book::{Diagram, DiagramEdge, DiagramNode},
glam::Vec2,
};
@@ -84,16 +84,31 @@ pub(crate) fn recipe_diagram(
diag.nodes.push(DiagramNode {
label: Message::Item(i),
position: Vec2::ZERO,
+ color: None,
+ shape: None,
});
}
for r in recipes {
let index = diag.nodes.len();
+ let recipe = data.recipe(r.index);
+ let (kind, color) = match recipe {
+ Recipe::Passive { .. } => ("Passive", "#c4a32b"),
+ Recipe::Active { .. } => ("Active", "#47c42b"),
+ Recipe::Instant { .. } => ("Instant", "#5452d8"),
+ };
diag.nodes.push(DiagramNode {
position: Vec2::ZERO,
- label: Message::Text("blub".to_string()),
+ label: Message::Text(if let Some(tile) = recipe.tile() {
+ format!("{kind} on {}", data.tile_name(tile))
+ } else {
+ format!("{kind}")
+ }),
+ color: Some(color.to_string()),
+ shape: Some("box".to_string()),
});
for i in r.inputs {
+ eprintln!("{}", data.item_name(i));
diag.edges.push(DiagramEdge {
src: item_index[&i],
dst: index,