cleanup
This commit is contained in:
parent
e223a75c0e
commit
e9e763332f
4 changed files with 14 additions and 20 deletions
|
@ -722,7 +722,7 @@ impl Editor {
|
|||
let max = selection.0.max(selection.1);
|
||||
for x in min.x..=max.x {
|
||||
for y in min.y..=max.y {
|
||||
self.source_board.set(Pos { x, y }, Tile::default());
|
||||
self.source_board.set(Pos { x, y }, Tile::BLANK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ impl Editor {
|
|||
if d.is_mouse_button_down(MouseButton::MOUSE_BUTTON_LEFT)
|
||||
&& self.active_tool == Tool::Erase
|
||||
{
|
||||
self.set_tile(tile_pos.into(), Tile::default())
|
||||
self.set_tile(tile_pos.into(), Tile::BLANK)
|
||||
}
|
||||
if let Tool::SelectArea(selection) = &mut self.active_tool {
|
||||
if d.is_mouse_button_down(MouseButton::MOUSE_BUTTON_LEFT) {
|
||||
|
|
|
@ -145,8 +145,7 @@ impl Machine {
|
|||
}
|
||||
}
|
||||
PTile::IO => {
|
||||
if front_tile == &Tile::default()
|
||||
&& self.input_index < self.input.len()
|
||||
if front_tile == &Tile::BLANK && self.input_index < self.input.len()
|
||||
{
|
||||
let value = self.input[self.input_index] as MarbleValue;
|
||||
self.input_index += 1;
|
||||
|
@ -154,7 +153,7 @@ impl Machine {
|
|||
}
|
||||
}
|
||||
PTile::Bag => {
|
||||
if front_tile == &Tile::default() {
|
||||
if front_tile == &Tile::BLANK {
|
||||
new_marbles.push((front_pos, 0, dir));
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +337,7 @@ impl Machine {
|
|||
OpenTile::Blank => value,
|
||||
OpenTile::Digit(n) => value.wrapping_mul(10).wrapping_add(n as MarbleValue),
|
||||
};
|
||||
board.set(*pos, Tile::default());
|
||||
board.set(*pos, Tile::BLANK);
|
||||
board.set(target_pos, Tile::Marble { value, dir });
|
||||
*pos = target_pos;
|
||||
};
|
||||
|
@ -405,7 +404,7 @@ impl Machine {
|
|||
|
||||
// remove marbles
|
||||
for &i in removed_marbles.iter().rev() {
|
||||
self.board.set(self.marbles[i], Tile::default());
|
||||
self.board.set(self.marbles[i], Tile::BLANK);
|
||||
self.marbles.swap_remove(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ impl Board {
|
|||
rows.push(tiles);
|
||||
}
|
||||
for line in &mut rows {
|
||||
line.resize(width, Tile::default());
|
||||
line.resize(width, Tile::BLANK);
|
||||
}
|
||||
|
||||
Board::new(rows)
|
||||
|
@ -44,7 +44,7 @@ impl Board {
|
|||
}
|
||||
|
||||
pub fn new_empty(width: usize, height: usize) -> Self {
|
||||
let rows = vec![vec![Tile::default(); width]; height];
|
||||
let rows = vec![vec![Tile::BLANK; width]; height];
|
||||
Self {
|
||||
rows,
|
||||
width,
|
||||
|
@ -89,7 +89,7 @@ impl Board {
|
|||
if self.in_bounds(p) {
|
||||
self.rows[p.y as usize][p.x as usize]
|
||||
} else {
|
||||
Tile::default()
|
||||
Tile::BLANK
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ impl Board {
|
|||
if p.x < 0 {
|
||||
let len = p.x.unsigned_abs() as usize;
|
||||
for row in &mut self.rows {
|
||||
let mut new_row = vec![Tile::default(); len];
|
||||
let mut new_row = vec![Tile::BLANK; len];
|
||||
new_row.append(row);
|
||||
*row = new_row;
|
||||
}
|
||||
|
@ -146,21 +146,21 @@ impl Board {
|
|||
} else if p.x as usize >= self.width {
|
||||
let new_width = p.x as usize + 1;
|
||||
for row in &mut self.rows {
|
||||
row.resize(new_width, Tile::default());
|
||||
row.resize(new_width, Tile::BLANK);
|
||||
}
|
||||
self.width = new_width;
|
||||
}
|
||||
|
||||
if p.y < 0 {
|
||||
let len = p.y.unsigned_abs() as usize;
|
||||
let mut new_rows = vec![vec![Tile::default(); self.width]; len];
|
||||
let mut new_rows = vec![vec![Tile::BLANK; self.width]; len];
|
||||
new_rows.append(&mut self.rows);
|
||||
self.rows = new_rows;
|
||||
offset_y = len;
|
||||
self.height += len;
|
||||
} else if p.y as usize >= self.height {
|
||||
let new_height = p.y as usize + 1;
|
||||
self.rows.resize(new_height, vec![Tile::default(); self.width]);
|
||||
self.rows.resize(new_height, vec![Tile::BLANK; self.width]);
|
||||
self.height = new_height;
|
||||
}
|
||||
(offset_x as PosInt, offset_y as PosInt)
|
||||
|
|
|
@ -76,13 +76,8 @@ pub enum Direction {
|
|||
Right,
|
||||
}
|
||||
|
||||
impl Default for Tile {
|
||||
fn default() -> Self {
|
||||
Tile::Open(OpenTile::Blank, Claim::Free)
|
||||
}
|
||||
}
|
||||
|
||||
impl Tile {
|
||||
pub const BLANK: Self = Tile::Open(OpenTile::Blank, Claim::Free);
|
||||
pub const fn from_char(c: char) -> Tile {
|
||||
match c {
|
||||
'o' => Tile::Marble {
|
||||
|
|
Loading…
Reference in a new issue