Lua: gui.set_video_scale()

This commit is contained in:
Ilari Liusvaara 2014-01-17 22:18:13 +02:00
parent 56c15a59a3
commit 4bb75bc30e
7 changed files with 31 additions and 4 deletions

View file

@ -19,6 +19,8 @@ void push_keygroup_parameters(lua::state& L, keyboard::key& p);
extern lua_render_context* lua_render_ctx;
extern controller_frame* lua_input_controllerdata;
extern bool* lua_kill_frame;
extern uint32_t* lua_hscl;
extern uint32_t* lua_vscl;
extern bool lua_booted_flag;
extern uint64_t lua_idle_hook_time;
extern uint64_t lua_timer_hook_time;

View file

@ -10,7 +10,7 @@
void init_lua() throw();
void quit_lua() throw();
void lua_callback_do_paint(struct lua_render_context* ctx, bool non_synthethic) throw();
void lua_callback_do_video(struct lua_render_context* ctx, bool& kill_frame) throw();
void lua_callback_do_video(struct lua_render_context* ctx, bool& kill_frame, uint32_t& hscl, uint32_t& vscl) throw();
void lua_callback_do_input(controller_frame& data, bool subframe) throw();
void lua_callback_do_reset() throw();
void lua_callback_do_frame() throw();

13
lua.lyx
View file

@ -1945,6 +1945,19 @@ Kills the currently dumped video frame + the associated sound.
Only valid in on_video callback.
\end_layout
\begin_layout Subsection
gui.set_video_scale: Set video frame scale
\end_layout
\begin_layout Itemize
Syntax: none gui.set_video_scale(number h, number v)
\end_layout
\begin_layout Standard
Sets the scale factors of current frame to <h>x<v>.
Only valid in on_video callback.
\end_layout
\begin_layout Subsection
gui.arrow: Draw an arrow
\end_layout

BIN
lua.pdf

Binary file not shown.

View file

@ -57,7 +57,7 @@ template<bool X> bool render_video_hud(struct framebuffer::fb<X>& target, struct
lrc.queue = &rq;
lrc.width = source.get_width();
lrc.height = source.get_height();
lua_callback_do_video(&lrc, lua_kill_video);
lua_callback_do_video(&lrc, lua_kill_video, hscl, vscl);
if(fn)
fn();
target.set_palette(roffset, goffset, boffset);

View file

@ -109,4 +109,14 @@ namespace
if(lua_kill_frame)
*lua_kill_frame = true;
});
lua::fnptr gui_setscale(lua_func_misc, "gui.set_video_scale", [](lua::state& L, const std::string& fname)
-> int {
if(lua_hscl && lua_vscl) {
uint32_t h = L.get_numeric_argument<uint32_t>(1, fname.c_str());
uint32_t v = L.get_numeric_argument<uint32_t>(2, fname.c_str());
*lua_hscl = h;
*lua_vscl = v;
}
});
}

View file

@ -20,6 +20,8 @@ uint64_t lua_idle_hook_time = 0x7EFFFFFFFFFFFFFFULL;
uint64_t lua_timer_hook_time = 0x7EFFFFFFFFFFFFFFULL;
bool* lua_veto_flag = NULL;
bool* lua_kill_frame = NULL;
uint32_t* lua_hscl = NULL;
uint32_t* lua_vscl = NULL;
extern const char* lua_sysrc_script;
void* synchronous_paint_ctx;
@ -282,10 +284,10 @@ void lua_callback_do_paint(struct lua_render_context* ctx, bool non_synthetic) t
run_callback(on_paint, lua::state::store_tag(lua_render_ctx, ctx), lua::state::boolean_tag(non_synthetic));
}
void lua_callback_do_video(struct lua_render_context* ctx, bool& kill_frame) throw()
void lua_callback_do_video(struct lua_render_context* ctx, bool& kill_frame, uint32_t& hscl, uint32_t& vscl) throw()
{
run_callback(on_video, lua::state::store_tag(lua_render_ctx, ctx), lua::state::store_tag(lua_kill_frame,
&kill_frame));
&kill_frame), lua::state::store_tag(lua_hscl, &hscl), lua::state::store_tag(lua_vscl, &vscl));
}
void lua_callback_do_reset() throw()