?? gameswf_impl.h
字號:
// gameswf_impl.h -- Thatcher Ulrich <tu@tulrich.com> 2003// This source code has been donated to the Public Domain. Do// whatever you want with it.// Some implementation code for the gameswf SWF player library.#ifndef GAMESWF_IMPL_H#define GAMESWF_IMPL_H#include "gameswf.h"#include "gameswf_action.h"#include "gameswf_types.h"#include "gameswf_log.h"#include <assert.h>#include "base/container.h"#include "base/utility.h"#include "base/smart_ptr.h"#include <stdarg.h>namespace jpeg { struct input; }namespace gameswf{ struct action_buffer; struct bitmap_character_def; struct bitmap_info; struct character; struct character_def; struct display_info; struct execute_tag; struct font; struct movie_root; struct sound_sample : public resource //virtual public ref_counted { virtual sound_sample* cast_to_sound_sample() { return this; } }; struct stream; struct swf_event; void save_extern_movie(movie_interface* m); // Extra internal interfaces added to movie_definition struct movie_definition_sub : public movie_definition { virtual const array<execute_tag*>& get_playlist(int frame_number) = 0; virtual const array<execute_tag*>* get_init_actions(int frame_number) = 0; virtual smart_ptr<resource> get_exported_resource(const tu_string& symbol) = 0; virtual character_def* get_character_def(int id) = 0; virtual bool get_labeled_frame(const char* label, int* frame_number) = 0; // For use during creation. virtual int get_loading_frame() const = 0; virtual void add_character(int id, character_def* ch) = 0; virtual void add_font(int id, font* ch) = 0; virtual font* get_font(int id) = 0; virtual void add_execute_tag(execute_tag* c) = 0; virtual void add_init_action(int sprite_id, execute_tag* c) = 0; virtual void add_frame_name(const char* name) = 0; virtual void set_jpeg_loader(jpeg::input* j_in) = 0; virtual jpeg::input* get_jpeg_loader() = 0; virtual bitmap_character_def* get_bitmap_character(int character_id) = 0; virtual void add_bitmap_character(int character_id, bitmap_character_def* ch) = 0; virtual sound_sample* get_sound_sample(int character_id) = 0; virtual void add_sound_sample(int character_id, sound_sample* sam) = 0; virtual void export_resource(const tu_string& symbol, resource* res) = 0; virtual void add_import(const char* source_url, int id, const char* symbol_name) = 0; virtual void add_bitmap_info(bitmap_info* ch) = 0; virtual create_bitmaps_flag get_create_bitmaps() const = 0; virtual create_font_shapes_flag get_create_font_shapes() const = 0; }; // For internal use. movie_definition_sub* create_movie_sub(const char* filename); movie_definition_sub* create_library_movie_sub(const char* filename); movie_interface* create_library_movie_inst_sub(movie_definition_sub* md);//v for extern movies movie_interface* create_library_movie_inst(movie_definition* md); movie_interface* get_current_root(); void set_current_root(movie_interface* m); const char* get_workdir(); void set_workdir(const char* dir); void delete_unused_root(); struct movie : public movie_interface { virtual void set_extern_movie(movie_interface* m) { } virtual movie_interface* get_extern_movie() { return NULL; } virtual movie_definition* get_movie_definition() { return NULL; } virtual movie_root* get_root() { return NULL; } virtual movie_interface* get_root_interface() { return NULL; } virtual movie* get_root_movie() { return NULL; } virtual float get_pixel_scale() const { return 1.0f; } virtual character* get_character(int id) { return NULL; } virtual matrix get_world_matrix() const { return matrix::identity; } virtual cxform get_world_cxform() const { return cxform::identity; } // // display-list management. // virtual execute_tag* find_previous_replace_or_add_tag(int current_frame, int depth, int id) { return NULL; } virtual character* add_display_object( Uint16 character_id, const char* name, const array<swf_event*>& event_handlers, Uint16 depth, bool replace_if_depth_is_occupied, const cxform& color_transform, const matrix& mat, float ratio, Uint16 clip_depth) { return NULL; } virtual void move_display_object( Uint16 depth, bool use_cxform, const cxform& color_transform, bool use_matrix, const matrix& mat, float ratio, Uint16 clip_depth) { } virtual void replace_display_object( Uint16 character_id, const char* name, Uint16 depth, bool use_cxform, const cxform& color_transform, bool use_matrix, const matrix& mat, float ratio, Uint16 clip_depth) { } virtual void replace_display_object( character* ch, const char* name, Uint16 depth, bool use_cxform, const cxform& color_transform, bool use_matrix, const matrix& mat, float ratio, Uint16 clip_depth) { } virtual void remove_display_object(Uint16 depth, int id) {} virtual void set_background_color(const rgba& color) {} virtual void set_background_alpha(float alpha) {} virtual float get_background_alpha() const { return 1.0f; } virtual void set_display_viewport(int x0, int y0, int width, int height) {} virtual void add_action_buffer(action_buffer* a) { assert(0); } virtual void goto_frame(int target_frame_number) { assert(0); } virtual bool goto_labeled_frame(const char* label) { assert(0); return false; } virtual void set_play_state(play_state s) {} virtual play_state get_play_state() const { assert(0); return STOP; } virtual void notify_mouse_state(int x, int y, int buttons) // The host app uses this to tell the movie where the // user's mouse pointer is. { } virtual void get_mouse_state(int* x, int* y, int* buttons) // Use this to retrieve the last state of the mouse, as set via // notify_mouse_state(). { assert(0); } struct drag_state { movie* m_character; bool m_lock_center; bool m_bound; float m_bound_x0; float m_bound_y0; float m_bound_x1; float m_bound_y1; drag_state() : m_character(0), m_lock_center(0), m_bound(0), m_bound_x0(0), m_bound_y0(0), m_bound_x1(1), m_bound_y1(1) { } }; virtual void get_drag_state(drag_state* st) { assert(0); *st = drag_state(); } virtual void set_drag_state(const drag_state& st) { assert(0); } virtual void stop_drag() { assert(0); } // External virtual void set_variable(const char* path_to_var, const char* new_value) { assert(0); } // External virtual void set_variable(const char* path_to_var, const wchar_t* new_value) { assert(0); } // External virtual const char* get_variable(const char* path_to_var) const { assert(0); return ""; } virtual void * get_userdata() { assert(0); return NULL; } virtual void set_userdata(void *) { assert(0); } // External virtual bool has_looped() const { return true; } // // Mouse/Button interface. // virtual movie* get_topmost_mouse_entity(float x, float y) { return NULL; } virtual bool get_track_as_menu() const { return false; } virtual void on_button_event(event_id id) { on_event(id); } // // ActionScript. // virtual movie* get_relative_target(const tu_string& name) { assert(0); return NULL; } // ActionScript event handler. Returns true if a handler was called. virtual bool on_event(event_id id) { return false; } int add_interval_timer(void *timer) { log_msg("FIXME: %s: unimplemented\n", __FUNCTION__); return -1; // ??? } void clear_interval_timer(int x) { log_msg("FIXME: %s: unimplemented\n", __FUNCTION__); } virtual void do_something(void *timer) { log_msg("FIXME: %s: unimplemented\n", __FUNCTION__); } // Special event handler; sprites also execute their frame1 actions on this event. virtual void on_event_load() { on_event(event_id::LOAD); }#if 0 // tulrich: @@ is there a good reason these are in the // vtable? I.e. can the caller just call // on_event(event_id::SOCK_DATA) instead of // on_event_xmlsocket_ondata()? virtual void on_event_xmlsocket_ondata() { on_event(event_id::SOCK_DATA); } virtual void on_event_xmlsocket_onxml() { on_event(event_id::SOCK_XML); } virtual void on_event_interval_timer() { on_event(event_id::TIMER); } virtual void on_event_load_progress() { on_event(event_id::LOAD_PROGRESS); }#endif // as_object_interface stuff virtual void set_member(const tu_stringi& name, const as_value& val) { assert(0); } virtual bool get_member(const tu_stringi& name, as_value* val) { assert(0); return false; } virtual void call_frame_actions(const as_value& frame_spec) { assert(0); } virtual float get_timer() const { return 0.0f; } virtual movie* to_movie() { return this; } virtual void clone_display_object(const tu_string& name, const tu_string& newname, Uint16 depth) { assert(0); } virtual void remove_display_object(const tu_string& name) { assert(0); } // Forward vararg call to version taking va_list. virtual const char* call_method(const char* method_name, const char* method_arg_fmt, ...) { va_list args; va_start(args, method_arg_fmt); const char* result = call_method_args(method_name, method_arg_fmt, args); va_end(args); return result; } virtual const char* call_method_args(const char* method_name, const char* method_arg_fmt, va_list args) // Override this if you implement call_method. { assert(0); return NULL; } virtual void execute_frame_tags(int frame, bool state_only = false) {} // External. virtual void attach_display_callback(const char* path_to_object, void (*callback)(void*), void* user_ptr) { assert(0); } virtual void set_display_callback(void (*callback)(void*), void* user_ptr) // Override me to provide this functionality. { } };
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -