forked from ruffle-rs/ruffle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
avm1_button.rs
738 lines (651 loc) · 24.8 KB
/
avm1_button.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
use crate::avm1::{Activation, ActivationIdentifier, Object, StageObject, TObject, Value};
use crate::backend::ui::MouseCursor;
use crate::context::{ActionType, RenderContext, UpdateContext};
use crate::display_object::container::{
dispatch_added_event, dispatch_removed_event, ChildContainer,
};
use crate::display_object::interactive::{
InteractiveObject, InteractiveObjectBase, TInteractiveObject,
};
use crate::display_object::{DisplayObjectBase, DisplayObjectPtr};
use crate::events::{ClipEvent, ClipEventResult};
use crate::prelude::*;
use crate::tag_utils::{SwfMovie, SwfSlice};
use crate::vminterface::Instantiator;
use core::fmt;
use gc_arena::barrier::unlock;
use gc_arena::lock::{Lock, RefLock};
use gc_arena::{Collect, Gc, Mutation};
use ruffle_render::filters::Filter;
use std::cell::{Cell, Ref, RefCell, RefMut};
use std::collections::BTreeMap;
use std::sync::Arc;
use swf::ButtonActionCondition;
use super::interactive::Avm2MousePick;
#[derive(Clone, Collect, Copy)]
#[collect(no_drop)]
pub struct Avm1Button<'gc>(Gc<'gc, Avm1ButtonData<'gc>>);
impl fmt::Debug for Avm1Button<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Avm1Button")
.field("ptr", &Gc::as_ptr(self.0))
.finish()
}
}
#[derive(Clone, Collect)]
#[collect(no_drop)]
pub struct Avm1ButtonData<'gc> {
cell: RefLock<Avm1ButtonDataMut<'gc>>,
static_data: Gc<'gc, ButtonStatic>,
state: Cell<ButtonState>,
tracking: Cell<ButtonTracking>,
object: Lock<Option<Object<'gc>>>,
initialized: Cell<bool>,
has_focus: Cell<bool>,
// TODO Consider moving this to InteractiveObject along with
// TextField's and MovieClip's tab indices after AVM2 analysis
tab_index: Cell<Option<i32>>,
}
#[derive(Clone, Collect)]
#[collect(no_drop)]
struct Avm1ButtonDataMut<'gc> {
base: InteractiveObjectBase<'gc>,
hit_area: BTreeMap<Depth, DisplayObject<'gc>>,
container: ChildContainer<'gc>,
}
impl<'gc> Avm1Button<'gc> {
pub fn from_swf_tag(button: &swf::Button, source_movie: &SwfSlice, mc: &Mutation<'gc>) -> Self {
let actions = button
.actions
.iter()
.map(|action| ButtonAction {
action_data: source_movie.to_unbounded_subslice(action.action_data),
conditions: action.conditions,
})
.collect();
Avm1Button(Gc::new(
mc,
Avm1ButtonData {
cell: RefLock::new(Avm1ButtonDataMut {
base: Default::default(),
container: ChildContainer::new(source_movie.movie.clone()),
hit_area: BTreeMap::new(),
}),
static_data: Gc::new(
mc,
ButtonStatic {
swf: source_movie.movie.clone(),
id: button.id,
actions,
cell: RefCell::new(ButtonStaticMut {
records: button.records.clone(),
up_to_over_sound: None,
over_to_down_sound: None,
down_to_over_sound: None,
over_to_up_sound: None,
}),
},
),
state: Cell::new(ButtonState::Up),
initialized: Cell::new(false),
object: Lock::new(None),
tracking: Cell::new(if button.is_track_as_menu {
ButtonTracking::Menu
} else {
ButtonTracking::Push
}),
has_focus: Cell::new(false),
tab_index: Cell::new(None),
},
))
}
pub fn set_sounds(self, sounds: swf::ButtonSounds) {
let mut static_data = self.0.static_data.cell.borrow_mut();
static_data.up_to_over_sound = sounds.up_to_over_sound;
static_data.over_to_down_sound = sounds.over_to_down_sound;
static_data.down_to_over_sound = sounds.down_to_over_sound;
static_data.over_to_up_sound = sounds.over_to_up_sound;
}
/// Handles the ancient DefineButtonCxform SWF tag.
/// Set the color transform for all children of each state.
pub fn set_colors(self, color_transforms: &[swf::ColorTransform]) {
let mut static_data = self.0.static_data.cell.borrow_mut();
// This tag isn't documented well in SWF19. It is only used in very old SWF<=2 content.
// It applies color transforms to every character in a button, in sequence(?).
for (record, color_transform) in static_data.records.iter_mut().zip(color_transforms.iter())
{
record.color_transform = *color_transform;
}
}
/// Set the state of a button, creating or destroying children as needed.
///
/// This function instantiates children and thus must not be called whilst
/// the caller is holding a write lock on the button data.
pub fn set_state(
mut self,
context: &mut crate::context::UpdateContext<'_, 'gc>,
state: ButtonState,
) {
let mut removed_depths: fnv::FnvHashSet<_> =
self.iter_render_list().map(|o| o.depth()).collect();
let movie = self.movie();
self.0.state.set(state);
// Create any new children that exist in this state, and remove children
// that only exist in the previous state.
// Children that exist in both states should persist and not be recreated.
// TODO: This behavior probably differs in AVM2 (I suspect they always get recreated).
let mut children = Vec::new();
for record in &self.0.static_data.cell.borrow().records {
if record.states.contains(state.into()) {
// State contains this depth, so we don't have to remove it.
removed_depths.remove(&record.depth.into());
let child = match self.child_by_depth(record.depth.into()) {
// Re-use existing child.
Some(child) if child.id() == record.id => child,
// Instantiate new child.
_ => {
if let Ok(child) = context
.library
.library_for_movie_mut(movie.clone())
.instantiate_by_id(record.id, context.gc_context)
{
// New child that did not previously exist, create it.
child.set_parent(context, Some(self.into()));
child.set_depth(context.gc(), record.depth.into());
children.push((child, record.depth));
child
} else {
continue;
}
}
};
// Set transform of child (and modify previous child if it already existed)
child.set_matrix(context.gc(), record.matrix.into());
child.set_color_transform(context.gc(), record.color_transform);
child.set_blend_mode(context.gc(), record.blend_mode.into());
child.set_filters(
context.gc(),
record.filters.iter().map(Filter::from).collect(),
);
}
}
// Kill children that no longer exist in this state.
for depth in removed_depths {
if let Some(child) = self.child_by_depth(depth) {
self.remove_child(context, child);
}
}
for (child, depth) in children {
// Initialize new child.
child.post_instantiation(context, None, Instantiator::Movie, false);
child.run_frame_avm1(context);
let removed_child = self.replace_at_depth(context, child, depth.into());
dispatch_added_event(self.into(), child, false, context);
if let Some(removed_child) = removed_child {
dispatch_removed_event(removed_child, context);
}
}
self.invalidate_cached_bitmap(context.gc());
}
pub fn state(&self) -> Option<ButtonState> {
Some(self.0.state.get())
}
fn get_boolean_property(
self,
context: &mut UpdateContext<'_, 'gc>,
name: &'static str,
default: bool,
) -> bool {
if let Value::Object(object) = self.object() {
let mut activation = Activation::from_nothing(
context.reborrow(),
ActivationIdentifier::root("[AVM1 Boolean Property]"),
self.avm1_root(),
);
if let Ok(value) = object.get(name, &mut activation) {
match value {
Value::Undefined => default,
_ => value.as_bool(activation.swf_version()),
}
} else {
default
}
} else {
false
}
}
fn enabled(self, context: &mut UpdateContext<'_, 'gc>) -> bool {
self.get_boolean_property(context, "enabled", true)
}
fn use_hand_cursor(self, context: &mut UpdateContext<'_, 'gc>) -> bool {
self.get_boolean_property(context, "useHandCursor", true)
}
/// Get the value of `tabIndex` used in AS.
///
/// Do not confuse it with `tab_index`, which returns the value used for ordering.
pub fn tab_index_value(&self) -> Option<i32> {
self.0.tab_index.get()
}
/// Set the value of `tabIndex` used in AS.
pub fn set_tab_index_value(&self, _context: &mut UpdateContext<'_, 'gc>, value: Option<i32>) {
self.0.tab_index.set(value)
}
}
impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
fn base(&self) -> Ref<DisplayObjectBase<'gc>> {
Ref::map(self.0.cell.borrow(), |r| &r.base.base)
}
fn base_mut<'a>(&'a self, mc: &Mutation<'gc>) -> RefMut<'a, DisplayObjectBase<'gc>> {
let data = unlock!(Gc::write(mc, self.0), Avm1ButtonData, cell);
RefMut::map(data.borrow_mut(), |w| &mut w.base.base)
}
fn instantiate(&self, mc: &Mutation<'gc>) -> DisplayObject<'gc> {
let data: &Avm1ButtonData = &self.0;
Self(Gc::new(mc, data.clone())).into()
}
fn as_ptr(&self) -> *const DisplayObjectPtr {
Gc::as_ptr(self.0) as *const DisplayObjectPtr
}
fn id(&self) -> CharacterId {
self.0.static_data.id
}
fn movie(&self) -> Arc<SwfMovie> {
self.0.movie()
}
fn post_instantiation(
&self,
context: &mut UpdateContext<'_, 'gc>,
_init_object: Option<Object<'gc>>,
_instantiated_by: Instantiator,
run_frame: bool,
) {
self.set_default_instance_name(context);
if !self.movie().is_action_script_3() {
context
.avm1
.add_to_exec_list(context.gc_context, (*self).into());
}
if self.0.object.get().is_none() {
let object = StageObject::for_display_object(
context.gc(),
(*self).into(),
context.avm1.prototypes().button,
);
let obj = unlock!(Gc::write(context.gc(), self.0), Avm1ButtonData, object);
obj.set(Some(object.into()));
if run_frame {
self.run_frame_avm1(context);
}
}
}
fn run_frame_avm1(&self, context: &mut UpdateContext<'_, 'gc>) {
let self_display_object = (*self).into();
let initialized = self.0.initialized.get();
// TODO: Move this to post_instantiation.
if !initialized {
let mut new_children = Vec::new();
self.set_state(context, ButtonState::Up);
self.0.initialized.set(true);
for record in &self.0.static_data.cell.borrow().records {
if record.states.contains(swf::ButtonState::HIT_TEST) {
match context
.library
.library_for_movie_mut(self.0.movie())
.instantiate_by_id(record.id, context.gc_context)
{
Ok(child) => {
child.set_matrix(context.gc(), record.matrix.into());
child.set_parent(context, Some(self_display_object));
child.set_depth(context.gc(), record.depth.into());
new_children.push((child, record.depth.into()));
}
Err(error) => {
tracing::error!(
"Button ID {}: could not instantiate child ID {}: {}",
self.0.static_data.id,
record.id,
error
);
}
}
}
}
let write = unlock!(Gc::write(context.gc(), self.0), Avm1ButtonData, cell);
for (child, depth) in new_children {
child.post_instantiation(context, None, Instantiator::Movie, false);
write.borrow_mut().hit_area.insert(depth, child);
}
}
}
fn render_self(&self, context: &mut RenderContext<'_, 'gc>) {
self.render_children(context);
}
fn self_bounds(&self) -> Rectangle<Twips> {
// No inherent bounds; contains child DisplayObjects.
Default::default()
}
fn hit_test_shape(
&self,
context: &mut UpdateContext<'_, 'gc>,
point: Point<Twips>,
options: HitTestOptions,
) -> bool {
for child in self.iter_render_list() {
if child.hit_test_shape(context, point, options) {
return true;
}
}
false
}
fn object(&self) -> Value<'gc> {
self.0
.object
.get()
.map(Value::from)
.unwrap_or(Value::Undefined)
}
fn as_avm1_button(&self) -> Option<Self> {
Some(*self)
}
fn as_interactive(self) -> Option<InteractiveObject<'gc>> {
Some(self.into())
}
fn as_container(self) -> Option<DisplayObjectContainer<'gc>> {
Some(self.into())
}
fn allow_as_mask(&self) -> bool {
!self.is_empty()
}
fn is_focusable(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {
true
}
fn on_focus_changed(
&self,
context: &mut UpdateContext<'_, 'gc>,
focused: bool,
other: Option<DisplayObject<'gc>>,
) {
self.0.has_focus.set(focused);
self.call_focus_handler(context, focused, other);
}
fn is_tab_enabled(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {
self.get_avm1_boolean_property(context, "tabEnabled", true)
}
fn tab_index(&self) -> Option<i64> {
self.0.tab_index.get().map(|i| i as i64)
}
fn is_highlight_enabled(&self) -> bool {
// TODO focusrect support
true
}
fn avm1_unload(&self, context: &mut UpdateContext<'_, 'gc>) {
let had_focus = self.0.has_focus.get();
if had_focus {
let tracker = context.focus_tracker;
tracker.set(None, context);
}
if let Some(node) = self.maskee() {
node.set_masker(context.gc(), None, true);
} else if let Some(node) = self.masker() {
node.set_maskee(context.gc(), None, true);
}
self.set_avm1_removed(context.gc(), true);
}
}
impl<'gc> TDisplayObjectContainer<'gc> for Avm1Button<'gc> {
fn raw_container(&self) -> Ref<'_, ChildContainer<'gc>> {
Ref::map(self.0.cell.borrow(), |this| &this.container)
}
fn raw_container_mut(&self, mc: &Mutation<'gc>) -> RefMut<'_, ChildContainer<'gc>> {
let data = unlock!(Gc::write(mc, self.0), Avm1ButtonData, cell);
RefMut::map(data.borrow_mut(), |this| &mut this.container)
}
}
impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
fn raw_interactive(&self) -> Ref<InteractiveObjectBase<'gc>> {
Ref::map(self.0.cell.borrow(), |r| &r.base)
}
fn raw_interactive_mut(&self, mc: &Mutation<'gc>) -> RefMut<InteractiveObjectBase<'gc>> {
let data = unlock!(Gc::write(mc, self.0), Avm1ButtonData, cell);
RefMut::map(data.borrow_mut(), |w| &mut w.base)
}
fn as_displayobject(self) -> DisplayObject<'gc> {
self.into()
}
fn filter_clip_event(
self,
_context: &mut UpdateContext<'_, 'gc>,
event: ClipEvent,
) -> ClipEventResult {
// An invisible button can still run its `rollOut` or `releaseOutside` event.
// A disabled button doesn't run its events (`KeyPress` being the exception) but
// its state can still change. This is tested at "avm1/mouse_events_visible_enabled".
if !self.visible() && self.0.state.get() == ButtonState::Up {
return ClipEventResult::NotHandled;
}
// The `keyPress` event doesn't fire if the button is inside another button.
if matches!(event, ClipEvent::KeyPress { .. })
&& self
.base()
.parent
.and_then(|p| p.as_avm1_button())
.is_some()
{
return ClipEventResult::NotHandled;
}
ClipEventResult::Handled
}
fn event_dispatch(
self,
context: &mut UpdateContext<'_, 'gc>,
event: ClipEvent,
) -> ClipEventResult {
let self_display_object = self.into();
let is_enabled = self.enabled(context);
let movie_version = self.movie().version();
// Translate the clip event to a button event, based on how the button state changes.
let static_data = self.0.static_data;
let static_data = static_data.cell.borrow();
let (new_state, condition, sound) = match event {
ClipEvent::DragOut { .. } => (
ButtonState::Over,
ButtonActionCondition::OVER_DOWN_TO_OUT_DOWN,
None,
),
ClipEvent::DragOver { .. } => (
ButtonState::Down,
ButtonActionCondition::OUT_DOWN_TO_OVER_DOWN,
None,
),
ClipEvent::Press => (
ButtonState::Down,
ButtonActionCondition::OVER_UP_TO_OVER_DOWN,
static_data.over_to_down_sound.as_ref(),
),
ClipEvent::Release => (
ButtonState::Over,
ButtonActionCondition::OVER_DOWN_TO_OVER_UP,
static_data.down_to_over_sound.as_ref(),
),
ClipEvent::ReleaseOutside => (
ButtonState::Up,
ButtonActionCondition::OUT_DOWN_TO_IDLE,
static_data.over_to_up_sound.as_ref(),
),
ClipEvent::RollOut { .. } => (
ButtonState::Up,
ButtonActionCondition::OVER_UP_TO_IDLE,
static_data.over_to_up_sound.as_ref(),
),
ClipEvent::RollOver { .. } => (
ButtonState::Over,
ButtonActionCondition::IDLE_TO_OVER_UP,
static_data.up_to_over_sound.as_ref(),
),
ClipEvent::KeyPress { key_code } => {
return self.0.run_actions(
context,
swf::ButtonActionCondition::from_key_code(key_code.to_u8()),
);
}
_ => return ClipEventResult::NotHandled,
};
let (update_state, new_state) = if is_enabled {
self.0.run_actions(context, condition);
self.0.play_sound(context, sound);
// Queue ActionScript-defined event handlers after the SWF defined ones.
// (e.g., clip.onRelease = foo).
if movie_version >= 6 {
if let Some(name) = event.method_name() {
context.action_queue.queue_action(
self_display_object,
ActionType::Method {
object: self.0.object.get().unwrap(),
name,
args: vec![],
},
false,
);
}
}
(self.0.state.get() != new_state, new_state)
} else {
// Remove the current mouse hovered and mouse down objects.
// This is required to make sure the button will fire its events if it gets enabled.
if InteractiveObject::option_ptr_eq(self.as_interactive(), context.mouse_over_object) {
context.mouse_over_object = None;
}
if InteractiveObject::option_ptr_eq(self.as_interactive(), context.mouse_down_object) {
context.mouse_down_object = None;
}
(new_state != ButtonState::Over, ButtonState::Up)
};
if update_state {
self.set_state(context, new_state);
}
ClipEventResult::NotHandled
}
fn mouse_pick_avm1(
&self,
context: &mut UpdateContext<'_, 'gc>,
point: Point<Twips>,
require_button_mode: bool,
) -> Option<InteractiveObject<'gc>> {
// The button is hovered if the mouse is over any child nodes.
if self.visible() && self.mouse_enabled() {
for child in self.iter_render_list().rev() {
let result = child
.as_interactive()
.and_then(|c| c.mouse_pick_avm1(context, point, require_button_mode));
if result.is_some() {
return result;
}
}
for child in self.0.cell.borrow().hit_area.values() {
if child.hit_test_shape(context, point, HitTestOptions::MOUSE_PICK) {
return Some((*self).into());
}
}
}
None
}
fn mouse_pick_avm2(
&self,
_context: &mut UpdateContext<'_, 'gc>,
_point: Point<Twips>,
_require_button_mode: bool,
) -> Avm2MousePick<'gc> {
Avm2MousePick::Miss
}
fn mouse_cursor(self, context: &mut UpdateContext<'_, 'gc>) -> MouseCursor {
if self.use_hand_cursor(context) && self.enabled(context) {
MouseCursor::Hand
} else {
MouseCursor::Arrow
}
}
}
impl<'gc> Avm1ButtonData<'gc> {
fn play_sound(&self, context: &mut UpdateContext<'_, 'gc>, sound: Option<&swf::ButtonSound>) {
if let Some((id, sound_info)) = sound {
if let Some(sound_handle) = context
.library
.library_for_movie_mut(self.movie())
.get_sound(*id)
{
let _ = context.start_sound(sound_handle, sound_info, None, None);
}
}
}
fn run_actions(
&self,
context: &mut UpdateContext<'_, 'gc>,
condition: swf::ButtonActionCondition,
) -> ClipEventResult {
let mut handled = ClipEventResult::NotHandled;
if let Some(parent) = self.cell.borrow().base.base.parent {
for action in &self.static_data.actions {
if action.conditions.matches(condition) {
// Note that AVM1 buttons run actions relative to their parent, not themselves.
handled = ClipEventResult::Handled;
context.action_queue.queue_action(
parent,
ActionType::Normal {
bytecode: action.action_data.clone(),
},
false,
);
}
}
}
handled
}
fn movie(&self) -> Arc<SwfMovie> {
self.static_data.swf.clone()
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Collect)]
#[collect(require_static)]
#[allow(dead_code)]
pub enum ButtonState {
Up,
Over,
Down,
}
impl From<ButtonState> for swf::ButtonState {
fn from(bs: ButtonState) -> Self {
match bs {
ButtonState::Up => Self::UP,
ButtonState::Over => Self::OVER,
ButtonState::Down => Self::DOWN,
}
}
}
#[derive(Clone, Debug)]
struct ButtonAction {
action_data: SwfSlice,
conditions: swf::ButtonActionCondition,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ButtonTracking {
Push,
Menu,
}
/// Static data shared between all instances of a button.
#[derive(Collect, Debug)]
#[collect(require_static)]
struct ButtonStatic {
swf: Arc<SwfMovie>,
id: CharacterId,
actions: Vec<ButtonAction>,
cell: RefCell<ButtonStaticMut>,
}
#[derive(Debug)]
struct ButtonStaticMut {
records: Vec<swf::ButtonRecord>,
/// The sounds to play on state changes for this button.
up_to_over_sound: Option<swf::ButtonSound>,
over_to_down_sound: Option<swf::ButtonSound>,
down_to_over_sound: Option<swf::ButtonSound>,
over_to_up_sound: Option<swf::ButtonSound>,
}