From 5382f935bdcca66a73225033d012ae2c00db490c Mon Sep 17 00:00:00 2001 From: "Tristan F." Date: Fri, 9 Aug 2024 12:28:41 -0400 Subject: [PATCH] style: fmt --- crates/games/src/chomp/gui.rs | 1 + crates/games/src/domineering/gui.rs | 1 + crates/games/src/nim/gui.rs | 54 +++++++++++++++++-------- crates/games/src/order_and_chaos/gui.rs | 1 + crates/games/src/reversi/gui.rs | 1 + crates/games/src/tic_tac_toe/gui.rs | 1 + crates/games/src/util/gui/mod.rs | 2 +- 7 files changed, 43 insertions(+), 18 deletions(-) diff --git a/crates/games/src/chomp/gui.rs b/crates/games/src/chomp/gui.rs index e69de29..8b13789 100644 --- a/crates/games/src/chomp/gui.rs +++ b/crates/games/src/chomp/gui.rs @@ -0,0 +1 @@ + diff --git a/crates/games/src/domineering/gui.rs b/crates/games/src/domineering/gui.rs index e69de29..8b13789 100644 --- a/crates/games/src/domineering/gui.rs +++ b/crates/games/src/domineering/gui.rs @@ -0,0 +1 @@ + diff --git a/crates/games/src/nim/gui.rs b/crates/games/src/nim/gui.rs index 59e64dd..7d55b65 100644 --- a/crates/games/src/nim/gui.rs +++ b/crates/games/src/nim/gui.rs @@ -14,31 +14,51 @@ impl EguiDisplay for Nim { if let Some(max_cell_count) = self.heaps.iter().max() { let max_size = Vec2 { x: (CELL_WIDTH * max_cell_count + CELL_MARGIN_X * (max_cell_count - 1)) as f32, - y: (CELL_HEIGHT * self.heaps.len() + CELL_MARGIN_Y * (self.heaps.len() - 1)) as f32 + y: (CELL_HEIGHT * self.heaps.len() + CELL_MARGIN_Y * (self.heaps.len() - 1)) as f32, }; - let (response, painter) = - ui.allocate_painter(max_size, Sense::drag()); + let (response, painter) = ui.allocate_painter(max_size, Sense::drag()); let to_screen = emath::RectTransform::from_to( Rect::from_min_size(Pos2::ZERO, max_size), response.rect, ); - painter.extend(self.heaps.iter().enumerate().map(|(i, heap)| { - (0..(*heap)).map(|j| { - egui::Shape::rect_filled(Rect::from_two_pos( - to_screen * Pos2 { - x: (j * CELL_WIDTH + (j * CELL_MARGIN_X)) as f32, - y: (i * CELL_HEIGHT + (i * CELL_MARGIN_Y)) as f32 - }, - to_screen * Pos2 { - x: (j * CELL_WIDTH + (j * CELL_MARGIN_X) + CELL_WIDTH) as f32, - y: (i * CELL_HEIGHT + (i * CELL_MARGIN_Y) + CELL_HEIGHT) as f32 - } - ), Rounding::ZERO, Color32::LIGHT_GRAY) - }).collect::>() - }).flatten().collect::>()); + painter.extend( + self.heaps + .iter() + .enumerate() + .map(|(i, heap)| { + (0..(*heap)) + .map(|j| { + egui::Shape::rect_filled( + Rect::from_two_pos( + to_screen + * Pos2 { + x: (j * CELL_WIDTH + (j * CELL_MARGIN_X)) as f32, + y: (i * CELL_HEIGHT + (i * CELL_MARGIN_Y)) as f32, + }, + to_screen + * Pos2 { + x: (j * CELL_WIDTH + + (j * CELL_MARGIN_X) + + CELL_WIDTH) + as f32, + y: (i * CELL_HEIGHT + + (i * CELL_MARGIN_Y) + + CELL_HEIGHT) + as f32, + }, + ), + Rounding::ZERO, + Color32::LIGHT_GRAY, + ) + }) + .collect::>() + }) + .flatten() + .collect::>(), + ); } } } diff --git a/crates/games/src/order_and_chaos/gui.rs b/crates/games/src/order_and_chaos/gui.rs index e69de29..8b13789 100644 --- a/crates/games/src/order_and_chaos/gui.rs +++ b/crates/games/src/order_and_chaos/gui.rs @@ -0,0 +1 @@ + diff --git a/crates/games/src/reversi/gui.rs b/crates/games/src/reversi/gui.rs index e69de29..8b13789 100644 --- a/crates/games/src/reversi/gui.rs +++ b/crates/games/src/reversi/gui.rs @@ -0,0 +1 @@ + diff --git a/crates/games/src/tic_tac_toe/gui.rs b/crates/games/src/tic_tac_toe/gui.rs index e69de29..8b13789 100644 --- a/crates/games/src/tic_tac_toe/gui.rs +++ b/crates/games/src/tic_tac_toe/gui.rs @@ -0,0 +1 @@ + diff --git a/crates/games/src/util/gui/mod.rs b/crates/games/src/util/gui/mod.rs index ae007d2..8ae98e4 100644 --- a/crates/games/src/util/gui/mod.rs +++ b/crates/games/src/util/gui/mod.rs @@ -1 +1 @@ -pub mod egui_display; \ No newline at end of file +pub mod egui_display;