@@ -40,7 +40,7 @@ impl fmt::Debug for Avm1Button<'_> {
40
40
#[ collect( no_drop) ]
41
41
pub struct Avm1ButtonData < ' gc > {
42
42
cell : RefLock < Avm1ButtonDataMut < ' gc > > ,
43
- static_data : Gc < ' gc , ButtonStatic > ,
43
+ shared : Gc < ' gc , ButtonShared > ,
44
44
state : Cell < ButtonState > ,
45
45
tracking : Cell < ButtonTracking > ,
46
46
object : Lock < Option < Object < ' gc > > > ,
@@ -77,13 +77,13 @@ impl<'gc> Avm1Button<'gc> {
77
77
hit_area : BTreeMap :: new ( ) ,
78
78
hit_bounds : Default :: default ( ) ,
79
79
} ) ,
80
- static_data : Gc :: new (
80
+ shared : Gc :: new (
81
81
mc,
82
- ButtonStatic {
82
+ ButtonShared {
83
83
swf : source_movie. movie . clone ( ) ,
84
84
id : button. id ,
85
85
actions,
86
- cell : RefCell :: new ( ButtonStaticMut {
86
+ cell : RefCell :: new ( ButtonSharedMut {
87
87
records : button. records . clone ( ) ,
88
88
up_to_over_sound : None ,
89
89
over_to_down_sound : None ,
@@ -105,22 +105,21 @@ impl<'gc> Avm1Button<'gc> {
105
105
}
106
106
107
107
pub fn set_sounds ( self , sounds : swf:: ButtonSounds ) {
108
- let mut static_data = self . 0 . static_data . cell . borrow_mut ( ) ;
109
- static_data . up_to_over_sound = sounds. up_to_over_sound ;
110
- static_data . over_to_down_sound = sounds. over_to_down_sound ;
111
- static_data . down_to_over_sound = sounds. down_to_over_sound ;
112
- static_data . over_to_up_sound = sounds. over_to_up_sound ;
108
+ let mut shared = self . 0 . shared . cell . borrow_mut ( ) ;
109
+ shared . up_to_over_sound = sounds. up_to_over_sound ;
110
+ shared . over_to_down_sound = sounds. over_to_down_sound ;
111
+ shared . down_to_over_sound = sounds. down_to_over_sound ;
112
+ shared . over_to_up_sound = sounds. over_to_up_sound ;
113
113
}
114
114
115
115
/// Handles the ancient DefineButtonCxform SWF tag.
116
116
/// Set the color transform for all children of each state.
117
117
pub fn set_colors ( self , color_transforms : & [ swf:: ColorTransform ] ) {
118
- let mut static_data = self . 0 . static_data . cell . borrow_mut ( ) ;
118
+ let mut shared = self . 0 . shared . cell . borrow_mut ( ) ;
119
119
120
120
// This tag isn't documented well in SWF19. It is only used in very old SWF<=2 content.
121
121
// It applies color transforms to every character in a button, in sequence(?).
122
- for ( record, color_transform) in static_data. records . iter_mut ( ) . zip ( color_transforms. iter ( ) )
123
- {
122
+ for ( record, color_transform) in shared. records . iter_mut ( ) . zip ( color_transforms. iter ( ) ) {
124
123
record. color_transform = * color_transform;
125
124
}
126
125
}
@@ -142,7 +141,7 @@ impl<'gc> Avm1Button<'gc> {
142
141
// TODO: This behavior probably differs in AVM2 (I suspect they always get recreated).
143
142
let mut children = Vec :: new ( ) ;
144
143
145
- for record in & self . 0 . static_data . cell . borrow ( ) . records {
144
+ for record in & self . 0 . shared . cell . borrow ( ) . records {
146
145
if record. states . contains ( state. into ( ) ) {
147
146
// State contains this depth, so we don't have to remove it.
148
147
removed_depths. remove ( & record. depth . into ( ) ) ;
@@ -260,7 +259,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
260
259
}
261
260
262
261
fn id ( & self ) -> CharacterId {
263
- self . 0 . static_data . id
262
+ self . 0 . shared . id
264
263
}
265
264
266
265
fn movie ( & self ) -> Arc < SwfMovie > {
@@ -306,7 +305,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
306
305
self . set_state ( context, ButtonState :: Up ) ;
307
306
self . 0 . initialized . set ( true ) ;
308
307
309
- for record in & self . 0 . static_data . cell . borrow ( ) . records {
308
+ for record in & self . 0 . shared . cell . borrow ( ) . records {
310
309
if record. states . contains ( swf:: ButtonState :: HIT_TEST ) {
311
310
match context
312
311
. library
@@ -322,7 +321,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
322
321
Err ( error) => {
323
322
tracing:: error!(
324
323
"Button ID {}: could not instantiate child ID {}: {}" ,
325
- self . 0 . static_data . id,
324
+ self . 0 . shared . id,
326
325
record. id,
327
326
error
328
327
) ;
@@ -463,8 +462,8 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
463
462
let is_enabled = self . enabled ( context) ;
464
463
465
464
// Translate the clip event to a button event, based on how the button state changes.
466
- let static_data = self . 0 . static_data ;
467
- let static_data = static_data . cell . borrow ( ) ;
465
+ let shared = self . 0 . shared ;
466
+ let shared = shared . cell . borrow ( ) ;
468
467
let ( new_state, condition, sound) = match event {
469
468
ClipEvent :: DragOut { .. } => (
470
469
ButtonState :: Over ,
@@ -479,27 +478,27 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
479
478
ClipEvent :: Press { .. } => (
480
479
ButtonState :: Down ,
481
480
Some ( ButtonActionCondition :: OVER_UP_TO_OVER_DOWN ) ,
482
- static_data . over_to_down_sound . as_ref ( ) ,
481
+ shared . over_to_down_sound . as_ref ( ) ,
483
482
) ,
484
483
ClipEvent :: Release { .. } => (
485
484
ButtonState :: Over ,
486
485
Some ( ButtonActionCondition :: OVER_DOWN_TO_OVER_UP ) ,
487
- static_data . down_to_over_sound . as_ref ( ) ,
486
+ shared . down_to_over_sound . as_ref ( ) ,
488
487
) ,
489
488
ClipEvent :: ReleaseOutside => (
490
489
ButtonState :: Up ,
491
490
Some ( ButtonActionCondition :: OUT_DOWN_TO_IDLE ) ,
492
- static_data . over_to_up_sound . as_ref ( ) ,
491
+ shared . over_to_up_sound . as_ref ( ) ,
493
492
) ,
494
493
ClipEvent :: RollOut { .. } => (
495
494
ButtonState :: Up ,
496
495
Some ( ButtonActionCondition :: OVER_UP_TO_IDLE ) ,
497
- static_data . over_to_up_sound . as_ref ( ) ,
496
+ shared . over_to_up_sound . as_ref ( ) ,
498
497
) ,
499
498
ClipEvent :: RollOver { .. } => (
500
499
ButtonState :: Over ,
501
500
Some ( ButtonActionCondition :: IDLE_TO_OVER_UP ) ,
502
- static_data . up_to_over_sound . as_ref ( ) ,
501
+ shared . up_to_over_sound . as_ref ( ) ,
503
502
) ,
504
503
ClipEvent :: KeyPress { key_code } => {
505
504
return self . 0 . run_actions (
@@ -623,7 +622,7 @@ impl<'gc> Avm1ButtonData<'gc> {
623
622
) -> ClipEventResult {
624
623
let mut handled = ClipEventResult :: NotHandled ;
625
624
if let Some ( parent) = self . cell . borrow ( ) . base . base . parent {
626
- for action in & self . static_data . actions {
625
+ for action in & self . shared . actions {
627
626
if action. conditions . matches ( condition) {
628
627
// Note that AVM1 buttons run actions relative to their parent, not themselves.
629
628
handled = ClipEventResult :: Handled ;
@@ -641,7 +640,7 @@ impl<'gc> Avm1ButtonData<'gc> {
641
640
}
642
641
643
642
fn movie ( & self ) -> Arc < SwfMovie > {
644
- self . static_data . swf . clone ( )
643
+ self . shared . swf . clone ( )
645
644
}
646
645
}
647
646
@@ -676,18 +675,18 @@ pub enum ButtonTracking {
676
675
Menu ,
677
676
}
678
677
679
- /// Static data shared between all instances of a button.
678
+ /// Data shared between all instances of a button.
680
679
#[ derive( Collect , Debug ) ]
681
680
#[ collect( require_static) ]
682
- struct ButtonStatic {
681
+ struct ButtonShared {
683
682
swf : Arc < SwfMovie > ,
684
683
id : CharacterId ,
685
684
actions : Vec < ButtonAction > ,
686
- cell : RefCell < ButtonStaticMut > ,
685
+ cell : RefCell < ButtonSharedMut > ,
687
686
}
688
687
689
688
#[ derive( Debug ) ]
690
- struct ButtonStaticMut {
689
+ struct ButtonSharedMut {
691
690
records : Vec < swf:: ButtonRecord > ,
692
691
693
692
/// The sounds to play on state changes for this button.
0 commit comments