📄 swfdec_tag.c
字号:
cur->end = 4; swfdec_rect_transform (&rect, &content->graphic->extents, &cur->transform); swfdec_rect_union (&SWFDEC_GRAPHIC (button)->extents, &SWFDEC_GRAPHIC (button)->extents, &rect); } if (content->end == G_MAXUINT) { SWFDEC_ERROR ("button record for graphic %u is not used in any state, discarding", SWFDEC_CHARACTER (content->graphic)->id); swfdec_content_free (content); }}inttag_func_define_button_2 (SwfdecSwfDecoder * s){ SwfdecBits *bits = &s->b; int id; int flags; int offset; SwfdecButton *button; char *script_name; id = swfdec_bits_get_u16 (bits); button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON); if (!button) return SWFDEC_STATUS_OK; SWFDEC_LOG (" ID: %d", id); flags = swfdec_bits_get_u8 (bits); if (flags & 0x01) button->menubutton = TRUE; offset = swfdec_bits_get_u16 (bits); SWFDEC_LOG (" flags = %d", flags); SWFDEC_LOG (" offset = %d", offset); while (swfdec_bits_peek_u8 (bits)) { int reserved; unsigned int character; unsigned int depth; unsigned int states; SwfdecContent *content; swfdec_bits_syncbits (bits); reserved = swfdec_bits_getbits (bits, 4); states = swfdec_bits_getbits (bits, 4); character = swfdec_bits_get_u16 (bits); depth = swfdec_bits_get_u16 (bits); SWFDEC_LOG (" reserved = %d", reserved); SWFDEC_LOG ("states: %s%s%s%scharacter=%u layer=%u", states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "", states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "", states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "", states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "", character, depth); content = swfdec_content_new (depth); swfdec_bits_get_matrix (bits, &content->transform, NULL); SWFDEC_LOG ("matrix: %g %g %g %g %g %g", content->transform.xx, content->transform.yy, content->transform.xy, content->transform.yx, content->transform.x0, content->transform.y0); swfdec_bits_get_color_transform (bits, &content->color_transform); content->graphic = swfdec_swf_decoder_get_character (s, character); if (!SWFDEC_IS_GRAPHIC (content->graphic)) { SWFDEC_ERROR ("id %u does not reference a graphic, ignoring", character); swfdec_content_free (content); } else { swfdec_button_append_content (button, states, content); } } swfdec_bits_get_u8 (bits); script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id); while (offset != 0) { guint condition, key; offset = swfdec_bits_get_u16 (bits); condition = swfdec_bits_get_u16 (bits); key = condition >> 9; condition &= 0x1FF; SWFDEC_LOG (" offset = %d", offset); if (button->events == NULL) button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player); SWFDEC_LOG ("new event for condition %u (key %u)", condition, key); swfdec_event_list_parse (button->events, &s->b, s->version, condition, key, script_name); } g_free (script_name); return SWFDEC_STATUS_OK;}inttag_func_define_button (SwfdecSwfDecoder * s){ SwfdecBits *bits = &s->b; int id; SwfdecButton *button; char *script_name; id = swfdec_bits_get_u16 (bits); button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON); if (!button) return SWFDEC_STATUS_OK; SWFDEC_LOG (" ID: %d", id); while (swfdec_bits_peek_u8 (bits)) { int reserved; unsigned int character; unsigned int depth; unsigned int states; SwfdecContent *content; swfdec_bits_syncbits (bits); reserved = swfdec_bits_getbits (bits, 4); states = swfdec_bits_getbits (bits, 4); character = swfdec_bits_get_u16 (bits); depth = swfdec_bits_get_u16 (bits); SWFDEC_LOG (" reserved = %d", reserved); SWFDEC_LOG ("states: %s%s%s%scharacter=%u layer=%u", states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "", states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "", states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "", states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "", character, depth); content = swfdec_content_new (depth); swfdec_bits_get_matrix (bits, &content->transform, NULL); SWFDEC_LOG ("matrix: %g %g %g %g %g %g", content->transform.xx, content->transform.yy, content->transform.xy, content->transform.yx, content->transform.x0, content->transform.y0); content->graphic = swfdec_swf_decoder_get_character (s, character); if (!SWFDEC_IS_GRAPHIC (content->graphic)) { SWFDEC_ERROR ("id %u does not reference a graphic, ignoring", character); swfdec_content_free (content); } else { swfdec_button_append_content (button, states, content); } } swfdec_bits_get_u8 (bits); script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id); button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player); swfdec_event_list_parse (button->events, &s->b, s->version, SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN, 0, script_name); g_free (script_name); return SWFDEC_STATUS_OK;}static inttag_func_define_font_info_1 (SwfdecSwfDecoder *s){ return tag_func_define_font_info (s, 1);}static inttag_func_define_font_info_2 (SwfdecSwfDecoder *s){ return tag_func_define_font_info (s, 2);}static inttag_func_file_attributes (SwfdecSwfDecoder *s){ int has_metadata, use_network; if (swfdec_bits_getbits (&s->b, 3)) SWFDEC_INFO ("reserved bits (1) aren't 0"); has_metadata = swfdec_bits_getbit (&s->b); if (swfdec_bits_getbits (&s->b, 3)) SWFDEC_INFO ("reserved bits (2) aren't 0"); use_network = swfdec_bits_getbit (&s->b); /* FIXME: do something useful with this data */ if (swfdec_bits_getbits (&s->b, 24)) SWFDEC_INFO ("reserved bits (3) aren't 0"); return SWFDEC_STATUS_OK;}/* may appear inside DefineSprite */#define SPRITE 1struct tag_func_struct{ char *name; int (*func) (SwfdecSwfDecoder * s); int flag;};static struct tag_func_struct tag_funcs[] = { [SWFDEC_TAG_END] = {"End", tag_func_end, SPRITE}, [SWFDEC_TAG_SHOWFRAME] = {"ShowFrame", tag_show_frame, SPRITE}, [SWFDEC_TAG_DEFINESHAPE] = {"DefineShape", tag_define_shape, 0}, [SWFDEC_TAG_FREECHARACTER] = {"FreeCharacter", NULL, 0}, [SWFDEC_TAG_PLACEOBJECT] = {"PlaceObject", NULL, SPRITE}, [SWFDEC_TAG_REMOVEOBJECT] = {"RemoveObject", swfdec_spriteseg_remove_object, SPRITE}, [SWFDEC_TAG_DEFINEBITSJPEG] = {"DefineBitsJPEG", tag_func_define_bits_jpeg, 0}, [SWFDEC_TAG_DEFINEBUTTON] = {"DefineButton", tag_func_define_button, 0}, [SWFDEC_TAG_JPEGTABLES] = {"JPEGTables", swfdec_image_jpegtables, 0}, [SWFDEC_TAG_SETBACKGROUNDCOLOR] = {"SetBackgroundColor", tag_func_set_background_color, 0}, [SWFDEC_TAG_DEFINEFONT] = {"DefineFont", tag_func_define_font, 0}, [SWFDEC_TAG_DEFINETEXT] = {"DefineText", tag_func_define_text, 0}, [SWFDEC_TAG_DOACTION] = {"DoAction", tag_func_do_action, SPRITE}, [SWFDEC_TAG_DEFINEFONTINFO] = {"DefineFontInfo", tag_func_define_font_info_1, 0}, [SWFDEC_TAG_DEFINESOUND] = {"DefineSound", tag_func_define_sound, 0}, [SWFDEC_TAG_STARTSOUND] = {"StartSound", tag_func_start_sound, SPRITE}, [SWFDEC_TAG_DEFINEBUTTONSOUND] = {"DefineButtonSound", tag_func_define_button_sound, 0}, [SWFDEC_TAG_SOUNDSTREAMHEAD] = {"SoundStreamHead", tag_func_sound_stream_head, SPRITE}, [SWFDEC_TAG_SOUNDSTREAMBLOCK] = {"SoundStreamBlock", tag_func_sound_stream_block, SPRITE}, [SWFDEC_TAG_DEFINEBITSLOSSLESS] = {"DefineBitsLossless", tag_func_define_bits_lossless, 0}, [SWFDEC_TAG_DEFINEBITSJPEG2] = {"DefineBitsJPEG2", tag_func_define_bits_jpeg_2, 0}, [SWFDEC_TAG_DEFINESHAPE2] = {"DefineShape2", tag_define_shape_2, 0}, [SWFDEC_TAG_DEFINEBUTTONCXFORM] = {"DefineButtonCXForm", NULL, 0}, [SWFDEC_TAG_PROTECT] = {"Protect", tag_func_protect, 0}, [SWFDEC_TAG_PLACEOBJECT2] = {"PlaceObject2", swfdec_spriteseg_place_object_2, SPRITE}, [SWFDEC_TAG_REMOVEOBJECT2] = {"RemoveObject2", swfdec_spriteseg_remove_object_2, SPRITE}, [SWFDEC_TAG_DEFINESHAPE3] = {"DefineShape3", tag_define_shape_3, 0}, [SWFDEC_TAG_DEFINETEXT2] = {"DefineText2", tag_func_define_text_2, 0}, [SWFDEC_TAG_DEFINEBUTTON2] = {"DefineButton2", tag_func_define_button_2, 0}, [SWFDEC_TAG_DEFINEBITSJPEG3] = {"DefineBitsJPEG3", tag_func_define_bits_jpeg_3, 0}, [SWFDEC_TAG_DEFINEBITSLOSSLESS2] = {"DefineBitsLossless2", tag_func_define_bits_lossless_2, 0}, [SWFDEC_TAG_DEFINEEDITTEXT] = {"DefineEditText", tag_func_define_edit_text, 0}, [SWFDEC_TAG_DEFINEMOVIE] = {"DefineMovie", NULL, 0}, [SWFDEC_TAG_DEFINESPRITE] = {"DefineSprite", tag_func_define_sprite, 0}, [SWFDEC_TAG_NAMECHARACTER] = {"NameCharacter", NULL, 0}, [SWFDEC_TAG_SERIALNUMBER] = {"SerialNumber", NULL, 0}, [SWFDEC_TAG_GENERATORTEXT] = {"GeneratorText", NULL, 0}, [SWFDEC_TAG_FRAMELABEL] = {"FrameLabel", tag_func_frame_label, SPRITE}, [SWFDEC_TAG_SOUNDSTREAMHEAD2] = {"SoundStreamHead2", tag_func_sound_stream_head, SPRITE}, [SWFDEC_TAG_DEFINEMORPHSHAPE] = {"DefineMorphShape", tag_define_morph_shape, 0}, [SWFDEC_TAG_DEFINEFONT2] = {"DefineFont2", tag_func_define_font_2, 0}, [SWFDEC_TAG_TEMPLATECOMMAND] = {"TemplateCommand", NULL, 0}, [SWFDEC_TAG_GENERATOR3] = {"Generator3", NULL, 0}, [SWFDEC_TAG_EXTERNALFONT] = {"ExternalFont", NULL, 0}, [SWFDEC_TAG_EXPORTASSETS] = {"ExportAssets", tag_func_export_assets, 0}, [SWFDEC_TAG_IMPORTASSETS] = {"ImportAssets", NULL, 0}, [SWFDEC_TAG_ENABLEDEBUGGER] = {"EnableDebugger", NULL, 0}, [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_do_init_action, SPRITE}, [SWFDEC_TAG_DEFINEVIDEOSTREAM] = {"DefineVideoStream", tag_func_define_video, 0}, [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, 0}, [SWFDEC_TAG_DEFINEFONTINFO2] = {"DefineFontInfo2", tag_func_define_font_info_2, 0}, [SWFDEC_TAG_MX4] = {"MX4", NULL, 0}, [SWFDEC_TAG_ENABLEDEBUGGER2] = {"EnableDebugger2", NULL, 0}, [SWFDEC_TAG_SCRIPTLIMITS] = {"ScriptLimits", NULL, 0}, [SWFDEC_TAG_SETTABINDEX] = {"SetTabIndex", NULL, 0}, [SWFDEC_TAG_FILEATTRIBUTES] = {"FileAttributes", tag_func_file_attributes, 0}, [SWFDEC_TAG_PLACEOBJECT3] = {"PlaceObject3", NULL, 0}, [SWFDEC_TAG_IMPORTASSETS2] = {"ImportAssets2", NULL, 0}, [SWFDEC_TAG_DEFINEFONTALIGNZONES] = {"DefineFontAlignZones", NULL, 0}, [SWFDEC_TAG_CSMTEXTSETTINGS] = {"CSMTextSettings", NULL, 0}, [SWFDEC_TAG_DEFINEFONT3] = {"DefineFont3", tag_func_define_font_3, 0}, [SWFDEC_TAG_AVM2DECL] = {"AVM2Decl", NULL, 0}, [SWFDEC_TAG_METADATA] = {"Metadata", NULL, 0}, [SWFDEC_TAG_DEFINESCALINGGRID] = {"DefineScalingGrid", NULL, 0}, [SWFDEC_TAG_AVM2ACTION] = {"AVM2Action", NULL, 0}, [SWFDEC_TAG_DEFINESHAPE4] = {"DefineShape4", NULL, 0}, [SWFDEC_TAG_DEFINEMORPHSHAPE2] = {"DefineMorphShape2", NULL, 0},};static const int n_tag_funcs = sizeof (tag_funcs) / sizeof (tag_funcs[0]);const char *swfdec_swf_decoder_get_tag_name (int tag){ if (tag >= 0 && tag < n_tag_funcs) { if (tag_funcs[tag].name) { return tag_funcs[tag].name; } } return "unknown";}SwfdecTagFunc *swfdec_swf_decoder_get_tag_func (int tag){ if (tag >= 0 && tag < n_tag_funcs) { if (tag_funcs[tag].func) { return tag_funcs[tag].func; } } return NULL;}intswfdec_swf_decoder_get_tag_flag (int tag){ if (tag >= 0 && tag < n_tag_funcs) { return tag_funcs[tag].flag; } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -