aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-10-06 14:09:47 +0200
committermetamuffin <metamuffin@disroot.org>2025-10-06 14:09:47 +0200
commit5925c4da0d9c0e40203531d2c0c61a653e10824b (patch)
tree4955bf99814d150664995f64e70bac709d0f08c1
parenta5814a2a81c0ea7bcf6d56626ff7167af78d63a6 (diff)
downloadhurrycurry-5925c4da0d9c0e40203531d2c0c61a653e10824b.tar
hurrycurry-5925c4da0d9c0e40203531d2c0c61a653e10824b.tar.bz2
hurrycurry-5925c4da0d9c0e40203531d2c0c61a653e10824b.tar.zst
Remove edge style feature
-rw-r--r--server/protocol/src/book.rs12
-rw-r--r--server/tools/src/diagram_dot.rs5
-rw-r--r--server/tools/src/diagram_svg.rs14
-rw-r--r--server/tools/src/recipe_diagram.rs16
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<Message>,
- 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<String> {
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<String> {
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#"<path fill="none" stroke="{color}" stroke-width="2" d="M{} {} L{} {}" />"#,
+ r#"<path fill="none" stroke="black" stroke-width="2" d="M{} {} L{} {}" />"#,
src.x, src.y, dst.x, dst.y,
)?;
// tip path
writeln!(
out,
- r#"<path fill="{color}" stroke="none" d="M{} {} L{} {} L{} {} Z" />"#,
+ r#"<path fill="black" stroke="none" d="M{} {} L{} {} L{} {} Z" />"#,
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,
});
}
}