aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs125
1 files changed, 31 insertions, 94 deletions
diff --git a/src/config.rs b/src/config.rs
index b4703a2..2a1e5ed 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -8,58 +8,34 @@ use std::path::Path;
#[derive(Deserialize, Serialize)]
pub struct Config {
- pub deletion_keybindings: DeletionToolKeybindings,
- pub icon_keybindings: IconToolKeybindings,
- pub polygon_keybindings: PolygonRoomToolKeybindings,
- pub room_keybindings: RoomToolKeybindings,
- pub wall_keybindings: WallToolKeybindings,
+ pub tool_activation_keys: ToolActivationKeys,
+ pub tool_general_keys: ToolGeneralKeys,
+ pub icon_keys: IconToolKeys,
}
-pub trait ToolKeybindings {
- /// Get the key which will activate the tool it is made for.
- fn activation_key(&self) -> Button;
+#[derive(Deserialize, Serialize)]
+pub struct ToolActivationKeys {
+ pub deletion: Button,
+ pub icon: Button,
+ pub polygon_room: Button,
+ pub rect_room: Button,
+ pub selection: Button,
+ pub wall: Button,
}
-#[derive(Serialize, Deserialize)]
-pub struct DeletionToolKeybindings {
- pub activation: Button,
- pub start_selection: Button,
- pub do_delete: Button,
- pub abort_deletion: Button,
+#[derive(Deserialize, Serialize)]
+pub struct ToolGeneralKeys {
+ pub place_single: Button,
+ pub finish: Button,
+ pub abort: Button,
}
-#[derive(Serialize, Deserialize)]
-pub struct IconToolKeybindings {
- pub activation: Button,
+#[derive(Clone, Serialize, Deserialize)]
+pub struct IconToolKeys {
pub next: Button,
pub previous: Button,
pub rotate_clockwise: Button,
pub rotate_counterclockwise: Button,
- pub place: Button,
-}
-
-#[derive(Serialize, Deserialize)]
-pub struct PolygonRoomToolKeybindings {
- pub activation: Button,
- pub place_node: Button,
- pub finish: Button,
- pub abort: Button,
-}
-
-#[derive(Serialize, Deserialize)]
-pub struct RoomToolKeybindings {
- pub activation: Button,
- pub start_draw: Button,
- pub finish_draw: Button,
- pub abort_draw: Button,
-}
-
-#[derive(Serialize, Deserialize)]
-pub struct WallToolKeybindings {
- pub activation: Button,
- pub start_wall: Button,
- pub finish_segment: Button,
- pub abort_segment: Button,
}
impl Config {
@@ -93,64 +69,25 @@ impl Config {
impl Default for Config {
fn default() -> Self {
Config {
- deletion_keybindings: DeletionToolKeybindings {
- activation: Button::Keyboard(KeyboardKey::D),
- start_selection: Button::Mouse(MouseButton::Left),
- do_delete: Button::Mouse(MouseButton::Left),
- abort_deletion: Button::Mouse(MouseButton::Right),
+ tool_activation_keys: ToolActivationKeys {
+ deletion: Button::Keyboard(KeyboardKey::D),
+ icon: Button::Keyboard(KeyboardKey::I),
+ polygon_room: Button::Keyboard(KeyboardKey::P),
+ rect_room: Button::Keyboard(KeyboardKey::R),
+ selection: Button::Keyboard(KeyboardKey::S),
+ wall: Button::Keyboard(KeyboardKey::W),
},
- icon_keybindings: IconToolKeybindings {
- activation: Button::Keyboard(KeyboardKey::I),
+ tool_general_keys: ToolGeneralKeys {
+ place_single: Button::Mouse(MouseButton::Left),
+ finish: Button::Keyboard(KeyboardKey::Enter),
+ abort: Button::Mouse(MouseButton::Right),
+ },
+ icon_keys: IconToolKeys {
next: Button::Keyboard(KeyboardKey::I),
previous: Button::Keyboard(KeyboardKey::J),
rotate_clockwise: Button::Mouse(MouseButton::Right),
rotate_counterclockwise: Button::Keyboard(KeyboardKey::Minus),
- place: Button::Mouse(MouseButton::Left),
- },
- polygon_keybindings: PolygonRoomToolKeybindings {
- activation: Button::Keyboard(KeyboardKey::P),
- place_node: Button::Mouse(MouseButton::Left),
- finish: Button::Keyboard(KeyboardKey::Enter),
- abort: Button::Mouse(MouseButton::Right),
- },
- room_keybindings: RoomToolKeybindings {
- activation: Button::Keyboard(KeyboardKey::R),
- start_draw: Button::Mouse(MouseButton::Left),
- finish_draw: Button::Mouse(MouseButton::Left),
- abort_draw: Button::Mouse(MouseButton::Right),
- },
- wall_keybindings: WallToolKeybindings {
- activation: Button::Keyboard(KeyboardKey::W),
- start_wall: Button::Mouse(MouseButton::Left),
- finish_segment: Button::Mouse(MouseButton::Left),
- abort_segment: Button::Mouse(MouseButton::Right),
},
}
}
}
-
-impl ToolKeybindings for DeletionToolKeybindings {
- fn activation_key(&self) -> Button {
- self.activation
- }
-}
-impl ToolKeybindings for IconToolKeybindings {
- fn activation_key(&self) -> Button {
- self.activation
- }
-}
-impl ToolKeybindings for PolygonRoomToolKeybindings {
- fn activation_key(&self) -> Button {
- self.activation
- }
-}
-impl ToolKeybindings for RoomToolKeybindings {
- fn activation_key(&self) -> Button {
- self.activation
- }
-}
-impl ToolKeybindings for WallToolKeybindings {
- fn activation_key(&self) -> Button {
- self.activation
- }
-}