diff options
Diffstat (limited to 'apps/fparkan-game/src')
| -rw-r--r-- | apps/fparkan-game/src/mission_loading.rs | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/apps/fparkan-game/src/mission_loading.rs b/apps/fparkan-game/src/mission_loading.rs index 823c6b35..bff5790b 100644 --- a/apps/fparkan-game/src/mission_loading.rs +++ b/apps/fparkan-game/src/mission_loading.rs @@ -5,7 +5,9 @@ use super::{ mission_startup::{self, PreparedMission}, Args, Engine, LegacyCameraCapture, StaticVulkanApp, }; +use fparkan_assets::game_settings::{DisplaySettings, GameSettings}; use fparkan_platform_winit::{new_game_event_loop, WinitWindowPlan}; +use fparkan_vfs::DirectoryVfs; use std::{ panic::{catch_unwind, AssertUnwindSafe}, path::Path, @@ -17,7 +19,7 @@ use winit::{ dpi::PhysicalSize, event::{DeviceEvent, DeviceId, WindowEvent}, event_loop::{ActiveEventLoop, ControlFlow, EventLoopProxy}, - window::{Window, WindowId}, + window::{Fullscreen, Window, WindowId}, }; #[cfg(windows)] @@ -25,7 +27,6 @@ use { super::startup_intro::StartupIntro, fparkan_assets::mission_loader::MissionLoader, fparkan_platform_winit::{startup_window, text::StringResources}, - fparkan_vfs::DirectoryVfs, std::time::{Duration, Instant}, winit::event::{ElementState, MouseButton}, }; @@ -57,7 +58,17 @@ pub(super) fn run( .as_ref() .map(LegacyCameraCapture::captured_viewport) .transpose()?; - let extent = capture.map_or([plan.width, plan.height], |viewport| viewport.extent); + let display = if capture.is_none() && !args.viewer { + GameSettings::load(&DirectoryVfs::new(&args.root)) + .map_err(|error| format!("read Iron_3D.ini: {error}"))? + .display() + } else { + None + }; + let extent = capture.map_or_else( + || display.map_or([plan.width, plan.height], |display| display.extent), + |viewport| viewport.extent, + ); let event_loop = new_game_event_loop().map_err(|error| format!("winit event loop: {error}"))?; event_loop.set_control_flow(ControlFlow::Wait); let mut startup = WindowedMission { @@ -65,6 +76,7 @@ pub(super) fn run( intro: menu.as_ref().and_then(|_| StartupIntro::open(&args.root)), args, extent, + exclusive_display: display.filter(|display| cfg!(windows) && !display.windowed), resizable: capture.is_none(), menu, loading: MissionLoading::default(), @@ -110,6 +122,7 @@ struct LoadRequest { struct WindowedMission { args: Args, extent: [u32; 2], + exclusive_display: Option<DisplaySettings>, resizable: bool, menu: Option<LaunchMenu>, // The DirectShow child and its graph must release before the window. @@ -188,9 +201,27 @@ impl ApplicationHandler for WindowedMission { return; } let [width, height] = self.extent; + let fullscreen = match self.exclusive_display { + Some(display) => { + let mode = event_loop.primary_monitor().and_then(|monitor| { + monitor.video_modes().min_by_key(|mode| { + let size = mode.size(); + display.mode_distance([size.width, size.height], mode.bit_depth().into()) + }) + }); + let Some(mode) = mode else { + self.error = Some("Iron_3D.ini requests fullscreen with no video modes".into()); + event_loop.exit(); + return; + }; + Some(Fullscreen::Exclusive(mode)) + } + None => None, + }; let attributes = Window::default_attributes() .with_title("FParkan") .with_inner_size(PhysicalSize::new(width, height)) + .with_fullscreen(fullscreen) // Preserve the recorded crop when playing from a captured camera. .with_resizable(self.resizable); match event_loop.create_window(attributes) { |
