add rule copy button
This commit is contained in:
parent
e2869af4a7
commit
3d9fd8d311
2 changed files with 15 additions and 4 deletions
|
@ -18,7 +18,7 @@ pub struct Chunk {
|
||||||
pub contents: Box<[[Cell; CHUNK_SIZE]; CHUNK_SIZE]>,
|
pub contents: Box<[[Cell; CHUNK_SIZE]; CHUNK_SIZE]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Rule {
|
pub struct Rule {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
|
@ -174,16 +174,27 @@ impl eframe::App for UScope {
|
||||||
ui.heading("Rules");
|
ui.heading("Rules");
|
||||||
|
|
||||||
let mut to_remove = None;
|
let mut to_remove = None;
|
||||||
|
let mut to_clone = None;
|
||||||
for (i, rule) in self.dish.rules.iter_mut().enumerate() {
|
for (i, rule) in self.dish.rules.iter_mut().enumerate() {
|
||||||
ui.separator();
|
ui.separator();
|
||||||
rule_editor(ui, rule, &self.cell_types, &self.dish.cell_groups);
|
rule_editor(ui, rule, &self.cell_types, &self.dish.cell_groups);
|
||||||
if ui.button("delete").clicked() {
|
ui.horizontal(|ui| {
|
||||||
to_remove = Some(i);
|
if ui.button("delete").clicked() {
|
||||||
}
|
to_remove = Some(i);
|
||||||
|
}
|
||||||
|
if ui.button("copy").clicked() {
|
||||||
|
to_clone = Some(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if let Some(i) = to_remove {
|
if let Some(i) = to_remove {
|
||||||
self.dish.rules.remove(i);
|
self.dish.rules.remove(i);
|
||||||
}
|
}
|
||||||
|
if let Some(i) = to_clone {
|
||||||
|
let mut new_rule = self.dish.rules[i].clone();
|
||||||
|
new_rule.enabled = false;
|
||||||
|
self.dish.rules.push(new_rule);
|
||||||
|
}
|
||||||
ui.separator();
|
ui.separator();
|
||||||
if ui.button("add rule").clicked() {
|
if ui.button("add rule").clicked() {
|
||||||
self.dish.rules.push(Rule::new());
|
self.dish.rules.push(Rule::new());
|
||||||
|
|
Loading…
Reference in a new issue