add Toggle Shadows menu entry
This commit is contained in:
parent
556e98deec
commit
b505312f6e
|
@ -305,33 +305,22 @@ pub fn update_fov(
|
||||||
|
|
||||||
pub fn handle_input(
|
pub fn handle_input(
|
||||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut q_light: Query<&mut DirectionalLight>,
|
settings: Res<var::Settings>,
|
||||||
mut settings: ResMut<var::Settings>,
|
|
||||||
mut mapcam: ResMut<MapCam>,
|
|
||||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||||
mut ew_updateoverlays: EventWriter<hud::UpdateOverlayVisibility>,
|
mut ew_game: EventWriter<GameEvent>,
|
||||||
) {
|
) {
|
||||||
if keyboard_input.just_pressed(settings.key_camera) {
|
if keyboard_input.just_pressed(settings.key_camera) {
|
||||||
settings.third_person ^= true;
|
ew_game.send(GameEvent::SetThirdPerson(Toggle));
|
||||||
}
|
}
|
||||||
if keyboard_input.just_pressed(settings.key_shadows) {
|
if keyboard_input.just_pressed(settings.key_shadows) {
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
|
ew_game.send(GameEvent::SetShadows(Toggle));
|
||||||
settings.shadows_sun ^= true;
|
|
||||||
for mut light in &mut q_light {
|
|
||||||
light.shadows_enabled = settings.shadows_sun;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if keyboard_input.just_pressed(settings.key_map) {
|
if keyboard_input.just_pressed(settings.key_map) {
|
||||||
settings.map_active ^= true;
|
ew_game.send(GameEvent::SetMap(Toggle));
|
||||||
if settings.map_active {
|
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Woosh));
|
|
||||||
}
|
|
||||||
*mapcam = MapCam::default();
|
|
||||||
ew_updateoverlays.send(hud::UpdateOverlayVisibility);
|
|
||||||
}
|
}
|
||||||
if keyboard_input.just_pressed(settings.key_rotation_stabilizer) {
|
if keyboard_input.just_pressed(settings.key_rotation_stabilizer) {
|
||||||
|
ew_game.send(GameEvent::SetRotationStabilizer(Toggle));
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
|
||||||
settings.rotation_stabilizer_active ^= true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
src/game.rs
17
src/game.rs
|
@ -43,6 +43,9 @@ pub enum GameEvent {
|
||||||
SetMap(Turn),
|
SetMap(Turn),
|
||||||
SetFullscreen(Turn),
|
SetFullscreen(Turn),
|
||||||
SetMenu(Turn),
|
SetMenu(Turn),
|
||||||
|
SetThirdPerson(Turn),
|
||||||
|
SetRotationStabilizer(Turn),
|
||||||
|
SetShadows(Turn),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Turn {
|
pub enum Turn {
|
||||||
|
@ -69,6 +72,7 @@ fn handle_game_event(
|
||||||
mut ew_togglemusic: EventWriter<audio::ToggleMusicEvent>,
|
mut ew_togglemusic: EventWriter<audio::ToggleMusicEvent>,
|
||||||
mut q_window: Query<&mut Window, With<PrimaryWindow>>,
|
mut q_window: Query<&mut Window, With<PrimaryWindow>>,
|
||||||
mut q_menu_vis: Query<&mut Visibility, With<menu::MenuElement>>,
|
mut q_menu_vis: Query<&mut Visibility, With<menu::MenuElement>>,
|
||||||
|
mut q_light: Query<&mut DirectionalLight>,
|
||||||
mut mapcam: ResMut<camera::MapCam>,
|
mut mapcam: ResMut<camera::MapCam>,
|
||||||
opt: Res<var::CommandLineOptions>,
|
opt: Res<var::CommandLineOptions>,
|
||||||
) {
|
) {
|
||||||
|
@ -112,6 +116,19 @@ fn handle_game_event(
|
||||||
*vis = bool2vis(settings.menu_active);
|
*vis = bool2vis(settings.menu_active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GameEvent::SetThirdPerson(turn) => {
|
||||||
|
settings.third_person = turn.to_bool(settings.third_person);
|
||||||
|
}
|
||||||
|
GameEvent::SetRotationStabilizer(turn) => {
|
||||||
|
settings.rotation_stabilizer_active
|
||||||
|
= turn.to_bool(settings.rotation_stabilizer_active);
|
||||||
|
}
|
||||||
|
GameEvent::SetShadows(turn) => {
|
||||||
|
settings.shadows_sun = turn.to_bool(settings.shadows_sun);
|
||||||
|
for mut light in &mut q_light {
|
||||||
|
light.shadows_enabled = settings.shadows_sun;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ pub const MENUDEF: &[(&str, MenuAction)] = &[
|
||||||
("Toggle Sound", MenuAction::ToggleSound),
|
("Toggle Sound", MenuAction::ToggleSound),
|
||||||
("Toggle Music", MenuAction::ToggleMusic),
|
("Toggle Music", MenuAction::ToggleMusic),
|
||||||
("Toggle Fullscreen", MenuAction::ToggleFullscreen),
|
("Toggle Fullscreen", MenuAction::ToggleFullscreen),
|
||||||
|
("Toggle Shadows", MenuAction::ToggleShadows),
|
||||||
("Restart Game", MenuAction::Restart),
|
("Restart Game", MenuAction::Restart),
|
||||||
("Quit", MenuAction::Quit),
|
("Quit", MenuAction::Quit),
|
||||||
];
|
];
|
||||||
|
@ -55,6 +56,7 @@ pub enum MenuAction {
|
||||||
ToggleSound,
|
ToggleSound,
|
||||||
ToggleMusic,
|
ToggleMusic,
|
||||||
ToggleFullscreen,
|
ToggleFullscreen,
|
||||||
|
ToggleShadows,
|
||||||
Restart,
|
Restart,
|
||||||
Quit,
|
Quit,
|
||||||
}
|
}
|
||||||
|
@ -311,6 +313,9 @@ pub fn handle_input(
|
||||||
MenuAction::ToggleFullscreen => {
|
MenuAction::ToggleFullscreen => {
|
||||||
ew_game.send(GameEvent::SetFullscreen(Toggle));
|
ew_game.send(GameEvent::SetFullscreen(Toggle));
|
||||||
},
|
},
|
||||||
|
MenuAction::ToggleShadows => {
|
||||||
|
ew_game.send(GameEvent::SetShadows(Toggle));
|
||||||
|
},
|
||||||
MenuAction::Restart => {
|
MenuAction::Restart => {
|
||||||
settings.god_mode = false;
|
settings.god_mode = false;
|
||||||
ew_playerdies.send(game::PlayerDiesEvent(actor::DamageType::DivineIntervention));
|
ew_playerdies.send(game::PlayerDiesEvent(actor::DamageType::DivineIntervention));
|
||||||
|
|
Loading…
Reference in a new issue