📄 swfdec_sprite_movie_as.c
字号:
/* Swfdec * Copyright (C) 2003-2006 David Schleef <ds@schleef.org> * 2005-2006 Eric Anholt <eric@anholt.net> * 2006-2007 Benjamin Otte <otte@gnome.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "swfdec_movie.h"#include "swfdec_as_strings.h"#include "swfdec_bits.h"#include "swfdec_debug.h"#include "swfdec_decoder.h"#include "swfdec_internal.h"#include "swfdec_player_internal.h"#include "swfdec_sprite.h"#include "swfdec_sprite_movie.h"#include "swfdec_swf_decoder.h"#include "swfdec_swf_instance.h"static voidswfdec_sprite_movie_play (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SWFDEC_SPRITE_MOVIE (obj)->playing = TRUE;}static voidswfdec_sprite_movie_stop (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SWFDEC_SPRITE_MOVIE (obj)->playing = FALSE;}static voidswfdec_sprite_movie_getBytesLoaded (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecMovie *movie = SWFDEC_MOVIE (obj); if (SWFDEC_MOVIE (movie->swf->movie) == movie) { SWFDEC_AS_VALUE_SET_INT (rval, movie->swf->decoder->bytes_loaded); } else { SWFDEC_AS_VALUE_SET_INT (rval, 0); }}static voidswfdec_sprite_movie_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecMovie *movie = SWFDEC_MOVIE (obj); if (SWFDEC_MOVIE (movie->swf->movie) == movie) { SWFDEC_AS_VALUE_SET_INT (rval, movie->swf->decoder->bytes_total); } else { SWFDEC_AS_VALUE_SET_INT (rval, 0); }}static voidswfdec_sprite_movie_getNextHighestDepth (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecMovie *movie = SWFDEC_MOVIE (obj); int depth; if (movie->list) { depth = SWFDEC_MOVIE (g_list_last (movie->list)->data)->depth + 1; if (depth < 0) depth = 0; } else { depth = 0; } SWFDEC_AS_VALUE_SET_INT (rval, depth);}static voidswfdec_sprite_movie_do_goto (SwfdecSpriteMovie *movie, SwfdecAsValue *target){ int frame; if (SWFDEC_AS_VALUE_IS_STRING (target)) { const char *label = SWFDEC_AS_VALUE_GET_STRING (target); frame = swfdec_sprite_get_frame (movie->sprite, label); /* FIXME: nonexisting frames? */ if (frame == -1) return; frame++; } else { frame = swfdec_as_value_to_integer (SWFDEC_AS_OBJECT (movie)->context, target); } /* FIXME: how to handle overflow? */ frame = CLAMP (frame, 1, (int) movie->n_frames); swfdec_sprite_movie_goto (movie, frame);}static voidswfdec_sprite_movie_gotoAndPlay (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (obj); swfdec_sprite_movie_do_goto (movie, &argv[0]); movie->playing = TRUE;}static voidswfdec_sprite_movie_gotoAndStop (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (obj); swfdec_sprite_movie_do_goto (movie, &argv[0]); movie->playing = FALSE;}static voidswfdec_sprite_movie_nextFrame (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (obj); swfdec_sprite_movie_goto (movie, movie->frame + 1); movie->playing = FALSE;}static voidswfdec_sprite_movie_prevFrame (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (obj); swfdec_sprite_movie_goto (movie, movie->frame - 1); movie->playing = FALSE;}static voidswfdec_sprite_movie_hitTest (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecMovie *movie = SWFDEC_MOVIE (obj); if (argc == 1) { SwfdecMovie *other; SwfdecRect movie_rect, other_rect; if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) || !SWFDEC_IS_MOVIE (other = (SwfdecMovie *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]))) { SWFDEC_ERROR ("FIXME: what happens now?"); return; } swfdec_movie_update (movie); swfdec_movie_update (other); movie_rect = movie->extents; if (movie->parent) swfdec_movie_rect_local_to_global (movie->parent, &movie_rect); other_rect = other->extents; if (other->parent) swfdec_movie_rect_local_to_global (other->parent, &other_rect); SWFDEC_AS_VALUE_SET_BOOLEAN (rval, swfdec_rect_intersect (NULL, &movie_rect, &other_rect)); } else if (argc >= 2) { double x, y; gboolean shape, ret; x = swfdec_as_value_to_number (cx, &argv[0]) * SWFDEC_TWIPS_SCALE_FACTOR; y = swfdec_as_value_to_number (cx, &argv[1]) * SWFDEC_TWIPS_SCALE_FACTOR; shape = (argc >= 3 && swfdec_as_value_to_boolean (cx, &argv[2])); swfdec_movie_global_to_local (movie, &x, &y); if (shape && FALSE) { ret = swfdec_movie_mouse_in (movie, x, y); } else { ret = swfdec_rect_contains (&movie->original_extents, x, y); } SWFDEC_AS_VALUE_SET_BOOLEAN (rval, ret); } else { SWFDEC_FIXME ("hitTest with 0 parameters, what to do?"); }}static voidswfdec_sprite_movie_startDrag (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecMovie *movie = SWFDEC_MOVIE (obj); SwfdecPlayer *player = SWFDEC_PLAYER (cx); gboolean center = FALSE; if (argc > 0) { center = swfdec_as_value_to_boolean (cx, &argv[0]); } if (argc >= 5) { SwfdecRect rect; rect.x0 = swfdec_as_value_to_number (cx, &argv[1]); rect.y0 = swfdec_as_value_to_number (cx, &argv[2]); rect.x1 = swfdec_as_value_to_number (cx, &argv[3]); rect.y1 = swfdec_as_value_to_number (cx, &argv[4]); swfdec_rect_scale (&rect, &rect, SWFDEC_TWIPS_SCALE_FACTOR); swfdec_player_set_drag_movie (player, movie, center, &rect); } else { swfdec_player_set_drag_movie (player, movie, center, NULL); }}static voidswfdec_sprite_movie_stopDrag (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), NULL, FALSE, NULL);}static voidswfdec_sprite_movie_swapDepths (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval){ SwfdecMovie *movie = SWFDEC_MOVIE (obj); SwfdecMovie *other; int depth; if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) { other = (SwfdecMovie *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]); if (!SWFDEC_IS_MOVIE (other) || other->parent != movie->parent) return; depth = other->depth;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -