swf/
tag_code.rs

1#[derive(Clone, Copy, Debug, Eq, FromPrimitive, PartialEq)]
2pub enum TagCode {
3    End = 0,
4    ShowFrame = 1,
5    DefineShape = 2,
6
7    PlaceObject = 4,
8    RemoveObject = 5,
9    DefineBits = 6,
10    DefineButton = 7,
11    JpegTables = 8,
12    SetBackgroundColor = 9,
13    DefineFont = 10,
14    DefineText = 11,
15    DoAction = 12,
16    DefineFontInfo = 13,
17    DefineSound = 14,
18    StartSound = 15,
19
20    DefineButtonSound = 17,
21    SoundStreamHead = 18,
22    SoundStreamBlock = 19,
23    DefineBitsLossless = 20,
24    DefineBitsJpeg2 = 21,
25    DefineShape2 = 22,
26    DefineButtonCxform = 23,
27    Protect = 24,
28
29    PlaceObject2 = 26,
30
31    RemoveObject2 = 28,
32
33    DefineShape3 = 32,
34    DefineText2 = 33,
35    DefineButton2 = 34,
36    DefineBitsJpeg3 = 35,
37    DefineBitsLossless2 = 36,
38    DefineEditText = 37,
39
40    DefineSprite = 39,
41    NameCharacter = 40,
42    ProductInfo = 41,
43
44    FrameLabel = 43,
45
46    SoundStreamHead2 = 45,
47    DefineMorphShape = 46,
48
49    DefineFont2 = 48,
50
51    ExportAssets = 56,
52    ImportAssets = 57,
53    EnableDebugger = 58,
54    DoInitAction = 59,
55    DefineVideoStream = 60,
56    VideoFrame = 61,
57    DefineFontInfo2 = 62,
58
59    DebugId = 63,
60    EnableDebugger2 = 64,
61    ScriptLimits = 65,
62    SetTabIndex = 66,
63
64    FileAttributes = 69,
65
66    PlaceObject3 = 70,
67    ImportAssets2 = 71,
68    DoAbc = 72,
69    DefineFontAlignZones = 73,
70    CsmTextSettings = 74,
71    DefineFont3 = 75,
72    SymbolClass = 76,
73    Metadata = 77,
74    DefineScalingGrid = 78,
75
76    DoAbc2 = 82,
77    DefineShape4 = 83,
78    DefineMorphShape2 = 84,
79
80    DefineSceneAndFrameLabelData = 86,
81    DefineBinaryData = 87,
82    DefineFontName = 88,
83    StartSound2 = 89,
84    DefineBitsJpeg4 = 90,
85    DefineFont4 = 91,
86
87    EnableTelemetry = 93,
88    PlaceObject4 = 94,
89}
90
91impl TagCode {
92    pub fn from_u16(n: u16) -> Option<Self> {
93        num_traits::FromPrimitive::from_u16(n)
94    }
95
96    pub fn format(tag_code: u16) -> String {
97        if let Some(tag_code) = TagCode::from_u16(tag_code) {
98            format!("{tag_code:?}")
99        } else {
100            format!("Unknown({tag_code})")
101        }
102    }
103}