1 #include "lua/internal.hpp"
2 #include "lua/unsaferewind.hpp"
3 #include "core/movie.hpp"
4 #include "core/rrdata.hpp"
5 #include "core/moviedata.hpp"
6 #include "core/mainloop.hpp"
10 function_ptr_luafun
mcurframe(LS
, "movie.currentframe", [](lua_state
& L
, const std::string
& fname
) -> int {
11 auto& m
= get_movie();
12 L
.pushnumber(m
.get_current_frame());
16 function_ptr_luafun
mfc(LS
, "movie.framecount", [](lua_state
& L
, const std::string
& fname
) -> int {
17 auto& m
= get_movie();
18 L
.pushnumber(m
.get_frame_count());
22 function_ptr_luafun
mrrs(LS
, "movie.rerecords", [](lua_state
& L
, const std::string
& fname
) -> int {
23 L
.pushnumber(rrdata::count());
27 function_ptr_luafun
mro(LS
, "movie.readonly", [](lua_state
& L
, const std::string
& fname
) -> int {
28 auto& m
= get_movie();
29 L
.pushboolean(m
.readonly_mode() ? 1 : 0);
33 function_ptr_luafun
mrw(LS
, "movie.readwrite", [](lua_state
& L
, const std::string
& fname
) -> int {
34 auto& m
= get_movie();
35 m
.readonly_mode(false);
39 function_ptr_luafun
mfs(LS
, "movie.frame_subframes", [](lua_state
& L
, const std::string
& fname
) -> int {
40 uint64_t frame
= L
.get_numeric_argument
<uint64_t>(1, "movie.frame_subframes");
41 auto& m
= get_movie();
42 L
.pushnumber(m
.frame_subframes(frame
));
46 function_ptr_luafun
mrs(LS
, "movie.read_subframes", [](lua_state
& L
, const std::string
& fname
) -> int {
47 uint64_t frame
= L
.get_numeric_argument
<uint64_t>(1, "movie.frame_subframes");
48 uint64_t subframe
= L
.get_numeric_argument
<uint64_t>(2, "movie.frame_subframes");
49 auto& m
= get_movie();
50 controller_frame r
= m
.read_subframe(frame
, subframe
);
54 L
.pushnumber(r
.sync() ? 1 : 0);
57 L
.pushnumber(r
.axis3(0, 0, 1) ? 1 : 0);
60 L
.pushnumber(r
.axis3(0, 0, 2));
63 L
.pushnumber(r
.axis3(0, 0, 3));
66 for(size_t i
= 4; i
< r
.get_index_count(); i
++) {
68 L
.pushnumber(r
.axis2(i
));
74 function_ptr_luafun
rrc(LS
, "movie.read_rtc", [](lua_state
& L
, const std::string
& fname
) -> int {
75 L
.pushnumber(our_movie
.rtc_second
);
76 L
.pushnumber(our_movie
.rtc_subsecond
);
80 function_ptr_luafun
musv(LS
, "movie.unsafe_rewind", [](lua_state
& L
, const std::string
& fname
) -> int {
81 if(L
.isnoneornil(1)) {
82 //Start process to mark save.
83 mainloop_signal_need_rewind(NULL
);
84 } else if(lua_class
<lua_unsaferewind
>::is(L
, 1)) {
86 lua_obj_pin
<lua_unsaferewind
>* u
= lua_class
<lua_unsaferewind
>::pin(L
, 1, fname
.c_str());
87 mainloop_signal_need_rewind(u
);
89 L
.pushstring("movie.unsafe_rewind: Expected nil or UNSAFEREWIND as 1st argument");