From 8db909a7d400b881fb4ea0a1de2be3a119f6160a Mon Sep 17 00:00:00 2001 From: CUB3D Date: Thu, 29 Dec 2022 21:44:20 +0000 Subject: [PATCH] desktop: Allow specifying player version --- core/src/player.rs | 16 +++++++++++++--- desktop/src/main.rs | 7 ++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/src/player.rs b/core/src/player.rs index 787163740..6abb10123 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -1917,6 +1917,7 @@ pub struct PlayerBuilder { warn_on_unsupported_content: bool, load_behavior: LoadBehavior, spoofed_url: Option, + player_version: Option, } impl PlayerBuilder { @@ -1952,6 +1953,7 @@ impl PlayerBuilder { warn_on_unsupported_content: true, load_behavior: LoadBehavior::Streaming, spoofed_url: None, + player_version: None, } } @@ -2071,6 +2073,12 @@ impl PlayerBuilder { self } + // Configures the target player version. + pub fn with_player_version(mut self, version: Option) -> Self { + self.player_version = version; + self + } + /// Builds the player, wiring up the backends and configuring the specified settings. pub fn build(self) -> Arc> { use crate::backend::*; @@ -2101,8 +2109,10 @@ impl PlayerBuilder { .video .unwrap_or_else(|| Box::new(null::NullVideoBackend::new())); + let player_version = self.player_version.unwrap_or(NEWEST_PLAYER_VERSION); + // Instantiate the player. - let fake_movie = Arc::new(SwfMovie::empty(NEWEST_PLAYER_VERSION)); + let fake_movie = Arc::new(SwfMovie::empty(player_version)); let frame_rate = 12.0; let player = Arc::new_cyclic(|self_ref| { Mutex::new(Player { @@ -2141,7 +2151,7 @@ impl PlayerBuilder { system: SystemProperties::default(), transform_stack: TransformStack::new(), instance_counter: 0, - player_version: NEWEST_PLAYER_VERSION, + player_version, is_playing: self.autoplay, needs_render: true, warn_on_unsupported_content: self.warn_on_unsupported_content, @@ -2159,7 +2169,7 @@ impl PlayerBuilder { GcRootData { audio_manager: AudioManager::new(), action_queue: ActionQueue::new(), - avm1: Avm1::new(gc_context, NEWEST_PLAYER_VERSION), + avm1: Avm1::new(gc_context, player_version), avm2: Avm2::new(gc_context), current_context_menu: None, drag_object: None, diff --git a/desktop/src/main.rs b/desktop/src/main.rs index a54bdc5a3..f319275b4 100644 --- a/desktop/src/main.rs +++ b/desktop/src/main.rs @@ -113,6 +113,10 @@ struct Opt { /// Spoofs the root SWF URL provided to ActionScript. #[clap(long, value_parser)] spoof_url: Option, + + /// The version of the player to emulate + #[clap(long, short)] + player_version: Option } #[cfg(feature = "render_trace")] @@ -281,7 +285,8 @@ impl App { .with_warn_on_unsupported_content(!opt.dont_warn_on_unsupported_content) .with_fullscreen(opt.fullscreen) .with_load_behavior(opt.load_behavior) - .with_spoofed_url(opt.spoof_url.clone().map(|url| url.to_string())); + .with_spoofed_url(opt.spoof_url.clone().map(|url| url.to_string())) + .with_player_version(opt.player_version); let player = builder.build();