mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
added option for borderless fullscreen in setting -> graphics menu
This commit is contained in:
parent
b933db8b68
commit
906da2f0c7
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Some more combat sound effects
|
||||
- Beehives and bees
|
||||
- Fireflies
|
||||
- Fullscreen modes now show two options (exclusive and borderless)
|
||||
|
||||
### Changed
|
||||
|
||||
|
719
Cargo.lock
generated
719
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -299,11 +299,14 @@ magically infused items?"#,
|
||||
"hud.settings.fluid_rendering_mode.cheap": "Cheap",
|
||||
"hud.settings.fluid_rendering_mode.shiny": "Shiny",
|
||||
"hud.settings.cloud_rendering_mode.regular": "Regular",
|
||||
"hud.settings.fullscreen": "Fullscreen",
|
||||
"hud.settings.fullscreen_mode": "Fullscreen Mode",
|
||||
"hud.settings.fullscreen_mode.exclusive": "Exclusive",
|
||||
"hud.settings.fullscreen_mode.borderless": "Borderless",
|
||||
"hud.settings.particles": "Particles",
|
||||
"hud.settings.resolution": "Resolution",
|
||||
"hud.settings.bit_depth": "Bit Depth",
|
||||
"hud.settings.refresh_rate": "Refresh Rate",
|
||||
"hud.settings.fullscreen": "Fullscreen",
|
||||
"hud.settings.save_window_size": "Save window size",
|
||||
"hud.settings.lighting_rendering_mode": "Lighting Rendering Mode",
|
||||
"hud.settings.lighting_rendering_mode.ashikhmin": "Type A",
|
||||
|
@ -19,7 +19,6 @@ mod social;
|
||||
mod spell;
|
||||
mod util;
|
||||
|
||||
use crate::{ecs::comp::HpFloaterList, hud::img_ids::ImgsRot, ui::img_ids::Rotations};
|
||||
pub use hotbar::{SlotContents as HotbarSlotContents, State as HotbarState};
|
||||
|
||||
pub use settings_window::ScaleChange;
|
||||
@ -44,15 +43,16 @@ use social::{Social, SocialTab};
|
||||
use spell::Spell;
|
||||
|
||||
use crate::{
|
||||
ecs::comp as vcomp,
|
||||
ecs::{comp as vcomp, comp::HpFloaterList},
|
||||
hud::img_ids::ImgsRot,
|
||||
i18n::{i18n_asset_key, LanguageMetadata, VoxygenLocalization},
|
||||
render::{Consts, Globals, RenderMode, Renderer},
|
||||
scene::{
|
||||
camera::{self, Camera},
|
||||
lod,
|
||||
},
|
||||
ui::{fonts::ConrodVoxygenFonts, slot, Graphic, Ingameable, ScaleMode, Ui},
|
||||
window::{Event as WinEvent, GameInput},
|
||||
ui::{fonts::ConrodVoxygenFonts, img_ids::Rotations, slot, Graphic, Ingameable, ScaleMode, Ui},
|
||||
window::{Event as WinEvent, FullScreenSettings, GameInput},
|
||||
GlobalState,
|
||||
};
|
||||
use client::Client;
|
||||
@ -285,11 +285,8 @@ pub enum Event {
|
||||
ChangeGamma(f32),
|
||||
MapZoom(f64),
|
||||
AdjustWindowSize([u16; 2]),
|
||||
ChangeFullscreenMode(FullScreenSettings),
|
||||
ToggleParticlesEnabled(bool),
|
||||
ToggleFullscreen,
|
||||
ChangeResolution([u16; 2]),
|
||||
ChangeBitDepth(Option<u16>),
|
||||
ChangeRefreshRate(Option<u16>),
|
||||
CrosshairTransp(f32),
|
||||
ChatTransp(f32),
|
||||
ChatCharName(bool),
|
||||
@ -1972,24 +1969,15 @@ impl Hud {
|
||||
settings_window::Event::ChangeRenderMode(new_render_mode) => {
|
||||
events.push(Event::ChangeRenderMode(new_render_mode));
|
||||
},
|
||||
settings_window::Event::ChangeResolution(new_resolution) => {
|
||||
events.push(Event::ChangeResolution(new_resolution));
|
||||
},
|
||||
settings_window::Event::ChangeBitDepth(new_bit_depth) => {
|
||||
events.push(Event::ChangeBitDepth(new_bit_depth));
|
||||
},
|
||||
settings_window::Event::ChangeRefreshRate(new_refresh_rate) => {
|
||||
events.push(Event::ChangeRefreshRate(new_refresh_rate));
|
||||
},
|
||||
settings_window::Event::ChangeLanguage(language) => {
|
||||
events.push(Event::ChangeLanguage(language));
|
||||
},
|
||||
settings_window::Event::ChangeFullscreenMode(new_fullscreen_settings) => {
|
||||
events.push(Event::ChangeFullscreenMode(new_fullscreen_settings));
|
||||
},
|
||||
settings_window::Event::ToggleParticlesEnabled(particles_enabled) => {
|
||||
events.push(Event::ToggleParticlesEnabled(particles_enabled));
|
||||
},
|
||||
settings_window::Event::ToggleFullscreen => {
|
||||
events.push(Event::ToggleFullscreen);
|
||||
},
|
||||
settings_window::Event::AdjustWindowSize(new_size) => {
|
||||
events.push(Event::AdjustWindowSize(new_size));
|
||||
},
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
i18n::{list_localizations, LanguageMetadata, VoxygenLocalization},
|
||||
render::{AaMode, CloudMode, FluidMode, LightingMode, RenderMode, ShadowMapMode, ShadowMode},
|
||||
ui::{fonts::ConrodVoxygenFonts, ImageSlider, ScaleMode, ToggleButton},
|
||||
window::GameInput,
|
||||
window::{FullScreenSettings, FullscreenMode, GameInput},
|
||||
GlobalState,
|
||||
};
|
||||
use conrod_core::{
|
||||
@ -119,6 +119,8 @@ widget_ids! {
|
||||
cloud_mode_list,
|
||||
fluid_mode_text,
|
||||
fluid_mode_list,
|
||||
fullscreen_mode_text,
|
||||
fullscreen_mode_list,
|
||||
//
|
||||
resolution,
|
||||
resolution_label,
|
||||
@ -259,12 +261,9 @@ pub enum Event {
|
||||
AdjustLodDetail(u32),
|
||||
AdjustGamma(f32),
|
||||
AdjustWindowSize([u16; 2]),
|
||||
ChangeFullscreenMode(FullScreenSettings),
|
||||
ToggleParticlesEnabled(bool),
|
||||
ToggleFullscreen,
|
||||
ChangeRenderMode(Box<RenderMode>),
|
||||
ChangeResolution([u16; 2]),
|
||||
ChangeBitDepth(Option<u16>),
|
||||
ChangeRefreshRate(Option<u16>),
|
||||
AdjustMusicVolume(f32),
|
||||
AdjustSfxVolume(f32),
|
||||
ChangeAudioDevice(String),
|
||||
@ -2284,9 +2283,9 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.map(|res| format!("{}x{}", res[0], res[1]))
|
||||
.collect::<Vec<String>>()
|
||||
.as_slice(),
|
||||
resolutions
|
||||
.iter()
|
||||
.position(|res| res == &self.global_state.settings.graphics.resolution),
|
||||
resolutions.iter().position(|res| {
|
||||
res == &self.global_state.settings.graphics.fullscreen.resolution
|
||||
}),
|
||||
)
|
||||
.w_h(128.0, 22.0)
|
||||
.color(MENU_BG)
|
||||
@ -2295,17 +2294,22 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.down_from(state.ids.resolution_label, 10.0)
|
||||
.set(state.ids.resolution, ui)
|
||||
{
|
||||
events.push(Event::ChangeResolution(resolutions[clicked]));
|
||||
events.push(Event::ChangeFullscreenMode(FullScreenSettings {
|
||||
resolution: resolutions[clicked],
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
}
|
||||
|
||||
// Bit Depth and Refresh Rate
|
||||
let correct_res: Vec<VideoMode> = video_modes
|
||||
.into_iter()
|
||||
.filter(|mode| {
|
||||
mode.size().width == self.global_state.settings.graphics.resolution[0] as u32
|
||||
mode.size().width
|
||||
== self.global_state.settings.graphics.fullscreen.resolution[0] as u32
|
||||
})
|
||||
.filter(|mode| {
|
||||
mode.size().height == self.global_state.settings.graphics.resolution[1] as u32
|
||||
mode.size().height
|
||||
== self.global_state.settings.graphics.fullscreen.resolution[1] as u32
|
||||
})
|
||||
.collect();
|
||||
|
||||
@ -2313,7 +2317,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
let bit_depths: Vec<u16> = correct_res
|
||||
.iter()
|
||||
.filter(
|
||||
|mode| match self.global_state.settings.graphics.refresh_rate {
|
||||
|mode| match self.global_state.settings.graphics.fullscreen.refresh_rate {
|
||||
Some(refresh_rate) => mode.refresh_rate() == refresh_rate,
|
||||
None => true,
|
||||
},
|
||||
@ -2337,7 +2341,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.chain(bit_depths.iter().map(|depth| format!("{}", depth)))
|
||||
.collect::<Vec<String>>()
|
||||
.as_slice(),
|
||||
match self.global_state.settings.graphics.bit_depth {
|
||||
match self.global_state.settings.graphics.fullscreen.bit_depth {
|
||||
Some(bit_depth) => bit_depths
|
||||
.iter()
|
||||
.position(|depth| depth == &bit_depth)
|
||||
@ -2353,20 +2357,25 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.right_from(state.ids.resolution, 8.0)
|
||||
.set(state.ids.bit_depth, ui)
|
||||
{
|
||||
events.push(Event::ChangeBitDepth(if clicked == 0 {
|
||||
events.push(Event::ChangeFullscreenMode(FullScreenSettings {
|
||||
bit_depth: if clicked == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(bit_depths[clicked - 1])
|
||||
},
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
}
|
||||
|
||||
// Refresh Rate
|
||||
let refresh_rates: Vec<u16> = correct_res
|
||||
.into_iter()
|
||||
.filter(|mode| match self.global_state.settings.graphics.bit_depth {
|
||||
.filter(
|
||||
|mode| match self.global_state.settings.graphics.fullscreen.bit_depth {
|
||||
Some(bit_depth) => mode.bit_depth() == bit_depth,
|
||||
None => true,
|
||||
})
|
||||
},
|
||||
)
|
||||
.sorted_by_key(|mode| mode.refresh_rate())
|
||||
.map(|mode| mode.refresh_rate())
|
||||
.rev()
|
||||
@ -2386,7 +2395,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.chain(refresh_rates.iter().map(|rate| format!("{}", rate)))
|
||||
.collect::<Vec<String>>()
|
||||
.as_slice(),
|
||||
match self.global_state.settings.graphics.refresh_rate {
|
||||
match self.global_state.settings.graphics.fullscreen.refresh_rate {
|
||||
Some(refresh_rate) => refresh_rates
|
||||
.iter()
|
||||
.position(|rate| rate == &refresh_rate)
|
||||
@ -2402,10 +2411,13 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.right_from(state.ids.bit_depth, 8.0)
|
||||
.set(state.ids.refresh_rate, ui)
|
||||
{
|
||||
events.push(Event::ChangeRefreshRate(if clicked == 0 {
|
||||
events.push(Event::ChangeFullscreenMode(FullScreenSettings {
|
||||
refresh_rate: if clicked == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(refresh_rates[clicked - 1])
|
||||
},
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
}
|
||||
|
||||
@ -2417,8 +2429,8 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.fullscreen_label, ui);
|
||||
|
||||
let fullscreen = ToggleButton::new(
|
||||
self.global_state.settings.graphics.fullscreen,
|
||||
let enabled = ToggleButton::new(
|
||||
self.global_state.settings.graphics.fullscreen.enabled,
|
||||
self.imgs.checkbox,
|
||||
self.imgs.checkbox_checked,
|
||||
)
|
||||
@ -2428,8 +2440,48 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
|
||||
.set(state.ids.fullscreen_button, ui);
|
||||
|
||||
if self.global_state.settings.graphics.fullscreen != fullscreen {
|
||||
events.push(Event::ToggleFullscreen);
|
||||
if self.global_state.settings.graphics.fullscreen.enabled != enabled {
|
||||
events.push(Event::ChangeFullscreenMode(FullScreenSettings {
|
||||
enabled,
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
}
|
||||
|
||||
// Fullscreen Mode
|
||||
Text::new(&self.localized_strings.get("hud.settings.fullscreen_mode"))
|
||||
.down_from(state.ids.fullscreen_label, 8.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.fullscreen_mode_text, ui);
|
||||
|
||||
let mode_list = [FullscreenMode::Exclusive, FullscreenMode::Borderless];
|
||||
let mode_label_list = [
|
||||
&self
|
||||
.localized_strings
|
||||
.get("hud.settings.fullscreen_mode.exclusive"),
|
||||
&self
|
||||
.localized_strings
|
||||
.get("hud.settings.fullscreen_mode.borderless"),
|
||||
];
|
||||
|
||||
// Get which fullscreen mode is currently active
|
||||
let selected = mode_list
|
||||
.iter()
|
||||
.position(|x| *x == self.global_state.settings.graphics.fullscreen.mode);
|
||||
|
||||
if let Some(clicked) = DropDownList::new(&mode_label_list, selected)
|
||||
.w_h(400.0, 22.0)
|
||||
.color(MENU_BG)
|
||||
.label_color(TEXT_COLOR)
|
||||
.label_font_id(self.fonts.cyri.conrod_id)
|
||||
.down_from(state.ids.fullscreen_mode_text, 8.0)
|
||||
.set(state.ids.fullscreen_mode_list, ui)
|
||||
{
|
||||
events.push(Event::ChangeFullscreenMode(FullScreenSettings {
|
||||
mode: mode_list[clicked],
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
}
|
||||
|
||||
// Save current screen size
|
||||
@ -2437,7 +2489,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.w_h(31.0 * 5.0, 12.0 * 2.0)
|
||||
.hover_image(self.imgs.settings_button_hover)
|
||||
.press_image(self.imgs.settings_button_press)
|
||||
.down_from(state.ids.fullscreen_label, 12.0)
|
||||
.down_from(state.ids.fullscreen_mode_list, 12.0)
|
||||
.label(&self.localized_strings.get("hud.settings.save_window_size"))
|
||||
.label_font_size(self.fonts.cyri.scale(14))
|
||||
.label_color(TEXT_COLOR)
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::{img_ids::Imgs, Show, TEXT_COLOR, UI_MAIN};
|
||||
use crate::ui::fonts::ConrodVoxygenFonts;
|
||||
use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts};
|
||||
use conrod_core::{
|
||||
color,
|
||||
widget::{self, Button, Image, Rectangle, Text},
|
||||
@ -8,8 +8,6 @@ use conrod_core::{
|
||||
|
||||
use client::{self, Client};
|
||||
|
||||
use crate::i18n::VoxygenLocalization;
|
||||
|
||||
widget_ids! {
|
||||
pub struct Ids {
|
||||
spell_frame,
|
||||
|
@ -957,37 +957,6 @@ impl PlayState for SessionState {
|
||||
global_state.settings.graphics.render_mode = *new_render_mode;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ChangeResolution(new_resolution) => {
|
||||
// Do this first so if it crashes the setting isn't saved :)
|
||||
global_state.window.fullscreen(
|
||||
global_state.settings.graphics.fullscreen,
|
||||
new_resolution,
|
||||
global_state.settings.graphics.bit_depth,
|
||||
global_state.settings.graphics.refresh_rate,
|
||||
);
|
||||
global_state.settings.graphics.resolution = new_resolution;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ChangeBitDepth(new_bit_depth) => {
|
||||
global_state.window.fullscreen(
|
||||
global_state.settings.graphics.fullscreen,
|
||||
global_state.settings.graphics.resolution,
|
||||
new_bit_depth,
|
||||
global_state.settings.graphics.refresh_rate,
|
||||
);
|
||||
global_state.settings.graphics.bit_depth = new_bit_depth;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ChangeRefreshRate(new_refresh_rate) => {
|
||||
global_state.window.fullscreen(
|
||||
global_state.settings.graphics.fullscreen,
|
||||
global_state.settings.graphics.resolution,
|
||||
global_state.settings.graphics.bit_depth,
|
||||
new_refresh_rate,
|
||||
);
|
||||
global_state.settings.graphics.refresh_rate = new_refresh_rate;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ChangeLanguage(new_language) => {
|
||||
global_state.settings.language.selected_language =
|
||||
new_language.language_identifier;
|
||||
@ -999,15 +968,17 @@ impl PlayState for SessionState {
|
||||
self.voxygen_i18n.log_missing_entries();
|
||||
self.hud.update_language(self.voxygen_i18n.clone());
|
||||
},
|
||||
HudEvent::ChangeFullscreenMode(new_fullscreen_settings) => {
|
||||
global_state
|
||||
.window
|
||||
.set_fullscreen_mode(new_fullscreen_settings);
|
||||
global_state.settings.graphics.fullscreen = new_fullscreen_settings;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ToggleParticlesEnabled(particles_enabled) => {
|
||||
global_state.settings.graphics.particles_enabled = particles_enabled;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ToggleFullscreen => {
|
||||
global_state
|
||||
.window
|
||||
.toggle_fullscreen(&mut global_state.settings);
|
||||
},
|
||||
HudEvent::AdjustWindowSize(new_size) => {
|
||||
global_state.window.set_size(new_size.into());
|
||||
global_state.settings.graphics.window_size = new_size;
|
||||
|
@ -3,7 +3,7 @@ use crate::{
|
||||
i18n,
|
||||
render::RenderMode,
|
||||
ui::ScaleMode,
|
||||
window::{GameInput, KeyMouse},
|
||||
window::{FullScreenSettings, GameInput, KeyMouse},
|
||||
};
|
||||
use directories_next::{ProjectDirs, UserDirs};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
@ -617,11 +617,8 @@ pub struct GraphicsSettings {
|
||||
pub fov: u16,
|
||||
pub gamma: f32,
|
||||
pub render_mode: RenderMode,
|
||||
pub resolution: [u16; 2],
|
||||
pub bit_depth: Option<u16>,
|
||||
pub refresh_rate: Option<u16>,
|
||||
pub window_size: [u16; 2],
|
||||
pub fullscreen: bool,
|
||||
pub fullscreen: FullScreenSettings,
|
||||
pub lod_detail: u32,
|
||||
}
|
||||
|
||||
@ -636,11 +633,8 @@ impl Default for GraphicsSettings {
|
||||
fov: 50,
|
||||
gamma: 1.0,
|
||||
render_mode: RenderMode::default(),
|
||||
resolution: [1920, 1080],
|
||||
bit_depth: None,
|
||||
refresh_rate: None,
|
||||
window_size: [1920, 1080],
|
||||
fullscreen: false,
|
||||
fullscreen: FullScreenSettings::default(),
|
||||
lod_detail: 300,
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ enum DrawKind {
|
||||
// Text and non-textured geometry
|
||||
Plain,
|
||||
}
|
||||
|
||||
enum DrawCommand {
|
||||
Draw { kind: DrawKind, verts: Range<u32> },
|
||||
Scissor(Aabr<u16>),
|
||||
|
@ -489,7 +489,7 @@ pub struct Window {
|
||||
pub zoom_sensitivity: u32,
|
||||
pub zoom_inversion: bool,
|
||||
pub mouse_y_inversion: bool,
|
||||
fullscreen: bool,
|
||||
fullscreen: FullScreenSettings,
|
||||
modifiers: winit::event::ModifiersState,
|
||||
needs_refresh_resize: bool,
|
||||
keypress_map: HashMap<GameInput, winit::event::ElementState>,
|
||||
@ -593,7 +593,7 @@ impl Window {
|
||||
zoom_sensitivity: settings.gameplay.zoom_sensitivity,
|
||||
zoom_inversion: settings.gameplay.zoom_inversion,
|
||||
mouse_y_inversion: settings.gameplay.mouse_y_inversion,
|
||||
fullscreen: false,
|
||||
fullscreen: FullScreenSettings::default(),
|
||||
modifiers: Default::default(),
|
||||
needs_refresh_resize: false,
|
||||
keypress_map,
|
||||
@ -611,12 +611,7 @@ impl Window {
|
||||
toggle_fullscreen: false,
|
||||
};
|
||||
|
||||
this.fullscreen(
|
||||
settings.graphics.fullscreen,
|
||||
settings.graphics.resolution,
|
||||
settings.graphics.bit_depth,
|
||||
settings.graphics.refresh_rate,
|
||||
);
|
||||
this.set_fullscreen_mode(settings.graphics.fullscreen);
|
||||
|
||||
Ok((this, event_loop))
|
||||
}
|
||||
@ -1062,17 +1057,17 @@ impl Window {
|
||||
}
|
||||
|
||||
pub fn toggle_fullscreen(&mut self, settings: &mut Settings) {
|
||||
self.fullscreen(
|
||||
!self.is_fullscreen(),
|
||||
settings.graphics.resolution,
|
||||
settings.graphics.bit_depth,
|
||||
settings.graphics.refresh_rate,
|
||||
);
|
||||
settings.graphics.fullscreen = self.is_fullscreen();
|
||||
let fullscreen = FullScreenSettings {
|
||||
enabled: !self.is_fullscreen(),
|
||||
..settings.graphics.fullscreen
|
||||
};
|
||||
|
||||
self.set_fullscreen_mode(fullscreen);
|
||||
settings.graphics.fullscreen = fullscreen;
|
||||
settings.save_to_file_warn();
|
||||
}
|
||||
|
||||
pub fn is_fullscreen(&self) -> bool { self.fullscreen }
|
||||
pub fn is_fullscreen(&self) -> bool { self.fullscreen.enabled }
|
||||
|
||||
pub fn select_video_mode_rec(
|
||||
&self,
|
||||
@ -1250,22 +1245,26 @@ impl Window {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn fullscreen(
|
||||
&mut self,
|
||||
fullscreen: bool,
|
||||
resolution: [u16; 2],
|
||||
bit_depth: Option<u16>,
|
||||
refresh_rate: Option<u16>,
|
||||
) {
|
||||
pub fn set_fullscreen_mode(&mut self, fullscreen: FullScreenSettings) {
|
||||
let window = self.window.window();
|
||||
self.fullscreen = fullscreen;
|
||||
if fullscreen {
|
||||
window.set_fullscreen(Some(winit::window::Fullscreen::Exclusive(
|
||||
self.select_video_mode(resolution, bit_depth, refresh_rate),
|
||||
)));
|
||||
} else {
|
||||
window.set_fullscreen(None);
|
||||
}
|
||||
window.set_fullscreen(
|
||||
fullscreen
|
||||
.enabled
|
||||
.then(|| match fullscreen.mode {
|
||||
FullscreenMode::Exclusive => {
|
||||
winit::window::Fullscreen::Exclusive(self.select_video_mode(
|
||||
fullscreen.resolution,
|
||||
fullscreen.bit_depth,
|
||||
fullscreen.refresh_rate,
|
||||
))
|
||||
},
|
||||
FullscreenMode::Borderless => {
|
||||
winit::window::Fullscreen::Borderless(window.current_monitor())
|
||||
},
|
||||
})
|
||||
.or_else(|| None),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn needs_refresh_resize(&mut self) { self.needs_refresh_resize = true; }
|
||||
@ -1376,3 +1375,33 @@ impl Window {
|
||||
self.remapping_keybindings = Some(game_input);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub enum FullscreenMode {
|
||||
Exclusive,
|
||||
Borderless,
|
||||
}
|
||||
|
||||
impl Default for FullscreenMode {
|
||||
fn default() -> Self { FullscreenMode::Borderless }
|
||||
}
|
||||
#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)]
|
||||
pub struct FullScreenSettings {
|
||||
pub enabled: bool,
|
||||
pub mode: FullscreenMode,
|
||||
pub resolution: [u16; 2],
|
||||
pub bit_depth: Option<u16>,
|
||||
pub refresh_rate: Option<u16>,
|
||||
}
|
||||
|
||||
impl Default for FullScreenSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
mode: FullscreenMode::Borderless,
|
||||
resolution: [1920, 1080],
|
||||
bit_depth: None,
|
||||
refresh_rate: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user