41 lines
1.4 KiB
Rust
41 lines
1.4 KiB
Rust
use crate::vvlib::inputs::{BinaryInputBinding, BinaryInputID, InputRegister, InputRegisterPlugin};
|
|
use bevy::prelude::*;
|
|
|
|
use super::editor_ui::edit_click_events;
|
|
|
|
pub fn setup_inputs(app: &mut bevy::app::App) -> &mut bevy::app::App {
|
|
app.add_plugins(InputRegisterPlugin);
|
|
app.add_systems(Startup, initiate_default_or_load_controls);
|
|
app.add_systems(Update, edit_click_events)
|
|
}
|
|
|
|
pub mod keybind_codes {
|
|
pub const INSERT_VOXEL: &str = "INSERT_VOXEL";
|
|
pub const REMOVE_VOXEL: &str = "REMOVE_VOXEL";
|
|
pub const PAINT_VOXEL: &str = "PAINT_VOXEL";
|
|
}
|
|
|
|
pub fn initiate_default_or_load_controls(
|
|
// system that will setup default keybinds until i implement loading and saving settings from file
|
|
mut input_data: ResMut<InputRegister>,
|
|
) {
|
|
input_data.set_binary_input(
|
|
&keybind_codes::INSERT_VOXEL.into(),
|
|
BinaryInputBinding::create_binding(BinaryInputID::MouseButton(MouseButton::Left)),
|
|
);
|
|
input_data.set_binary_input(
|
|
&keybind_codes::REMOVE_VOXEL.into(),
|
|
BinaryInputBinding::create_binding_2(
|
|
BinaryInputID::MouseButton(MouseButton::Left),
|
|
BinaryInputID::KeyCode(KeyCode::KeyR),
|
|
),
|
|
);
|
|
input_data.set_binary_input(
|
|
&keybind_codes::PAINT_VOXEL.into(),
|
|
BinaryInputBinding::create_binding_2(
|
|
BinaryInputID::MouseButton(MouseButton::Left),
|
|
BinaryInputID::KeyCode(KeyCode::KeyE),
|
|
),
|
|
);
|
|
}
|