diff --git a/README.md b/README.md index a78dc5c..8df3fcc 100644 --- a/README.md +++ b/README.md @@ -401,6 +401,8 @@ some ops make a circle do things to its targets. like `process`, `del_targets`, - when color changes, set the color of the selection lasso circle (and draw mode indicator) - `connection_color` - when color changes, set the color of connection arrows +- `connection_width` + - when this circle's num changes, set the width of the connection arrows - `connecting_line_color` - when color changes, set the connect mode indicator - `command_color` diff --git a/src/components.rs b/src/components.rs index 1401bb8..6e97a2d 100644 --- a/src/components.rs +++ b/src/components.rs @@ -237,6 +237,10 @@ pub struct ConnectionColor(pub Color); #[reflect(Resource)] pub struct CommandColor(pub Color); +#[derive(Resource, Reflect, Default)] +#[reflect(Resource)] +pub struct ConnectionWidth(pub f32); + #[derive(Resource)] pub struct DefaultLT(pub (i8, i8)); diff --git a/src/connections.rs b/src/connections.rs index 76e2244..86783b5 100644 --- a/src/connections.rs +++ b/src/connections.rs @@ -174,6 +174,7 @@ pub fn update_connection_arrows( trans_query: Query<&Transform, With>, mut arrow_trans: Query<&mut Transform, Without>, arrow_query: Query<&ConnectionArrow>, + connection_width: Res, ) { for (id, bh) in bh_query.iter() { if wh_query.contains(bh.wh) { continue; } @@ -189,7 +190,7 @@ pub fn update_connection_arrows( let f = bh_trans + bh_radius * norm; *arrow_trans.get_mut(arrow_id.0).unwrap() = Transform { translation: ((i+f) / 2.).extend(100.), - scale: Vec3::new(4., wh_trans.distance(bh_trans) - (bh_radius + wh_radius), 1.), + scale: Vec3::new(connection_width.0, wh_trans.distance(bh_trans) - (bh_radius + wh_radius), 1.), rotation: Quat::from_rotation_z(perp.to_angle()), }; } @@ -208,7 +209,7 @@ pub fn update_connection_arrows( let f = bh_trans + bh_radius * norm; *arrow_trans.get_mut(arrow_id.0).unwrap() = Transform { translation: ((i+f) / 2.).extend(100.), - scale: Vec3::new(4., wh_trans.distance(bh_trans) - (bh_radius + wh_radius), 1.), + scale: Vec3::new(connection_width.0, wh_trans.distance(bh_trans) - (bh_radius + wh_radius), 1.), rotation: Quat::from_rotation_z(perp.to_angle()), }; } diff --git a/src/main.rs b/src/main.rs index 76c968c..c64c4e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ fn main() { .insert_resource(DefaultDrawVerts(4)) .insert_resource(HighlightColor(Color::hsl(0.0,1.0,0.5))) .insert_resource(ConnectionColor(Color::hsla(0., 1., 1., 0.7))) + .insert_resource(ConnectionWidth(4.)) .insert_resource(CommandColor(Color::hsla(0., 0., 0.7, 1.))) .insert_resource(DefaultLT((0, 0))) .insert_resource(SystemClipboard(ClipboardContext::new().unwrap())) @@ -150,6 +151,7 @@ fn main() { .register_type::() .register_type::() .register_type::() + .register_type::() .register_type::() .register_type::() .register_type::() @@ -292,6 +294,7 @@ fn save_scene(world: &mut World) { .allow_resource::() .allow_resource::() .allow_resource::() + .allow_resource::() .allow_resource::() .allow_resource::() .allow_resource::() diff --git a/src/process.rs b/src/process.rs index 5f35da5..94b1e8c 100644 --- a/src/process.rs +++ b/src/process.rs @@ -83,6 +83,8 @@ pub struct Access<'w, 's> { default_verts: ResMut<'w, DefaultDrawVerts>, highlight_color: ResMut<'w, HighlightColor>, connection_color: ResMut<'w, ConnectionColor>, + connection_width: ResMut<'w, ConnectionWidth>, + arrow_query: Query<'w, 's, &'static ConnectionArrow>, selection_circle: Res<'w, SelectionCircle>, connecting_line: Res<'w, ConnectingLine>, command_line_text: Query<'w, 's, &'static mut Text, With>, @@ -707,6 +709,14 @@ pub fn process( let clt = &mut access.command_line_text.single_mut(); clt.sections[0].style.color = color.0; } + } else if op == "connection_width" { + let n = access.num_query.get_mut(*id).unwrap(); + if n.is_changed() { + access.connection_width.0 = n.0; + for e in access.arrow_query.iter() { + access.trans_query.get_mut(e.0).unwrap().scale.x = n.0; + } + } } else if op == "tonemapping" { let mut tm = access.tonemapping.single_mut(); for hole in holes {