1 #ifndef _lua__hpp__included__
2 #define _lua__hpp__included__
7 #include "core/controllerframe.hpp"
8 #include "library/movie.hpp"
9 #include "library/framebuffer.hpp"
10 #include "library/lua-base.hpp"
11 #include "library/lua-framebuffer.hpp"
13 namespace command
{ class group
; }
14 namespace keyboard
{ class key
; }
16 #define LUA_TIMED_HOOK_IDLE 0
17 #define LUA_TIMED_HOOK_TIMER 1
19 void init_lua() throw();
20 void quit_lua() throw();
24 lua_state(lua::state
& _L
, command::group
& _command
);
27 lua::state::callback_list
* on_paint
;
28 lua::state::callback_list
* on_video
;
29 lua::state::callback_list
* on_reset
;
30 lua::state::callback_list
* on_frame
;
31 lua::state::callback_list
* on_rewind
;
32 lua::state::callback_list
* on_idle
;
33 lua::state::callback_list
* on_timer
;
34 lua::state::callback_list
* on_frame_emulated
;
35 lua::state::callback_list
* on_readwrite
;
36 lua::state::callback_list
* on_startup
;
37 lua::state::callback_list
* on_pre_load
;
38 lua::state::callback_list
* on_post_load
;
39 lua::state::callback_list
* on_err_load
;
40 lua::state::callback_list
* on_pre_save
;
41 lua::state::callback_list
* on_post_save
;
42 lua::state::callback_list
* on_err_save
;
43 lua::state::callback_list
* on_input
;
44 lua::state::callback_list
* on_snoop
;
45 lua::state::callback_list
* on_snoop2
;
46 lua::state::callback_list
* on_button
;
47 lua::state::callback_list
* on_quit
;
48 lua::state::callback_list
* on_keyhook
;
49 lua::state::callback_list
* on_movie_lost
;
50 lua::state::callback_list
* on_pre_rewind
;
51 lua::state::callback_list
* on_post_rewind
;
52 lua::state::callback_list
* on_set_rewind
;
53 lua::state::callback_list
* on_latch
;
55 void callback_do_paint(struct lua::render_context
* ctx
, bool non_synthethic
) throw();
56 void callback_do_video(struct lua::render_context
* ctx
, bool& kill_frame
, uint32_t& hscl
, uint32_t& vscl
)
58 void callback_do_input(controller_frame
& data
, bool subframe
) throw();
59 void callback_do_reset() throw();
60 void callback_do_frame() throw();
61 void callback_do_frame_emulated() throw();
62 void callback_do_rewind() throw();
63 void callback_do_readwrite() throw();
64 void callback_do_idle() throw();
65 void callback_do_timer() throw();
66 void callback_pre_load(const std::string
& name
) throw();
67 void callback_err_load(const std::string
& name
) throw();
68 void callback_post_load(const std::string
& name
, bool was_state
) throw();
69 void callback_pre_save(const std::string
& name
, bool is_state
) throw();
70 void callback_err_save(const std::string
& name
) throw();
71 void callback_post_save(const std::string
& name
, bool is_state
) throw();
72 void callback_snoop_input(uint32_t port
, uint32_t controller
, uint32_t index
, short value
) throw();
73 void callback_quit() throw();
74 void callback_keyhook(const std::string
& key
, keyboard::key
& p
) throw();
75 void callback_do_unsafe_rewind(const std::vector
<char>& save
, uint64_t secs
, uint64_t ssecs
, movie
& mov
,
77 bool callback_do_button(uint32_t port
, uint32_t controller
, uint32_t index
, const char* type
);
78 void callback_movie_lost(const char* what
);
79 void callback_do_latch(std::list
<std::string
>& args
);
80 void run_startup_scripts();
81 void add_startup_script(const std::string
& file
);
83 uint64_t timed_hook(int timer
) throw();
84 const std::map
<std::string
, std::u32string
>& get_watch_vars();
86 void do_eval_lua(const std::string
& c
) throw(std::bad_alloc
);
87 void do_run_lua(const std::string
& c
) throw(std::bad_alloc
);
90 bool requests_repaint
;
91 bool requests_subframe_paint
;
92 lua::render_context
* render_ctx
;
93 controller_frame
* input_controllerdata
;
95 void* synchronous_paint_ctx
;
99 std::set
<std::string
> hooked_keys
;
100 uint64_t idle_hook_time
;
101 uint64_t timer_hook_time
;
103 std::list
<std::string
> startup_scripts
;
104 std::map
<std::string
, std::u32string
> watch_vars
;
106 void run_lua_fragment() throw(std::bad_alloc
);
107 template<typename
... T
> bool run_callback(lua::state::callback_list
& list
, T
... args
);
108 void run_synchronous_paint(struct lua::render_context
* ctx
);
110 command::group
& command
;
112 char* luareader_fragment
;