add more tiles to gui, with controls to rotate between variants in a group
This commit is contained in:
parent
175d01cb03
commit
bf82d1455f
3 changed files with 195 additions and 72 deletions
|
@ -85,50 +85,15 @@ impl Tile {
|
|||
Tile::Blank => "transparent",
|
||||
Tile::Block => "block",
|
||||
Tile::Marble { value: _, dir: _ } => "marble",
|
||||
Tile::Digit(n) => match n {
|
||||
b'0' => "digit_0",
|
||||
b'1' => "digit_1",
|
||||
b'2' => "digit_2",
|
||||
b'3' => "digit_3",
|
||||
b'4' => "digit_4",
|
||||
b'5' => "digit_5",
|
||||
b'6' => "digit_6",
|
||||
b'7' => "digit_7",
|
||||
b'8' => "digit_8",
|
||||
b'9' => "digit_9",
|
||||
_ => unreachable!("invalid digit"),
|
||||
},
|
||||
Tile::Mirror(mirror) => match mirror {
|
||||
MirrorType::Forward => "mirror_forward",
|
||||
MirrorType::Back => "mirror_back",
|
||||
},
|
||||
Tile::Arrow(dir) => match dir {
|
||||
Direction::Up => "arrow_up",
|
||||
Direction::Down => "arrow_down",
|
||||
Direction::Left => "arrow_left",
|
||||
Direction::Right => "arrow_right",
|
||||
},
|
||||
Tile::Digit(n) => return format!("digit_{n}"),
|
||||
Tile::Mirror(mirror) => mirror.texture_name(),
|
||||
Tile::Arrow(dir) => dir.arrow_texture_name(),
|
||||
Tile::Powerable(tile, state) => {
|
||||
let root = match tile {
|
||||
PTile::Trigger => "trigger",
|
||||
PTile::Wire(wire) => match wire {
|
||||
WireType::Vertical => "wire_vertical",
|
||||
WireType::Horizontal => "wire_horizontal",
|
||||
WireType::Cross => "wire_cross",
|
||||
},
|
||||
PTile::Gate(gate) => match gate {
|
||||
GateType::LessThan => "lt",
|
||||
GateType::GreaterThan => "gt",
|
||||
GateType::Equal => "eq",
|
||||
GateType::NotEqual => "neq",
|
||||
},
|
||||
PTile::Math(math_op) => match math_op {
|
||||
MathOp::Add => "add",
|
||||
MathOp::Sub => "sub",
|
||||
MathOp::Mul => "mul",
|
||||
MathOp::Div => "div",
|
||||
MathOp::Rem => "rem",
|
||||
},
|
||||
PTile::Wire(wire) => wire.texture_name(),
|
||||
PTile::Gate(gate) => gate.texture_name(),
|
||||
PTile::Math(math_op) => math_op.texture_name(),
|
||||
PTile::Bag => "bag",
|
||||
PTile::Flipper => "flipper",
|
||||
PTile::Input => "input",
|
||||
|
@ -180,6 +145,15 @@ impl Direction {
|
|||
}
|
||||
pos
|
||||
}
|
||||
|
||||
pub const fn arrow_texture_name(&self) -> &'static str {
|
||||
match self {
|
||||
Direction::Up => "arrow_up",
|
||||
Direction::Down => "arrow_down",
|
||||
Direction::Left => "arrow_left",
|
||||
Direction::Right => "arrow_right",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WireType {
|
||||
|
@ -190,6 +164,14 @@ impl WireType {
|
|||
WireType::Cross => &Direction::ALL,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn texture_name(&self) -> &'static str {
|
||||
match self {
|
||||
WireType::Vertical => "wire_vertical",
|
||||
WireType::Horizontal => "wire_horizontal",
|
||||
WireType::Cross => "wire_cross",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MirrorType {
|
||||
|
@ -209,4 +191,35 @@ impl MirrorType {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn texture_name(&self) -> &'static str {
|
||||
match self {
|
||||
MirrorType::Forward => "mirror_forward",
|
||||
MirrorType::Back => "mirror_back",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MathOp {
|
||||
pub const fn texture_name(&self) -> &'static str {
|
||||
match self {
|
||||
MathOp::Add => "add",
|
||||
MathOp::Sub => "sub",
|
||||
MathOp::Mul => "mul",
|
||||
MathOp::Div => "div",
|
||||
MathOp::Rem => "rem",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GateType {
|
||||
pub const fn texture_name(&self) -> &'static str {
|
||||
match self {
|
||||
GateType::LessThan => "lt",
|
||||
GateType::GreaterThan => "gt",
|
||||
GateType::Equal => "eq",
|
||||
GateType::NotEqual => "neq",
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue