-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make game start in fullscreen and add fullscreen setting. (#859)
You can also toggle fullscreen with the F11 key.
- Loading branch information
Showing
7 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::prelude::*; | ||
|
||
pub fn game_plugin(game: &mut Game) { | ||
game.systems.add_before_system(update_fullscreen); | ||
} | ||
|
||
fn update_fullscreen(game: &mut Game) { | ||
let storage = game.shared_resource_cell::<Storage>().unwrap(); | ||
let mut storage = storage.borrow_mut(); | ||
let window = game.shared_resource_cell::<Window>().unwrap(); | ||
let mut window = window.borrow_mut(); | ||
let keyboard = game.shared_resource::<KeyboardInputs>().unwrap(); | ||
|
||
let f11_pressed = keyboard | ||
.key_events | ||
.iter() | ||
.any(|x| x.key_code == Set(KeyCode::F11) && x.button_state.pressed()); | ||
|
||
let settings = storage.get_mut::<Settings>().unwrap(); | ||
if f11_pressed { | ||
settings.fullscreen = !settings.fullscreen; | ||
} | ||
window.fullscreen = settings.fullscreen; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use super::*; | ||
|
||
pub(super) fn widget( | ||
mut args: In<(&mut egui::Ui, &mut SettingsState, bool)>, | ||
meta: Root<GameMeta>, | ||
localization: Localization<GameMeta>, | ||
) { | ||
let (ui, state, should_reset) = &mut *args; | ||
|
||
let normal_font = meta | ||
.theme | ||
.font_styles | ||
.normal | ||
.with_color(meta.theme.panel.font_color); | ||
|
||
if *should_reset { | ||
state.modified_settings.fullscreen = meta.default_settings.fullscreen; | ||
} | ||
|
||
ui.add_space(normal_font.size / 2.0); | ||
|
||
ui.horizontal(|ui| { | ||
ui.add_space(normal_font.size * 3.0); | ||
ui.checkbox( | ||
&mut state.modified_settings.fullscreen, | ||
normal_font.rich(localization.get("fullscreen")), | ||
); | ||
}); | ||
} |