traaains/editor/track/placing/states/
current_shape.rs1use std::fmt::Display;
2
3use bevy::state::state::SubStates;
4
5use crate::editor::track::TrackEditorState;
6
7#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, SubStates)]
8#[source(TrackEditorState = TrackEditorState::Placing)]
9pub enum CurrentShape {
10 #[default]
11 Linear,
12 Quadratic,
13 Cubic,
14}
15
16impl CurrentShape {
17 pub fn prev(&self) -> Self {
18 match self {
19 CurrentShape::Linear => CurrentShape::Cubic,
20 CurrentShape::Quadratic => CurrentShape::Linear,
21 CurrentShape::Cubic => CurrentShape::Quadratic,
22 }
23 }
24
25 pub fn next(&self) -> Self {
26 match self {
27 CurrentShape::Linear => CurrentShape::Quadratic,
28 CurrentShape::Quadratic => CurrentShape::Cubic,
29 CurrentShape::Cubic => CurrentShape::Linear,
30 }
31 }
32}
33
34impl Display for CurrentShape {
35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 f.write_str(match self {
37 CurrentShape::Linear => "Linear",
38 CurrentShape::Quadratic => "Quadratic",
39 CurrentShape::Cubic => "Cubic",
40 })
41 }
42}