From 5925c4da0d9c0e40203531d2c0c61a653e10824b Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 6 Oct 2025 14:09:47 +0200 Subject: Remove edge style feature --- server/protocol/src/book.rs | 12 ------------ server/tools/src/diagram_dot.rs | 5 ++--- server/tools/src/diagram_svg.rs | 14 +++----------- server/tools/src/recipe_diagram.rs | 16 ++++++---------- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/server/protocol/src/book.rs b/server/protocol/src/book.rs index 1654e014..7c529f22 100644 --- a/server/protocol/src/book.rs +++ b/server/protocol/src/book.rs @@ -69,20 +69,8 @@ pub struct DiagramEdge { pub src: usize, pub dst: usize, pub label: Option, - pub style: EdgeStyle, } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum EdgeStyle { - Regular, - ProcessPassive, -} - -impl EdgeStyle { - pub fn is_regular(&self) -> bool { - matches!(self, Self::Regular) - } -} impl NodeStyle { pub fn is_procuct(&self) -> bool { matches!( diff --git a/server/tools/src/diagram_dot.rs b/server/tools/src/diagram_dot.rs index f86a2d4e..f5c4714b 100644 --- a/server/tools/src/diagram_dot.rs +++ b/server/tools/src/diagram_dot.rs @@ -27,7 +27,7 @@ use std::{ process::{Command, Stdio}, }; -use crate::diagram_svg::{edge_color, node_color}; +use crate::diagram_svg::node_color; pub fn diagram_dot_svg(data: &Gamedata, diagram: &Diagram) -> Result { let mut child = Command::new("dot") @@ -86,8 +86,7 @@ pub fn diagram_dot(data: &Gamedata, diagram: &Diagram, use_position: bool) -> Re writeln!(out, "k{i} [{}]", attrs.join(" "))?; } for edge in &diagram.edges { - let color = edge_color(edge); - writeln!(out, "k{} -> k{} [color=\"{color}\"]", edge.src, edge.dst)?; + writeln!(out, "k{} -> k{}", edge.src, edge.dst)?; } writeln!(out, "}}")?; Ok(out) diff --git a/server/tools/src/diagram_svg.rs b/server/tools/src/diagram_svg.rs index fe3d9de4..d006ce78 100644 --- a/server/tools/src/diagram_svg.rs +++ b/server/tools/src/diagram_svg.rs @@ -19,7 +19,7 @@ use anyhow::Result; use hurrycurry_protocol::{ Gamedata, Message, - book::{Diagram, DiagramEdge, DiagramNode, EdgeStyle, NodeStyle}, + book::{Diagram, DiagramNode, NodeStyle}, glam::Vec2, }; use std::fmt::Write; @@ -80,18 +80,16 @@ pub fn diagram_svg(data: &Gamedata, diagram: &Diagram) -> Result { let tip2 = dst + (dir + dir.perp() * -0.5) * 10.; dst += dir * 5.; // prevent miter line cap from peeking out - let color = edge_color(edge); - // line path writeln!( out, - r#""#, + r#""#, src.x, src.y, dst.x, dst.y, )?; // tip path writeln!( out, - r#""#, + r#""#, tip0.x, tip0.y, tip1.x, tip1.y, tip2.x, tip2.y )?; } @@ -121,12 +119,6 @@ pub(crate) fn node_color(node: &DiagramNode) -> &'static str { NodeStyle::ProcessInstant => "#5452d8", } } -pub(crate) fn edge_color(edge: &DiagramEdge) -> &'static str { - match edge.style { - EdgeStyle::Regular => "#000000", - EdgeStyle::ProcessPassive => "#c4a32b", - } -} fn image_node(out: &mut String, node: &DiagramNode, path: String) -> Result<()> { if matches!( diff --git a/server/tools/src/recipe_diagram.rs b/server/tools/src/recipe_diagram.rs index 903b869a..b463e3b6 100644 --- a/server/tools/src/recipe_diagram.rs +++ b/server/tools/src/recipe_diagram.rs @@ -19,7 +19,7 @@ use anyhow::Result; use hurrycurry_protocol::{ Gamedata, ItemIndex, Message, Recipe, RecipeIndex, - book::{Diagram, DiagramEdge, DiagramNode, EdgeStyle, NodeStyle}, + book::{Diagram, DiagramEdge, DiagramNode, NodeStyle}, glam::Vec2, }; use hurrycurry_server::data::Serverdata; @@ -104,7 +104,6 @@ pub(crate) fn recipe_diagram( src: item_index[&i], dst: item_index[&r.outputs[0]], label: None, - style: EdgeStyle::Regular, }); } continue; @@ -113,11 +112,11 @@ pub(crate) fn recipe_diagram( && r.inputs.len() == 1 && r.outputs.len() == 1 { + diag.nodes[item_index[&r.inputs[0]]].style = NodeStyle::ProcessPassive; diag.edges.push(DiagramEdge { src: item_index[&r.inputs[0]], dst: item_index[&r.outputs[0]], label: None, - style: EdgeStyle::ProcessPassive, }); continue; } @@ -142,7 +141,6 @@ pub(crate) fn recipe_diagram( src: item_index[&i], dst: index, label: None, - style: EdgeStyle::Regular, }); } for o in r.outputs { @@ -150,7 +148,6 @@ pub(crate) fn recipe_diagram( src: index, dst: item_index[&o], label: None, - style: EdgeStyle::Regular, }); } } @@ -188,10 +185,10 @@ fn merge_combine_clusters(diag: &mut Diagram) { if outputs .iter() - .all(|&(ei, ni)| diag.nodes[ni].style.is_procuct() && diag.edges[ei].style.is_regular()) - && inputs.iter().all(|&(ei, ni)| { - diag.nodes[ni].style.is_procuct() && diag.edges[ei].style.is_regular() - }) + .all(|&(ei, ni)| diag.nodes[ni].style.is_procuct()) + && inputs + .iter() + .all(|&(ei, ni)| diag.nodes[ni].style.is_procuct()) { let mut to_remove = inputs .iter() @@ -214,7 +211,6 @@ fn merge_combine_clusters(diag: &mut Diagram) { src: input.1, dst: output.1, label: None, - style: EdgeStyle::Regular, }); } } -- cgit v1.2.3-70-g09d2