Skip to content

Commit

Permalink
web: Add a config option to disable the message about unsupported con…
Browse files Browse the repository at this point in the history
…tent
  • Loading branch information
torokati44 authored and Herschel committed Jan 11, 2021
1 parent c2470d3 commit cce3a81
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ pub struct Player {

swf: Arc<SwfMovie>,

warn_on_unsupported_content: bool,

is_playing: bool,
needs_render: bool,

Expand Down Expand Up @@ -241,6 +243,8 @@ impl Player {

swf: fake_movie.clone(),

warn_on_unsupported_content: true,

is_playing: false,
needs_render: true,

Expand Down Expand Up @@ -535,6 +539,14 @@ impl Player {
|| (self.letterbox == Letterbox::Fullscreen && self.user_interface.is_fullscreen())
}

pub fn warn_on_unsupported_content(&self) -> bool {
self.warn_on_unsupported_content
}

pub fn set_warn_on_unsupported_content(&mut self, warn_on_unsupported_content: bool) {
self.warn_on_unsupported_content = warn_on_unsupported_content
}

pub fn movie_width(&self) -> u32 {
self.movie_width
}
Expand Down Expand Up @@ -868,7 +880,7 @@ impl Player {
lib.register_character(id, crate::character::Character::MorphShape(morph_shape));
}
});
if is_action_script_3 {
if is_action_script_3 && self.warn_on_unsupported_content {
self.user_interface.message("This SWF contains ActionScript 3 which is not yet supported by Ruffle. The movie may not work as intended.");
}
}
Expand Down
8 changes: 8 additions & 0 deletions web/packages/core/src/load-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ export interface BaseLoadOptions {
* @default true
*/
upgradeToHttps?: boolean;

/**
* Whether or not to display an overlay with a warning when
* loading a movie with unsupported content.
*
* @default true
*/
warnOnUnsupportedContent?: boolean;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,17 @@ pub struct Config {

#[serde(rename = "upgradeToHttps")]
upgrade_to_https: bool,

#[serde(rename = "warnOnUnsupportedContent")]
warn_on_unsupported_content: bool,
}

impl Default for Config {
fn default() -> Self {
Self {
letterbox: Default::default(),
upgrade_to_https: true,
warn_on_unsupported_content: true,
}
}
}
Expand Down Expand Up @@ -359,6 +363,9 @@ impl Ruffle {
user_interface,
)?;
core.lock().unwrap().set_letterbox(config.letterbox);
core.lock()
.unwrap()
.set_warn_on_unsupported_content(config.warn_on_unsupported_content);

// Create instance.
let instance = RuffleInstance {
Expand Down

0 comments on commit cce3a81

Please sign in to comment.