⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gameswf_impl.h

📁 一个开源的Flash 播放器,可以在Windows/Linux 上运行
💻 H
📖 第 1 页 / 共 2 页
字号:
	// Information about how to display a character.	struct display_info	{		movie*	m_parent;		int	m_depth;		cxform	m_color_transform;		matrix	m_matrix;		float	m_ratio;                Uint16 	m_clip_depth;		display_info()			:			m_parent(NULL),			m_depth(0),			m_ratio(0.0f),                        m_clip_depth(0)		{		}		void	concatenate(const display_info& di)		// Concatenate the transforms from di into our		// transforms.		{			m_depth = di.m_depth;			m_color_transform.concatenate(di.m_color_transform);			m_matrix.concatenate(di.m_matrix);			m_ratio = di.m_ratio;                        m_clip_depth = di.m_clip_depth;		}	};	// character is a live, stateful instance of a character_def.	// It represents a single active element in a movie.	struct character : public movie	{		int		m_id;		movie*		m_parent;		tu_string	m_name;		int		m_depth;		cxform		m_color_transform;		matrix		m_matrix;		float		m_ratio;                Uint16		m_clip_depth;		bool		m_visible;		hash<event_id, as_value>	m_event_handlers;		void		(*m_display_callback)(void*);		void*		m_display_callback_user_ptr;		character(movie* parent, int id)			:			m_id(id),			m_parent(parent),			m_depth(-1),			m_ratio(0.0f),			m_clip_depth(0),			m_visible(true),			m_display_callback(NULL),			m_display_callback_user_ptr(NULL)					{			assert((parent == NULL && m_id == -1)			       || (parent != NULL && m_id >= 0));		}		// Accessors for basic display info.		int	get_id() const { return m_id; }		movie*	get_parent() const { return m_parent; }		void set_parent(movie* parent) { m_parent = parent; }  // for extern movie		int	get_depth() const { return m_depth; }		void	set_depth(int d) { m_depth = d; }		const matrix&	get_matrix() const { return m_matrix; }		void	set_matrix(const matrix& m)		{			assert(m.is_valid());			m_matrix = m;		}		const cxform&	get_cxform() const { return m_color_transform; }		void	set_cxform(const cxform& cx) { m_color_transform = cx; }		void	concatenate_cxform(const cxform& cx) { m_color_transform.concatenate(cx); }		void	concatenate_matrix(const matrix& m) { m_matrix.concatenate(m); }		float	get_ratio() const { return m_ratio; }		void	set_ratio(float f) { m_ratio = f; }		Uint16	get_clip_depth() const { return m_clip_depth; }		void	set_clip_depth(Uint16 d) { m_clip_depth = d; }		void	set_name(const char* name) { m_name = name; }		const tu_string&	get_name() const { return m_name; }		// For edit_text support (Flash 5).  More correct way		// is to do "text_character.text = whatever", via		// set_member().		virtual const char*	get_text_name() const { return ""; }		virtual void	set_text_value(const char* new_text) { assert(0); }		virtual matrix	get_world_matrix() const		// Get our concatenated matrix (all our ancestor transforms, times our matrix).  Maps		// from our local space into "world" space (i.e. root movie space).		{			matrix	m;			if (m_parent)			{				m = m_parent->get_world_matrix();			}			m.concatenate(get_matrix());			return m;		}		virtual cxform	get_world_cxform() const		// Get our concatenated color transform (all our ancestor transforms,		// times our cxform).  Maps from our local space into normal color space.		{			cxform	m;			if (m_parent)			{				m = m_parent->get_world_cxform();			}			m.concatenate(get_cxform());			return m;		}		// Event handler accessors.		bool	get_event_handler(event_id id, as_value* result)		{			return m_event_handlers.get(id, result);		}		void	set_event_handler(event_id id, const as_value& method)		{			m_event_handlers.set(id, method);		}		// Movie interfaces.  By default do nothing.  sprite_instance and some others override these.		virtual void	display() {}		virtual float	get_height() { return 0; }		virtual float	get_width() { return 0; }		virtual movie*	get_root_movie() { return m_parent->get_root_movie(); }		virtual int	get_current_frame() const { assert(0); return 0; }		virtual bool	has_looped() const { assert(0); return false; }		virtual void	restart() { /*assert(0);*/ }		virtual void	advance(float delta_time) {}	// for buttons and sprites		virtual void	goto_frame(int target_frame) {}		virtual bool	get_accept_anim_moves() const { return true; }		virtual void	get_drag_state(drag_state* st) { assert(m_parent); m_parent->get_drag_state(st); }		virtual void	set_visible(bool visible) { m_visible = visible; }		virtual bool	get_visible() const { return m_visible; }		virtual void	set_display_callback(void (*callback)(void*), void* user_ptr)		{			m_display_callback = callback;			m_display_callback_user_ptr = user_ptr;		}		virtual void	do_display_callback()		{			if (m_display_callback)			{				(*m_display_callback)(m_display_callback_user_ptr);			}		}		virtual void	get_mouse_state(int* x, int* y, int* buttons) { get_parent()->get_mouse_state(x, y, buttons); }		// Utility.		void	do_mouse_drag();	};	// For characters that don't store unusual state in their instances.	struct generic_character : public character	{		character_def*	m_def;		generic_character(character_def* def, movie* parent, int id)			:			character(parent, id),			m_def(def)		{			assert(m_def);		}		virtual void	display()		{			m_def->display(this);	// pass in transform info			do_display_callback();		}		// @@ tulrich: these are used for finding bounds; TODO		// need to do this using enclose_transformed_rect(),		// not by scaling the local height/width!		virtual float	get_height()		{			matrix	m = get_world_matrix();			float	h = m_def->get_height_local() * m.m_[1][1];			return h;		}		virtual float	get_width()		{			matrix	m = get_world_matrix();			float	w = m_def->get_width_local() * m.m_[0][0];			return w;		}		// new, from Vitaly.		virtual movie*	get_topmost_mouse_entity(float x, float y)		{			assert(get_visible());	// caller should check this.			matrix	m = get_matrix();			point	p;			m.transform_by_inverse(&p, point(x, y));			if (m_def->point_test_local(p.m_x, p.m_y))			{				// The mouse is inside the shape.				return this;			}			return NULL;		}	};	struct bitmap_character_def : public character_def	{		virtual gameswf::bitmap_info*	get_bitmap_info() = 0;	};#if 1	// Bitmap character	struct bitmap_character : public bitmap_character_def	{		bitmap_character(bitmap_info* bi)			:			m_bitmap_info(bi)		{		}// 		bitmap_character(image::rgb* image)// 		{// 			assert(image != 0);// 			// Create our bitmap info, from our image.// 			m_bitmap_info = gameswf::render::create_bitmap_info_rgb(image);// 		}// 		bitmap_character(image::rgba* image)// 		{// 			assert(image != 0);// 			// Create our bitmap info, from our image.// 			m_bitmap_info = gameswf::render::create_bitmap_info_rgba(image);// 		}		gameswf::bitmap_info*	get_bitmap_info()		{			return m_bitmap_info.get_ptr();		}	private:		smart_ptr<gameswf::bitmap_info>	m_bitmap_info;	};#endif	// Execute tags include things that control the operation of	// the movie.  Essentially, these are the events associated	// with a frame.	struct execute_tag	{		virtual ~execute_tag() {}		virtual void	execute(movie* m) {}		virtual void	execute_state(movie* m) {}		virtual void	execute_state_reverse(movie* m, int frame) { execute_state(m); }		virtual bool	is_remove_tag() const { return false; }		virtual bool	is_action_tag() const { return false; }		virtual uint32	get_depth_id_of_replace_or_add_tag() const { return static_cast<uint32>(-1); }	};	//	// Loader callbacks.	//		// Register a loader function for a certain tag type.  Most	// standard tags are handled within gameswf.  Host apps might want	// to call this in order to handle special tag types.	typedef void (*loader_function)(stream* input, int tag_type, movie_definition_sub* m);	void	register_tag_loader(int tag_type, loader_function lf);			// Tag loader functions.	void	null_loader(stream* in, int tag_type, movie_definition_sub* m);	void	set_background_color_loader(stream* in, int tag_type, movie_definition_sub* m);	void	jpeg_tables_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_bits_jpeg_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_bits_jpeg2_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_bits_jpeg3_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_shape_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_shape_morph_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_font_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_font_info_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_text_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_edit_text_loader(stream* in, int tag_type, movie_definition_sub* m);	void	place_object_2_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_bits_lossless_2_loader(stream* in, int tag_type, movie_definition_sub* m);	void	sprite_loader(stream* in, int tag_type, movie_definition_sub* m);	void	end_loader(stream* in, int tag_type, movie_definition_sub* m);	void	remove_object_2_loader(stream* in, int tag_type, movie_definition_sub* m);	void	do_action_loader(stream* in, int tag_type, movie_definition_sub* m);	void	button_character_loader(stream* in, int tag_type, movie_definition_sub* m);	void	frame_label_loader(stream* in, int tag_type, movie_definition_sub* m);	void	export_loader(stream* in, int tag_type, movie_definition_sub* m);	void	import_loader(stream* in, int tag_type, movie_definition_sub* m);	void	define_sound_loader(stream* in, int tag_type, movie_definition_sub* m);	void	start_sound_loader(stream* in, int tag_type, movie_definition_sub* m);	void	button_sound_loader(stream* in, int tag_type, movie_definition_sub* m);	void	do_init_action_loader(stream* in, int tag_type, movie_definition_sub* m);	// sound_stream_loader();	// head, head2, block}	// end namespace gameswf#endif // GAMESWF_IMPL_H// Local Variables:// mode: C++// c-basic-offset: 8 // tab-width: 8// indent-tabs-mode: t// End:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -