fix undo for digit tile placement

This commit is contained in:
Crispy 2024-12-17 15:45:10 +01:00
parent 64fb7ca5ba
commit 73a1c62f52
2 changed files with 4 additions and 6 deletions

View file

@ -120,7 +120,6 @@ pub enum ExitState {
Dont, Dont,
ExitAndSave, ExitAndSave,
Save, Save,
ExitNoSave,
} }
impl Editor { impl Editor {
@ -1087,10 +1086,10 @@ impl Editor {
Tool::Mirror => self.set_tile(pos, Tile::Mirror(self.tool_mirror)), Tool::Mirror => self.set_tile(pos, Tile::Mirror(self.tool_mirror)),
Tool::Digits(_pos) => { Tool::Digits(_pos) => {
self.active_tool = Tool::Digits(Some(pos)); self.active_tool = Tool::Digits(Some(pos));
if let Some(tile) = self.source_board.get_mut(pos) {
let tile = self.source_board.get_or_blank(pos);
if !matches!(tile, Tile::Open(OpenTile::Digit(_), _)) { if !matches!(tile, Tile::Open(OpenTile::Digit(_), _)) {
*tile = Tile::Open(OpenTile::Digit(0), Claim::Free); self.set_tile(pos, Tile::Open(OpenTile::Digit(0), Claim::Free));
}
} }
} }
Tool::Blueprint => { Tool::Blueprint => {

View file

@ -97,7 +97,6 @@ impl Game {
solution.score = editor.score(); solution.score = editor.score();
solution.save(); solution.save();
} }
ExitState::ExitNoSave => self.open_editor = None,
} }
} else { } else {
self.draw(&mut d); self.draw(&mut d);