mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Enhancing LUA video:begin_recording() function with optional format (#6533)
parameter
This commit is contained in:
parent
26bb180082
commit
d9027a7ca4
@ -222,6 +222,39 @@ static input_seq_type parse_seq_type(const std::string &s)
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// parse_movie_format - processes a movie format
|
||||
// string
|
||||
//-------------------------------------------------
|
||||
|
||||
static movie_recording::format parse_movie_format(const std::string &s)
|
||||
{
|
||||
movie_recording::format result = movie_recording::format::AVI;
|
||||
if (s == "avi")
|
||||
result = movie_recording::format::AVI;
|
||||
else if (s == "mng")
|
||||
result = movie_recording::format::MNG;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// process_snapshot_filename - processes a snapshot
|
||||
// filename
|
||||
//-------------------------------------------------
|
||||
|
||||
static std::string process_snapshot_filename(running_machine &machine, const char *s)
|
||||
{
|
||||
std::string result(s);
|
||||
if (!osd_is_absolute_path(s))
|
||||
{
|
||||
strreplace(result, "/", PATH_SEPARATOR);
|
||||
strreplace(result, "%g", machine.basename());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// mem_read - templated memory readers for <sign>,<size>
|
||||
// -> manager:machine().devices[":maincpu"].spaces["program"]:read_i8(0xC000)
|
||||
@ -2107,7 +2140,7 @@ void lua_engine::initialize()
|
||||
*
|
||||
* manager:machine():video()
|
||||
*
|
||||
* video:begin_recording([opt] filename) - start AVI recording to filename if given or default
|
||||
* video:begin_recording([opt] filename, [opt] format) - start AVI recording to filename if given or default
|
||||
* video:end_recording() - stop AVI recording
|
||||
* video:is_recording() - get recording status
|
||||
* video:snapshot() - save shot of all screens
|
||||
@ -2125,13 +2158,18 @@ void lua_engine::initialize()
|
||||
|
||||
auto video_type = sol().registry().create_simple_usertype<video_manager>("new", sol::no_constructor);
|
||||
video_type.set("begin_recording", sol::overload(
|
||||
[this](video_manager &vm, const char *filename, const char *format_string) {
|
||||
std::string fn = process_snapshot_filename(machine(), filename);
|
||||
movie_recording::format format = parse_movie_format(format_string);
|
||||
vm.begin_recording(fn.c_str(), format);
|
||||
},
|
||||
[this](video_manager &vm, const char *filename) {
|
||||
std::string fn = filename;
|
||||
strreplace(fn, "/", PATH_SEPARATOR);
|
||||
strreplace(fn, "%g", machine().basename());
|
||||
std::string fn = process_snapshot_filename(machine(), filename);
|
||||
vm.begin_recording(fn.c_str(), movie_recording::format::AVI);
|
||||
},
|
||||
[](video_manager &vm) { vm.begin_recording(nullptr, movie_recording::format::AVI); }));
|
||||
[](video_manager &vm) {
|
||||
vm.begin_recording(nullptr, movie_recording::format::AVI);
|
||||
}));
|
||||
video_type.set("end_recording", [this](video_manager &vm) {
|
||||
if(!vm.is_recording())
|
||||
{
|
||||
@ -2580,13 +2618,8 @@ void lua_engine::initialize()
|
||||
if (filename.is<const char *>())
|
||||
{
|
||||
// a filename was specified; if it isn't absolute postprocess it
|
||||
snapstr = filename.as<const char *>();
|
||||
snapstr = process_snapshot_filename(machine(), filename.as<const char *>());
|
||||
is_absolute_path = osd_is_absolute_path(snapstr);
|
||||
if (!is_absolute_path)
|
||||
{
|
||||
strreplace(snapstr, "/", PATH_SEPARATOR);
|
||||
strreplace(snapstr, "%g", machine().basename());
|
||||
}
|
||||
}
|
||||
|
||||
// open the file
|
||||
|
Loading…
Reference in New Issue
Block a user