Skip to content

Commit

Permalink
style: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoDog896 committed Aug 9, 2024
1 parent 14b7ca1 commit 5382f93
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
1 change: 1 addition & 0 deletions crates/games/src/chomp/gui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions crates/games/src/domineering/gui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

54 changes: 37 additions & 17 deletions crates/games/src/nim/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>()
}).flatten().collect::<Vec<_>>());
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::<Vec<_>>()
})
.flatten()
.collect::<Vec<_>>(),
);
}
}
}
1 change: 1 addition & 0 deletions crates/games/src/order_and_chaos/gui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions crates/games/src/reversi/gui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions crates/games/src/tic_tac_toe/gui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion crates/games/src/util/gui/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod egui_display;
pub mod egui_display;

0 comments on commit 5382f93

Please sign in to comment.