web: Store StageScaleMode directly in builder, not Option<>

This commit is contained in:
Nathan Adams 2024-06-05 12:46:13 +02:00
parent 7c340f5b6c
commit af71ef3276
2 changed files with 7 additions and 7 deletions

View File

@ -24,7 +24,7 @@ pub struct RuffleInstanceBuilder {
pub(crate) stage_align: StageAlign, pub(crate) stage_align: StageAlign,
pub(crate) force_align: bool, pub(crate) force_align: bool,
pub(crate) quality: Option<StageQuality>, pub(crate) quality: Option<StageQuality>,
pub(crate) scale: Option<StageScaleMode>, pub(crate) scale: StageScaleMode,
pub(crate) force_scale: bool, pub(crate) force_scale: bool,
pub(crate) frame_rate: Option<f64>, pub(crate) frame_rate: Option<f64>,
pub(crate) wmode: Option<String>, // TODO: Enumify? `Player` is working in strings here too... pub(crate) wmode: Option<String>, // TODO: Enumify? `Player` is working in strings here too...
@ -59,7 +59,7 @@ impl Default for RuffleInstanceBuilder {
stage_align: StageAlign::empty(), stage_align: StageAlign::empty(),
force_align: false, force_align: false,
quality: None, quality: None,
scale: None, scale: StageScaleMode::ShowAll,
force_scale: false, force_scale: false,
frame_rate: None, frame_rate: None,
wmode: None, wmode: None,
@ -174,10 +174,10 @@ impl RuffleInstanceBuilder {
#[wasm_bindgen(js_name = "setScale")] #[wasm_bindgen(js_name = "setScale")]
pub fn set_scale(&mut self, value: &str) { pub fn set_scale(&mut self, value: &str) {
self.scale = match value { self.scale = match value {
"exactfit" => Some(StageScaleMode::ExactFit), "exactfit" => StageScaleMode::ExactFit,
"noborder" => Some(StageScaleMode::NoBorder), "noborder" => StageScaleMode::NoBorder,
"noscale" => Some(StageScaleMode::NoScale), "noscale" => StageScaleMode::NoScale,
"showall" => Some(StageScaleMode::ShowAll), "showall" => StageScaleMode::ShowAll,
_ => return, _ => return,
}; };
} }

View File

@ -525,7 +525,7 @@ impl RuffleHandle {
.with_compatibility_rules(config.compatibility_rules) .with_compatibility_rules(config.compatibility_rules)
.with_quality(config.quality.unwrap_or(default_quality)) .with_quality(config.quality.unwrap_or(default_quality))
.with_align(config.stage_align, config.force_align) .with_align(config.stage_align, config.force_align)
.with_scale_mode(config.scale.unwrap_or_default(), config.force_scale) .with_scale_mode(config.scale, config.force_scale)
.with_frame_rate(config.frame_rate) .with_frame_rate(config.frame_rate)
// FIXME - should this be configurable? // FIXME - should this be configurable?
.with_sandbox_type(SandboxType::Remote) .with_sandbox_type(SandboxType::Remote)