fix blueprint id generation overwriting old blueprints if any were removed before
This commit is contained in:
parent
ce90a22ea0
commit
52288bdf6c
2 changed files with 15 additions and 1 deletions
|
@ -27,6 +27,10 @@ impl Blueprint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn id(&self)->&String{
|
||||||
|
&self.id
|
||||||
|
}
|
||||||
|
|
||||||
pub fn convert_board(&mut self) -> &Board {
|
pub fn convert_board(&mut self) -> &Board {
|
||||||
if self.tile_board.is_none() {
|
if self.tile_board.is_none() {
|
||||||
self.tile_board = Some(Board::parse(&self.board));
|
self.tile_board = Some(Board::parse(&self.board));
|
||||||
|
|
|
@ -280,7 +280,17 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
board.trim_size(0);
|
board.trim_size(0);
|
||||||
let mut blueprint = Blueprint::new(&board, self.blueprints.len());
|
let mut id = 0;
|
||||||
|
'outer: loop {
|
||||||
|
for b in &self.blueprints {
|
||||||
|
if b.id() == &format!("blueprint_{id}") {
|
||||||
|
id += 1;
|
||||||
|
continue 'outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let mut blueprint = Blueprint::new(&board, id);
|
||||||
if !self.new_blueprint_name.is_empty() {
|
if !self.new_blueprint_name.is_empty() {
|
||||||
blueprint.name = self.new_blueprint_name.clone();
|
blueprint.name = self.new_blueprint_name.clone();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue